[Mesa-dev] [PATCH 2/4] radv: Detect if all immutable samplers for a binding are equal.

Bas Nieuwenhuizen bas at basnieuwenhuizen.nl
Mon Feb 27 23:08:07 UTC 2017


We can then use constants for indexed loads.

Signed-off-by: Bas Nieuwenhuizen <basni at google.com>
---
 src/amd/vulkan/radv_descriptor_set.c | 5 +++++
 src/amd/vulkan/radv_descriptor_set.h | 1 +
 2 files changed, 6 insertions(+)

diff --git a/src/amd/vulkan/radv_descriptor_set.c b/src/amd/vulkan/radv_descriptor_set.c
index b24ff91d3ed..d8399574f2a 100644
--- a/src/amd/vulkan/radv_descriptor_set.c
+++ b/src/amd/vulkan/radv_descriptor_set.c
@@ -132,10 +132,15 @@ VkResult radv_CreateDescriptorSetLayout(
 
 		if (binding->pImmutableSamplers) {
 			set_layout->binding[b].immutable_samplers = samplers;
+			set_layout->binding[b].immutable_samplers_equal = true;
 			samplers += 4 * binding->descriptorCount;
 
 			for (uint32_t i = 0; i < binding->descriptorCount; i++)
 				memcpy(set_layout->binding[b].immutable_samplers + 4 * i, &radv_sampler_from_handle(binding->pImmutableSamplers[i])->state, 16);
+			for (uint32_t i = 1; i < binding->descriptorCount; i++)
+				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;
 		}
diff --git a/src/amd/vulkan/radv_descriptor_set.h b/src/amd/vulkan/radv_descriptor_set.h
index 8849d053121..c373489ccb3 100644
--- a/src/amd/vulkan/radv_descriptor_set.h
+++ b/src/amd/vulkan/radv_descriptor_set.h
@@ -45,6 +45,7 @@ struct radv_descriptor_set_binding_layout {
 
    /* Immutable samplers (or NULL if no immutable samplers) */
    uint32_t *immutable_samplers;
+   bool immutable_samplers_equal;
 };
 
 struct radv_descriptor_set_layout {
-- 
2.11.1



More information about the mesa-dev mailing list