-
Notifications
You must be signed in to change notification settings - Fork 237
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
[SpecializationConstant] should not cause allocation of descriptor set binding. #5595
Comments
The In Slang, the native way to use push constants is to define them as entrypoint uniform parameters. For example:
will result in SPIRV that puts both See playground demo here. |
Thanks that works for me. Also I am unsure if the Thanks a lot for the quick reply. Lastly, would you mind giving your opinion if this is a good approach to handle scenario where both bindless and bindful path need to be supported by a shader or is there a better way to do it with slang. Thanks in advance. |
I think it is a bug for the ParameterBlock to be assigned set 1. This is likely due to the existence of:
Slang might be thinking these are normal uniforms and need a uniform buffer binding in set 0, so any future parmaeter blocks got assigned set 1. Removing these the Slang currently does not have a first-class way of doing bindless, so I think your solution should work fine. |
Thanks, if you are okay, I keep this issue open to track the bug related to set assignment, or I could open a new issue, as you want. |
We can keep this issue as is, I updated the title to reflect the issue. |
Thanks for the patch, however, I am still having issues with a generated shader after applying your patch. The SPIR-V output still contains DescriptorSet index as 1 as the only descriptor set. I will share with you the shader I am using and the SPIR-V generated. Shader / EDIT: Note that I tested without the Specialization constants, and set number and bindings are correct when I dont use them. |
The playground hasn’t been updated to use top of tree slang. I updated it just now and it is now using set 0 with your shader code. |
My apologies. Indeed, I pulled the latest changes again and clean rebuild everything. Seems to be working after that. |
In-fact the issue I was having is not due to SpecializationConstants. I still end up having a descriptor set at index 1. Updated shader The shader I have should not produce a new DescriptorSet. I was actually having the issue in the GraphicsPipeline creation which was reporting I have no layout in my descriptorSetLayout for DescriptorSet 1, and it had me confused why was there a set at 1 to begin with, because indeed the reflection interface was also not reporting it. EDIT: The issue is probably because the texture is not in use in vertex shader, so when I link the two shaders, it computes set numbers separately for the ubo block and for the texture. Is there a way to force not to remove unused parameters or force all parameter group elements to be in a single set? |
I think this is due to a bug when compiling both entry points into the same spirv module. What happens if you compile just the fragment shader EntryPoint?
|
It feels like the entry point parameters some how got duplicated when there are two entry points. |
In-fact if I just compile using shader playground for example, by removing either of the entry points, everything is good. |
|
You may be thinking of |
After looking more into this issue, I think we should keep the existing behavior. Consider the following:
When compiling both shader entrypoints into the same spirv module, we have to put So the current behavior that you are seeing is actually correct. When you have two entrypoints each declaring a ParameterBlock, the compiled spirv module will contain duplicate parameter declarations in different descriptor sets. If you wish to share the parameter binding across different entrypoints, the only solution right now is to declare them in the global scope. For this reason, I am going to close this issue as won't fix. |
Why is it not possible to match type-name between the two uniform passed to each method ? Does the set/binding assignment happen before linking the two shaders ? if not, I feel like it should be manageable to do the assignment once, if this info is stored in the AST. But anyway, if this is a permanent restriction, I don't see function parameters on entry points as very useful. |
This kind of matching and deduplication is too much magic and may lead to surprises. It is completely possible and valid for different EntryPoint parameters of the same type to mean different instances. In general the compiler shouldn't deduplicate two distinct declarations just because they have the same type. As said in previous post, if sharing of a parameter among different entry points is intended, then declaring it in global scope is the only viable way currently. |
Hi,
First off, thanks for providing a shader playground.
I was hoping that this could be supported, where all push constants are grouped together into a single constant block
Instead it generates glsl with two push constant blocks. I believe at-least it should throw an error. Shader link
Thanks in advance.
The text was updated successfully, but these errors were encountered: