Resolver: Validate <storage> var types

https://gpuweb.github.io/gpuweb/wgsl/#variable-declaration
Variables in the storage storage class and variables with a storage
texture type must have an access attribute applied to the store type.

https://gpuweb.github.io/gpuweb/wgsl/#module-scope-variables
A variable in the storage storage class is a storage buffer variable. Its
store type must be a host-shareable structure type with block attribute,
satisfying the storage class constraints.

Fixup tests, including those that were producing warnings about `var <in>`

The WGSL writer seems to want to put a newline after every decoration block, leading to some ugly output. I'll fix this as a separate change.

Fixes: tint:531
Fixes: tint:692
Change-Id: If09d987477247ab4a7c635f6ee6e616a06061515
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47763
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This commit is contained in:
Ben Clayton
2021-04-16 09:26:14 +00:00
committed by Commit Bot service account
parent 4485fcde64
commit 1773535e1c
19 changed files with 570 additions and 294 deletions

View File

@@ -40,7 +40,7 @@ type t0 = [[stride(16)]] array<vec4<f32>>;
type t1 = array<vec4<f32>>;
var<uniform> g0 : u32 = 20u;
var<out> g1 : f32 = 123.0;
var<private> g1 : f32 = 123.0;
var g2 : texture_2d<f32>;
var g3 : [[access(read)]] texture_storage_2d<r32uint>;
var g4 : [[access(write)]] texture_storage_2d<rg32float>;
@@ -48,7 +48,8 @@ var g5 : [[access(read)]] texture_storage_2d<r32uint>;
var g6 : [[access(write)]] texture_storage_2d<rg32float>;
[[builtin(position)]] var<uniform> g7 : vec3<f32>;
[[group(10), binding(20)]] var<storage> g8 : S;
[[group(10), binding(20)]] var<storage> g8 : [[access(write)]]
S;
[[group(10), binding(20)]] var<storage> g9 : [[access(read)]]
S;
[[group(10), binding(20)]] var<storage> g10 : [[access(read_write)]]