-
Notifications
You must be signed in to change notification settings - Fork 353
wgsl: access mode is no longer an attribute #1735
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
Conversation
|
Note: With this PR, the storage classes have minimum flexibility. Only the 'storage' storage class allows more than one access mode. (You can't create a read-only variable in function storage class, for example. ) |
alan-baker
left a comment
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.
I would merge both access modes into a single grammar.
| // 'ptr<function,i32>' is the type of a pointer value that references storage | ||
| // for keeping an 'i32' value, using memory locations in the 'function' storage | ||
| // class. Here 'i32' is the pointee type. | ||
| // 'ptr<function,i32,read_write>' is the type of a pointer value that references |
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.
are we forced to write read_write for all the pointers with this change?
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.
Only for storage buffers. Line 1806 effectively says if there is only one valid mode, then that is the default and it must not be specified. So this comment is for exposition only as it is invalid WGSL.
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.
With type inference for let-declarations, you never have to write this pointer type. (At least while pointer-to-storage is disallowed as in the baseline. And afterward you only need to write it for formal parameter declaration.)
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.
This just mentions ptr<function,i32,read_write>, which confused me. Is this a valid type to write, given that the access should only be seen on storage and workgroup classes?
| textureLoad(t: [[access(read)]] texture_storage_2d<F>, coords: vec2<i32>) -> vec4<T> | ||
| textureLoad(t: [[access(read)]] texture_storage_2d_array<F>, coords: vec2<i32>, array_index: i32) -> vec4<T> | ||
| textureLoad(t: [[access(read)]] texture_storage_3d<F>, coords: vec3<i32>) -> vec4<T> | ||
| textureLoad(t: texture_storage_1d<F,read>, coords: i32) -> vec4<T> |
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.
what's going to happen with read-write textures? are we going to provide overloads for read-write for all of the builtin functions on storage textures?
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.
Similar to the proposal for coercing read_write pointers to read pointers, we could do the same thing with textures when read_write textures are added to WGSL. Or, yes, we could just provide overloads.
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.
I would say we add overloads for read_write. We don't need to add coercion for this.
|
I've addressed actionable feedback. PTAL. |
- Delete 'access' as an attribute. - Add "Memory Access Mode" section - Storage classes table gets a "Supported access modes" and "Default access mode" NOTE: This is the minimally flexible set of options; only 'storage' has any flexibility. - Add "Access Modes Defaults" section, among "Memory View Types" - Each memory view has an access mode. - Access modes are inherited by most reference-handling operations. - LHS of assignment must be write or read-write - Load Rule applies only if the reference is read or read-write. - Storage texture types are parameterized by 'read' or 'write' access mode. - Formal parameters that are pointers must match in access type with the call site's pointer argument. - Fix the description of modf and frexp to properly parameterize the pointer types. Fixes: gpuweb#1604
Mark 'read' as the default in the 'storage' row. The default-ness is already fully explained in its own section 'Memory Access Defaults'.
Instead of storage_textures_access and variable_access_mode, use a single access_mode and rely on external validation to catch the invalid combinations.
Move the grammar rule to the "Memory Access Mode" section.
|
Rebased and resolved conflicts. PTAL |
kvark
left a comment
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.
If I have a pointer, do I need to specify the storage access with this PR?
- always
- only for storage and workgroup classes
| // 'ptr<function,i32>' is the type of a pointer value that references storage | ||
| // for keeping an 'i32' value, using memory locations in the 'function' storage | ||
| // class. Here 'i32' is the pointee type. | ||
| // 'ptr<function,i32,read_write>' is the type of a pointer value that references |
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.
This just mentions ptr<function,i32,read_write>, which confused me. Is this a valid type to write, given that the access should only be seen on storage and workgroup classes?
(Edit to fix the answer.) Only for |
|
Checked again with @kvark, acceptable to merge. |
WGSL meeting minutes 2021-05-25
|
Remove access control decorations. See gpuweb/gpuweb#1735 arrayLength() now takes a pointer to the array. See gpuweb/gpuweb#1619
Remove access control decorations. See gpuweb/gpuweb#1735 arrayLength() now takes a pointer to the array. See gpuweb/gpuweb#1619
access mode"
NOTE: This is the minimally flexible set of options; only 'storage'
has any flexibility.
mode.
the call site's pointer argument.
the pointer types.
Fixes: #1604