Repository navigation
Description
From the discussion on #1120 there were concerns raised about the inconsistency with how read only is attributed on textures. Below I've listed the possibilities I can see, please comment with other possibilities if there is something I've missed.
Possible 0 (read_only on var declaration)
For buffers the read_only is on the variable declaration
[[block]] struct Buffer {
[[offset(0)]] a : i32;
};
[[read_only, binding(0), set(0)]]
var <storage> buf : Buffer;This is how textures exist now.
texture_sampled_1d<f32>
texture_sampled_1d_array<f32>
texture_sampled_2d<f32>
texture_sampled_2d_array<f32>
texture_sampled_3d<f32>
texture_sampled_cube<f32>
texture_sampled_cube_array<f32>
texture_multisampled_2d<f32>
texture_ro_1d<rgba32float>
texture_ro_1d_array<rgba32float>
texture_ro_2d<rgba32float>
texture_ro_2d_array<rgba32float>
texture_ro_3d<rgba32float>
texture_wo_1d<rgba32float>
texture_wo_1d_array<rgba32float>
texture_wo_2d<rgba32float>
texture_wo_2d_array<rgba32float>
texture_wo_3d<rgba32float>
texture_depth_2d
texture_depth_2d_array
texture_depth_cube
texture_depth_cube_array
sampler
sampler_comparisonExample
var tex : texture_sampled_2d<f32>;
var ro_tex : texture_ro_1d<rgba32float>;Possible 1 (read_only as attribute)
For buffers, move the read_only to the declaration of the struct, making it part of the type.
[[block, read_only]] struct Buffer {
[[offset(0)]] a : i32;
};
[[binding(0), set(0)]]
var <storage> buf : Buffer;For textures, make the attributes part of the type declaration for the variable.
[[read_only]] texture_1d<rgba32float>
[[sampled]] texture_1d<f32>
[[write_only]] texture_1d<rgba32float>
[[depth]] texture_2d
sampler
[[comparison]] samplerExample
var tex : [[sampled]] texture_2d<f32>;
var ro_tex : [[read_only]] texture_1d<rgba32float>;Possible 2 (attribute at variable decl on type)
Put the read_only on the type assignment for buffers, matches with the textures from Possible 1.
[[block]] struct Buffer {
[[offset(0)]] a : i32;
};
[[binding(0), set(0)]]
var <storage> buf : [[read_only]] Buffer;Possible 3 (struct_ro)
Make a new struct declaration for read_only as struct_ro.
[[block]] struct_ro Buffer {
[[offset(0)]] a : i32;
};
[[binding(0), set(0)]]
var <storage> buf : Buffer;Same as we have now.
texture_sampled_1d<f32>
texture_sampled_1d_array<f32>
texture_sampled_2d<f32>
texture_sampled_2d_array<f32>
texture_sampled_3d<f32>
texture_sampled_cube<f32>
texture_sampled_cube_array<f32>
texture_multisampled_2d<f32>
texture_ro_1d<rgba32float>
texture_ro_1d_array<rgba32float>
texture_ro_2d<rgba32float>
texture_ro_2d_array<rgba32float>
texture_ro_3d<rgba32float>
texture_wo_1d<rgba32float>
texture_wo_1d_array<rgba32float>
texture_wo_2d<rgba32float>
texture_wo_2d_array<rgba32float>
texture_wo_3d<rgba32float>
texture_depth_2d
texture_depth_2d_array
texture_depth_cube
texture_depth_cube_array
sampler
sampler_comparisonPossible 4 (attributes on vars)
The read_only is on the variable declaration.
[[block]] struct Buffer {
[[offset(0)]] a : i32;
};
[[read_only, binding(0), set(0)]]
var <storage> buf : Buffer;Put the decorations on the variable decoration same as buffers.
[[read_only]] texture_1d<rgba32float>
[[sampled]] texture_1d<f32>
[[write_only]] texture_1d<rgba32float>
[[depth]] texture_2d
sampler
[[comparison]] samplerExample
[[sampled]] var tex : texture_2d<f32>;
[[read_only]] var ro_tex : texture_1d<rgba32float>;
Activity
dj2 commentedon Oct 20, 2020
Related to #923
kvark commentedon Oct 21, 2020
Possible 5 (attributes and types)
Buffers differentiating in types (
struct_storage,struct_uniform,struct), but the access qualifier goes on the variable:Same for textures:
And samplers are left as is:
Possible 6 (full types)
Buffers get the typing:
Textures are unchanged from today.
Note that I removed the
[[block]]and<storage>because they are implied if we know that the buffer is a storage buffer by other means (types or decorations).dj2 commentedon Oct 21, 2020
Possible 7 (I'm running out of things to call these)
I like Possible 5, but what about leaving the
<storage>and<uniform>on thevarand just having a singlestruct.Example
dj2 commentedon Oct 22, 2020
Possible access values:
kvark commentedon Oct 22, 2020
Can we have the storage access qualifiers be similar between storage buffers and textures? I know that @dneto0 made an argument that they can be different. I don't think we have a strong reason to separate them though.
dj2 commentedon Oct 26, 2020
This was discussed at the VF2F (https://docs.google.com/document/d/1p1jREMgonZszFJ8eastnnDb36rKKm7xnDYnMjC6zj5c/edit?usp=sharing) with, I believe, the final concensus being:
We change to having
sampledtextures be the default one and thestoragetextures would have the longer name. So,texture_1dis a sampled texture andtexture_storage_1dis a storage texture. Depth textures and samplers don't change from the current spec.The
storagetextures have an extra template argument which isreadorwriteto specify if they are read only or write only. Thereadstorage texture specifier will map to aOpDecorate %tbuf NonWritableand awritewill map toOpDecorate %tbuf NonReadable.Storage buffer declarations have a decoration added
access(read|write)to let us set the access permission for the storage buffer. Setting thereadaccess will apply aOpDecorate %tbuf NonWritableto the structure and awritewill apply aOpDecorate %tbuf NonReadable.@kvark @dneto0 @litherum please let me know if I got anything wrong in the above. This was what I understood we settled on at the F2F.
dneto0 commentedon Oct 26, 2020
The texture changes sound right.
The storage buffer one, I'm not so sure the details were right. I think we had settled on "must give an attribute" for now, and then relax that later.
For storage buffer, they are either read+write or read-only. (I think I really goofed on #935 saying there were write-only buffers...)
So the buffer examples should be something like this.
[wgsl] Flip the default texture name. (#1180)
grorg commentedon Nov 10, 2020
Are we simply waiting on the above issues to resolve this?
dj2 commentedon Nov 10, 2020
Once the related issues are done this should be complete I believe.
[wgsl] Add access qualifier to buffer types (#1183)
[wgsl] Update storage textures to use access qualifiers (#1182)
[wgsl] Further update access qualifiers for storage textures
[wgsl] Further update access qualifiers for storage textures
[wgsl] Further update access qualifiers for storage textures
Additional tweaks after gpuweb#1182.
[wgsl] Further update access qualifiers for storage textures
[wgsl] Further update access qualifiers for storage textures
kvark commentedon Jan 29, 2021
I believe this can be closed now 🎉 , given #1182 has landed.
Please reopen otherwise.
Update blankspace tests to match spec.
Update comment ending characters.