summaryrefslogtreecommitdiffstats
path: root/src/amd
diff options
context:
space:
mode:
authorBas Nieuwenhuizen <[email protected]>2017-09-17 12:59:24 +0200
committerBas Nieuwenhuizen <[email protected]>2017-09-20 22:04:25 +0200
commitef721c77f12b7a8e6281fb56c85d4e09b14aeca8 (patch)
treefc361b7ede3f99f03db00ac74a6c319e2491ef64 /src/amd
parent68dc19d4002fac0c743fd1f16a2aa9d839bed762 (diff)
radv: Only enter the immutable samplers init loop when we have some.
Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Samuel Pitoiset <[email protected]>
Diffstat (limited to 'src/amd')
-rw-r--r--src/amd/vulkan/radv_descriptor_set.c28
-rw-r--r--src/amd/vulkan/radv_descriptor_set.h2
2 files changed, 18 insertions, 12 deletions
diff --git a/src/amd/vulkan/radv_descriptor_set.c b/src/amd/vulkan/radv_descriptor_set.c
index 314ab5a96d0..5b9cfe66331 100644
--- a/src/amd/vulkan/radv_descriptor_set.c
+++ b/src/amd/vulkan/radv_descriptor_set.c
@@ -67,6 +67,7 @@ VkResult radv_CreateDescriptorSetLayout(
set_layout->binding_count = max_binding + 1;
set_layout->shader_stages = 0;
set_layout->dynamic_shader_stages = 0;
+ set_layout->has_immutable_samplers = false;
set_layout->size = 0;
memset(set_layout->binding, 0, size - sizeof(struct radv_descriptor_set_layout));
@@ -132,6 +133,7 @@ VkResult radv_CreateDescriptorSetLayout(
if (binding->pImmutableSamplers) {
set_layout->binding[b].immutable_samplers_offset = samplers_offset;
set_layout->binding[b].immutable_samplers_equal = true;
+ set_layout->has_immutable_samplers = true;
for (uint32_t i = 0; i < binding->descriptorCount; i++)
@@ -329,21 +331,23 @@ radv_descriptor_set_create(struct radv_device *device,
return vk_error(VK_ERROR_OUT_OF_POOL_MEMORY_KHR);
}
- for (unsigned i = 0; i < layout->binding_count; ++i) {
- if (!layout->binding[i].immutable_samplers_offset ||
- layout->binding[i].immutable_samplers_equal)
- continue;
+ if (layout->has_immutable_samplers) {
+ for (unsigned i = 0; i < layout->binding_count; ++i) {
+ if (!layout->binding[i].immutable_samplers_offset ||
+ layout->binding[i].immutable_samplers_equal)
+ continue;
- unsigned offset = layout->binding[i].offset / 4;
- if (layout->binding[i].type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
- offset += 16;
+ unsigned offset = layout->binding[i].offset / 4;
+ if (layout->binding[i].type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
+ offset += 16;
- const uint32_t *samplers = (const uint32_t*)((const char*)layout + layout->binding[i].immutable_samplers_offset);
- for (unsigned j = 0; j < layout->binding[i].array_size; ++j) {
- memcpy(set->mapped_ptr + offset, samplers + 4 * j, 16);
- offset += layout->binding[i].size / 4;
- }
+ const uint32_t *samplers = (const uint32_t*)((const char*)layout + layout->binding[i].immutable_samplers_offset);
+ for (unsigned j = 0; j < layout->binding[i].array_size; ++j) {
+ memcpy(set->mapped_ptr + offset, samplers + 4 * j, 16);
+ offset += layout->binding[i].size / 4;
+ }
+ }
}
*out_set = set;
return VK_SUCCESS;
diff --git a/src/amd/vulkan/radv_descriptor_set.h b/src/amd/vulkan/radv_descriptor_set.h
index 4b63992b2bb..7fa79186a17 100644
--- a/src/amd/vulkan/radv_descriptor_set.h
+++ b/src/amd/vulkan/radv_descriptor_set.h
@@ -68,6 +68,8 @@ struct radv_descriptor_set_layout {
/* Number of dynamic offsets used by this descriptor set */
uint16_t dynamic_offset_count;
+ bool has_immutable_samplers;
+
/* Bindings in this descriptor set */
struct radv_descriptor_set_binding_layout binding[0];
};