From 6e9fb1de7f617eadc9322038424287950258e441 Mon Sep 17 00:00:00 2001 From: Bas Nieuwenhuizen Date: Mon, 27 Feb 2017 20:25:24 +0100 Subject: [PATCH] radv: Don't allocate space for unused immutable samplers. Signed-off-by: Bas Nieuwenhuizen Reviewed-by: Dave Airlie --- src/amd/vulkan/radv_descriptor_set.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/amd/vulkan/radv_descriptor_set.c b/src/amd/vulkan/radv_descriptor_set.c index d8399574f2a..ca5b28090b9 100644 --- a/src/amd/vulkan/radv_descriptor_set.c +++ b/src/amd/vulkan/radv_descriptor_set.c @@ -124,12 +124,6 @@ VkResult radv_CreateDescriptorSetLayout( set_layout->binding[b].buffer_offset = buffer_count; set_layout->binding[b].dynamic_offset_offset = dynamic_offset_count; - set_layout->size += binding->descriptorCount * set_layout->binding[b].size; - buffer_count += binding->descriptorCount * set_layout->binding[b].buffer_count; - dynamic_offset_count += binding->descriptorCount * - set_layout->binding[b].dynamic_offset_count; - - if (binding->pImmutableSamplers) { set_layout->binding[b].immutable_samplers = samplers; set_layout->binding[b].immutable_samplers_equal = true; @@ -141,10 +135,20 @@ VkResult radv_CreateDescriptorSetLayout( if (memcmp(set_layout->binding[b].immutable_samplers + 4 * i, set_layout->binding[b].immutable_samplers, 16) != 0) set_layout->binding[b].immutable_samplers_equal = false; - } else { - set_layout->binding[b].immutable_samplers = NULL; + + /* Don't reserve space for the samplers if they're not accessed. */ + if (set_layout->binding[b].immutable_samplers_equal) { + if (binding->descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) + set_layout->binding[b].size -= 32; + else if (binding->descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) + set_layout->binding[b].size -= 16; + } } + set_layout->size += binding->descriptorCount * set_layout->binding[b].size; + buffer_count += binding->descriptorCount * set_layout->binding[b].buffer_count; + dynamic_offset_count += binding->descriptorCount * + set_layout->binding[b].dynamic_offset_count; set_layout->shader_stages |= binding->stageFlags; } @@ -326,7 +330,8 @@ radv_descriptor_set_create(struct radv_device *device, } for (unsigned i = 0; i < layout->binding_count; ++i) { - if (!layout->binding[i].immutable_samplers) + if (!layout->binding[i].immutable_samplers || + layout->binding[i].immutable_samplers_equal) continue; unsigned offset = layout->binding[i].offset / 4; -- 2.30.2