panfrost: Fake RGTC support
authorIcecream95 <ixn@keemail.me>
Mon, 13 Jul 2020 10:45:51 +0000 (22:45 +1200)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 20 Jul 2020 13:54:49 +0000 (09:54 -0400)
For most GPUs RGTC is disabled, so it needs to be emulated, using the
fake_rgtc option of u_transfer_helper.

Passes the rgtc-teximage tests in piglit.

v2: Update docs/features.txt (Alyssa)

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5975>

docs/features.txt
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_resource.c
src/gallium/drivers/panfrost/pan_screen.c

index fed566e2318e0da035b56f122e026a35951ab777..9d5198e62d34db4dca23aba2883628d51df66f37 100644 (file)
@@ -52,7 +52,7 @@ GL 3.0, GLSL 1.30 --- all DONE: freedreno, i965, nv50, nvc0, r600, radeonsi, llv
   GL_EXT_texture_integer                                DONE (panfrost, v3d)
   GL_EXT_texture_array                                  DONE (panfrost, v3d)
   GL_EXT_draw_buffers2 (Per-buffer blend and masks)     DONE (panfrost, v3d)
-  GL_EXT_texture_compression_rgtc                       DONE (panfrost/if SoC supports)
+  GL_EXT_texture_compression_rgtc                       DONE (panfrost)
   GL_ARB_texture_rg                                     DONE (panfrost, v3d)
   GL_EXT_transform_feedback (Transform feedback)        DONE (panfrost, v3d)
   GL_ARB_vertex_array_object (Vertex array objects)     DONE (panfrost, v3d)
index d2b44f907de41a3a59b0742d8e759f490768edf1..5d84322109d741b4a0b78e0590bd4ac0c55a798e 100644 (file)
@@ -941,13 +941,25 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so,
         assert(prsrc->bo);
 
         /* Format to access the stencil portion of a Z32_S8 texture */
-        if (so->base.format == PIPE_FORMAT_X32_S8X24_UINT) {
+        if (format == PIPE_FORMAT_X32_S8X24_UINT) {
                 assert(prsrc->separate_stencil);
                 texture = &prsrc->separate_stencil->base;
                 prsrc = (struct panfrost_resource *)texture;
                 format = texture->format;
         }
 
+        const struct util_format_description *desc = util_format_description(format);
+
+        bool fake_rgtc = !panfrost_supports_compressed_format(device, MALI_BC4_UNORM);
+
+        if (desc->layout == UTIL_FORMAT_LAYOUT_RGTC && fake_rgtc) {
+                if (desc->is_snorm)
+                        format = PIPE_FORMAT_R8G8B8A8_SNORM;
+                else
+                        format = PIPE_FORMAT_R8G8B8A8_UNORM;
+                desc = util_format_description(format);
+        }
+
         so->texture_bo = prsrc->bo->gpu;
         so->layout = prsrc->layout;
 
@@ -985,8 +997,6 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so,
                 panfrost_translate_texture_type(so->base.target);
 
         if (device->quirks & IS_BIFROST) {
-                const struct util_format_description *desc =
-                        util_format_description(format);
                 unsigned char composed_swizzle[4];
                 util_format_compose_swizzles(desc->swizzle, user_swizzle, composed_swizzle);
 
index 3cd9b65bcae8e99786e91c9220810a63583f29f1..f03cd9c4ea35d2b414cef9e42317e500449f95c3 100644 (file)
@@ -934,6 +934,10 @@ static const struct u_transfer_vtbl transfer_vtbl = {
 void
 panfrost_resource_screen_init(struct pipe_screen *pscreen)
 {
+        struct panfrost_device *dev = pan_device(pscreen);
+
+        bool fake_rgtc = !panfrost_supports_compressed_format(dev, MALI_BC4_UNORM);
+
         //pscreen->base.resource_create_with_modifiers =
         //        panfrost_resource_create_with_modifiers;
         pscreen->resource_create = u_transfer_helper_resource_create;
@@ -942,7 +946,7 @@ panfrost_resource_screen_init(struct pipe_screen *pscreen)
         pscreen->resource_get_handle = panfrost_resource_get_handle;
         pscreen->transfer_helper = u_transfer_helper_create(&transfer_vtbl,
                                         true, false,
-                                        true, true);
+                                        fake_rgtc, true);
 }
 
 void
index a5d264e0b1733069073140db10453aa20c20d2ec..e776add1f20b8bc336562cbf3ecc3f69c3f49afb 100644 (file)
@@ -463,11 +463,6 @@ panfrost_is_format_supported( struct pipe_screen *screen,
         if (scanout && renderable && !util_format_is_rgba8_variant(format_desc))
                 return false;
 
-        if (dev->debug & (PAN_DBG_GL3 | PAN_DBG_DEQP)) {
-                if (format_desc->layout == UTIL_FORMAT_LAYOUT_RGTC)
-                        return true;
-        }
-
         /* Check we support the format with the given bind */
 
         unsigned relevant_bind = bind &
@@ -478,9 +473,12 @@ panfrost_is_format_supported( struct pipe_screen *screen,
 
         /* Also check that compressed texture formats are supported on this
          * particular chip. They may not be depending on system integration
-         * differences. */
+         * differences. RGTC can be emulated so is always supported. */
+
+        bool is_rgtc = format_desc->layout == UTIL_FORMAT_LAYOUT_RGTC;
+        bool supported = panfrost_supports_compressed_format(dev, fmt.hw);
 
-        if (!panfrost_supports_compressed_format(dev, fmt.hw))
+        if (!is_rgtc && !supported)
                 return false;
 
         return fmt.hw && ((relevant_bind & ~fmt.bind) == 0);