Skip noop dispatches on D3D12 backend

Execution warning is produced from D3D12 validation layers for noop
dispatches, which leads to device lost. The skip noop dispatch handling
was added to the front-end before, and moved to Metal backend due
to it gets in the way of a validation change in the follow-up CL. We
also need to add it to D3D12 backend now.

Bug: dawn:1028
Change-Id: I364f6f1e0ac79679a43c064cb402874f1e959537
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59960
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
diff --git a/src/dawn_native/d3d12/CommandBufferD3D12.cpp b/src/dawn_native/d3d12/CommandBufferD3D12.cpp
index 26ef024..626ca9b 100644
--- a/src/dawn_native/d3d12/CommandBufferD3D12.cpp
+++ b/src/dawn_native/d3d12/CommandBufferD3D12.cpp
@@ -995,6 +995,12 @@
                 case Command::Dispatch: {
                     DispatchCmd* dispatch = mCommands.NextCommand<DispatchCmd>();
 
+                    // Skip noop dispatches, it can cause D3D12 warning from validation layers and
+                    // leads to device lost.
+                    if (dispatch->x == 0 || dispatch->y == 0 || dispatch->z == 0) {
+                        break;
+                    }
+
                     TransitionAndClearForSyncScope(commandContext,
                                                    resourceUsages.dispatchUsages[currentDispatch]);
                     DAWN_TRY(bindingTracker->Apply(commandContext));