-
Notifications
You must be signed in to change notification settings - Fork 435
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
Reduce number of unused pipeline bindings reserved for argument buffers. #2417
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for submitting this! Makes a lot of sense.
And I'm an impressed at how simple the change was (ie. not triggering side-effects elsewhere).
I've made some inline recommendations about simplifying the change even more.
_descriptorSetLayouts.push_back(pDescSetLayout); | ||
_canUseMetalArgumentBuffers = _canUseMetalArgumentBuffers || pDescSetLayout->isUsingMetalArgumentBuffers(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than setting dslCnt
for use in place of kMVKMaxDescriptorSetCount
, is there a reason all this code was moved from where it was?
The only change in the loop itself seems to be setting _canUseMetalArgumentBuffers
, but I don't see _canUseMetalArgumentBuffers
used anywhere before the location of the original code.
And we seem to have ended up with two loops iterating the same data.
My preference would be to leave this code where it was, add the setting of _canUseMetalArgumentBuffers
there, and either set dslCnt
up here, or simply use pCreateInfo->setLayoutCount
in place of kMVKMaxDescriptorSetCount
below, and leave dslCnt
where it was just being used to clarify the loop test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When it calls isUsingMetalArgumentBuffers()
right below this, it takes into account the value of _canUseMetalArgumentBuffers
, so it needs to be known to reserve the right number of buffers. And then the push constants part and second loop below that needs to know how many buffers were reserved for descriptor sets, so we can't just move those down either.
Do you have any particular alternate preference for how to organize the code based on these constraints?
pDescSetLayout->retain(); | ||
_descriptorSetLayouts.push_back(pDescSetLayout); | ||
|
||
MVKDescriptorSetLayout* pDescSetLayout = _descriptorSetLayouts[i]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my suggestion about this code above. This line (and the second looping) won't be needed.
I was hitting limits on number of bind indices available because a fixed 8 are always reserved for argument buffers, even with only a single descriptor set using push descriptors (which do not use argument buffers). Mainly when tessellation is involved, it was unable to reserve indices for the output buffer.
Please let me know if there's anything I'm missing with this approach, I tested it in my application both as-is and with push descriptors disabled, and it seems to work fine.
Side note: It may be worth modifying the
maxPushDescriptors
property based on the number of potential reserved bindings needed, as it's what I use to determine whether to use push descriptors or not for a pipeline descriptor set layout. Advertising with the max possible number when in reality some may be taken away for argument buffers and other internal bindings can cause problems that could be avoided if the application knew to avoid using as many push descriptors. But I didn't delve into that in this PR.