turnip: Correctly set layer stride for 3D images
authorBrian Ho <brian@brkho.com>
Mon, 13 Apr 2020 21:57:45 +0000 (14:57 -0700)
committerMarge Bot <eric+marge@anholt.net>
Wed, 15 Apr 2020 16:19:34 +0000 (16:19 +0000)
Previously we were using layout.layer_size for the layer stride, but
in Vulkan, you can alias a 3D image as an array of 2D images via the
VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT flag. One reason to use
this behavior is so the geometry shader can write to a specific
depth in a 3D framebuffer with gl_Layer.

Since the 3D image is not a *true* layered image, layer_size is 0.
Instead, we can copy what freedreno does and use the slice size.

Fixes dEQP-VK.geometry.layered.3d.*

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4541>

src/freedreno/vulkan/tu_cmd_buffer.c

index a15797e104223ab0e4f782cd0872986e87eb0401..633ca11324c6e741a27612f54738f3c9afb7d2b4 100644 (file)
@@ -392,7 +392,8 @@ tu6_emit_zs(struct tu_cmd_buffer *cmd,
    tu_cs_emit_regs(cs,
                    A6XX_RB_DEPTH_BUFFER_INFO(.depth_format = fmt),
                    A6XX_RB_DEPTH_BUFFER_PITCH(tu_image_stride(iview->image, iview->base_mip)),
-                   A6XX_RB_DEPTH_BUFFER_ARRAY_PITCH(iview->image->layout.layer_size),
+                   A6XX_RB_DEPTH_BUFFER_ARRAY_PITCH(
+                           fdl_layer_stride(&iview->image->layout, iview->base_mip)),
                    A6XX_RB_DEPTH_BUFFER_BASE(tu_image_view_base_ref(iview)),
                    A6XX_RB_DEPTH_BUFFER_BASE_GMEM(cmd->state.pass->attachments[a].gmem_offset));
 
@@ -444,7 +445,8 @@ tu6_emit_mrt(struct tu_cmd_buffer *cmd,
                                            .color_format = format.fmt,
                                            .color_swap = format.swap),
                       A6XX_RB_MRT_PITCH(i, tu_image_stride(iview->image, iview->base_mip)),
-                      A6XX_RB_MRT_ARRAY_PITCH(i, iview->image->layout.layer_size),
+                      A6XX_RB_MRT_ARRAY_PITCH(i,
+                              fdl_layer_stride(&iview->image->layout, iview->base_mip)),
                       A6XX_RB_MRT_BASE(i, tu_image_view_base_ref(iview)),
                       A6XX_RB_MRT_BASE_GMEM(i, cmd->state.pass->attachments[a].gmem_offset));