summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIcecream95 <ixn@keemail.me>2020-01-11 20:00:38 +1300
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>2020-01-21 08:35:23 -0500
commit960fe9daea77e80b0dc72271bb6b8e10acf851be (patch)
tree92d60edd10cdaa0c1efaf00d72468d5324148a73
parent2091d311c9d063138d5c84bbf4afe99ca864e597 (diff)
panfrost: Add ETC1/ETC2 texture formats
Acked-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3414>
-rw-r--r--src/gallium/drivers/panfrost/pan_format.c23
-rw-r--r--src/gallium/drivers/panfrost/pan_resource.c3
-rw-r--r--src/gallium/drivers/panfrost/pan_screen.c12
-rw-r--r--src/panfrost/include/panfrost-job.h11
4 files changed, 45 insertions, 4 deletions
diff --git a/src/gallium/drivers/panfrost/pan_format.c b/src/gallium/drivers/panfrost/pan_format.c
index 9b0440eae37..040b01d9e5b 100644
--- a/src/gallium/drivers/panfrost/pan_format.c
+++ b/src/gallium/drivers/panfrost/pan_format.c
@@ -217,6 +217,29 @@ panfrost_find_format(const struct util_format_description *desc) {
case PIPE_FORMAT_R9G9B9E5_FLOAT:
return MALI_R9F_G9F_B9F_E5F;
+ case PIPE_FORMAT_ETC1_RGB8:
+ case PIPE_FORMAT_ETC2_RGB8:
+ case PIPE_FORMAT_ETC2_SRGB8:
+ return MALI_ETC2_RGB8;
+
+ case PIPE_FORMAT_ETC2_RGB8A1:
+ case PIPE_FORMAT_ETC2_SRGB8A1:
+ return MALI_ETC2_RGB8A1;
+
+ case PIPE_FORMAT_ETC2_RGBA8:
+ case PIPE_FORMAT_ETC2_SRGBA8:
+ return MALI_ETC2_RGBA8;
+
+ case PIPE_FORMAT_ETC2_R11_UNORM:
+ return MALI_ETC2_R11_UNORM;
+ case PIPE_FORMAT_ETC2_R11_SNORM:
+ return MALI_ETC2_R11_SNORM;
+
+ case PIPE_FORMAT_ETC2_RG11_UNORM:
+ return MALI_ETC2_RG11_UNORM;
+ case PIPE_FORMAT_ETC2_RG11_SNORM:
+ return MALI_ETC2_RG11_SNORM;
+
default:
/* Fallthrough to default */
break;
diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c
index 18c6e05ba3b..aac1e8cf19d 100644
--- a/src/gallium/drivers/panfrost/pan_resource.c
+++ b/src/gallium/drivers/panfrost/pan_resource.c
@@ -315,6 +315,9 @@ panfrost_setup_slices(struct panfrost_resource *pres, size_t *bo_size)
/* Compute the would-be stride */
unsigned stride = bytes_per_pixel * effective_width;
+ if (util_format_is_compressed(res->format))
+ stride /= 4;
+
/* ..but cache-line align it for performance */
if (can_align_stride && pres->layout == PAN_LINEAR)
stride = ALIGN_POT(stride, 64);
diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c
index 296be13484d..b7d24c93ea2 100644
--- a/src/gallium/drivers/panfrost/pan_screen.c
+++ b/src/gallium/drivers/panfrost/pan_screen.c
@@ -459,10 +459,14 @@ panfrost_is_format_supported( struct pipe_screen *screen,
if (scanout && renderable && !util_format_is_rgba8_variant(format_desc))
return false;
- if (format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN &&
- format_desc->layout != UTIL_FORMAT_LAYOUT_OTHER) {
- /* Compressed formats not yet hooked up. */
- return false;
+ switch (format_desc->layout) {
+ case UTIL_FORMAT_LAYOUT_PLAIN:
+ case UTIL_FORMAT_LAYOUT_OTHER:
+ break;
+ case UTIL_FORMAT_LAYOUT_ETC:
+ return true;
+ default:
+ return false;
}
/* Internally, formats that are depth/stencil renderable are limited.
diff --git a/src/panfrost/include/panfrost-job.h b/src/panfrost/include/panfrost-job.h
index b9a560911eb..95356699186 100644
--- a/src/panfrost/include/panfrost-job.h
+++ b/src/panfrost/include/panfrost-job.h
@@ -229,6 +229,9 @@ struct mali_channel_swizzle {
/* The top 3 bits specify how the bits of each component are interpreted. */
+/* e.g. ETC2_RGB8 */
+#define MALI_FORMAT_COMPRESSED (0 << 5)
+
/* e.g. R11F_G11F_B10F */
#define MALI_FORMAT_SPECIAL (2 << 5)
@@ -273,6 +276,14 @@ struct mali_channel_swizzle {
#define MALI_CHANNEL_FLOAT 7
enum mali_format {
+ MALI_ETC2_RGB8 = MALI_FORMAT_COMPRESSED | 0x1,
+ MALI_ETC2_R11_UNORM = MALI_FORMAT_COMPRESSED | 0x2,
+ MALI_ETC2_RGBA8 = MALI_FORMAT_COMPRESSED | 0x3,
+ MALI_ETC2_RG11_UNORM = MALI_FORMAT_COMPRESSED | 0x4,
+ MALI_ETC2_R11_SNORM = MALI_FORMAT_COMPRESSED | 0x11,
+ MALI_ETC2_RG11_SNORM = MALI_FORMAT_COMPRESSED | 0x12,
+ MALI_ETC2_RGB8A1 = MALI_FORMAT_COMPRESSED | 0x13,
+
MALI_RGB565 = MALI_FORMAT_SPECIAL | 0x0,
MALI_RGB5_A1_UNORM = MALI_FORMAT_SPECIAL | 0x2,
MALI_RGB10_A2_UNORM = MALI_FORMAT_SPECIAL | 0x3,