panfrost: Don't lie about Z/S formats
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 10 Jul 2019 21:50:48 +0000 (14:50 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 11 Jul 2019 14:27:25 +0000 (14:27 +0000)
Only Z24S8 is properly supported right now, so let's be careful. Fixes a
number of issues relating to improper Z/S handling. The most obvious is
depth buffers with incorrect strides, which manifests in truly bizarre
ways and can happen commonly with FBOs.

Fixes WebGL (Aquarium runs, etc).

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/ci/expected-failures.txt
src/gallium/drivers/panfrost/pan_afbc.c
src/gallium/drivers/panfrost/pan_mfbd.c
src/gallium/drivers/panfrost/pan_screen.c

index e76ef331a134875527f2e0d6c0041a8550fc2eb6..dfc088616753f13f93558e388e3837442e55223b 100644 (file)
@@ -27,11 +27,8 @@ dEQP-GLES2.functional.fbo.render.recreate_colorbuffer.rebind_tex2d_rgb_depth_com
 dEQP-GLES2.functional.fbo.render.recreate_colorbuffer.rebind_tex2d_rgb_stencil_index8
 dEQP-GLES2.functional.fbo.render.recreate_colorbuffer.rebind_tex2d_rgba_depth_component16
 dEQP-GLES2.functional.fbo.render.recreate_colorbuffer.rebind_tex2d_rgba_stencil_index8
-dEQP-GLES2.functional.fbo.render.resize.rbo_rgb565_depth_component16
 dEQP-GLES2.functional.fbo.render.resize.rbo_rgb565_stencil_index8
-dEQP-GLES2.functional.fbo.render.resize.rbo_rgb5_a1_depth_component16
 dEQP-GLES2.functional.fbo.render.resize.rbo_rgb5_a1_stencil_index8
-dEQP-GLES2.functional.fbo.render.resize.rbo_rgba4_depth_component16
 dEQP-GLES2.functional.fbo.render.resize.rbo_rgba4_stencil_index8
 dEQP-GLES2.functional.fbo.render.resize.tex2d_rgb_depth_component16
 dEQP-GLES2.functional.fbo.render.resize.tex2d_rgb_stencil_index8
@@ -248,10 +245,8 @@ dEQP-GLES2.functional.fragment_ops.random.97
 dEQP-GLES2.functional.fragment_ops.random.98
 dEQP-GLES2.functional.fragment_ops.random.99
 dEQP-GLES2.functional.polygon_offset.fixed16_displacement_with_units
-dEQP-GLES2.functional.polygon_offset.fixed16_enable
 dEQP-GLES2.functional.polygon_offset.fixed16_render_with_factor
 dEQP-GLES2.functional.polygon_offset.fixed16_render_with_units
-dEQP-GLES2.functional.polygon_offset.fixed16_result_depth_clamp
 dEQP-GLES2.functional.shaders.builtin_variable.fragcoord_w
 dEQP-GLES2.functional.shaders.preprocessor.predefined_macros.line_2_fragment
 dEQP-GLES2.functional.shaders.preprocessor.predefined_macros.line_2_vertex
index 298c04be1c45b07c6bc0609a4d9efa9d4541d049..23e1ec921dd35c997962f6e04025d4b56501d340 100644 (file)
@@ -93,7 +93,12 @@ panfrost_format_supports_afbc(enum pipe_format format)
         if (util_format_is_rgba8_variant(desc))
                 return true;
 
-        if (format == PIPE_FORMAT_Z32_UNORM)
+        /* Z32/Z16/S8 are all compressible as well, but they are implemented as
+         * Z24S8 with wasted bits. So Z24S8 is the only format we actually need
+         * to handle compressed, and we can make the state tracker deal with
+         * the rest. */
+
+        if (format == PIPE_FORMAT_Z24_UNORM_S8_UINT)
                 return true;
 
         /* TODO: AFBC of other formats */
index 11cd2aca5a6841bb722ea65f40afdda3b2778681..463e91904008a35e94139b8dc744cc39d731c5d3 100644 (file)
@@ -254,6 +254,7 @@ panfrost_mfbd_set_zsbuf(
         struct pipe_surface *surf)
 {
         struct panfrost_resource *rsrc = pan_resource(surf->texture);
+        enum pipe_format format = surf->format;
 
         unsigned level = surf->u.tex.level;
         assert(surf->u.tex.first_layer == 0);
@@ -261,6 +262,10 @@ panfrost_mfbd_set_zsbuf(
         unsigned offset = rsrc->slices[level].offset;
 
         if (rsrc->layout == PAN_AFBC) {
+                /* The only Z/S format we can compress is Z24S8 or variants
+                 * thereof (handled by the state tracker) */
+                assert(format == PIPE_FORMAT_Z24_UNORM_S8_UINT);
+
                 mali_ptr base = rsrc->bo->gpu + offset;
                 unsigned header_size = rsrc->slices[level].header_size;
 
@@ -280,6 +285,9 @@ panfrost_mfbd_set_zsbuf(
                 fbx->ds_afbc.zero1 = 0x10009;
                 fbx->ds_afbc.padding = 0x1000;
         } else if (rsrc->layout == PAN_LINEAR) {
+                /* TODO: Z32F(S8) support, which is always linear */
+
+                assert(format == PIPE_FORMAT_Z24_UNORM_S8_UINT);
                 int stride = rsrc->slices[level].stride;
                 fb->mfbd_flags |= MALI_MFBD_EXTRA;
 
index f8a637be850aaa43b8999593a35eb32b8d5fa9c0..cfcee5743b9b809b2bf5256fcfdcfd7cd10b887c 100644 (file)
@@ -410,6 +410,26 @@ panfrost_is_format_supported( struct pipe_screen *screen,
                 return FALSE;
         }
 
+        /* Internally, formats that are depth/stencil renderable are limited.
+         *
+         * In particular: Z16, Z24, Z24S8, S8 are all identical from the GPU
+         * rendering perspective. That is, we render to Z24S8 (which we can
+         * AFBC compress), ignore the different when texturing (who cares?),
+         * and then in the off-chance there's a CPU read we blit back to
+         * staging.
+         *
+         * ...alternatively, we can make the state tracker deal with that. */
+
+        if (bind & PIPE_BIND_DEPTH_STENCIL) {
+                switch (format) {
+                        case PIPE_FORMAT_Z24_UNORM_S8_UINT:
+                                return true;
+
+                        default:
+                                return false;
+                }
+        }
+
         return TRUE;
 }