-
Notifications
You must be signed in to change notification settings - Fork 419
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
Support dynamically allocating descriptors when pool is exhausted. #2291
Support dynamically allocating descriptors when pool is exhausted. #2291
Conversation
7f8886f
to
9b9ac03
Compare
The Vulkan spec says:
So it's up to the implementation to define how strict it's going to be in enforcing these rules. Previously, MoltenVK chose to fail and report in both of these situations. But based on the issue that triggered this PR (#2282), other implementations are more lax. This PR relaxes the second directive, dynamically allocating additional descriptors of a type once that type has been exhausted in the pool. Design questions for you:
More discussion in the triggering issue. Thoughts? |
A couple of thoughts:
That's definitely what we do in our engine, yes. I guess it depends on what the cost/trade-off is going to be having MoltenVK dynamically allocate versus if the app had created its own new descriptor pool.
That seems like the right call. |
Thanks for all the background info.
Thanks for pointing that out. The app (vkQuake) is not opting in on
Can you clarify which of the two options I suggested you think is the right call? |
Reporting a failure and not allocating a Metal argument buffer. |
9b9ac03
to
d39adce
Compare
It's easy to dismiss vkQuake's behavior as being outside the spec, because it requested 1.1 behavior but failed to handle the out-of-memory condition. I suppose it's even easy enough to fix in vkQuake, given that John Carmack (thankfully) open-sourced his game engines. However, now I'm worried that there are other existing apps out there that can't be so easily updated. Also, I'm not sure how valid this concern is, given how argument buffers work: memory is memory; there's no separate memory for texture references vs. buffer pointers. I think the approach here is the right call.
I agree with @danginsburg here. I'd add that supporting this would come at the cost of additional complexity in the descriptor set code--that code is hairy enough as it is. |
Thanks for the additional advice and feedback. If you have the cycles, can you also review the PR content, please? |
Done. Sorry about the delay. |
d39adce
to
944033b
Compare
- MVKDescriptorTypePool if the pool is exhausted, report a warning, allocate a new descriptor instance, and when it is freed, destroy it. - Deprecate MVKConfiguration::preallocateDescriptors and MVK_CONFIG_PREALLOCATE_DESCRIPTORS, as both preallocation and dynamic allocation of descriptors are now supported. - vkAllocateDescriptorSets(): Per Vulkan spec, if any descriptor set allocation fails, free any successful allocations, and populate all descriptor set pointers with VK_NULL_HANDLE. In addition, return VK_ERROR_FRAGMENTED_POOL if failure was due to Metal argument buffer fragmentation. - vkUpdateDescriptorSets() accepts null VkDescriptorSets as no-ops. - MVKDescriptorPool::getLogDescription() include count of remaining descriptors in the pool, for diagnostic logging during debugging.
944033b
to
ddd5bf4
Compare
MVKDescriptorTypePool
if the pool is exhausted, report a warning, allocate a new descriptor instance, and when it is freed, destroy it.MVKConfiguration::preallocateDescriptors
andMVK_CONFIG_PREALLOCATE_DESCRIPTORS
, as both preallocation and dynamic allocation of descriptors are now supported.vkAllocateDescriptorSets()
: Per Vulkan spec, if any descriptor set allocation fails, free any successful allocations, and populate all descriptor set pointers withVK_NULL_HANDLE
. In addition, returnVK_ERROR_FRAGMENTED_POOL
if failure was due to Metal argument buffer fragmentation.vkUpdateDescriptorSets()
accepts nullVkDescriptorSet
s as no-ops.MVKDescriptorPool::getLogDescription()
include count of remaining descriptors in the pool, for diagnostic logging during debugging.Fix #2282.