Fix D3D12 Device Initialize calls NextSerial

Device shouldn't be used until after DeviceBase::Initialize so we need
to move the NextSerial call to after Device Initialization is completed.

Bug: chromium:1094477
Change-Id: I2ab317c1d75f853c022faac3fc0bbd66fbd7c14e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23261
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Natasha Lee <natlee@microsoft.com>
diff --git a/src/dawn_native/d3d12/DeviceD3D12.cpp b/src/dawn_native/d3d12/DeviceD3D12.cpp
index dcb0227..9f18045 100644
--- a/src/dawn_native/d3d12/DeviceD3D12.cpp
+++ b/src/dawn_native/d3d12/DeviceD3D12.cpp
@@ -121,8 +121,6 @@
             mViewShaderVisibleDescriptorAllocator,
             ShaderVisibleDescriptorAllocator::Create(this, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV));
 
-        DAWN_TRY(NextSerial());
-
         // Initialize indirect commands
         D3D12_INDIRECT_ARGUMENT_DESC argumentDesc = {};
         argumentDesc.Type = D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH;
@@ -147,7 +145,11 @@
         GetD3D12Device()->CreateCommandSignature(&programDesc, NULL,
                                                  IID_PPV_ARGS(&mDrawIndexedIndirectSignature));
 
-        return DeviceBase::Initialize(new Queue(this));
+        DAWN_TRY(DeviceBase::Initialize(new Queue(this)));
+        // Device shouldn't be used until after DeviceBase::Initialize so we must wait until after
+        // device initialization to call NextSerial
+        DAWN_TRY(NextSerial());
+        return {};
     }
 
     Device::~Device() {