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
Provide shader inputs as arguments to entry point functions #1315
Comments
What's the benefit of not moving the resources into the struct? Having everything passed to the function means they need to be passed to all call functions. This would be nice as we can stop doing the analysis of what's used by the shader, we just take the param / return values. Passing some, and referencing others means we still have to do the analysis for the resources. |
I'm fine either way. My worry is that with resources specifically there is going to be a whole lot of repetition in the code. |
About resources: SPIR-V/Vulkan base functionality doesn't let you pass pointers to buffers (storage or uniform) into helper functions. So that argues in favour of leaving them outside. |
Doesn't putting things in structs entangle one field with another? |
How does this affect certain builtin variables with special behaviour:
Putting the variables in the parameter list / return struct makes it much less straightforward to track modifications when they can be across function boundaries (via pointer passing). |
Actually, I'd argue for the exact opposite 😝 So overall the validation becomes easier, WGSL rules become simpler (no need to specify that all control flow writes to an output), and writing this code is easier (no repeating of varyings). It's a win all around. |
WGSL meeting minutes 2021-01-26
|
For handling pipeline inputs as entry point arguments, and pipeline outputs as entry point return, I thought about the translation path from SPIR-V (Vulkan) and to SPIR-V (Vulkan). The translation scheme is fairly straightforward in both directions. There is no blowup in complexity of the code itself, so I think there will be negligible performance cost. For details, see https://dawn-review.googlesource.com/c/tint/+/38961 [KN: Preview link] I have not thought about other impact on the WGSL spec. |
(Nitpick on the example at the top. The locations must overlap in the fragment output.) |
WGSL meeting minutes 2021-02-02
|
This PR moves the in/out storage class variables to be entry point parameters/return values. Fixes #1315
This is a proposal to address #1155 .
Aligns well with #1171.
We should consider:
Here is how it may look like:
This is how we can return more than one value:
The in/out variables and builtins can be specified either directly as argument (or return values), or put into a struct. This largely follows the HLSL (see example) and MSL (see example) shaders.
In the specification, we can say that struct layouts can be one of the 3 different kinds:
[[location(xxx)]]
or[[builtin(xxx)]
.[[span(xx)]
Note: returning tuples may improve some of the cases, but it's not required in this proposal, can be considered after MVP.
The text was updated successfully, but these errors were encountered: