v3dv/pipeline: fix adding texture/samplers array elements to texture/sampler map
authorAlejandro Piñeiro <apinheiro@igalia.com>
Thu, 26 Mar 2020 15:30:20 +0000 (16:30 +0100)
committerMarge Bot <eric+marge@anholt.net>
Tue, 13 Oct 2020 21:21:29 +0000 (21:21 +0000)
For arrays we are adding one entry on the map per array element. This
makes getting back the descriptor for each array element easier, as
for example, for ubo arrays, each array element can be bound to a
different descriptor buffer.

For samplers arrays this would also make sense.

Fixes crashes on tests like:
dEQP-VK.binding_model.shader_access.primary_cmd_buf.combined_image_sampler_mutable.fragment.descriptor_array.2d

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

src/broadcom/vulkan/v3dv_pipeline.c

index 4e8dcea..ff74cc2 100644 (file)
@@ -553,8 +553,8 @@ lower_tex_src_to_offset(nir_builder *b, nir_tex_instr *instr, unsigned src_idx,
                          &pipeline->sampler_map : &pipeline->texture_map,
                          deref->var->data.descriptor_set,
                          deref->var->data.binding,
-                         deref->var->data.index,
-                         binding_layout->array_size) + base_index;
+                         deref->var->data.index + base_index,
+                         binding_layout->array_size);
    if (is_sampler)
       instr->sampler_index = desc_index;
    else