summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2019-01-19 09:40:12 -0600
committerEmil Velikov <emil.l.velikov@gmail.com>2019-01-29 17:44:27 +0000
commitf5b6f5ad645b30e0a70a2e515dc5ee5172b4b221 (patch)
tree985b75f1879e769d7d5bc0afec73c5f1c6be1ec1
parent93db1e7153df523434c1190fd4361af9405a0dc6 (diff)
anv: Only parse pImmutableSamplers if the descriptor has samplers
Cc: mesa-stable@lists.freedesktop.org Reviewed-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> (cherry picked from commit c7f4a2867ce492d78c1f8e2870c0a593d280572d)
-rw-r--r--src/intel/vulkan/anv_descriptor_set.c43
1 files changed, 31 insertions, 12 deletions
diff --git a/src/intel/vulkan/anv_descriptor_set.c b/src/intel/vulkan/anv_descriptor_set.c
index 2bd1d86f4d4..bbe7369fadc 100644
--- a/src/intel/vulkan/anv_descriptor_set.c
+++ b/src/intel/vulkan/anv_descriptor_set.c
@@ -94,7 +94,22 @@ VkResult anv_CreateDescriptorSetLayout(
uint32_t immutable_sampler_count = 0;
for (uint32_t j = 0; j < pCreateInfo->bindingCount; j++) {
max_binding = MAX2(max_binding, pCreateInfo->pBindings[j].binding);
- if (pCreateInfo->pBindings[j].pImmutableSamplers)
+
+ /* From the Vulkan 1.1.97 spec for VkDescriptorSetLayoutBinding:
+ *
+ * "If descriptorType specifies a VK_DESCRIPTOR_TYPE_SAMPLER or
+ * VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER type descriptor, then
+ * pImmutableSamplers can be used to initialize a set of immutable
+ * samplers. [...] If descriptorType is not one of these descriptor
+ * types, then pImmutableSamplers is ignored.
+ *
+ * We need to be careful here and only parse pImmutableSamplers if we
+ * have one of the right descriptor types.
+ */
+ VkDescriptorType desc_type = pCreateInfo->pBindings[j].descriptorType;
+ if ((desc_type == VK_DESCRIPTOR_TYPE_SAMPLER ||
+ desc_type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) &&
+ pCreateInfo->pBindings[j].pImmutableSamplers)
immutable_sampler_count += pCreateInfo->pBindings[j].descriptorCount;
}
@@ -153,6 +168,12 @@ VkResult anv_CreateDescriptorSetLayout(
if (binding == NULL)
continue;
+ /* We temporarily stashed the pointer to the binding in the
+ * immutable_samplers pointer. Now that we've pulled it back out
+ * again, we reset immutable_samplers to NULL.
+ */
+ set_layout->binding[b].immutable_samplers = NULL;
+
if (binding->descriptorCount == 0)
continue;
@@ -170,6 +191,15 @@ VkResult anv_CreateDescriptorSetLayout(
set_layout->binding[b].stage[s].sampler_index = sampler_count[s];
sampler_count[s] += binding->descriptorCount;
}
+
+ if (binding->pImmutableSamplers) {
+ set_layout->binding[b].immutable_samplers = samplers;
+ samplers += binding->descriptorCount;
+
+ for (uint32_t i = 0; i < binding->descriptorCount; i++)
+ set_layout->binding[b].immutable_samplers[i] =
+ anv_sampler_from_handle(binding->pImmutableSamplers[i]);
+ }
break;
default:
break;
@@ -221,17 +251,6 @@ VkResult anv_CreateDescriptorSetLayout(
break;
}
- if (binding->pImmutableSamplers) {
- set_layout->binding[b].immutable_samplers = samplers;
- samplers += binding->descriptorCount;
-
- for (uint32_t i = 0; i < binding->descriptorCount; i++)
- set_layout->binding[b].immutable_samplers[i] =
- anv_sampler_from_handle(binding->pImmutableSamplers[i]);
- } else {
- set_layout->binding[b].immutable_samplers = NULL;
- }
-
set_layout->shader_stages |= binding->stageFlags;
}