Only Increment Serials When Necessary On D3D12

Only increments last submitted and last completed serials from the D3D12
backend when commands were submitted to the GPU.

Bug: dawn:119
Change-Id: I01748b7f4ac90443adac4cdef29016184f992e9c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/32162
Commit-Queue: Brandon Jones <brandon1.jones@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/tests/white_box/D3D12DescriptorHeapTests.cpp b/src/tests/white_box/D3D12DescriptorHeapTests.cpp
index 341ca3f..b9bc8f7 100644
--- a/src/tests/white_box/D3D12DescriptorHeapTests.cpp
+++ b/src/tests/white_box/D3D12DescriptorHeapTests.cpp
@@ -14,6 +14,7 @@
 
 #include "tests/DawnTest.h"
 
+#include "dawn_native/Device.h"
 #include "dawn_native/Toggles.h"
 #include "dawn_native/d3d12/BindGroupLayoutD3D12.h"
 #include "dawn_native/d3d12/DeviceD3D12.h"
@@ -230,13 +231,16 @@
 
     EXPECT_EQ(allocator->GetShaderVisiblePoolSizeForTesting(), 0u);
 
-    // Allocate + Tick() up to |kFrameDepth| and ensure heaps are always unique.
+    // Allocate + increment internal serials up to |kFrameDepth| and ensure heaps are always unique.
     for (uint32_t i = 0; i < kFrameDepth; i++) {
         EXPECT_TRUE(allocator->AllocateAndSwitchShaderVisibleHeap().IsSuccess());
         ComPtr<ID3D12DescriptorHeap> heap = allocator->GetShaderVisibleHeap();
         EXPECT_TRUE(std::find(heaps.begin(), heaps.end(), heap) == heaps.end());
         heaps.push_back(heap);
-        mD3DDevice->Tick();
+        // CheckPassedSerials() will update the last internally completed serial.
+        mD3DDevice->CheckPassedSerials();
+        // NextSerial() will increment the last internally submitted serial.
+        EXPECT_TRUE(mD3DDevice->NextSerial().IsSuccess());
     }
 
     // Repeat up to |kFrameDepth| again but ensure heaps are the same in the expected order
@@ -247,7 +251,8 @@
         ComPtr<ID3D12DescriptorHeap> heap = allocator->GetShaderVisibleHeap();
         EXPECT_TRUE(heaps.front() == heap);
         heaps.pop_front();
-        mD3DDevice->Tick();
+        mD3DDevice->CheckPassedSerials();
+        EXPECT_TRUE(mD3DDevice->NextSerial().IsSuccess());
     }
 
     EXPECT_TRUE(heaps.empty());