Remove device->GetPendingCommandSerial device->GetLastSubmittedCommandSerial

Bug: dawn:1413
Change-Id: I0621cc8e79b1c2a9f2b19eb03dbbcabd0833d598
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/170143
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
diff --git a/src/dawn/native/Buffer.cpp b/src/dawn/native/Buffer.cpp
index 490ceee..d5cb53d 100644
--- a/src/dawn/native/Buffer.cpp
+++ b/src/dawn/native/Buffer.cpp
@@ -858,7 +858,7 @@
 }
 
 void BufferBase::MarkUsedInPendingCommands() {
-    ExecutionSerial serial = GetDevice()->GetPendingCommandSerial();
+    ExecutionSerial serial = GetDevice()->GetQueue()->GetPendingCommandSerial();
     DAWN_ASSERT(serial >= mLastUsageSerial);
     mLastUsageSerial = serial;
 }
diff --git a/src/dawn/native/Device.cpp b/src/dawn/native/Device.cpp
index 26ccd67..4889f74 100644
--- a/src/dawn/native/Device.cpp
+++ b/src/dawn/native/Device.cpp
@@ -503,7 +503,7 @@
 
     if (mState != State::BeingCreated) {
         // The GPU timeline is finished.
-        DAWN_ASSERT(mQueue->GetCompletedCommandSerial() == GetLastSubmittedCommandSerial());
+        DAWN_ASSERT(mQueue->GetCompletedCommandSerial() == mQueue->GetLastSubmittedCommandSerial());
 
         // Finish destroying all objects owned by the device and tick the queue-related tasks
         // since they should be complete. This must be done before DestroyImpl() it may
@@ -2121,14 +2121,6 @@
 
 void DeviceBase::SetLabelImpl() {}
 
-ExecutionSerial DeviceBase::GetLastSubmittedCommandSerial() const {
-    return mQueue->GetLastSubmittedCommandSerial();
-}
-
-ExecutionSerial DeviceBase::GetPendingCommandSerial() const {
-    return mQueue->GetPendingCommandSerial();
-}
-
 bool DeviceBase::ShouldDuplicateNumWorkgroupsForDispatchIndirect(
     ComputePipelineBase* computePipeline) const {
     return false;
diff --git a/src/dawn/native/Device.h b/src/dawn/native/Device.h
index 0f6277d..ca7cfb6 100644
--- a/src/dawn/native/Device.h
+++ b/src/dawn/native/Device.h
@@ -300,7 +300,6 @@
     TextureBase* APICreateTexture(const TextureDescriptor* descriptor);
 
     wgpu::TextureUsage APIGetSupportedSurfaceUsage(Surface* surface);
-    size_t APIQueryMemoryHeapInfo(MemoryHeapInfo* info);
 
     InternalPipelineStore* GetInternalPipelineStore();
 
@@ -462,10 +461,6 @@
     // TODO(dawn:1413): remove this enum forwarding once no longer necessary.
     using SubmitMode = ExecutionQueueBase::SubmitMode;
 
-    // TODO(dawn:1413): Remove this proxy methods in favor of using the ExecutionQueue directly.
-    ExecutionSerial GetLastSubmittedCommandSerial() const;
-    ExecutionSerial GetPendingCommandSerial() const;
-
   protected:
     // Constructor used only for mocking and testing.
     DeviceBase();
diff --git a/src/dawn/native/DynamicUploader.cpp b/src/dawn/native/DynamicUploader.cpp
index e8d6c70..88aeb69 100644
--- a/src/dawn/native/DynamicUploader.cpp
+++ b/src/dawn/native/DynamicUploader.cpp
@@ -32,6 +32,7 @@
 #include "dawn/common/Math.h"
 #include "dawn/native/Buffer.h"
 #include "dawn/native/Device.h"
+#include "dawn/native/Queue.h"
 
 namespace dawn::native {
 
@@ -41,7 +42,8 @@
 }
 
 void DynamicUploader::ReleaseStagingBuffer(Ref<BufferBase> stagingBuffer) {
-    mReleasedStagingBuffers.Enqueue(std::move(stagingBuffer), mDevice->GetPendingCommandSerial());
+    mReleasedStagingBuffers.Enqueue(std::move(stagingBuffer),
+                                    mDevice->GetQueue()->GetPendingCommandSerial());
 }
 
 ResultOrError<UploadHandle> DynamicUploader::AllocateInternal(uint64_t allocationSize,
diff --git a/src/dawn/native/Queue.cpp b/src/dawn/native/Queue.cpp
index f83b4c6..449bf78 100644
--- a/src/dawn/native/Queue.cpp
+++ b/src/dawn/native/Queue.cpp
@@ -124,9 +124,10 @@
     }
 
     UploadHandle uploadHandle;
-    DAWN_TRY_ASSIGN(uploadHandle,
-                    device->GetDynamicUploader()->Allocate(
-                        newDataSizeBytes, device->GetPendingCommandSerial(), offsetAlignment));
+    DAWN_TRY_ASSIGN(
+        uploadHandle,
+        device->GetDynamicUploader()->Allocate(
+            newDataSizeBytes, device->GetQueue()->GetPendingCommandSerial(), offsetAlignment));
     DAWN_ASSERT(uploadHandle.mappedBuffer != nullptr);
 
     uint8_t* dstPointer = static_cast<uint8_t*>(uploadHandle.mappedBuffer);
@@ -298,7 +299,7 @@
     TrackTaskAfterEventualFlush(std::move(task));
 
     TRACE_EVENT1(GetDevice()->GetPlatform(), General, "Queue::APIOnSubmittedWorkDone", "serial",
-                 uint64_t(GetDevice()->GetPendingCommandSerial()));
+                 uint64_t(GetPendingCommandSerial()));
 }
 
 Future QueueBase::APIOnSubmittedWorkDoneF(const QueueWorkDoneCallbackInfo& callbackInfo) {
@@ -423,7 +424,7 @@
 
     UploadHandle uploadHandle;
     DAWN_TRY_ASSIGN(uploadHandle,
-                    device->GetDynamicUploader()->Allocate(size, device->GetPendingCommandSerial(),
+                    device->GetDynamicUploader()->Allocate(size, GetPendingCommandSerial(),
                                                            kCopyBufferToBufferOffsetAlignment));
     DAWN_ASSERT(uploadHandle.mappedBuffer != nullptr);
 
diff --git a/src/dawn/native/d3d11/CommandBufferD3D11.cpp b/src/dawn/native/d3d11/CommandBufferD3D11.cpp
index 818c1c6..582bb37 100644
--- a/src/dawn/native/d3d11/CommandBufferD3D11.cpp
+++ b/src/dawn/native/d3d11/CommandBufferD3D11.cpp
@@ -39,6 +39,7 @@
 #include "dawn/native/CommandValidation.h"
 #include "dawn/native/Commands.h"
 #include "dawn/native/ExternalTexture.h"
+#include "dawn/native/Queue.h"
 #include "dawn/native/RenderBundle.h"
 #include "dawn/native/d3d/D3DError.h"
 #include "dawn/native/d3d11/BindGroupTrackerD3D11.h"
@@ -119,7 +120,7 @@
     }
 
     contents->AcquirePendingFences(&fences);
-    contents->SetLastUsageSerial(texture->GetDevice()->GetPendingCommandSerial());
+    contents->SetLastUsageSerial(texture->GetDevice()->GetQueue()->GetPendingCommandSerial());
 
     for (auto& fence : fences) {
         DAWN_TRY(CheckHRESULT(commandContext->GetD3D11DeviceContext4()->Wait(
diff --git a/src/dawn/native/d3d11/DeviceD3D11.cpp b/src/dawn/native/d3d11/DeviceD3D11.cpp
index 5e94827..f41fce9 100644
--- a/src/dawn/native/d3d11/DeviceD3D11.cpp
+++ b/src/dawn/native/d3d11/DeviceD3D11.cpp
@@ -166,7 +166,7 @@
 }
 
 void Device::ReferenceUntilUnused(ComPtr<IUnknown> object) {
-    mUsedComObjectRefs.Enqueue(object, GetPendingCommandSerial());
+    mUsedComObjectRefs.Enqueue(object, GetQueue()->GetPendingCommandSerial());
 }
 
 ResultOrError<Ref<BindGroupBase>> Device::CreateBindGroupImpl(
diff --git a/src/dawn/native/d3d11/TextureD3D11.cpp b/src/dawn/native/d3d11/TextureD3D11.cpp
index fdc2775..23d818f 100644
--- a/src/dawn/native/d3d11/TextureD3D11.cpp
+++ b/src/dawn/native/d3d11/TextureD3D11.cpp
@@ -39,6 +39,7 @@
 #include "dawn/native/DynamicUploader.h"
 #include "dawn/native/EnumMaskIterator.h"
 #include "dawn/native/IntegerTypes.h"
+#include "dawn/native/Queue.h"
 #include "dawn/native/ToBackend.h"
 #include "dawn/native/d3d/D3DError.h"
 #include "dawn/native/d3d/UtilsD3D.h"
@@ -1108,7 +1109,7 @@
 
 ResultOrError<ExecutionSerial> Texture::EndAccess() {
     // TODO(dawn:1705): submit pending commands if deferred context is used.
-    return GetDevice()->GetLastSubmittedCommandSerial();
+    return GetDevice()->GetQueue()->GetLastSubmittedCommandSerial();
 }
 
 ResultOrError<ComPtr<ID3D11ShaderResourceView>> Texture::GetStencilSRV(
diff --git a/src/dawn/native/d3d12/BindGroupD3D12.cpp b/src/dawn/native/d3d12/BindGroupD3D12.cpp
index abfeeb7..7b27cbd 100644
--- a/src/dawn/native/d3d12/BindGroupD3D12.cpp
+++ b/src/dawn/native/d3d12/BindGroupD3D12.cpp
@@ -31,6 +31,7 @@
 
 #include "dawn/common/BitSetIterator.h"
 #include "dawn/native/ExternalTexture.h"
+#include "dawn/native/Queue.h"
 #include "dawn/native/d3d12/BindGroupLayoutD3D12.h"
 #include "dawn/native/d3d12/BufferD3D12.h"
 #include "dawn/native/d3d12/DeviceD3D12.h"
@@ -246,7 +247,8 @@
     Device* device = ToBackend(GetDevice());
 
     D3D12_CPU_DESCRIPTOR_HANDLE baseCPUDescriptor;
-    if (!viewAllocator->AllocateGPUDescriptors(descriptorCount, device->GetPendingCommandSerial(),
+    if (!viewAllocator->AllocateGPUDescriptors(descriptorCount,
+                                               device->GetQueue()->GetPendingCommandSerial(),
                                                &baseCPUDescriptor, &mGPUViewAllocation)) {
         return false;
     }
diff --git a/src/dawn/native/d3d12/BufferD3D12.cpp b/src/dawn/native/d3d12/BufferD3D12.cpp
index 6f2f0f2..0a9f81d 100644
--- a/src/dawn/native/d3d12/BufferD3D12.cpp
+++ b/src/dawn/native/d3d12/BufferD3D12.cpp
@@ -299,7 +299,7 @@
     // There may be no heap if the allocation is an external one.
     Heap* heap = ToBackend(mResourceAllocation.GetResourceHeap());
     if (heap) {
-        commandContext->TrackHeapUsage(heap, GetDevice()->GetPendingCommandSerial());
+        commandContext->TrackHeapUsage(heap, GetDevice()->GetQueue()->GetPendingCommandSerial());
     }
 
     MarkUsedInPendingCommands();
@@ -350,7 +350,8 @@
     // occur. When that buffer is used again, the previously recorded serial must be compared to
     // the last completed serial to determine if the buffer has implicity decayed to the common
     // state.
-    const ExecutionSerial pendingCommandSerial = ToBackend(GetDevice())->GetPendingCommandSerial();
+    const ExecutionSerial pendingCommandSerial =
+        ToBackend(GetDevice())->GetQueue()->GetPendingCommandSerial();
     if (pendingCommandSerial > mLastUsedSerial) {
         lastState = D3D12_RESOURCE_STATE_COMMON;
         mLastUsedSerial = pendingCommandSerial;
@@ -611,8 +612,9 @@
         // includes STORAGE.
         DynamicUploader* uploader = device->GetDynamicUploader();
         UploadHandle uploadHandle;
-        DAWN_TRY_ASSIGN(uploadHandle, uploader->Allocate(size, device->GetPendingCommandSerial(),
-                                                         kCopyBufferToBufferOffsetAlignment));
+        DAWN_TRY_ASSIGN(uploadHandle,
+                        uploader->Allocate(size, device->GetQueue()->GetPendingCommandSerial(),
+                                           kCopyBufferToBufferOffsetAlignment));
 
         memset(uploadHandle.mappedBuffer, clearValue, size);
 
diff --git a/src/dawn/native/d3d12/CommandBufferD3D12.cpp b/src/dawn/native/d3d12/CommandBufferD3D12.cpp
index f925447..d8835dd 100644
--- a/src/dawn/native/d3d12/CommandBufferD3D12.cpp
+++ b/src/dawn/native/d3d12/CommandBufferD3D12.cpp
@@ -37,6 +37,7 @@
 #include "dawn/native/CommandValidation.h"
 #include "dawn/native/DynamicUploader.h"
 #include "dawn/native/Error.h"
+#include "dawn/native/Queue.h"
 #include "dawn/native/RenderBundle.h"
 #include "dawn/native/d3d12/BindGroupD3D12.h"
 #include "dawn/native/d3d12/BindGroupLayoutD3D12.h"
@@ -1149,9 +1150,10 @@
                 uint8_t* data = mCommands.NextData<uint8_t>(size);
 
                 UploadHandle uploadHandle;
-                DAWN_TRY_ASSIGN(uploadHandle, device->GetDynamicUploader()->Allocate(
-                                                  size, device->GetPendingCommandSerial(),
-                                                  kCopyBufferToBufferOffsetAlignment));
+                DAWN_TRY_ASSIGN(uploadHandle,
+                                device->GetDynamicUploader()->Allocate(
+                                    size, device->GetQueue()->GetPendingCommandSerial(),
+                                    kCopyBufferToBufferOffsetAlignment));
                 DAWN_ASSERT(uploadHandle.mappedBuffer != nullptr);
                 memcpy(uploadHandle.mappedBuffer, data, size);
 
diff --git a/src/dawn/native/d3d12/DeviceD3D12.cpp b/src/dawn/native/d3d12/DeviceD3D12.cpp
index 388d8eb..e5c8761 100644
--- a/src/dawn/native/d3d12/DeviceD3D12.cpp
+++ b/src/dawn/native/d3d12/DeviceD3D12.cpp
@@ -250,8 +250,9 @@
     if (!mZeroBuffer->IsDataInitialized()) {
         DynamicUploader* uploader = GetDynamicUploader();
         UploadHandle uploadHandle;
-        DAWN_TRY_ASSIGN(uploadHandle, uploader->Allocate(kZeroBufferSize, GetPendingCommandSerial(),
-                                                         kCopyBufferToBufferOffsetAlignment));
+        DAWN_TRY_ASSIGN(uploadHandle,
+                        uploader->Allocate(kZeroBufferSize, GetQueue()->GetPendingCommandSerial(),
+                                           kCopyBufferToBufferOffsetAlignment));
 
         memset(uploadHandle.mappedBuffer, 0u, kZeroBufferSize);
 
@@ -299,7 +300,7 @@
 }
 
 void Device::ReferenceUntilUnused(ComPtr<IUnknown> object) {
-    mUsedComObjectRefs->Enqueue(std::move(object), GetPendingCommandSerial());
+    mUsedComObjectRefs->Enqueue(std::move(object), GetQueue()->GetPendingCommandSerial());
 }
 
 ResultOrError<Ref<BindGroupBase>> Device::CreateBindGroupImpl(
diff --git a/src/dawn/native/d3d12/QueueD3D12.cpp b/src/dawn/native/d3d12/QueueD3D12.cpp
index 6743ea6..bfee9f1 100644
--- a/src/dawn/native/d3d12/QueueD3D12.cpp
+++ b/src/dawn/native/d3d12/QueueD3D12.cpp
@@ -122,12 +122,12 @@
     DAWN_TRY_ASSIGN(commandContext, GetPendingCommandContext());
 
     TRACE_EVENT_BEGIN1(GetDevice()->GetPlatform(), Recording, "CommandBufferD3D12::RecordCommands",
-                       "serial", uint64_t(GetDevice()->GetPendingCommandSerial()));
+                       "serial", uint64_t(GetPendingCommandSerial()));
     for (uint32_t i = 0; i < commandCount; ++i) {
         DAWN_TRY(ToBackend(commands[i])->RecordCommands(commandContext));
     }
     TRACE_EVENT_END1(GetDevice()->GetPlatform(), Recording, "CommandBufferD3D12::RecordCommands",
-                     "serial", uint64_t(GetDevice()->GetPendingCommandSerial()));
+                     "serial", uint64_t(GetPendingCommandSerial()));
 
     return SubmitPendingCommands();
 }
diff --git a/src/dawn/native/d3d12/ResidencyManagerD3D12.cpp b/src/dawn/native/d3d12/ResidencyManagerD3D12.cpp
index b1b848e..fc070d4 100644
--- a/src/dawn/native/d3d12/ResidencyManagerD3D12.cpp
+++ b/src/dawn/native/d3d12/ResidencyManagerD3D12.cpp
@@ -177,7 +177,7 @@
     // If the next candidate for eviction was inserted into the LRU during the current serial,
     // it is because more memory is being used in a single command list than is available.
     // In this scenario, we cannot make any more resources resident and thrashing must occur.
-    if (lastSubmissionSerial == mDevice->GetPendingCommandSerial()) {
+    if (lastSubmissionSerial == mDevice->GetQueue()->GetPendingCommandSerial()) {
         return nullptr;
     }
 
@@ -257,7 +257,7 @@
     uint64_t localSizeToMakeResident = 0;
     uint64_t nonLocalSizeToMakeResident = 0;
 
-    ExecutionSerial pendingCommandSerial = mDevice->GetPendingCommandSerial();
+    ExecutionSerial pendingCommandSerial = mDevice->GetQueue()->GetPendingCommandSerial();
     for (size_t i = 0; i < heapCount; i++) {
         Heap* heap = heaps[i];
 
diff --git a/src/dawn/native/d3d12/ResourceAllocatorManagerD3D12.cpp b/src/dawn/native/d3d12/ResourceAllocatorManagerD3D12.cpp
index c2dc4072..5b22bba 100644
--- a/src/dawn/native/d3d12/ResourceAllocatorManagerD3D12.cpp
+++ b/src/dawn/native/d3d12/ResourceAllocatorManagerD3D12.cpp
@@ -31,6 +31,7 @@
 #include <limits>
 #include <utility>
 
+#include "dawn/native/Queue.h"
 #include "dawn/native/d3d/D3DError.h"
 #include "dawn/native/d3d12/DeviceD3D12.h"
 #include "dawn/native/d3d12/HeapAllocatorD3D12.h"
@@ -457,7 +458,7 @@
         return;
     }
 
-    mAllocationsToDelete.Enqueue(allocation, mDevice->GetPendingCommandSerial());
+    mAllocationsToDelete.Enqueue(allocation, mDevice->GetQueue()->GetPendingCommandSerial());
 
     // Directly allocated ResourceHeapAllocations are created with a heap object that must be
     // manually deleted upon deallocation. See ResourceAllocatorManager::CreateCommittedResource
@@ -466,7 +467,7 @@
     // pending commands.
     if (allocation.GetInfo().mMethod == AllocationMethod::kDirect) {
         mHeapsToDelete.Enqueue(std::unique_ptr<ResourceHeapBase>(allocation.GetResourceHeap()),
-                               mDevice->GetPendingCommandSerial());
+                               mDevice->GetQueue()->GetPendingCommandSerial());
     }
 
     // Invalidate the allocation immediately in case one accidentally
diff --git a/src/dawn/native/d3d12/SamplerHeapCacheD3D12.cpp b/src/dawn/native/d3d12/SamplerHeapCacheD3D12.cpp
index 0646590..0351bbc 100644
--- a/src/dawn/native/d3d12/SamplerHeapCacheD3D12.cpp
+++ b/src/dawn/native/d3d12/SamplerHeapCacheD3D12.cpp
@@ -31,6 +31,7 @@
 
 #include "dawn/common/Assert.h"
 #include "dawn/common/HashUtils.h"
+#include "dawn/native/Queue.h"
 #include "dawn/native/d3d12/BindGroupD3D12.h"
 #include "dawn/native/d3d12/BindGroupLayoutD3D12.h"
 #include "dawn/native/d3d12/DeviceD3D12.h"
@@ -84,7 +85,8 @@
     // If either failed, return early to re-allocate and switch the heaps.
     const uint32_t descriptorCount = mSamplers.size();
     D3D12_CPU_DESCRIPTOR_HANDLE baseCPUDescriptor;
-    if (!allocator->AllocateGPUDescriptors(descriptorCount, device->GetPendingCommandSerial(),
+    if (!allocator->AllocateGPUDescriptors(descriptorCount,
+                                           device->GetQueue()->GetPendingCommandSerial(),
                                            &baseCPUDescriptor, &mGPUAllocation)) {
         return false;
     }
diff --git a/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp b/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp
index 0bda7c5..bae9a74 100644
--- a/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp
+++ b/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp
@@ -202,7 +202,7 @@
             // longer used by GPU. This maintains a heap buffer to avoid frequently re-creating
             // heaps for heavy users.
             // TODO(dawn:256): Consider periodically triming to avoid OOM.
-            mPool.push_back({mDevice->GetPendingCommandSerial(), std::move(mHeap)});
+            mPool.push_back({mDevice->GetQueue()->GetPendingCommandSerial(), std::move(mHeap)});
             if (mPool.front().heapSerial <= mDevice->GetQueue()->GetCompletedCommandSerial()) {
                 descriptorHeap = std::move(mPool.front().heap);
                 mPool.pop_front();
diff --git a/src/dawn/native/d3d12/StagingDescriptorAllocatorD3D12.cpp b/src/dawn/native/d3d12/StagingDescriptorAllocatorD3D12.cpp
index f5824df..6be04da 100644
--- a/src/dawn/native/d3d12/StagingDescriptorAllocatorD3D12.cpp
+++ b/src/dawn/native/d3d12/StagingDescriptorAllocatorD3D12.cpp
@@ -30,6 +30,7 @@
 #include <utility>
 
 #include "dawn/common/Math.h"
+#include "dawn/native/Queue.h"
 #include "dawn/native/d3d/D3DError.h"
 #include "dawn/native/d3d12/DeviceD3D12.h"
 
@@ -150,7 +151,7 @@
 StagingDescriptorAllocator::AllocateTransientCPUDescriptors() {
     CPUDescriptorHeapAllocation allocation;
     DAWN_TRY_ASSIGN(allocation, AllocateCPUDescriptors());
-    mAllocationsToDelete.Enqueue(allocation, mDevice->GetPendingCommandSerial());
+    mAllocationsToDelete.Enqueue(allocation, mDevice->GetQueue()->GetPendingCommandSerial());
     return allocation;
 }
 
diff --git a/src/dawn/native/d3d12/TextureD3D12.cpp b/src/dawn/native/d3d12/TextureD3D12.cpp
index 9e7f1ce..5753552 100644
--- a/src/dawn/native/d3d12/TextureD3D12.cpp
+++ b/src/dawn/native/d3d12/TextureD3D12.cpp
@@ -439,7 +439,7 @@
     SharedTextureMemoryContents* contents = GetSharedTextureMemoryContents();
     if (contents != nullptr) {
         contents->AcquirePendingFences(&fences);
-        contents->SetLastUsageSerial(GetDevice()->GetPendingCommandSerial());
+        contents->SetLastUsageSerial(GetDevice()->GetQueue()->GetPendingCommandSerial());
     }
 
     for (const auto& fence : fences) {
@@ -483,7 +483,7 @@
     if (mResourceAllocation.GetInfo().mMethod != AllocationMethod::kExternal) {
         // Track the underlying heap to ensure residency.
         Heap* heap = ToBackend(mResourceAllocation.GetResourceHeap());
-        commandContext->TrackHeapUsage(heap, GetDevice()->GetPendingCommandSerial());
+        commandContext->TrackHeapUsage(heap, GetDevice()->GetQueue()->GetPendingCommandSerial());
     }
 
     std::vector<D3D12_RESOURCE_BARRIER> barriers;
@@ -628,7 +628,7 @@
                                                    const SubresourceRange& range) {
     HandleTransitionSpecialCases(commandContext);
 
-    const ExecutionSerial pendingCommandSerial = ToBackend(GetDevice())->GetPendingCommandSerial();
+    const ExecutionSerial pendingCommandSerial = GetDevice()->GetQueue()->GetPendingCommandSerial();
 
     mSubresourceStateAndDecay.Update(range, [&](const SubresourceRange& updateRange,
                                                 StateAndDecay* state) {
@@ -643,12 +643,12 @@
     if (mResourceAllocation.GetInfo().mMethod != AllocationMethod::kExternal) {
         // Track the underlying heap to ensure residency.
         Heap* heap = ToBackend(mResourceAllocation.GetResourceHeap());
-        commandContext->TrackHeapUsage(heap, GetDevice()->GetPendingCommandSerial());
+        commandContext->TrackHeapUsage(heap, GetDevice()->GetQueue()->GetPendingCommandSerial());
     }
 
     HandleTransitionSpecialCases(commandContext);
 
-    const ExecutionSerial pendingCommandSerial = ToBackend(GetDevice())->GetPendingCommandSerial();
+    const ExecutionSerial pendingCommandSerial = GetDevice()->GetQueue()->GetPendingCommandSerial();
 
     mSubresourceStateAndDecay.Merge(
         textureSyncInfos, [&](const SubresourceRange& mergeRange, StateAndDecay* state,
@@ -862,9 +862,10 @@
                                   largestMipSize.depthOrArrayLayers;
             DynamicUploader* uploader = device->GetDynamicUploader();
             UploadHandle uploadHandle;
-            DAWN_TRY_ASSIGN(uploadHandle,
-                            uploader->Allocate(bufferSize, device->GetPendingCommandSerial(),
-                                               blockInfo.byteSize));
+            DAWN_TRY_ASSIGN(
+                uploadHandle,
+                uploader->Allocate(bufferSize, device->GetQueue()->GetPendingCommandSerial(),
+                                   blockInfo.byteSize));
             memset(uploadHandle.mappedBuffer, clearColor, bufferSize);
 
             for (uint32_t level = range.baseMipLevel; level < range.baseMipLevel + range.levelCount;
diff --git a/src/dawn/native/metal/CommandBufferMTL.mm b/src/dawn/native/metal/CommandBufferMTL.mm
index 64f4865..d4da77f 100644
--- a/src/dawn/native/metal/CommandBufferMTL.mm
+++ b/src/dawn/native/metal/CommandBufferMTL.mm
@@ -32,6 +32,7 @@
 #include "dawn/native/Commands.h"
 #include "dawn/native/DynamicUploader.h"
 #include "dawn/native/ExternalTexture.h"
+#include "dawn/native/Queue.h"
 #include "dawn/native/RenderBundle.h"
 #include "dawn/native/metal/BindGroupMTL.h"
 #include "dawn/native/metal/BufferMTL.h"
@@ -1247,9 +1248,10 @@
                 Device* device = ToBackend(GetDevice());
 
                 UploadHandle uploadHandle;
-                DAWN_TRY_ASSIGN(uploadHandle, device->GetDynamicUploader()->Allocate(
-                                                  size, device->GetPendingCommandSerial(),
-                                                  kCopyBufferToBufferOffsetAlignment));
+                DAWN_TRY_ASSIGN(uploadHandle,
+                                device->GetDynamicUploader()->Allocate(
+                                    size, device->GetQueue()->GetPendingCommandSerial(),
+                                    kCopyBufferToBufferOffsetAlignment));
                 DAWN_ASSERT(uploadHandle.mappedBuffer != nullptr);
                 memcpy(uploadHandle.mappedBuffer, data, size);
 
diff --git a/src/dawn/native/metal/TextureMTL.mm b/src/dawn/native/metal/TextureMTL.mm
index 357df7b..853e67d 100644
--- a/src/dawn/native/metal/TextureMTL.mm
+++ b/src/dawn/native/metal/TextureMTL.mm
@@ -35,6 +35,7 @@
 #include "dawn/native/ChainUtils.h"
 #include "dawn/native/DynamicUploader.h"
 #include "dawn/native/EnumMaskIterator.h"
+#include "dawn/native/Queue.h"
 #include "dawn/native/metal/BufferMTL.h"
 #include "dawn/native/metal/DeviceMTL.h"
 #include "dawn/native/metal/QueueMTL.h"
@@ -466,7 +467,7 @@
         SharedTextureMemoryContents* contents = GetSharedTextureMemoryContents();
         if (contents != nullptr) {
             contents->AcquirePendingFences(&fences);
-            contents->SetLastUsageSerial(GetDevice()->GetPendingCommandSerial());
+            contents->SetLastUsageSerial(GetDevice()->GetQueue()->GetPendingCommandSerial());
         }
 
         if (!mWaitEvents.empty() || !fences->empty()) {
@@ -756,9 +757,10 @@
 
             DynamicUploader* uploader = device->GetDynamicUploader();
             UploadHandle uploadHandle;
-            DAWN_TRY_ASSIGN(uploadHandle,
-                            uploader->Allocate(bufferSize, device->GetPendingCommandSerial(),
-                                               blockInfo.byteSize));
+            DAWN_TRY_ASSIGN(
+                uploadHandle,
+                uploader->Allocate(bufferSize, device->GetQueue()->GetPendingCommandSerial(),
+                                   blockInfo.byteSize));
             memset(uploadHandle.mappedBuffer, clearColor, bufferSize);
 
             id<MTLBuffer> uploadBuffer = ToBackend(uploadHandle.stagingBuffer)->GetMTLBuffer();
diff --git a/src/dawn/native/vulkan/CommandBufferVk.cpp b/src/dawn/native/vulkan/CommandBufferVk.cpp
index d21444c..a3ad777 100644
--- a/src/dawn/native/vulkan/CommandBufferVk.cpp
+++ b/src/dawn/native/vulkan/CommandBufferVk.cpp
@@ -944,9 +944,10 @@
                 uint8_t* data = mCommands.NextData<uint8_t>(size);
 
                 UploadHandle uploadHandle;
-                DAWN_TRY_ASSIGN(uploadHandle, device->GetDynamicUploader()->Allocate(
-                                                  size, device->GetPendingCommandSerial(),
-                                                  kCopyBufferToBufferOffsetAlignment));
+                DAWN_TRY_ASSIGN(uploadHandle,
+                                device->GetDynamicUploader()->Allocate(
+                                    size, device->GetQueue()->GetPendingCommandSerial(),
+                                    kCopyBufferToBufferOffsetAlignment));
                 DAWN_ASSERT(uploadHandle.mappedBuffer != nullptr);
                 memcpy(uploadHandle.mappedBuffer, data, size);
 
diff --git a/src/dawn/native/vulkan/DescriptorSetAllocator.cpp b/src/dawn/native/vulkan/DescriptorSetAllocator.cpp
index 2937177..ff3d6e8 100644
--- a/src/dawn/native/vulkan/DescriptorSetAllocator.cpp
+++ b/src/dawn/native/vulkan/DescriptorSetAllocator.cpp
@@ -29,6 +29,7 @@
 
 #include <utility>
 
+#include "dawn/native/Queue.h"
 #include "dawn/native/vulkan/BindGroupLayoutVk.h"
 #include "dawn/native/vulkan/DeviceVk.h"
 #include "dawn/native/vulkan/FencedDeleter.h"
@@ -124,7 +125,7 @@
     // documentation for vkCmdBindDescriptorSets that the set may be consumed any time between
     // host execution of the command and the end of the draw/dispatch.
     Device* device = ToBackend(GetDevice());
-    const ExecutionSerial serial = device->GetPendingCommandSerial();
+    const ExecutionSerial serial = device->GetQueue()->GetPendingCommandSerial();
     mPendingDeallocations.Enqueue({allocationInfo->poolIndex, allocationInfo->setIndex}, serial);
 
     if (mLastDeallocationSerial != serial) {
diff --git a/src/dawn/native/vulkan/DeviceVk.cpp b/src/dawn/native/vulkan/DeviceVk.cpp
index 36ebc4a..2274c47 100644
--- a/src/dawn/native/vulkan/DeviceVk.cpp
+++ b/src/dawn/native/vulkan/DeviceVk.cpp
@@ -352,7 +352,8 @@
 }
 
 void Device::EnqueueDeferredDeallocation(DescriptorSetAllocator* allocator) {
-    mDescriptorAllocatorsPendingDeallocation.Enqueue(allocator, GetPendingCommandSerial());
+    mDescriptorAllocatorsPendingDeallocation.Enqueue(allocator,
+                                                     GetQueue()->GetPendingCommandSerial());
 }
 
 ResultOrError<VulkanDeviceKnobs> Device::CreateDevice(VkPhysicalDevice vkPhysicalDevice) {
diff --git a/src/dawn/native/vulkan/FencedDeleter.cpp b/src/dawn/native/vulkan/FencedDeleter.cpp
index 3a1c21e..5894a59 100644
--- a/src/dawn/native/vulkan/FencedDeleter.cpp
+++ b/src/dawn/native/vulkan/FencedDeleter.cpp
@@ -27,6 +27,7 @@
 
 #include "dawn/native/vulkan/FencedDeleter.h"
 
+#include "dawn/native/Queue.h"
 #include "dawn/native/vulkan/DeviceVk.h"
 
 namespace dawn::native::vulkan {
@@ -52,63 +53,63 @@
 }
 
 void FencedDeleter::DeleteWhenUnused(VkBuffer buffer) {
-    mBuffersToDelete.Enqueue(buffer, mDevice->GetPendingCommandSerial());
+    mBuffersToDelete.Enqueue(buffer, mDevice->GetQueue()->GetPendingCommandSerial());
 }
 
 void FencedDeleter::DeleteWhenUnused(VkDescriptorPool pool) {
-    mDescriptorPoolsToDelete.Enqueue(pool, mDevice->GetPendingCommandSerial());
+    mDescriptorPoolsToDelete.Enqueue(pool, mDevice->GetQueue()->GetPendingCommandSerial());
 }
 
 void FencedDeleter::DeleteWhenUnused(VkDeviceMemory memory) {
-    mMemoriesToDelete.Enqueue(memory, mDevice->GetPendingCommandSerial());
+    mMemoriesToDelete.Enqueue(memory, mDevice->GetQueue()->GetPendingCommandSerial());
 }
 
 void FencedDeleter::DeleteWhenUnused(VkFramebuffer framebuffer) {
-    mFramebuffersToDelete.Enqueue(framebuffer, mDevice->GetPendingCommandSerial());
+    mFramebuffersToDelete.Enqueue(framebuffer, mDevice->GetQueue()->GetPendingCommandSerial());
 }
 
 void FencedDeleter::DeleteWhenUnused(VkImage image) {
-    mImagesToDelete.Enqueue(image, mDevice->GetPendingCommandSerial());
+    mImagesToDelete.Enqueue(image, mDevice->GetQueue()->GetPendingCommandSerial());
 }
 
 void FencedDeleter::DeleteWhenUnused(VkImageView view) {
-    mImageViewsToDelete.Enqueue(view, mDevice->GetPendingCommandSerial());
+    mImageViewsToDelete.Enqueue(view, mDevice->GetQueue()->GetPendingCommandSerial());
 }
 
 void FencedDeleter::DeleteWhenUnused(VkPipeline pipeline) {
-    mPipelinesToDelete.Enqueue(pipeline, mDevice->GetPendingCommandSerial());
+    mPipelinesToDelete.Enqueue(pipeline, mDevice->GetQueue()->GetPendingCommandSerial());
 }
 
 void FencedDeleter::DeleteWhenUnused(VkPipelineLayout layout) {
-    mPipelineLayoutsToDelete.Enqueue(layout, mDevice->GetPendingCommandSerial());
+    mPipelineLayoutsToDelete.Enqueue(layout, mDevice->GetQueue()->GetPendingCommandSerial());
 }
 
 void FencedDeleter::DeleteWhenUnused(VkQueryPool querypool) {
-    mQueryPoolsToDelete.Enqueue(querypool, mDevice->GetPendingCommandSerial());
+    mQueryPoolsToDelete.Enqueue(querypool, mDevice->GetQueue()->GetPendingCommandSerial());
 }
 
 void FencedDeleter::DeleteWhenUnused(VkRenderPass renderPass) {
-    mRenderPassesToDelete.Enqueue(renderPass, mDevice->GetPendingCommandSerial());
+    mRenderPassesToDelete.Enqueue(renderPass, mDevice->GetQueue()->GetPendingCommandSerial());
 }
 
 void FencedDeleter::DeleteWhenUnused(VkSampler sampler) {
-    mSamplersToDelete.Enqueue(sampler, mDevice->GetPendingCommandSerial());
+    mSamplersToDelete.Enqueue(sampler, mDevice->GetQueue()->GetPendingCommandSerial());
 }
 
 void FencedDeleter::DeleteWhenUnused(VkSemaphore semaphore) {
-    mSemaphoresToDelete.Enqueue(semaphore, mDevice->GetPendingCommandSerial());
+    mSemaphoresToDelete.Enqueue(semaphore, mDevice->GetQueue()->GetPendingCommandSerial());
 }
 
 void FencedDeleter::DeleteWhenUnused(VkShaderModule module) {
-    mShaderModulesToDelete.Enqueue(module, mDevice->GetPendingCommandSerial());
+    mShaderModulesToDelete.Enqueue(module, mDevice->GetQueue()->GetPendingCommandSerial());
 }
 
 void FencedDeleter::DeleteWhenUnused(VkSurfaceKHR surface) {
-    mSurfacesToDelete.Enqueue(surface, mDevice->GetPendingCommandSerial());
+    mSurfacesToDelete.Enqueue(surface, mDevice->GetQueue()->GetPendingCommandSerial());
 }
 
 void FencedDeleter::DeleteWhenUnused(VkSwapchainKHR swapChain) {
-    mSwapChainsToDelete.Enqueue(swapChain, mDevice->GetPendingCommandSerial());
+    mSwapChainsToDelete.Enqueue(swapChain, mDevice->GetQueue()->GetPendingCommandSerial());
 }
 
 void FencedDeleter::Tick(ExecutionSerial completedSerial) {
diff --git a/src/dawn/native/vulkan/ResourceMemoryAllocatorVk.cpp b/src/dawn/native/vulkan/ResourceMemoryAllocatorVk.cpp
index 65a1a9e..90c4847 100644
--- a/src/dawn/native/vulkan/ResourceMemoryAllocatorVk.cpp
+++ b/src/dawn/native/vulkan/ResourceMemoryAllocatorVk.cpp
@@ -32,6 +32,7 @@
 
 #include "dawn/common/Math.h"
 #include "dawn/native/BuddyMemoryAllocator.h"
+#include "dawn/native/Queue.h"
 #include "dawn/native/ResourceHeapAllocator.h"
 #include "dawn/native/vulkan/DeviceVk.h"
 #include "dawn/native/vulkan/FencedDeleter.h"
@@ -232,7 +233,8 @@
         // TODO(crbug.com/dawn/851): Maybe we can produce the correct barriers to reduce the
         // latency to reclaim memory.
         case AllocationMethod::kSubAllocated:
-            mSubAllocationsToDelete.Enqueue(*allocation, mDevice->GetPendingCommandSerial());
+            mSubAllocationsToDelete.Enqueue(*allocation,
+                                            mDevice->GetQueue()->GetPendingCommandSerial());
             break;
 
         default:
diff --git a/src/dawn/native/vulkan/TextureVk.cpp b/src/dawn/native/vulkan/TextureVk.cpp
index e61f49c..226f884 100644
--- a/src/dawn/native/vulkan/TextureVk.cpp
+++ b/src/dawn/native/vulkan/TextureVk.cpp
@@ -1577,9 +1577,9 @@
                               largestMipSize.depthOrArrayLayers;
         DynamicUploader* uploader = device->GetDynamicUploader();
         UploadHandle uploadHandle;
-        DAWN_TRY_ASSIGN(
-            uploadHandle,
-            uploader->Allocate(bufferSize, device->GetPendingCommandSerial(), blockInfo.byteSize));
+        DAWN_TRY_ASSIGN(uploadHandle, uploader->Allocate(
+                                          bufferSize, device->GetQueue()->GetPendingCommandSerial(),
+                                          blockInfo.byteSize));
         memset(uploadHandle.mappedBuffer, uClearColor, bufferSize);
 
         std::vector<VkBufferImageCopy> regions;
diff --git a/src/dawn/tests/white_box/D3D12DescriptorHeapTests.cpp b/src/dawn/tests/white_box/D3D12DescriptorHeapTests.cpp
index 17527f8..6cff306 100644
--- a/src/dawn/tests/white_box/D3D12DescriptorHeapTests.cpp
+++ b/src/dawn/tests/white_box/D3D12DescriptorHeapTests.cpp
@@ -1063,7 +1063,7 @@
     GPUDescriptorHeapAllocation gpuHeapDescAllocation;
 
     D3D12_CPU_DESCRIPTOR_HANDLE baseCPUDescriptor;
-    gpuAllocator->AllocateGPUDescriptors(1, mD3DDevice->GetPendingCommandSerial(),
+    gpuAllocator->AllocateGPUDescriptors(1, mD3DDevice->GetQueue()->GetPendingCommandSerial(),
                                          &baseCPUDescriptor, &gpuHeapDescAllocation);
 
     EXPECT_TRUE(gpuAllocator->IsAllocationStillValid(gpuHeapDescAllocation));