WIP: Let SPIRV-Cross assign MSL resource indices. #1173
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There's an issue with assigning Metal resource indices upfront that this PR attempts to address.
Suppose that a client creates a pipeline with more resources in the layout than is allowed for a shader to use, say, more than 16 samplers. In the current scheme, even if no single stage uses too many samplers by itself, they will get numbered globally for the entire pipeline and crash when an index is > 15.
The proposed solution is to let SPIRV-Cross allocate the resource indices on demand. There's already a mechanism to do that, although I made some changes to make use of it more easily.
Apart from fixing that problem, there are some other upsides to it: we can stop binding unused resources and maybe handle implicit buffers more nicely.
Currently this PR is in a work in progress, not quite working yet state. Although it does seem to work with some games I was testing. @billhollings please let me know if that's a direction you like, or should the problem be addressed in some other way?