Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Does MVK support VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT_EXT? #2246

Open
SRSaunders opened this issue Jun 1, 2024 · 2 comments

Comments

@SRSaunders
Copy link
Contributor

SRSaunders commented Jun 1, 2024

The descriptor_indexing sample in the official Khronos Vulkan-Samples repo fails (https://github.com/KhronosGroup/Vulkan-Samples/blob/main/samples/extensions/descriptor_indexing/descriptor_indexing.cpp), even with argument buffers enabled.

I have tracked down the issue, and it relates to exhaustion of the descriptor pool. The sample defines bindings with set_layout_binding.descriptorCount = maxDescriptorSetUpdateAfterBindSampledImages, i.e. the max. This seems excessive, but may not be an issue for other platforms that respect the VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT_EXT flag which is set by the sample.

The problem arises when actually allocating descriptor sets, i.e. when calling vkAllocateDescriptorSets() extended by the VkDescriptorSetVariableDescriptorCountAllocateInfoEXT structure. The structure properly defines the number of descriptors to be allocated (i.e. NumDescriptorsStreaming and NumDescriptorsNonUniform in two separate allocations), but MoltenVK's allocate action seems to check if there are set_layout_binding.descriptorCount resources available in the pool, which in this case is 500,000 (the max) and of course this fails since it exceeds the pool size.

I have been able to verify this and get the sample working by using NumDescriptorsStreaming in the binding definition, and by increasing the pool size to 2 x NumDescriptorsStreaming (for 2 allocation calls). However, I suspect this may violate the spirit of the sample where variable descriptor count allocations are used.

I am wondering whether MoltenVK supports the variable descriptor count flag and structure, and if so, should it instead be checking for variable_info.pDescriptorCounts resources in the pool when the variable bit is enabled and the variable descriptor count structure is present in the pNext chain of allocate_info.

I am putting this forward as a question, since I may not have this right. However, I wanted to report it here before going back to the official sample repo and offering any solutions for MoltenVK in that forum.

@SRSaunders SRSaunders changed the title Possible MVK defect exposed by Khronos descriptor indexing sample Question: Does MVK support VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT_EXT? Jun 14, 2024
@billhollings
Copy link
Contributor

The use of Metal Argument Buffers in MoltenVK is currently being overhauled. It should be published in the next week or so. At that point, you can retest this, and if it's still an issue, we can fix it within the new argument buffer environment.

@SRSaunders
Copy link
Contributor Author

Thanks for the heads up and I will retest when you release your new argument buffer code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants