radv: Add hashing for the ycbcr samplers.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Sun, 7 Apr 2019 15:16:50 +0000 (17:16 +0200)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Thu, 25 Apr 2019 19:56:20 +0000 (19:56 +0000)
Otherwise caching gets very confused.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/amd/vulkan/radv_descriptor_set.c
src/amd/vulkan/radv_descriptor_set.h

index e1b5992d63571f746e3238218c4ee2ec9f176fea..4e9c73c94d0ac70fb7a010281ea8e75a9b34dd66 100644 (file)
@@ -109,12 +109,13 @@ VkResult radv_CreateDescriptorSetLayout(
                size += ycbcr_sampler_count * sizeof(struct radv_sampler_ycbcr_conversion) + (max_binding + 1) * sizeof(uint32_t);
        }
 
-       set_layout = vk_alloc2(&device->alloc, pAllocator, size, 8,
-                                VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
+       set_layout = vk_zalloc2(&device->alloc, pAllocator, size, 8,
+                               VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
        if (!set_layout)
                return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
 
        set_layout->flags = pCreateInfo->flags;
+       set_layout->layout_size = size;
 
        /* We just allocate all the samplers at the end of the struct */
        uint32_t *samplers = (uint32_t*)&set_layout->binding[max_binding + 1];
@@ -429,12 +430,8 @@ VkResult radv_CreatePipelineLayout(
                for (uint32_t b = 0; b < set_layout->binding_count; b++) {
                        dynamic_offset_count += set_layout->binding[b].array_size * set_layout->binding[b].dynamic_offset_count;
                        dynamic_shader_stages |= set_layout->dynamic_shader_stages;
-                       if (set_layout->binding[b].immutable_samplers_offset)
-                               _mesa_sha1_update(&ctx, radv_immutable_samplers(set_layout, set_layout->binding + b),
-                                                 set_layout->binding[b].array_size * 4 * sizeof(uint32_t));
                }
-               _mesa_sha1_update(&ctx, set_layout->binding,
-                                 sizeof(set_layout->binding[0]) * set_layout->binding_count);
+               _mesa_sha1_update(&ctx, set_layout, set_layout->layout_size);
        }
 
        layout->dynamic_offset_count = dynamic_offset_count;
index 55cc1c9c4623f47e097c00d978e851424a814ba3..5fd19d94482fc077435ea3de95dd366ff527c68e 100644 (file)
@@ -58,6 +58,9 @@ struct radv_descriptor_set_layout {
    /* Total size of the descriptor set with room for all array entries */
    uint32_t size;
 
+   /* CPU size of this struct + all associated data, for hashing. */
+   uint32_t layout_size;
+
    /* Shader stages affected by this descriptor set */
    uint16_t shader_stages;
    uint16_t dynamic_shader_stages;