Skip to content

Commit

Permalink
layers: Check vkGetDescriptorSetLayoutSupport
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-lunarg committed Mar 1, 2024
1 parent 2390b65 commit e5af159
Show file tree
Hide file tree
Showing 4 changed files with 662 additions and 449 deletions.
41 changes: 37 additions & 4 deletions layers/core_checks/cc_descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ bool CoreChecks::PreCallValidateCreateDescriptorSetLayout(VkDevice device, const
uint32_t uniform_buffer_dynamic = pCreateInfo->bindingCount;
uint32_t storage_buffer_dynamic = pCreateInfo->bindingCount;
const Location create_info_loc = error_obj.location.dot(Field::pCreateInfo);
bool using_mutable_type = false;

for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
const Location binding_loc = create_info_loc.dot(Field::pBindings, i);
Expand Down Expand Up @@ -701,10 +702,13 @@ bool CoreChecks::PreCallValidateCreateDescriptorSetLayout(VkDevice device, const
}
}

if (binding_info.descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_EXT && binding_info.pImmutableSamplers != nullptr) {
skip |=
LogError("VUID-VkDescriptorSetLayoutBinding-descriptorType-04605", device, binding_loc.dot(Field::descriptorType),
"is VK_DESCRIPTOR_TYPE_MUTABLE_EXT but pImmutableSamplers is not NULL.");
if (binding_info.descriptorType == VK_DESCRIPTOR_TYPE_MUTABLE_EXT) {
using_mutable_type = true;
if (binding_info.pImmutableSamplers != nullptr) {
skip |= LogError("VUID-VkDescriptorSetLayoutBinding-descriptorType-04605", device,
binding_loc.dot(Field::descriptorType),
"is VK_DESCRIPTOR_TYPE_MUTABLE_EXT but pImmutableSamplers is not NULL.");
}
}

if (pCreateInfo->flags & VK_DESCRIPTOR_SET_LAYOUT_CREATE_EMBEDDED_IMMUTABLE_SAMPLERS_BIT_EXT) {
Expand Down Expand Up @@ -759,6 +763,35 @@ bool CoreChecks::PreCallValidateCreateDescriptorSetLayout(VkDevice device, const
total_descriptors, phys_dev_ext_props.push_descriptor_props.maxPushDescriptors);
}

// No point of checking for support if other VUs have been triggered already
if (!skip && IsExtEnabled(device_extensions.vk_khr_maintenance3)) {
VkDescriptorSetVariableDescriptorCountLayoutSupport count_layout_support = vku::InitStructHelper();
const bool descriptor_indexing = IsExtEnabled(device_extensions.vk_ext_descriptor_indexing);
VkDescriptorSetLayoutSupport support = vku::InitStructHelper(descriptor_indexing ? &count_layout_support : nullptr);

if (IsExtEnabledByCreateinfo(device_extensions.vk_khr_maintenance3)) {
DispatchGetDescriptorSetLayoutSupportKHR(device, pCreateInfo, &support);
} else {
DispatchGetDescriptorSetLayoutSupport(device, pCreateInfo, &support);
}
if (!support.supported) {
std::stringstream error_str;
error_str << "was passed into vkGetDescriptorSetLayoutSupport and returned not supported";
if (descriptor_indexing) {
error_str << ", VkDescriptorSetVariableDescriptorCountLayoutSupport::maxVariableDescriptorCount = "
<< count_layout_support.maxVariableDescriptorCount;
}
if (using_mutable_type) {
error_str << " (verify mutable type are supported, not every driver supports mutable types such as "
"VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)";
}

// VU being added in https://gitlab.khronos.org/vulkan/vulkan/-/merge_requests/6269
skip |= LogError("UNASSIGNED-vkCreateDescriptorSetLayout-pCreateInfo", device,
error_obj.location.dot(Field::pCreateInfo), "%s", error_str.str().c_str());
}
}

return skip;
}

Expand Down
Loading

0 comments on commit e5af159

Please sign in to comment.