-
Notifications
You must be signed in to change notification settings - Fork 722
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
[SPIR-V] Implement vk::ext_builtin_input and vk::ext_builtin_output #6027
[SPIR-V] Implement vk::ext_builtin_input and vk::ext_builtin_output #6027
Conversation
That could be better. Let me know if you think the implementation would be to complicated. We can go back and change HLSL specs. This might also make is easier to pass as a parameter to a function. If it is a function, we cannot do that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just a little style comment.
@s-perron lmk what you think of this approach. |
tools/clang/test/CodeGenSPIRV_Lit/spv.inline.builtin.output.hlsl
Outdated
Show resolved
Hide resolved
I think this looks good. We should probably add more testing. For example, what happens if the builtin is passed as a parameter to a function? Making the variable static is not a problem. The input and output variables are not shared, and static tells you that. I wonder if we should enforce that. Add an error if we try to apply the attribute to a variable that is not static. We should update the spec to say that. |
Do you mean something like |
…o inline-spirv-builtin
Hello! Found another cases where the diagnostic should be improved [[vk::ext_builtin_output(/* FragStencilRefEXT */ 5014)]]
static int output;
[[vk::ext_builtin_input(/* FragStencilRefEXT */ 5014)]]
static int input;
[[vk::ext_extension("SPV_EXT_shader_stencil_export")]]
void main() {
int tmp = input;
output = 10;
}
If input is not read, it works. The error seems wrong as it puts the blame on output, which is marked as output. We may want to error out before, if 2 variables share the same builtin but with different I/O. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine with this.
It's easy to make the validation fails, but I'd assume that's like inline assembly, you are on your own to make sure you use this correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple more test to add.
tools/clang/test/CodeGenSPIRV_Lit/spv.inline.builtin.input.hlsl
Outdated
Show resolved
Hide resolved
Sure, I've added an error for that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, we let this sit until we update HLSL specs, and hear back from the community on some of the finer details.
I've added a |
I definitely think it would look better if we allowed these attributes on variables, ie microsoft/hlsl-specs#76. I haven't fully investigated how involved it would be to implement, but my intuition is that it wouldn't take that much more work.
Fixes #4217.