WIP: MVKDescriptor: Prevent batched write combined image-sampler from overwriting each other in argument buffer #2427
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.
Currently samplerXXArray is translated to one textureXX_array and a single sampler in MSL, consuming 2 bindings in Metal regardless of the array size. This is already not an accurate translation. In the meantime, the descriptor set update does not consider the difference in numbers between the approaches. Despite the inaccuracy, the current solution "works" in some cases when not using argument buffers. They are broken when argument buffer is enabled.
The underlying reason is that image (texture) and sampler are in the same index space when used in argument buffers, and when updated in a batch (as sampler array) using combined image-sampler descriptor type, the sampler is overwritten by the next texture. This change avoids this kind of overwriting.
The ultimate solution would be properly implement texture/sampler arrays and account for the semantic differences between Vulkan and Metal in descriptor sets. But let's make it less broken first as the appropriate solution would require considerable effort.
Not a full fix, but addresses the symptom of #2403 .