Repository navigation
Conversation
This CL adds the `read_only` decoration to variables. This may only be used on `storage_buffer` storage class variables. Issue #935
|
I put this on the variable instead of the type. Putting it on the type gets more complicated in SPIR-V as you may need to generate the same type multiple times with different decorations. If the same struct is used for a Moving to the variable cleaners that up with the further restriction that |
I specifically requested us to be consistent here. This argument already applies to texture types (where the read-only/write-only is a property of the type in WGSL but the variable in SPIR-V), so nothing new to be handled by the implementation. We need to have both textures and buffers read-only properties be either on the variable, or on the type, but not mixed up. |
dneto0
left a comment
There was a problem hiding this comment.
I think this is the right change.
|
Yup, I understand the consistency argument and I think we need to talk about it. From a SPIR-V perspective, this way makes the most sense. Maybe there is a better way to do this, or maybe we need to revisit the texture types and move the |
Which way? The current way of this PR? or the current spec for WGSL textures? I think we can go either way. Having the textures separated at the type level makes up for a stronger grammer, but ultimately not require, and we'd be totally fine validating this at shader module creation time. |
There's may be a significant distinction. The texture types are only accessed via builtin, and the available builtins are determined by types, so it's highly suggestive to distinguish the textures by type. For buffers, the variables are accessed directly. So there's less of a reason to distinguish by type. Read-only-ness for buffers is like the const qualifier in C++. It goes with a value type, and distinguishes poitner-to-const vs. pointer-to-non-const. But this is worth talking through. edited first line to properly show that it was a quote |
|
By "goes with a value type" I mean is not used for overload resolution, specifically. (If I remember correctly.) |
We could make it so The downside is that it's a little bit more abstract than what we have today (somewhat related to the discussion about abstracting away the grammar for decorators, builtins, etc). The upside is that it would map perfectly to SPIR-V. Here is a quick table showing the differences between the target APIs with regards to read-only property:
If the property is on the type, it's making the SPIR-V frontend work more complicated. It may need to generate a duplicate type in case the same SPIR-V type is used as both write-only and read-only, for example. If the property is on the variable, it's making the HLSL and Metal backends potentially do more work. Similarly, they may need to generate a duplicate type if there are multiple variables using the same WGSL type but with different access qualifiers. |
|
Can we see some examples of the various problems here? I'm having trouble following the concerns. |
|
As discussed in the 2020-10-06 meeting, I'm closing this. We're investigating putting the access modifier on the type for textures and will do the same here, or re-open this PR if that fails for whatever reason. |
This CL adds the
read_onlydecoration to variables. This may only beused on
storage_bufferstorage class variables.Issue #935