[Mesa-dev] [PATCH 1/4] radv: Store the immutable samplers as uint32_t[4].

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


So we don't need to know about radv_sampler in ac_nir_to_llvm.

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

diff --git a/src/amd/vulkan/radv_descriptor_set.c b/src/amd/vulkan/radv_descriptor_set.c
index e2bd9b92d90..b24ff91d3ed 100644
--- a/src/amd/vulkan/radv_descriptor_set.c
+++ b/src/amd/vulkan/radv_descriptor_set.c
@@ -52,7 +52,7 @@ VkResult radv_CreateDescriptorSetLayout(
 
 	size_t size = sizeof(struct radv_descriptor_set_layout) +
 		(max_binding + 1) * sizeof(set_layout->binding[0]) +
-		immutable_sampler_count * sizeof(struct radv_sampler *);
+		immutable_sampler_count * 4 * sizeof(uint32_t);
 
 	set_layout = vk_alloc2(&device->alloc, pAllocator, size, 8,
 				 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
@@ -60,8 +60,7 @@ VkResult radv_CreateDescriptorSetLayout(
 		return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
 
 	/* We just allocate all the samplers at the end of the struct */
-	struct radv_sampler **samplers =
-		(struct radv_sampler **)&set_layout->binding[max_binding + 1];
+	uint32_t *samplers = (uint32_t*)&set_layout->binding[max_binding + 1];
 
 	set_layout->binding_count = max_binding + 1;
 	set_layout->shader_stages = 0;
@@ -133,11 +132,10 @@ VkResult radv_CreateDescriptorSetLayout(
 
 		if (binding->pImmutableSamplers) {
 			set_layout->binding[b].immutable_samplers = samplers;
-			samplers += binding->descriptorCount;
+			samplers += 4 * binding->descriptorCount;
 
 			for (uint32_t i = 0; i < binding->descriptorCount; i++)
-				set_layout->binding[b].immutable_samplers[i] =
-					radv_sampler_from_handle(binding->pImmutableSamplers[i]);
+				memcpy(set_layout->binding[b].immutable_samplers + 4 * i, &radv_sampler_from_handle(binding->pImmutableSamplers[i])->state, 16);
 		} else {
 			set_layout->binding[b].immutable_samplers = NULL;
 		}
@@ -331,9 +329,7 @@ radv_descriptor_set_create(struct radv_device *device,
 			offset += 16;
 
 		for (unsigned j = 0; j < layout->binding[i].array_size; ++j) {
-			struct radv_sampler* sampler = layout->binding[i].immutable_samplers[j];
-
-			memcpy(set->mapped_ptr + offset, &sampler->state, 16);
+			memcpy(set->mapped_ptr + offset, layout->binding[i].immutable_samplers + 4 * j, 16);
 			offset += layout->binding[i].size / 4;
 		}
 
diff --git a/src/amd/vulkan/radv_descriptor_set.h b/src/amd/vulkan/radv_descriptor_set.h
index 0674822759b..8849d053121 100644
--- a/src/amd/vulkan/radv_descriptor_set.h
+++ b/src/amd/vulkan/radv_descriptor_set.h
@@ -44,7 +44,7 @@ struct radv_descriptor_set_binding_layout {
    uint16_t dynamic_offset_count;
 
    /* Immutable samplers (or NULL if no immutable samplers) */
-   struct radv_sampler **immutable_samplers;
+   uint32_t *immutable_samplers;
 };
 
 struct radv_descriptor_set_layout {
-- 
2.11.1



More information about the mesa-dev mailing list