summaryrefslogtreecommitdiff
path: root/src/amd/vulkan/radv_descriptor_set.c
diff options
context:
space:
mode:
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>2017-02-27 20:25:24 +0100
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>2017-02-28 20:48:18 +0100
commit6e9fb1de7f617eadc9322038424287950258e441 (patch)
tree3b6cddbec4cfbd201cf94cbde4446e33f669f315 /src/amd/vulkan/radv_descriptor_set.c
parent137b06b437eddef97978d76848a0e19cc564d39d (diff)
radv: Don't allocate space for unused immutable samplers.
Signed-off-by: Bas Nieuwenhuizen <basni@google.com> Reviewed-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'src/amd/vulkan/radv_descriptor_set.c')
-rw-r--r--src/amd/vulkan/radv_descriptor_set.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/amd/vulkan/radv_descriptor_set.c b/src/amd/vulkan/radv_descriptor_set.c
index d8399574f2..ca5b28090b 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;