From 2da68c8649b6061c38e303da962e236985d76fc5 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 16 Dec 2019 15:41:16 -0800 Subject: [PATCH] turnip: Fix support for immutable samplers. 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 Tested-by: Marge Bot Part-of: --- src/freedreno/vulkan/tu_cmd_buffer.c | 20 +++++++++++++++----- src/freedreno/vulkan/tu_descriptor_set.c | 7 ------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c index 71bb2639517..3d5a9835970 100644 --- a/src/freedreno/vulkan/tu_cmd_buffer.c +++ b/src/freedreno/vulkan/tu_cmd_buffer.c @@ -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; } diff --git a/src/freedreno/vulkan/tu_descriptor_set.c b/src/freedreno/vulkan/tu_descriptor_set.c index 26f49001d09..55f8f5b8552 100644 --- a/src/freedreno/vulkan/tu_descriptor_set.c +++ b/src/freedreno/vulkan/tu_descriptor_set.c @@ -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); -- 2.30.2