turnip: Fix support for immutable samplers.
authorEric Anholt <eric@anholt.net>
Mon, 16 Dec 2019 23:41:16 +0000 (15:41 -0800)
committerEric Anholt <eric@anholt.net>
Tue, 17 Dec 2019 03:51:27 +0000 (19:51 -0800)
We were setting up the hardware sampler state when updating a combined
image sampler, but never looking at the immutable sampler for in the
separate case.

Fixes failures in
dEQP-VK.binding_model.shader_access.primary_cmd_buf.sampler_immutable.fragment.*

Reviewed-by: Jonathan Marek <jonathan@marek.ca>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3127>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3127>

src/freedreno/vulkan/tu_cmd_buffer.c
src/freedreno/vulkan/tu_descriptor_set.c

index 71bb2639517b7ca2d810757e09481dc8d28cee25..3d5a9835970e2a586f0f10f5a7f92c5ceb780cef 100644 (file)
@@ -2488,7 +2488,7 @@ struct tu_draw_state_group
    struct tu_cs_entry ib;
 };
 
-static struct tu_sampler*
+const static struct tu_sampler*
 sampler_ptr(struct tu_descriptor_state *descriptors_state,
             const struct tu_descriptor_map *map, unsigned i,
             unsigned array_index)
@@ -2501,6 +2501,13 @@ sampler_ptr(struct tu_descriptor_state *descriptors_state,
    const struct tu_descriptor_set_binding_layout *layout =
       &set->layout->binding[map->binding[i]];
 
+   if (layout->immutable_samplers_offset) {
+      const struct tu_sampler *immutable_samplers =
+         tu_immutable_samplers(set->layout, layout);
+
+      return &immutable_samplers[array_index];
+   }
+
    switch (layout->type) {
    case VK_DESCRIPTOR_TYPE_SAMPLER:
       return (struct tu_sampler*) &set->mapped_ptr[layout->offset / 4];
@@ -2803,8 +2810,9 @@ tu6_emit_textures(struct tu_cmd_buffer *cmd,
       int sampler_index = 0;
       for (unsigned i = 0; i < link->sampler_map.num; i++) {
          for (int j = 0; j < link->sampler_map.array_size[i]; j++) {
-            struct tu_sampler *sampler = sampler_ptr(descriptors_state,
-                                                     &link->sampler_map, i, j);
+            const struct tu_sampler *sampler = sampler_ptr(descriptors_state,
+                                                           &link->sampler_map,
+                                                           i, j);
             memcpy(&tex_samp.map[A6XX_TEX_SAMP_DWORDS * sampler_index++],
                    sampler->state, sizeof(sampler->state));
             *needs_border |= sampler->needs_border;
@@ -3048,7 +3056,8 @@ tu6_emit_border_color(struct tu_cmd_buffer *cmd,
 
    for (unsigned i = 0; i < vs_sampler->num; i++) {
       for (unsigned j = 0; j < vs_sampler->array_size[i]; j++) {
-         struct tu_sampler *sampler = sampler_ptr(descriptors_state, vs_sampler, i, j);
+         const struct tu_sampler *sampler = sampler_ptr(descriptors_state,
+                                                        vs_sampler, i, j);
          memcpy(ptr.map, &border_color[sampler->border], 128);
          ptr.map += 128 / 4;
       }
@@ -3056,7 +3065,8 @@ tu6_emit_border_color(struct tu_cmd_buffer *cmd,
 
    for (unsigned i = 0; i < fs_sampler->num; i++) {
       for (unsigned j = 0; j < fs_sampler->array_size[i]; j++) {
-         struct tu_sampler *sampler = sampler_ptr(descriptors_state, fs_sampler, i, j);
+         const struct tu_sampler *sampler = sampler_ptr(descriptors_state,
+                                                        fs_sampler, i, j);
          memcpy(ptr.map, &border_color[sampler->border], 128);
          ptr.map += 128 / 4;
       }
index 26f49001d093916a471580a86bfb54e24bd7e61b..55f8f5b8552e8881676bda339f7c06b60ca4515f 100644 (file)
@@ -806,8 +806,6 @@ tu_update_descriptor_sets(struct tu_device *device,
       uint32_t *ptr = set->mapped_ptr;
       struct tu_bo **buffer_list = set->descriptors;
 
-      const struct tu_sampler *samplers = tu_immutable_samplers(set->layout, binding_layout);
-
       ptr += binding_layout->offset / 4;
 
       ptr += binding_layout->size * writeset->dstArrayElement / 4;
@@ -849,11 +847,6 @@ tu_update_descriptor_sets(struct tu_device *device,
                                                     writeset->descriptorType,
                                                     writeset->pImageInfo + j,
                                                     !binding_layout->immutable_samplers_offset);
-            if (binding_layout->immutable_samplers_offset) {
-               const unsigned idx = writeset->dstArrayElement + j;
-               memcpy((char*)ptr + A6XX_TEX_CONST_DWORDS*4, &samplers[idx],
-                      sizeof(struct tu_sampler));
-            }
             break;
          case VK_DESCRIPTOR_TYPE_SAMPLER:
             write_sampler_descriptor(device, ptr, writeset->pImageInfo + j);