pvr: Fix seg fault on unused ds attachment
authorJames Glanville <james.glanville@imgtec.com>
Thu, 11 May 2023 12:29:10 +0000 (13:29 +0100)
committerMarge Bot <emma+marge@anholt.net>
Wed, 17 May 2023 08:18:26 +0000 (08:18 +0000)
Fixes:
  dEQP-VK.renderpass.suballocation.formats.r16g16_sint.input
    .dont_care.dont_care.self_dep_clear

Signed-off-by: James Glanville <james.glanville@imgtec.com>
Reviewed-by: Frank Binns <frank.binns@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22958>

src/imagination/vulkan/pvr_cmd_buffer.c

index 36e3c71..d004f54 100644 (file)
@@ -7252,15 +7252,16 @@ static bool pvr_is_stencil_store_load_needed(
 
    hw_render_idx = state->current_sub_cmd->gfx.hw_render_idx;
    hw_render = &pass->hw_setup->renders[hw_render_idx];
+
+   if (hw_render->ds_attach_idx == VK_ATTACHMENT_UNUSED)
+      return false;
+
    attachment = attachments[hw_render->ds_attach_idx];
 
    if (!(vk_src_stage_mask & fragment_test_stages) &&
        vk_dst_stage_mask & VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT)
       return false;
 
-   if (hw_render->ds_attach_idx == VK_ATTACHMENT_UNUSED)
-      return false;
-
    for (uint32_t i = 0; i < memory_barrier_count; i++) {
       const uint32_t stencil_write_bit =
          VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;