Revert "Support validating buffer usage with usage validation mode"

This reverts commit 1f3f5df6810adfd8c37ce25fb3c22c92a4e9bf02.

Reason for revert: blocks rolling into Chromium
https://chromium-review.googlesource.com/c/chromium/src/+/5841338
https://ci.chromium.org/ui/p/chromium/builders/try/dawn-mac-arm64-deps-rel/8457/overview
[ RUN      ] InternalStorageBufferBindingTests.QueryResolveBufferBoundAsInternalStorageBuffer/Metal_Apple_M2
Error: Assertion failure at ../../third_party/dawn/src/dawn/native/CommandEncoder.cpp:1128 (BeginComputePass): device->IsLockedByCurrentThreadIfNeeded()

Original change's description:
> Support validating buffer usage with usage validation mode
>
> This patch adds `UsageValidationMode` as the third parameter of
> `ValidateCanUseAs` with a buffer as input to align with the
> format of the function `ValidateCanUseAs` with a texture as input.
>
> This patch also updates the test `InternalStorageBufferBindingTests`
> by using classes in `native::` instead of the `wgpu::` to better
> test the `internal usage` of the buffers.
>
> Bug: chromium:42240463
> Test: dawn_unittests
> Change-Id: I2db2c922555ded050949da20828be17c95499152
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/204914
> Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
> Reviewed-by: Corentin Wallez <cwallez@chromium.org>

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: chromium:42240463
Change-Id: I87fd848faba5d6515edaba32c25b7537e2ef81f0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/205994
Auto-Submit: Yuly Novikov <ynovikov@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
diff --git a/src/dawn/native/BindGroup.cpp b/src/dawn/native/BindGroup.cpp
index 2f31c8b..b397bf4 100644
--- a/src/dawn/native/BindGroup.cpp
+++ b/src/dawn/native/BindGroup.cpp
@@ -51,8 +51,7 @@
 
 MaybeError ValidateBufferBinding(const DeviceBase* device,
                                  const BindGroupEntry& entry,
-                                 const BufferBindingInfo& layout,
-                                 UsageValidationMode mode) {
+                                 const BufferBindingInfo& layout) {
     DAWN_INVALID_IF(entry.buffer == nullptr, "Binding entry buffer not set.");
 
     DAWN_INVALID_IF(entry.sampler != nullptr || entry.textureView != nullptr,
@@ -116,7 +115,9 @@
                     "Offset (%u) of %s does not satisfy the minimum %s alignment (%u).",
                     entry.offset, entry.buffer, layout.type, requiredBindingAlignment);
 
-    DAWN_TRY(ValidateCanUseAs(entry.buffer, requiredUsage, mode));
+    DAWN_INVALID_IF(!(entry.buffer->GetInternalUsage() & requiredUsage),
+                    "Binding usage (%s) of %s doesn't match expected usage (%s).",
+                    entry.buffer->GetUsage(), entry.buffer, requiredUsage);
 
     DAWN_INVALID_IF(bindingSize < layout.minBindingSize,
                     "Binding size (%u) of %s is smaller than the minimum binding size (%u).",
@@ -375,7 +376,8 @@
         DAWN_TRY(MatchVariant(
             bindingInfo.bindingLayout,
             [&](const BufferBindingInfo& layout) -> MaybeError {
-                DAWN_TRY_CONTEXT(ValidateBufferBinding(device, entry, layout, mode),
+                // TODO(dawn:1485): Validate buffer binding with usage validation mode.
+                DAWN_TRY_CONTEXT(ValidateBufferBinding(device, entry, layout),
                                  "validating entries[%u] as a Buffer."
                                  "\nExpected entry layout: %s",
                                  i, layout);
diff --git a/src/dawn/native/CommandEncoder.cpp b/src/dawn/native/CommandEncoder.cpp
index 468268b..3ded74a 100644
--- a/src/dawn/native/CommandEncoder.cpp
+++ b/src/dawn/native/CommandEncoder.cpp
@@ -1452,12 +1452,10 @@
                                  "validating destination %s copy size.", destination);
                 DAWN_TRY(ValidateB2BCopyAlignment(size, sourceOffset, destinationOffset));
 
-                DAWN_TRY_CONTEXT(
-                    ValidateCanUseAs(source, wgpu::BufferUsage::CopySrc, mUsageValidationMode),
-                    "validating source %s usage.", source);
-                DAWN_TRY_CONTEXT(
-                    ValidateCanUseAs(destination, wgpu::BufferUsage::CopyDst, mUsageValidationMode),
-                    "validating destination %s usage.", destination);
+                DAWN_TRY_CONTEXT(ValidateCanUseAs(source, wgpu::BufferUsage::CopySrc),
+                                 "validating source %s usage.", source);
+                DAWN_TRY_CONTEXT(ValidateCanUseAs(destination, wgpu::BufferUsage::CopyDst),
+                                 "validating destination %s usage.", destination);
             }
 
             mTopLevelBuffers.insert(source);
@@ -1503,12 +1501,10 @@
                                  destination);
                 DAWN_TRY(ValidateB2BCopyAlignment(size, sourceOffset, destinationOffset));
 
-                DAWN_TRY_CONTEXT(
-                    ValidateCanUseAs(source, wgpu::BufferUsage::CopySrc | kInternalCopySrcBuffer,
-                                     UsageValidationMode::Internal),
-                    "validating source %s usage.", source);
-                DAWN_TRY_CONTEXT(ValidateCanUseAs(destination, wgpu::BufferUsage::CopyDst,
-                                                  UsageValidationMode::Internal),
+                DAWN_TRY_CONTEXT(ValidateCanUseAsInternal(
+                                     source, wgpu::BufferUsage::CopySrc | kInternalCopySrcBuffer),
+                                 "validating source %s usage.", source);
+                DAWN_TRY_CONTEXT(ValidateCanUseAs(destination, wgpu::BufferUsage::CopyDst),
                                  "validating destination %s usage.", destination);
             }
 
@@ -1539,8 +1535,7 @@
         [&](CommandAllocator* allocator) -> MaybeError {
             if (GetDevice()->IsValidationEnabled()) {
                 DAWN_TRY(ValidateImageCopyBuffer(GetDevice(), *source));
-                DAWN_TRY_CONTEXT(ValidateCanUseAs(source->buffer, wgpu::BufferUsage::CopySrc,
-                                                  mUsageValidationMode),
+                DAWN_TRY_CONTEXT(ValidateCanUseAs(source->buffer, wgpu::BufferUsage::CopySrc),
                                  "validating source %s usage.", source->buffer);
 
                 DAWN_TRY(ValidateImageCopyTexture(GetDevice(), destination, *copySize));
@@ -1636,8 +1631,7 @@
                 DAWN_TRY(ValidateTextureDepthStencilToBufferCopyRestrictions(source));
 
                 DAWN_TRY(ValidateImageCopyBuffer(GetDevice(), *destination));
-                DAWN_TRY_CONTEXT(ValidateCanUseAs(destination->buffer, wgpu::BufferUsage::CopyDst,
-                                                  mUsageValidationMode),
+                DAWN_TRY_CONTEXT(ValidateCanUseAs(destination->buffer, wgpu::BufferUsage::CopyDst),
                                  "validating destination %s usage.", destination->buffer);
 
                 // We validate texture copy range before validating linear texture data,
@@ -1868,9 +1862,8 @@
                                     offset, size, bufferSize, buffer);
                 }
 
-                DAWN_TRY_CONTEXT(
-                    ValidateCanUseAs(buffer, wgpu::BufferUsage::CopyDst, mUsageValidationMode),
-                    "validating buffer %s usage.", buffer);
+                DAWN_TRY_CONTEXT(ValidateCanUseAs(buffer, wgpu::BufferUsage::CopyDst),
+                                 "validating buffer %s usage.", buffer);
 
                 // Size must be a multiple of 4 bytes on macOS.
                 DAWN_INVALID_IF(size % 4 != 0, "Fill size (%u) is not a multiple of 4 bytes.",
@@ -1974,8 +1967,7 @@
                 DAWN_TRY(ValidateQuerySetResolve(querySet, firstQuery, queryCount, destination,
                                                  destinationOffset));
 
-                DAWN_TRY(ValidateCanUseAs(destination, wgpu::BufferUsage::QueryResolve,
-                                          mUsageValidationMode));
+                DAWN_TRY(ValidateCanUseAs(destination, wgpu::BufferUsage::QueryResolve));
 
                 TrackUsedQuerySet(querySet);
             }
@@ -2016,8 +2008,7 @@
         this,
         [&](CommandAllocator* allocator) -> MaybeError {
             if (GetDevice()->IsValidationEnabled()) {
-                DAWN_TRY(ValidateWriteBuffer(GetDevice(), buffer, bufferOffset, size,
-                                             mUsageValidationMode));
+                DAWN_TRY(ValidateWriteBuffer(GetDevice(), buffer, bufferOffset, size));
             }
 
             WriteBufferCmd* cmd = allocator->Allocate<WriteBufferCmd>(Command::WriteBuffer);
diff --git a/src/dawn/native/CommandValidation.cpp b/src/dawn/native/CommandValidation.cpp
index d9c6f99..7bd537a 100644
--- a/src/dawn/native/CommandValidation.cpp
+++ b/src/dawn/native/CommandValidation.cpp
@@ -223,8 +223,7 @@
 MaybeError ValidateWriteBuffer(const DeviceBase* device,
                                const BufferBase* buffer,
                                uint64_t bufferOffset,
-                               uint64_t size,
-                               UsageValidationMode mode) {
+                               uint64_t size) {
     DAWN_TRY(device->ValidateObject(buffer));
 
     DAWN_INVALID_IF(bufferOffset % 4 != 0, "BufferOffset (%u) is not a multiple of 4.",
@@ -237,7 +236,7 @@
                     "Write range (bufferOffset: %u, size: %u) does not fit in %s size (%u).",
                     bufferOffset, size, buffer, bufferSize);
 
-    DAWN_TRY(ValidateCanUseAs(buffer, wgpu::BufferUsage::CopyDst, mode));
+    DAWN_TRY(ValidateCanUseAs(buffer, wgpu::BufferUsage::CopyDst));
 
     return {};
 }
@@ -649,21 +648,17 @@
     return {};
 }
 
-MaybeError ValidateCanUseAs(const BufferBase* buffer,
-                            wgpu::BufferUsage usage,
-                            UsageValidationMode mode) {
-    switch (mode) {
-        case UsageValidationMode::Default:
-            DAWN_ASSERT(wgpu::HasZeroOrOneBits(usage));
-            DAWN_INVALID_IF(!(buffer->GetUsage() & usage), "%s usage (%s) doesn't include %s.",
-                            buffer, buffer->GetUsage(), usage);
-            break;
-        case UsageValidationMode::Internal:
-            DAWN_INVALID_IF(!(buffer->GetInternalUsage() & usage),
-                            "%s internal usage (%s) doesn't include %s.", buffer,
-                            buffer->GetInternalUsage(), usage);
-            break;
-    }
+MaybeError ValidateCanUseAs(const BufferBase* buffer, wgpu::BufferUsage usage) {
+    DAWN_ASSERT(wgpu::HasZeroOrOneBits(usage));
+    DAWN_INVALID_IF(!(buffer->GetUsage() & usage), "%s usage (%s) doesn't include %s.", buffer,
+                    buffer->GetUsage(), usage);
+    return {};
+}
+
+MaybeError ValidateCanUseAsInternal(const BufferBase* buffer, wgpu::BufferUsage usage) {
+    DAWN_INVALID_IF(!(buffer->GetInternalUsage() & usage),
+                    "%s internal usage (%s) doesn't include %s.", buffer,
+                    buffer->GetInternalUsage(), usage);
     return {};
 }
 
diff --git a/src/dawn/native/CommandValidation.h b/src/dawn/native/CommandValidation.h
index 3afd684..36e737f 100644
--- a/src/dawn/native/CommandValidation.h
+++ b/src/dawn/native/CommandValidation.h
@@ -61,8 +61,7 @@
 MaybeError ValidateWriteBuffer(const DeviceBase* device,
                                const BufferBase* buffer,
                                uint64_t bufferOffset,
-                               uint64_t size,
-                               UsageValidationMode mode);
+                               uint64_t size);
 
 template <typename A, typename B>
 DAWN_FORCE_INLINE uint64_t Safe32x32(A a, B b) {
@@ -114,9 +113,8 @@
 MaybeError ValidateCanUseAs(const TextureBase* texture,
                             wgpu::TextureUsage usage,
                             UsageValidationMode mode);
-MaybeError ValidateCanUseAs(const BufferBase* buffer,
-                            wgpu::BufferUsage usage,
-                            UsageValidationMode mode);
+MaybeError ValidateCanUseAs(const BufferBase* buffer, wgpu::BufferUsage usage);
+MaybeError ValidateCanUseAsInternal(const BufferBase* buffer, wgpu::BufferUsage usage);
 
 using ColorAttachmentFormats = absl::InlinedVector<const Format*, kMaxColorAttachments>;
 MaybeError ValidateColorAttachmentBytesPerSample(DeviceBase* device,
diff --git a/src/dawn/native/ComputePassEncoder.cpp b/src/dawn/native/ComputePassEncoder.cpp
index f25767b..fb76d7f 100644
--- a/src/dawn/native/ComputePassEncoder.cpp
+++ b/src/dawn/native/ComputePassEncoder.cpp
@@ -352,10 +352,7 @@
         [&](CommandAllocator* allocator) -> MaybeError {
             if (IsValidationEnabled()) {
                 DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer));
-                // TODO(chromium:42240463): validate indirectBuffer usage with the usage validation
-                // mode of mCommandEncoder
-                DAWN_TRY(ValidateCanUseAs(indirectBuffer, wgpu::BufferUsage::Indirect,
-                                          UsageValidationMode::Default));
+                DAWN_TRY(ValidateCanUseAs(indirectBuffer, wgpu::BufferUsage::Indirect));
                 DAWN_TRY(mCommandBufferState.ValidateCanDispatch());
 
                 DAWN_INVALID_IF(indirectOffset % 4 != 0,
diff --git a/src/dawn/native/IndirectDrawValidationEncoder.cpp b/src/dawn/native/IndirectDrawValidationEncoder.cpp
index b9c4c5f..e373d9c 100644
--- a/src/dawn/native/IndirectDrawValidationEncoder.cpp
+++ b/src/dawn/native/IndirectDrawValidationEncoder.cpp
@@ -722,8 +722,7 @@
                 outputParamsBinding.size = batch.outputParamsSize;
 
                 Ref<BindGroupBase> bindGroup;
-                DAWN_TRY_ASSIGN(bindGroup, device->CreateBindGroup(&bindGroupDescriptor,
-                                                                   UsageValidationMode::Internal));
+                DAWN_TRY_ASSIGN(bindGroup, device->CreateBindGroup(&bindGroupDescriptor));
 
                 const uint32_t numDrawsRoundedUp =
                     (batch.batchInfo->numDraws + kWorkgroupSize - 1) / kWorkgroupSize;
@@ -847,8 +846,7 @@
             }
 
             Ref<BindGroupBase> bindGroup;
-            DAWN_TRY_ASSIGN(bindGroup, device->CreateBindGroup(&bindGroupDescriptor,
-                                                               UsageValidationMode::Internal));
+            DAWN_TRY_ASSIGN(bindGroup, device->CreateBindGroup(&bindGroupDescriptor));
 
             commandEncoder->APIWriteBuffer(drawConstantsBuffer.GetBuffer(), 0,
                                            reinterpret_cast<const uint8_t*>(&drawConstants),
diff --git a/src/dawn/native/Queue.cpp b/src/dawn/native/Queue.cpp
index d87847e..a8197d2 100644
--- a/src/dawn/native/Queue.cpp
+++ b/src/dawn/native/Queue.cpp
@@ -448,8 +448,7 @@
                                   size_t size) {
     DAWN_TRY(GetDevice()->ValidateIsAlive());
     DAWN_TRY(GetDevice()->ValidateObject(this));
-    DAWN_TRY(
-        ValidateWriteBuffer(GetDevice(), buffer, bufferOffset, size, UsageValidationMode::Default));
+    DAWN_TRY(ValidateWriteBuffer(GetDevice(), buffer, bufferOffset, size));
     DAWN_TRY(buffer->ValidateCanUseOnQueueNow());
     return WriteBufferImpl(buffer, bufferOffset, data, size);
 }
diff --git a/src/dawn/native/RenderEncoderBase.cpp b/src/dawn/native/RenderEncoderBase.cpp
index 6cafa62..67af801 100644
--- a/src/dawn/native/RenderEncoderBase.cpp
+++ b/src/dawn/native/RenderEncoderBase.cpp
@@ -202,11 +202,7 @@
         [&](CommandAllocator* allocator) -> MaybeError {
             if (IsValidationEnabled()) {
                 DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer));
-                // TODO(chromium:42240463): validate indirectBuffer usage with internal usage
-                // validation mode when we support creating RenderBundle with internal usage
-                // validation mode
-                DAWN_TRY(ValidateCanUseAs(indirectBuffer, wgpu::BufferUsage::Indirect,
-                                          UsageValidationMode::Default));
+                DAWN_TRY(ValidateCanUseAs(indirectBuffer, wgpu::BufferUsage::Indirect));
                 DAWN_TRY(mCommandBufferState.ValidateCanDraw());
                 if (GetDevice()->IsCompatibilityMode()) {
                     DAWN_TRY(mCommandBufferState.ValidateNoDifferentTextureViewsOnSameTexture());
@@ -265,11 +261,7 @@
         [&](CommandAllocator* allocator) -> MaybeError {
             if (IsValidationEnabled()) {
                 DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer));
-                // TODO(chromium:42240463): validate indirectBuffer usage with internal usage
-                // validation mode when we support creating RenderBundle with internal usage
-                // validation mode
-                DAWN_TRY(ValidateCanUseAs(indirectBuffer, wgpu::BufferUsage::Indirect,
-                                          UsageValidationMode::Default));
+                DAWN_TRY(ValidateCanUseAs(indirectBuffer, wgpu::BufferUsage::Indirect));
                 DAWN_TRY(mCommandBufferState.ValidateCanDrawIndexed());
                 if (GetDevice()->IsCompatibilityMode()) {
                     DAWN_TRY(mCommandBufferState.ValidateNoDifferentTextureViewsOnSameTexture());
@@ -340,11 +332,7 @@
                                 "%s is not enabled.", wgpu::FeatureName::MultiDrawIndirect);
 
                 DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer));
-                // TODO(chromium:42240463): validate indirectBuffer usage with internal usage
-                // validation mode when we support creating RenderBundle with internal usage
-                // validation mode
-                DAWN_TRY(ValidateCanUseAs(indirectBuffer, wgpu::BufferUsage::Indirect,
-                                          UsageValidationMode::Default));
+                DAWN_TRY(ValidateCanUseAs(indirectBuffer, wgpu::BufferUsage::Indirect));
 
                 DAWN_INVALID_IF(indirectOffset % 4 != 0,
                                 "Indirect offset (%u) is not a multiple of 4.", indirectOffset);
@@ -365,11 +353,7 @@
                 // draw count buffer is optional
                 if (drawCountBuffer != nullptr) {
                     DAWN_TRY(GetDevice()->ValidateObject(drawCountBuffer));
-                    // TODO(chromium:42240463): validate indirectBuffer usage with internal usage
-                    // validation mode when we support creating RenderBundle with internal usage
-                    // validation mode
-                    DAWN_TRY(ValidateCanUseAs(drawCountBuffer, wgpu::BufferUsage::Indirect,
-                                              UsageValidationMode::Default));
+                    DAWN_TRY(ValidateCanUseAs(drawCountBuffer, wgpu::BufferUsage::Indirect));
 
                     DAWN_INVALID_IF(drawCountBufferOffset % 4 != 0,
                                     "Draw count buffer offset (%u) is not a multiple of 4.",
@@ -451,11 +435,7 @@
                                 "%s is not enabled.", wgpu::FeatureName::MultiDrawIndirect);
 
                 DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer));
-                // TODO(chromium:42240463): validate indirectBuffer usage with internal usage
-                // validation mode when we support creating RenderBundle with internal usage
-                // validation mode
-                DAWN_TRY(ValidateCanUseAs(indirectBuffer, wgpu::BufferUsage::Indirect,
-                                          UsageValidationMode::Default));
+                DAWN_TRY(ValidateCanUseAs(indirectBuffer, wgpu::BufferUsage::Indirect));
 
                 DAWN_INVALID_IF(indirectOffset % 4 != 0,
                                 "Indirect offset (%u) is not a multiple of 4.", indirectOffset);
@@ -477,11 +457,7 @@
                 // draw count buffer is optional
                 if (drawCountBuffer != nullptr) {
                     DAWN_TRY(GetDevice()->ValidateObject(drawCountBuffer));
-                    // TODO(chromium:42240463): validate indirectBuffer usage with internal usage
-                    // validation mode when we support creating RenderBundle with internal usage
-                    // validation mode
-                    DAWN_TRY(ValidateCanUseAs(drawCountBuffer, wgpu::BufferUsage::Indirect,
-                                              UsageValidationMode::Default));
+                    DAWN_TRY(ValidateCanUseAs(drawCountBuffer, wgpu::BufferUsage::Indirect));
 
                     DAWN_INVALID_IF(drawCountBufferOffset % 4 != 0,
                                     "Draw count buffer offset (%u) is not a multiple of 4.",
@@ -595,11 +571,7 @@
         [&](CommandAllocator* allocator) -> MaybeError {
             if (IsValidationEnabled()) {
                 DAWN_TRY(GetDevice()->ValidateObject(buffer));
-                // TODO(chromium:42240463): validate indirectBuffer usage with internal usage
-                // validation mode when we support creating RenderBundle with internal usage
-                // validation mode
-                DAWN_TRY(ValidateCanUseAs(buffer, wgpu::BufferUsage::Index,
-                                          UsageValidationMode::Default));
+                DAWN_TRY(ValidateCanUseAs(buffer, wgpu::BufferUsage::Index));
 
                 DAWN_TRY(ValidateIndexFormat(format));
 
@@ -669,11 +641,7 @@
                         "Size (%u) must be either 0 or wgpu::kWholeSize if buffer is null", size);
                 } else {
                     DAWN_TRY(GetDevice()->ValidateObject(buffer));
-                    // TODO(chromium:42240463): validate indirectBuffer usage with internal usage
-                    // validation mode when we support creating RenderBundle with internal usage
-                    // validation mode
-                    DAWN_TRY(ValidateCanUseAs(buffer, wgpu::BufferUsage::Vertex,
-                                              UsageValidationMode::Default));
+                    DAWN_TRY(ValidateCanUseAs(buffer, wgpu::BufferUsage::Vertex));
                     DAWN_INVALID_IF(offset % 4 != 0,
                                     "Vertex buffer offset (%u) is not a multiple of 4", offset);
 
diff --git a/src/dawn/tests/white_box/InternalStorageBufferBindingTests.cpp b/src/dawn/tests/white_box/InternalStorageBufferBindingTests.cpp
index 373aa32..4060a58 100644
--- a/src/dawn/tests/white_box/InternalStorageBufferBindingTests.cpp
+++ b/src/dawn/tests/white_box/InternalStorageBufferBindingTests.cpp
@@ -28,18 +28,11 @@
 #include <utility>
 #include <vector>
 
-#include "dawn/native/BindGroup.h"
 #include "dawn/native/BindGroupLayout.h"
-#include "dawn/native/CommandBuffer.h"
-#include "dawn/native/CommandEncoder.h"
-#include "dawn/native/ComputePassEncoder.h"
-#include "dawn/native/ComputePipeline.h"
 #include "dawn/native/Device.h"
-#include "dawn/native/PipelineLayout.h"
-#include "dawn/native/Queue.h"
 #include "dawn/native/dawn_platform.h"
-#include "dawn/native/utils/WGPUHelpers.h"
 #include "dawn/tests/DawnTest.h"
+#include "dawn/utils/WGPUHelpers.h"
 
 namespace dawn {
 namespace {
@@ -54,11 +47,8 @@
         DAWN_TEST_UNSUPPORTED_IF(UsesWire());
     }
 
-    Ref<native::ComputePipelineBase> CreateComputePipelineWithInternalStorage() {
-        native::DeviceBase* nativeDevice = native::FromAPI(device.Get());
-
-        Ref<native::ShaderModuleBase> shaderModule =
-            native::utils::CreateShaderModule(nativeDevice, R"(
+    wgpu::ComputePipeline CreateComputePipelineWithInternalStorage() {
+        wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
             struct Buf {
                 data : array<u32, 4>
             }
@@ -69,24 +59,37 @@
             fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3u) {
                 buf.data[GlobalInvocationID.x] = buf.data[GlobalInvocationID.x] + 0x1234u;
             }
-        )")
-                .AcquireSuccess();
+        )");
 
         // Create binding group layout with internal storage buffer binding type
+        native::BindGroupLayoutEntry bglEntry;
+        bglEntry.binding = 0;
+        bglEntry.buffer.type = native::kInternalStorageBufferBinding;
+        bglEntry.visibility = wgpu::ShaderStage::Compute;
+
+        native::BindGroupLayoutDescriptor bglDesc;
+        bglDesc.entryCount = 1;
+        bglDesc.entries = &bglEntry;
+
+        native::DeviceBase* nativeDevice = native::FromAPI(device.Get());
+
         Ref<native::BindGroupLayoutBase> bglRef =
-            native::utils::MakeBindGroupLayout(
-                nativeDevice,
-                {{0, wgpu::ShaderStage::Compute, native::kInternalStorageBufferBinding}}, true)
-                .AcquireSuccess();
+            nativeDevice->CreateBindGroupLayout(&bglDesc, true).AcquireSuccess();
+
+        wgpu::BindGroupLayout bgl =
+            wgpu::BindGroupLayout::Acquire(native::ToAPI(ReturnToAPI(std::move(bglRef))));
 
         // Create pipeline layout
-        Ref<native::PipelineLayoutBase> layout =
-            native::utils::MakeBasicPipelineLayout(nativeDevice, bglRef).AcquireSuccess();
+        wgpu::PipelineLayoutDescriptor plDesc;
+        plDesc.bindGroupLayoutCount = 1;
+        plDesc.bindGroupLayouts = &bgl;
+        wgpu::PipelineLayout layout = device.CreatePipelineLayout(&plDesc);
 
-        native::ComputePipelineDescriptor pipelineDesc = {};
-        pipelineDesc.compute.module = shaderModule.Get();
-        pipelineDesc.layout = layout.Get();
-        return nativeDevice->CreateComputePipeline(&pipelineDesc).AcquireSuccess();
+        wgpu::ComputePipelineDescriptor pipelineDesc = {};
+        pipelineDesc.layout = layout;
+        pipelineDesc.compute.module = module;
+
+        return device.CreateComputePipeline(&pipelineDesc);
     }
 };
 
@@ -96,37 +99,28 @@
     std::vector<uint32_t> data(kNumValues, 0);
     std::vector<uint32_t> expected(kNumValues, 0x1234u * kIterations);
 
-    native::DeviceBase* nativeDevice = native::FromAPI(device.Get());
-
     uint64_t bufferSize = static_cast<uint64_t>(data.size() * sizeof(uint32_t));
-    Ref<native::BufferBase> buffer =
-        native::utils::CreateBufferFromData(nativeDevice,
-                                            wgpu::BufferUsage::QueryResolve |
-                                                wgpu::BufferUsage::CopySrc |
-                                                wgpu::BufferUsage::CopyDst,
-                                            data.data(), bufferSize)
-            .AcquireSuccess();
+    wgpu::Buffer buffer =
+        utils::CreateBufferFromData(device, data.data(), bufferSize,
+                                    wgpu::BufferUsage::QueryResolve | wgpu::BufferUsage::CopySrc);
 
-    Ref<native::ComputePipelineBase> pipeline = CreateComputePipelineWithInternalStorage();
-    Ref<native::BindGroupLayoutBase> bindGroupLayout =
-        pipeline->GetBindGroupLayout(0).AcquireSuccess();
-    Ref<native::BindGroupBase> bindGroup =
-        native::utils::MakeBindGroup(nativeDevice, bindGroupLayout, {{0, buffer.Get()}},
-                                     native::UsageValidationMode::Internal)
-            .AcquireSuccess();
+    wgpu::ComputePipeline pipeline = CreateComputePipelineWithInternalStorage();
 
-    Ref<native::CommandEncoderBase> encoder = nativeDevice->CreateCommandEncoder().AcquireSuccess();
-    Ref<native::ComputePassEncoderBase> pass = encoder->BeginComputePass();
-    pass->APISetPipeline(pipeline.Get());
-    pass->APISetBindGroup(0, bindGroup.Get());
+    wgpu::BindGroup bindGroup =
+        utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0), {{0, buffer, 0, bufferSize}});
+
+    wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
+    wgpu::ComputePassEncoder pass = encoder.BeginComputePass();
+    pass.SetPipeline(pipeline);
+    pass.SetBindGroup(0, bindGroup);
     for (uint32_t i = 0; i < kIterations; ++i) {
-        pass->APIDispatchWorkgroups(kNumValues);
+        pass.DispatchWorkgroups(kNumValues);
     }
-    pass->APIEnd();
-    Ref<native::CommandBufferBase> commandBuffer = encoder->Finish().AcquireSuccess();
-    nativeDevice->GetQueue()->APISubmit(1, &commandBuffer.Get());
+    pass.End();
+    wgpu::CommandBuffer commands = encoder.Finish();
+    queue.Submit(1, &commands);
 
-    EXPECT_BUFFER_U32_RANGE_EQ(expected.data(), native::ToAPI(buffer.Get()), 0, kNumValues);
+    EXPECT_BUFFER_U32_RANGE_EQ(expected.data(), buffer, 0, kNumValues);
 }
 
 DAWN_INSTANTIATE_TEST(InternalStorageBufferBindingTests,