layers: Ignore pImmutableSamplers on non-samplers
diff --git a/layers/object_tracker_utils.cpp b/layers/object_tracker_utils.cpp
index f4f148d..501083b 100644
--- a/layers/object_tracker_utils.cpp
+++ b/layers/object_tracker_utils.cpp
@@ -695,6 +695,41 @@
return result;
}
+VKAPI_ATTR VkResult VKAPI_CALL CreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
+ const VkAllocationCallbacks *pAllocator,
+ VkDescriptorSetLayout *pSetLayout) {
+ bool skip = false;
+ {
+ std::lock_guard<std::mutex> lock(global_lock);
+ skip |=
+ ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_1f805601, VALIDATION_ERROR_UNDEFINED);
+ if (pCreateInfo) {
+ if (pCreateInfo->pBindings) {
+ for (uint32_t binding_index = 0; binding_index < pCreateInfo->bindingCount; ++binding_index) {
+ const VkDescriptorSetLayoutBinding &binding = pCreateInfo->pBindings[binding_index];
+ const bool is_sampler_type = binding.descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER ||
+ binding.descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
+ if (binding.pImmutableSamplers && is_sampler_type) {
+ for (uint32_t index2 = 0; index2 < binding.descriptorCount; ++index2) {
+ const VkSampler sampler = binding.pImmutableSamplers[index2];
+ skip |= ValidateObject(device, sampler, kVulkanObjectTypeSampler, false, VALIDATION_ERROR_04e00234,
+ VALIDATION_ERROR_UNDEFINED);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;
+ VkResult result =
+ get_dispatch_table(ot_device_table_map, device)->CreateDescriptorSetLayout(device, pCreateInfo, pAllocator, pSetLayout);
+ if (VK_SUCCESS == result) {
+ std::lock_guard<std::mutex> lock(global_lock);
+ CreateObject(device, *pSetLayout, kVulkanObjectTypeDescriptorSetLayout, pAllocator);
+ }
+ return result;
+}
+
VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice,
uint32_t *pQueueFamilyPropertyCount,
VkQueueFamilyProperties *pQueueFamilyProperties) {
diff --git a/layers/vk_validation_error_database.txt b/layers/vk_validation_error_database.txt
index e28a05e..135603e 100644
--- a/layers/vk_validation_error_database.txt
+++ b/layers/vk_validation_error_database.txt
@@ -364,7 +364,7 @@
VALIDATION_ERROR_04c1c40d~^~Y~^~Unknown~^~vkAllocateDescriptorSets~^~VUID-VkDescriptorSetAllocateInfo-pNext-pNext~^~core~^~The spec valid usage text states 'pNext must be NULL' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkDescriptorSetAllocateInfo-pNext-pNext)~^~implicit, TBD in parameter validation layer.
VALIDATION_ERROR_04c22c01~^~Y~^~None~^~vkAllocateDescriptorSets~^~VUID-VkDescriptorSetAllocateInfo-pSetLayouts-parameter~^~core~^~The spec valid usage text states 'pSetLayouts must be a valid pointer to an array of descriptorSetCount valid VkDescriptorSetLayout handles' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkDescriptorSetAllocateInfo-pSetLayouts-parameter)~^~implicit
VALIDATION_ERROR_04c2b00b~^~Y~^~Unknown~^~vkAllocateDescriptorSets~^~VUID-VkDescriptorSetAllocateInfo-sType-sType~^~core~^~The spec valid usage text states 'sType must be VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkDescriptorSetAllocateInfo-sType-sType)~^~implicit, TBD in parameter validation layer.
-VALIDATION_ERROR_04e00234~^~N~^~None~^~vkCreateDescriptorSetLayout~^~VUID-VkDescriptorSetLayoutBinding-descriptorType-00282~^~core~^~The spec valid usage text states 'If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER or VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, and descriptorCount is not 0 and pImmutableSamplers is not NULL, pImmutableSamplers must be a valid pointer to an array of descriptorCount valid VkSampler handles' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkDescriptorSetLayoutBinding-descriptorType-00282)~^~
+VALIDATION_ERROR_04e00234~^~Y~^~None~^~vkCreateDescriptorSetLayout~^~VUID-VkDescriptorSetLayoutBinding-descriptorType-00282~^~core~^~The spec valid usage text states 'If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER or VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, and descriptorCount is not 0 and pImmutableSamplers is not NULL, pImmutableSamplers must be a valid pointer to an array of descriptorCount valid VkSampler handles' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkDescriptorSetLayoutBinding-descriptorType-00282)~^~
VALIDATION_ERROR_04e00236~^~Y~^~Unknown~^~vkCreateDescriptorSetLayout~^~VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283~^~core~^~The spec valid usage text states 'If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283)~^~
VALIDATION_ERROR_04e00bcc~^~N~^~None~^~VkDescriptorSetLayoutBinding~^~VUID-VkDescriptorSetLayoutBinding-descriptorType-01510~^~core~^~The spec valid usage text states 'If descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT and descriptorCount is not 0, then stageFlags must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkDescriptorSetLayoutBinding-descriptorType-01510)~^~
VALIDATION_ERROR_04e04e01~^~Y~^~Unknown~^~vkCreateDescriptorSetLayout~^~VUID-VkDescriptorSetLayoutBinding-descriptorType-parameter~^~core~^~The spec valid usage text states 'descriptorType must be a valid VkDescriptorType value' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkDescriptorSetLayoutBinding-descriptorType-parameter)~^~implicit
diff --git a/scripts/helper_file_generator.py b/scripts/helper_file_generator.py
index 1e59d0a..c588845 100644
--- a/scripts/helper_file_generator.py
+++ b/scripts/helper_file_generator.py
@@ -817,7 +817,7 @@
' default:\n'
' break;\n'
' }\n',
- 'VkShaderModuleCreateInfo' :
+ 'VkShaderModuleCreateInfo' :
' if (in_struct->pCode) {\n'
' pCode = reinterpret_cast<uint32_t *>(new uint8_t[codeSize]);\n'
' memcpy((void *)pCode, (void *)in_struct->pCode, codeSize);\n'
@@ -898,6 +898,15 @@
' }\n'
' else\n'
' pScissors = NULL;\n',
+ # VkDescriptorSetLayoutBinding is special case because its pImmutableSamplers pointer may be non-null but ignored
+ 'VkDescriptorSetLayoutBinding' :
+ ' const bool sampler_type = in_struct->descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER || in_struct->descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;\n'
+ ' if (descriptorCount && in_struct->pImmutableSamplers && sampler_type) {\n'
+ ' pImmutableSamplers = new VkSampler[descriptorCount];\n'
+ ' for (uint32_t i=0; i<descriptorCount; ++i) {\n'
+ ' pImmutableSamplers[i] = in_struct->pImmutableSamplers[i];\n'
+ ' }\n'
+ ' }\n',
}
custom_copy_txt = {
diff --git a/scripts/object_tracker_generator.py b/scripts/object_tracker_generator.py
index 4350fa3..9bcfb8b 100644
--- a/scripts/object_tracker_generator.py
+++ b/scripts/object_tracker_generator.py
@@ -169,6 +169,7 @@
'vkCreateComputePipelines',
'vkGetDeviceQueue',
'vkGetSwapchainImagesKHR',
+ 'vkCreateDescriptorSetLayout',
]
# These VUIDS are not implicit, but are best handled in this layer. Codegen for vkDestroy calls will generate a key
# which is translated here into a good VU. Saves ~40 checks.