-
Notifications
You must be signed in to change notification settings - Fork 437
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Allow for setting the array length in a shader using a specialization constant #2345
Allow for setting the array length in a shader using a specialization constant #2345
Conversation
That should be already implemented by #2329. Does it not work for you? |
I'm assuming what they meant to say is to allow this usage in vulkano-shaders. In other words, it's attempting to fix #1956. Using the default value of the specialization constant as the length is certainly a solution and one that I considered, but personally I would prefer if the struct wasn't generated at all. It's going to be useless anyway and I bet cause more confusion when it's generated like that. Nevertheless this would be the simplest solution. |
What about generating a struct with a const parameter for the length? |
That's also a good option. shaderc vomits up array length 1 in places where runtime lengths are illegal without warning. We could do something similar, length 0 ideally. |
Wait I misread your question. I thought you meant generating it with a const length. Generating a const parameter won't make it runtime-sized. |
Also you would have to propagate the const parameter(s) throughout all uses of the structs. |
Yes, sorry i did not check if this issue existed already. If you would rather not generate a struct at all you can just close this pull request. |
I think it would be best to use 0 as the array length. Hopefully it won't cause confusion, as SPIR-V doesn't allow it, so it fits nicely as a kind of sentinel value. The issue with the other options is that it would require a lot of logic because things need to be propagated through structs that use the problematic structs. Like not generating a struct using spec-constant-sized arrays, we would also have to not generate any structs using those structs, and structs using those... This on the other hand requires little to no effort, also for any kind of spec constant. This would of course also require changing the |
@marc0246 Sure, in that case, does https://github.com/vulkano-rs/vulkano/blob/master/vulkano-macros/src/derive_buffer_contents.rs#L250C50-L250C50 need to be changed too? |
You make a very good point, I had forgotten about that. That would complicate things quite a bit. Knowing this, I think your PR is perfect just the way it is. :D Thank you for looking into this! |
To allow for something like this using vulkano-shaders:
Fixes #1956
Changelog: