From 366c9d8c43a929ea60825e4f3d4876cf3baf5f32 Mon Sep 17 00:00:00 2001 From: Li Hao Date: Wed, 28 Jul 2021 05:00:26 +0000 Subject: [PATCH] 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 Reviewed-by: Austin Eng Commit-Queue: Hao Li --- src/dawn_native/d3d12/CommandBufferD3D12.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/dawn_native/d3d12/CommandBufferD3D12.cpp b/src/dawn_native/d3d12/CommandBufferD3D12.cpp index 26ef0244a8..626ca9b424 100644 --- a/src/dawn_native/d3d12/CommandBufferD3D12.cpp +++ b/src/dawn_native/d3d12/CommandBufferD3D12.cpp @@ -995,6 +995,12 @@ namespace dawn_native { namespace d3d12 { case Command::Dispatch: { DispatchCmd* dispatch = mCommands.NextCommand(); + // 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));