Test storage textures in compute passes are validated at queue submit

Bug: chromium:1516756, dawn:2304
Change-Id: I328ec7b7bca232b3dd452c6272711fea7de88e07
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/168301
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
diff --git a/src/dawn/tests/unittests/validation/QueueSubmitValidationTests.cpp b/src/dawn/tests/unittests/validation/QueueSubmitValidationTests.cpp
index 5abffda..a84d435 100644
--- a/src/dawn/tests/unittests/validation/QueueSubmitValidationTests.cpp
+++ b/src/dawn/tests/unittests/validation/QueueSubmitValidationTests.cpp
@@ -376,5 +376,45 @@
     }
 }
 
+// Test that storage textures in compute pass bindgroups are checked in
+// Queue::Submit validation. Regression test for crbug.com/1516756.
+TEST_F(QueueSubmitValidationTest, SubmitWithDestroyedComputeStorageTexture) {
+    wgpu::Queue queue = device.GetQueue();
+
+    wgpu::BindGroupLayout testBGL = utils::MakeBindGroupLayout(
+        device, {{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly,
+                  wgpu::TextureFormat::RGBA8Unorm}});
+
+    wgpu::ComputePipelineDescriptor cpDesc;
+    cpDesc.layout = utils::MakePipelineLayout(device, {testBGL});
+    cpDesc.compute.entryPoint = "main";
+    cpDesc.compute.module =
+        utils::CreateShaderModule(device, "@compute @workgroup_size(1) fn main() {}");
+    wgpu::ComputePipeline pipeline = device.CreateComputePipeline(&cpDesc);
+
+    wgpu::TextureDescriptor texDesc;
+    texDesc.size = {1, 1, 1};
+    texDesc.usage = wgpu::TextureUsage::StorageBinding;
+    texDesc.format = wgpu::TextureFormat::RGBA8Unorm;
+
+    for (bool destroy : {true, false}) {
+        wgpu::Texture texture = device.CreateTexture(&texDesc);
+        wgpu::BindGroup bg = utils::MakeBindGroup(device, testBGL, {{0, texture.CreateView()}});
+
+        wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
+        wgpu::ComputePassEncoder pass = encoder.BeginComputePass();
+        pass.SetBindGroup(0, bg);
+        pass.End();
+        wgpu::CommandBuffer commands = encoder.Finish();
+
+        if (destroy) {
+            texture.Destroy();
+            ASSERT_DEVICE_ERROR(queue.Submit(1, &commands));
+        } else {
+            queue.Submit(1, &commands);
+        }
+    }
+}
+
 }  // anonymous namespace
 }  // namespace dawn
diff --git a/src/dawn/tests/white_box/SharedTextureMemoryTests.cpp b/src/dawn/tests/white_box/SharedTextureMemoryTests.cpp
index 6cdfe15..3293b2d 100644
--- a/src/dawn/tests/white_box/SharedTextureMemoryTests.cpp
+++ b/src/dawn/tests/white_box/SharedTextureMemoryTests.cpp
@@ -1796,9 +1796,6 @@
 // Test writing to texture memory in compute pass on one device, then sampling it using another
 // device.
 TEST_P(SharedTextureMemoryTests, WriteStorageThenReadSample) {
-    // TODO(crbug.com/dawn/1745): Diagnose and fix on Apple GPUs.
-    DAWN_SUPPRESS_TEST_IF(IsApple());
-
     std::vector<wgpu::Device> devices = {device, CreateDevice()};
 
     for (const auto& memories :