pvr: Fix dynamic desc offset storage
authorKarmjit Mahil <Karmjit.Mahil@imgtec.com>
Tue, 19 Sep 2023 12:35:50 +0000 (13:35 +0100)
committerMarge Bot <emma+marge@anholt.net>
Sun, 24 Sep 2023 14:00:57 +0000 (14:00 +0000)
The index at which the dynamic descriptor offsets were being
stored was incorrect, leading to some offsets not being stored and
thus `0` being applied as the offset to the descriptors instead.

dEQP test fixed:
  dEQP-VK.binding_model.shader_access.{primary,secondary}_cmd_buf
    .uniform_buffer_dynamic
    .{vertex,fragment,compute,vertex_fragment}
    .multiple_discontiguous_descriptor_sets
    .*_descriptor.offset_view_{,non}zero_dynamic_nonzero

Fixes: aa791961a82e ("pvr: Add support for dynamic buffers descriptors")
Signed-off-by: Karmjit Mahil <Karmjit.Mahil@imgtec.com>
Reviewed-by: Frank Binns <frank.binns@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25320>

src/imagination/vulkan/pvr_cmd_buffer.c

index 031ca59..5f50adc 100644 (file)
@@ -2612,12 +2612,12 @@ void pvr_CmdBindDescriptorSets(VkCommandBuffer commandBuffer,
 
    if (dynamicOffsetCount > 0) {
       PVR_FROM_HANDLE(pvr_pipeline_layout, pipeline_layout, _layout);
-      uint32_t starting_idx = 0;
+      uint32_t set_offset = 0;
 
       for (uint32_t set = 0; set < firstSet; set++)
-         starting_idx += pipeline_layout->set_layout[set]->dynamic_buffer_count;
+         set_offset += pipeline_layout->set_layout[set]->dynamic_buffer_count;
 
-      assert(starting_idx + dynamicOffsetCount <=
+      assert(set_offset + dynamicOffsetCount <=
              ARRAY_SIZE(descriptor_state->dynamic_offsets));
 
       /* From the Vulkan 1.3.238 spec. :
@@ -2627,8 +2627,8 @@ void pvr_CmdBindDescriptorSets(VkCommandBuffer commandBuffer,
        *    element in each dynamic descriptor type binding in each set."
        *
        */
-      for (uint32_t i = starting_idx; i < dynamicOffsetCount; i++)
-         descriptor_state->dynamic_offsets[i] = pDynamicOffsets[i];
+      for (uint32_t i = 0; i < dynamicOffsetCount; i++)
+         descriptor_state->dynamic_offsets[set_offset + i] = pDynamicOffsets[i];
    }
 }