-
Notifications
You must be signed in to change notification settings - Fork 438
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
Unsound push_constants
command implementation
#1819
Comments
I'm not sure if you understood it that way, but there isn't different push constant data for different stages. Rather, there is one set of data for all stages, and each stage declares (in the pipeline layout) which part of that data it's going to access. So in the example you gave for point 2, To actually make them map to different ranges, you'd do it like this: layout(push_constant) uniform PushConstantData1 {
layout(offset = 0) uint a;
} pc; layout(push_constant) uniform PushConstantData2 {
layout(offset = 4) uint b;
} pc; Now, one stage has the range 0..4 and the other has 4..8. |
Yes, your example is correct if we want to push two data using one push_constant command.
|
"Incrementally" means between one draw/dispatch command and the next. But there is only one set of data per single draw/dispatch command, one command will always use the current push constant data for all stages. The |
I think I might have misunderstood some parts of it, I'll experiment it. |
If
Does that mean that all shaders will get the same data: |
Yes, assuming that they access the whole 0..8 range. |
Then, it is be possible to handle |
The stage flags must be set in order to do what VUID-vkCmdPushConstants-offset-01796 requires. The code here figures out the stages automatically: vulkano/vulkano/src/command_buffer/auto.rs Lines 1843 to 1871 in 4f09439
|
My plan to fix point 3. is to call |
I don't think 3 is an error at all. The VUID just means "every byte must be in at least one of the push constant ranges". And in this case it is, since all 8 bytes are within the vertex stage's range. |
Actually it is, the validator reports it, that's what got me to investigate it, but not sure if it's a bug in the validator. I got also confused by it. |
Hmm that may mean the code above has a bug in it then. What error did the validator give? |
|
The current implementation of
push_constants
inauto.rs
has many problems:1- Serious buffer overflow bug (increment offset with same size):
vulkano/vulkano/src/command_buffer/auto.rs
Lines 1874 to 1877 in 4f09439
2- When calling
push_constants
we don't know which stages will be pushed to:If you have multiple stages, it will try to include as many as it can.
For example if you have these push_constant ranges:
It will push to the two of them, even if the content is different, for example:
3- Also there is a bug in selecting the stages, if you have two stages
And you pushed struct of size
8
, it will push to the two of them, which invalidatesI'll create a PR on making it mandatory to supply the stage that is needed, and also fix the buffer overflow bug.
Any other suggestions to improve
push_constants
handling?The text was updated successfully, but these errors were encountered: