-
Notifications
You must be signed in to change notification settings - Fork 402
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
Validation issue with partially bound texture arrays #2205
Comments
By "binding", are you referring to If so, |
Sorry, I mean the Metal bindings set with |
So in other words, The Vulkan standard says only that, if a pipeline with a new layout is bound, and descriptor set n is then bound when there are already sets bound, then:
It also says that, once descriptor sets are disturbed, the descriptors become undefined, with everything that entails. Does what you're doing work with the validation layer? |
Thanks for the feedback. I don't have validation layers running on macOS because I link with MoltenVK directly, but the same codepath doesn't trigger validation issues on Windows. However I think the issue is at the Metal level, not at a Vulkan usage level. In Vulkan I would provide a descriptors for the integer textures and they'd get bound to metal indices 0 and 1. Then for the next shader I could provide a PARTIALLY_BOUND descriptor that only has an entry for index 0. When the geometry for that shader is rendered the binding at 1 is still leftover as an integer texture, triggering this metal assert (even though what I did was legal from a Vulkan standpoint). This is my understanding of what is happening from the outside atleast, without being a Metal expert. |
Hmmm. MoltenVK doesn't do anything with the The simplest thing to do would be for MoltenVK to disable |
I don't think it's a required feature of |
The Vulkan spec has wording that requires it:
Hmmm...but doesn't your situation have a texture in index 1, but that the shader is not using it, and validation complains anyway? MoltenVK would have to somehow know the shader doesn't ever access element 1, and remove it as being set. How would MoltenVK know what indexes the shader might be accessing?
This point is valid. We could adopt a stance that the validation is overly sensitive, and that the practical effect is that it works anyway. |
It is required for the EXT, but I don't think it is for Vulkan 1.2. |
Agreed that The OP indicates use of If The portability change would be to include spec wording that |
Ah my mistake, I thought
Right, neither MoltenVK nor Metal can know what the shader is actually using. The Metal validation issue occurs because there is a leftover incompatible binding at index 1, and the shader may use that binding, so it complains. |
Hmmm...so MoltenVK would query the shader for texture formats, check the descriptor texture formats at runtime, and refuse to bind them to Metal if they are different. This is possible with effort (both dev and runtime cost), but also does seem expensive for an edge case. Also, this will probably all become very different, and likely moot, once MoltenVK moves to a fully bindless model soon. |
I wouldn't expect it to compare formats. If the descriptor has a resource for a binding, it's up to the programmer to ensure it's a compatible format. This would only be for bindings that don't have an entry or have an invalid entry, since that results in 'leftover' bindings in the argument table from previous operations, that may be incompatible. If this isn't going to be a long term issue due to a different workflow coming in though, then I totally agree we can just ignore it until then. |
Isn't that the Metal validation error you're getting above? The shader is expecting the texture format type to be |
The descriptor only has an entry for binding 0, which is a float texture. There is nothing specified for binding 1, so it's left as-is in the Metal argument table. In this case it happens to be an int texture from a previous shader+render operation |
Ah. Okay. Just check that the second DS is only setting one texture, but the array is larger and so all the other elements need to be nilled. Can you post the Metal function declarations for your two respective shaders, so we can see how the arguments are being declared, please? We don't need the shader body, just the
part for each. You can generate those by setting a |
Here is the shader that is used beforehand
The shader with this declaration causes the validation error to occur when trying to render, due to a uint texture being left bound to binding 1.
|
Hey, not sure if this is the right spot to put this (should it go in discussions?). I'm currently diagnosing some issues with partially bound texture arrays and MoltenVK. Looking for some guidance to diagnose it and I'll make a PR once fixed.
I am not using argument buffers.
I have an array of size 128, but the shader only uses 1 element, and I'm only binding one texture on binding index = 0. This means that indexes 1-127 are also allocated for that texture array, but unused.
If a previous operation has binded a texture to index 1, I may get a metal validation errors such as:
Shouldn't any currently bound indices for that array get unbound to avoid stale bindings being checked during validation?
Does that only need to happen when validation is enabled, and can be ignored otherwise, with the presumption the shader isn't going to access that stale binding?
Thanks
The text was updated successfully, but these errors were encountered: