Move texture_storage access into type

Instead of having it as a decoration.
The old style is now deprecated and will be removed soon.

See  https://github.com/gpuweb/gpuweb/pull/1735 for the WGSL spec change.

Bug: tint:846
Change-Id: Id2fa681ddf7b97cd3fa41d7b5538029d96db7e28
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/53082
Reviewed-by: Corentin Wallez <cwallez@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/src/tests/end2end/BindGroupTests.cpp b/src/tests/end2end/BindGroupTests.cpp
index 155bd25..fbe6e52 100644
--- a/src/tests/end2end/BindGroupTests.cpp
+++ b/src/tests/end2end/BindGroupTests.cpp
@@ -1205,7 +1205,7 @@
         bgEntries.push_back({nullptr, binding, nullptr, 0, 0, nullptr, texture.CreateView()});
 
         interface << "[[group(0), binding(" << binding++ << ")]] "
-                  << "var image" << i << " : [[access(read)]] texture_storage_2d<r32uint>;\n";
+                  << "var image" << i << " : texture_storage_2d<r32uint, read>;\n";
 
         body << "if (textureLoad(image" << i << ", vec2<i32>(0, 0)).r != " << expectedValue++
              << "u) {\n";
diff --git a/src/tests/end2end/BufferZeroInitTests.cpp b/src/tests/end2end/BufferZeroInitTests.cpp
index d2ef631..7d78ec4 100644
--- a/src/tests/end2end/BufferZeroInitTests.cpp
+++ b/src/tests/end2end/BufferZeroInitTests.cpp
@@ -425,7 +425,7 @@
         // As long as the comptue shader is executed once, the pixel color of outImage will be set
         // to red.
         const char* computeShader = R"(
-            [[group(0), binding(0)]] var outImage : [[access(write)]] texture_storage_2d<rgba8unorm>;
+            [[group(0), binding(0)]] var outImage : texture_storage_2d<rgba8unorm, write>;
 
             [[stage(compute)]] fn main() {
                 textureStore(outImage, vec2<i32>(0, 0), vec4<f32>(1.0, 0.0, 0.0, 1.0));
@@ -997,7 +997,7 @@
             value : vec4<u32>;
         };
         [[group(0), binding(0)]] var<uniform> ubo : UBO;
-        [[group(0), binding(1)]] var outImage : [[access(write)]] texture_storage_2d<rgba8unorm>;
+        [[group(0), binding(1)]] var outImage : texture_storage_2d<rgba8unorm, write>;
 
         [[stage(compute)]] fn main() {
             if (all(ubo.value == vec4<u32>(0u, 0u, 0u, 0u))) {
@@ -1036,7 +1036,7 @@
             value : vec4<u32>;
         };
         [[group(0), binding(0)]] var<storage> ssbo : [[access(read_write)]] SSBO;
-        [[group(0), binding(1)]] var outImage : [[access(write)]] texture_storage_2d<rgba8unorm>;
+        [[group(0), binding(1)]] var outImage : texture_storage_2d<rgba8unorm, write>;
 
         [[stage(compute)]] fn main() {
             if (all(ssbo.value == vec4<u32>(0u, 0u, 0u, 0u))) {
@@ -1075,7 +1075,7 @@
             value : array<vec4<u32>, 2>;
         };
         [[group(0), binding(0)]] var<storage> ssbo : [[access(read_write)]] SSBO;
-        [[group(0), binding(1)]] var outImage : [[access(write)]] texture_storage_2d<rgba8unorm>;
+        [[group(0), binding(1)]] var outImage : texture_storage_2d<rgba8unorm, write>;
 
         [[stage(compute)]] fn main() {
             if (all(ssbo.value[0] == vec4<u32>(0u, 0u, 0u, 0u)) &&
diff --git a/src/tests/end2end/GpuMemorySynchronizationTests.cpp b/src/tests/end2end/GpuMemorySynchronizationTests.cpp
index 05523e2..1db5400 100644
--- a/src/tests/end2end/GpuMemorySynchronizationTests.cpp
+++ b/src/tests/end2end/GpuMemorySynchronizationTests.cpp
@@ -257,7 +257,7 @@
         };
         [[group(0), binding(0)]] var<storage> output : [[access(write)]] Output;
         [[group(0), binding(1)]] var sampledTex : texture_2d<u32>;
-        [[group(0), binding(2)]] var storageTex : [[access(read)]] texture_storage_2d<r32uint>;
+        [[group(0), binding(2)]] var storageTex : texture_storage_2d<r32uint, read>;
 
         [[stage(compute)]] fn main() {
             output.sampledOut = textureLoad(sampledTex, vec2<i32>(0, 0), 0).x;
diff --git a/src/tests/end2end/StorageTextureTests.cpp b/src/tests/end2end/StorageTextureTests.cpp
index 81126c1..bdc0fbf 100644
--- a/src/tests/end2end/StorageTextureTests.cpp
+++ b/src/tests/end2end/StorageTextureTests.cpp
@@ -982,8 +982,8 @@
         kTextureFormat, wgpu::TextureUsage::Storage | wgpu::TextureUsage::CopySrc, 1u, 1u);
 
     wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
-[[group(0), binding(0)]] var Src : [[access(read)]]  texture_storage_2d<r32uint>;
-[[group(0), binding(1)]] var Dst : [[access(write)]] texture_storage_2d<r32uint>;
+[[group(0), binding(0)]] var Src : texture_storage_2d<r32uint, read>;
+[[group(0), binding(1)]] var Dst : texture_storage_2d<r32uint, write>;
 [[stage(compute)]] fn main() {
   var srcValue : vec4<u32> = textureLoad(Src, vec2<i32>(0, 0));
   srcValue.x = srcValue.x + 1u;
@@ -1057,7 +1057,7 @@
         kTextureFormat, wgpu::TextureUsage::Sampled | wgpu::TextureUsage::Storage, 1u, 1u);
     wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
 [[group(0), binding(0)]] var Src : texture_2d<u32>;
-[[group(0), binding(1)]] var Dst : [[access(write)]] texture_storage_2d<r32uint>;
+[[group(0), binding(1)]] var Dst : texture_storage_2d<r32uint, write>;
 [[stage(compute)]] fn main() {
   var srcValue : vec4<u32> = textureLoad(Src, vec2<i32>(0, 0), 0);
   srcValue.x = srcValue.x + 1u;
@@ -1155,13 +1155,13 @@
 })";
 
     const char* kCommonWriteOnlyZeroInitTestCodeFragment = R"(
-[[group(0), binding(0)]] var dstImage : [[access(write)]] texture_storage_2d<r32uint>;
+[[group(0), binding(0)]] var dstImage : texture_storage_2d<r32uint, write>;
 
 [[stage(fragment)]] fn main() {
   textureStore(dstImage, vec2<i32>(0, 0), vec4<u32>(1u, 0u, 0u, 1u));
 })";
     const char* kCommonWriteOnlyZeroInitTestCodeCompute = R"(
-[[group(0), binding(0)]] var dstImage : [[access(write)]] texture_storage_2d<r32uint>;
+[[group(0), binding(0)]] var dstImage : texture_storage_2d<r32uint, write>;
 
 [[stage(compute)]] fn main() {
   textureStore(dstImage, vec2<i32>(0, 0), vec4<u32>(1u, 0u, 0u, 1u));
@@ -1178,7 +1178,7 @@
     // green as the output color, otherwise uses red instead.
     const char* kVertexShader = kSimpleVertexShader;
     const std::string kFragmentShader = std::string(R"(
-[[group(0), binding(0)]] var srcImage : [[access(read)]] texture_storage_2d<r32uint>;
+[[group(0), binding(0)]] var srcImage : texture_storage_2d<r32uint, read>;
 )") + kCommonReadOnlyZeroInitTestCode +
                                         R"(
 [[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
@@ -1203,7 +1203,7 @@
   result : u32;
 };
 
-[[group(0), binding(0)]] var srcImage : [[access(read)]] texture_storage_2d<r32uint>;
+[[group(0), binding(0)]] var srcImage : texture_storage_2d<r32uint, read>;
 [[group(0), binding(1)]] var<storage> dstBuffer : [[access(read_write)]] DstBuffer;
 )") + kCommonReadOnlyZeroInitTestCode + R"(
 [[stage(compute)]] fn main() {
diff --git a/src/tests/unittests/validation/ResourceUsageTrackingTests.cpp b/src/tests/unittests/validation/ResourceUsageTrackingTests.cpp
index a1ed2ea..142ba56 100644
--- a/src/tests/unittests/validation/ResourceUsageTrackingTests.cpp
+++ b/src/tests/unittests/validation/ResourceUsageTrackingTests.cpp
@@ -1508,7 +1508,7 @@
                 })");
 
             wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
-                [[group(0), binding(0)]] var tex : [[access(read)]] texture_storage_2d<rgba8unorm>;
+                [[group(0), binding(0)]] var tex : texture_storage_2d<rgba8unorm, read>;
                 [[stage(fragment)]] fn main() {
                 })");
             utils::ComboRenderPipelineDescriptor pipelineDescriptor;
diff --git a/src/tests/unittests/validation/StorageTextureValidationTests.cpp b/src/tests/unittests/validation/StorageTextureValidationTests.cpp
index 6660ca6..5294c0f 100644
--- a/src/tests/unittests/validation/StorageTextureValidationTests.cpp
+++ b/src/tests/unittests/validation/StorageTextureValidationTests.cpp
@@ -120,7 +120,7 @@
     // Readonly storage texture can be declared in a vertex shader.
     {
         wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
-            [[group(0), binding(0)]] var image0 : [[access(read)]] texture_storage_2d<rgba8unorm>;
+            [[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, read>;
             [[stage(vertex)]] fn main(
                 [[builtin(vertex_index)]] VertexIndex : u32
             ) -> [[builtin(position)]] vec4<f32> {
@@ -137,7 +137,7 @@
     // Read-only storage textures can be declared in a fragment shader.
     {
         wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
-            [[group(0), binding(0)]] var image0 : [[access(read)]] texture_storage_2d<rgba8unorm>;
+            [[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, read>;
             [[stage(fragment)]] fn main(
                 [[builtin(position)]] FragCoord : vec4<f32>
             ) -> [[location(0)]] vec4<f32> {
@@ -154,7 +154,7 @@
     // Write-only storage textures cannot be declared in a vertex shader.
     if ((false) /* TODO(https://crbug.com/tint/449) */) {
         wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
-            [[group(0), binding(0)]] var image0 : [[access(write)]] texture_storage_2d<rgba8unorm>;
+            [[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, write>;
             [[stage(vertex)]] fn main([[builtin(vertex_index)]] vertex_index : u32) {
                 textureStore(image0, vec2<i32>(i32(vertex_index), 0), vec4<f32>(1.0, 0.0, 0.0, 1.0));
             })");
@@ -169,7 +169,7 @@
     // Write-only storage textures can be declared in a fragment shader.
     {
         wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
-            [[group(0), binding(0)]] var image0 : [[access(write)]] texture_storage_2d<rgba8unorm>;
+            [[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, write>;
             [[stage(fragment)]] fn main([[builtin(position)]] position : vec4<f32>) {
                 textureStore(image0, vec2<i32>(position.xy), vec4<f32>(1.0, 0.0, 0.0, 1.0));
             })");
@@ -188,7 +188,7 @@
     // Read-only storage textures can be declared in a compute shader.
     {
         wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
-            [[group(0), binding(0)]] var image0 : [[access(read)]] texture_storage_2d<rgba8unorm>;
+            [[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, read>;
 
             [[block]] struct Buf {
                 data : f32;
@@ -210,7 +210,7 @@
     // Write-only storage textures can be declared in a compute shader.
     {
         wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
-            [[group(0), binding(0)]] var image0 : [[access(write)]] texture_storage_2d<rgba8unorm>;
+            [[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, write>;
 
             [[stage(compute)]] fn main([[builtin(local_invocation_id)]] LocalInvocationID : vec3<u32>) {
                 textureStore(image0, vec2<i32>(LocalInvocationID.xy), vec4<f32>(0.0, 0.0, 0.0, 0.0));
@@ -230,7 +230,7 @@
     // Read-write storage textures cannot be declared in a vertex shader by default.
     {
         ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
-            [[group(0), binding(0)]] var image0 : [[access(read_write)]] texture_storage_2d<rgba8unorm>;
+            [[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, read_write>;
             [[stage(vertex)]] fn main() {
                 textureDimensions(image0);
             })"));
@@ -239,7 +239,7 @@
     // Read-write storage textures cannot be declared in a fragment shader by default.
     {
         ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
-            [[group(0), binding(0)]] var image0 : [[access(read_write)]] texture_storage_2d<rgba8unorm>;
+            [[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, read_write>;
             [[stage(fragment)]] fn main() {
                 textureDimensions(image0);
             })"));
@@ -248,7 +248,7 @@
     // Read-write storage textures cannot be declared in a compute shader by default.
     {
         ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
-            [[group(0), binding(0)]] var image0 : [[access(read_write)]] texture_storage_2d<rgba8unorm>;
+            [[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, read_write>;
             [[stage(compute)]] fn main() {
                 textureDimensions(image0);
             })"));