Module: Mesa Branch: main Commit: 59a6ddd85c28868b3be2b1872f3867f7f9ca79c1 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=59a6ddd85c28868b3be2b1872f3867f7f9ca79c1
Author: Boris Brezillon <[email protected]> Date: Tue Apr 19 11:43:22 2022 +0200 dzn: Implement GetDescriptorSetLayoutSupport() The 2048 descriptors limit comes from the maximum number of samplers per heap, but the limit for other descriptors is actually much bigger. Let's implement GetDescriptorSetLayoutSupport() to reflect that. Reviewed-by: Erik Faye-Lund <[email protected]> Reviewed-by: Jesse Natalie <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16926> --- src/microsoft/vulkan/dzn_descriptor_set.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/microsoft/vulkan/dzn_descriptor_set.c b/src/microsoft/vulkan/dzn_descriptor_set.c index 7e12d2cf6b4..3d796d4f2f6 100644 --- a/src/microsoft/vulkan/dzn_descriptor_set.c +++ b/src/microsoft/vulkan/dzn_descriptor_set.c @@ -462,6 +462,31 @@ dzn_DestroyDescriptorSetLayout(VkDevice device, pAllocator); } +VKAPI_ATTR void VKAPI_CALL +dzn_GetDescriptorSetLayoutSupport(VkDevice device, + const VkDescriptorSetLayoutCreateInfo *pCreateInfo, + VkDescriptorSetLayoutSupport *pSupport) +{ + const VkDescriptorSetLayoutBinding *bindings = pCreateInfo->pBindings; + uint32_t sampler_count = 0, other_desc_count = 0; + + for (uint32_t i = 0; i < pCreateInfo->bindingCount; i++) { + VkDescriptorType desc_type = bindings[i].descriptorType; + bool has_sampler = dzn_desc_type_has_sampler(desc_type); + + if (has_sampler) + sampler_count += bindings[i].descriptorCount; + if (desc_type != VK_DESCRIPTOR_TYPE_SAMPLER) + other_desc_count += bindings[i].descriptorCount; + if (dzn_descriptor_type_depends_on_shader_usage(desc_type)) + other_desc_count += bindings[i].descriptorCount; + } + + pSupport->supported = + sampler_count <= (MAX_DESCS_PER_SAMPLER_HEAP / MAX_SETS) && + other_desc_count <= (MAX_DESCS_PER_CBV_SRV_UAV_HEAP / MAX_SETS); +} + static void dzn_pipeline_layout_destroy(struct dzn_pipeline_layout *layout) {
