From 500e6e40f683fbad09f38360bb79f8a12442c408 Mon Sep 17 00:00:00 2001 From: Bas Nieuwenhuizen Date: Mon, 27 Feb 2017 09:44:48 +0100 Subject: [PATCH] radv: Detect if all immutable samplers for a binding are equal. We can then use constants for indexed loads. Signed-off-by: Bas Nieuwenhuizen Reviewed-by: Dave Airlie --- 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.30.2