-
Notifications
You must be signed in to change notification settings - Fork 244
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
Move Output vars to return position (was: Storage class inference interface) #416
Comments
Some can be either, but I think the best default would be to picking input vs output based on the kind of reference, and use attributes to override that - we could also support outputs via returns, tho multiple/named outputs would require a |
For Vulkan 1.2, if anyone is curious, the valid Storage Classes for each builtin are listed here: Not sure if the information is available in a machine-readable format (haven't checked yet), but Ctrl+F |
How would a function like this be handled? Compiler error I guess? fn shader(#[spirv(input)] foo: &mut Vec4) {} How does the
(As you both know, I prefer a type based syntax for this because I think it's easier to read and write, more idiomatic, and will help with implementing safe CPU-GPU interop) |
Oh right, that's where I was suggesting Alternatively, we could return the value from the entry-point - this gets more interesting with multiple outputs (which may be builtins so they would need a place to attach attributes to anyway) - probably be the best thing in that case is returning a |
Small note that, that is blocked on #415 |
Based on #415 (comment) I think we're fine - I doubt ZST inputs/outputs would be common, if at all supported by SPIR-V and/or Vulkan. |
This would be nice imo as it allows to default to |
How would descriptor indexing work? #[spirv(uniform, descriptor_set = 0, binding = 0)] way_1: [&T],
#[spirv(uniform, descriptor_set = 0, binding = 0)] way_2: &[T],
#[spirv(uniform_array, descriptor_set = 0, binding = 0)] way_3: &T,
#[spirv(uniform_array, descriptor_set = 0, binding = 0)] way_4: &[T],
#[spirv(uniform_array, descriptor_set = 0, binding = 0)] way_5: &[&T],
Descriptor array bindings are created in Vulkan by specifying a count > 1 in VkDescriptorSetLayoutBinding. Runtime descriptor array bindings additionally require the appropriate flag to be set in VkDescriptorSetLayoutBindingFlagsCreateInfo. |
Storage class inference is now a thing as of #300/#414. This details the design for the interface system taking advantage of inference, pointing out all the rules of how storage classes are specified in entry points.
There are a handful of ways of specifying a storage class:
fn main(#[spirv(input)] x: &f32)
. This uses the current list of storage classes.fn main(#[spirv(position)] x: &Vector3)
(inferred as input). This uses the current list of builtins (a table is needed to map builtin to storage class, I think some are input, some are output, and there may be others)fn main(x: &Image2d)
(inferred as uniform_constant). I thiiink images are always uniform_constant and not uniform, but I'm not sure.If exactly one of these rules matches, then use the storage class it specifies.
If more than one of these rules matches, and they all compute the same storage class, emit a warning (e.g.
#[spirv(position, input)]
, warn oninput
and say it's redundant). If more than one of these rules matches, and they compute different storage classes, emit an error.If none of these rules matches, then we have an open design question. The options here are a trade-off between catching user errors that may be difficult to diagnose/guiding users with explicit syntax suggestions, and not annoying people with overly explicit syntax that takes a while to type out and read.
fn main(x: &f32)
-> is this an error, or does it default toinput
? (or something else)fn main(x: &Struct)
-> is this an error, does it default toinput
, or does it default touniform
? (or something else)fn main(x: &mut f32)
-> is this an error, or does it default tooutput
? (or something else)For 2, I don't know if it's valid to have a struct (or any other non-scalar) be an
input
/output
variable, more research is needed.An alternative is to keep the current system of
Input<T>
and friends. We would remove the.load()
and.store()
methods entirely, and implementDeref
/DerefMut
(when applicable) for them. I much prefer the readability, recognizability, and usability of using plain references, but I understand others don't feel the same way~The text was updated successfully, but these errors were encountered: