From b35e69b467f37770242e3ba429183517c778be40 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sat, 1 Mar 2025 11:26:43 +0100 Subject: [PATCH] [d3d11] Skip empty draws Watch Dogs 2 likes to do this with graphics UAVs bound, which introduces quite a bit of unnecessary GPU synchronization. --- src/d3d11/d3d11_context.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index f9aacc317..9ba60418d 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -1037,6 +1037,9 @@ namespace dxvk { UINT StartVertexLocation) { D3D10DeviceLock lock = LockContext(); + if (unlikely(!VertexCount)) + return; + VkDrawIndirectCommand draw = { }; draw.vertexCount = VertexCount; draw.instanceCount = 1u; @@ -1054,6 +1057,9 @@ namespace dxvk { INT BaseVertexLocation) { D3D10DeviceLock lock = LockContext(); + if (unlikely(!IndexCount)) + return; + VkDrawIndexedIndirectCommand draw = { }; draw.indexCount = IndexCount; draw.instanceCount = 1u; @@ -1073,6 +1079,9 @@ namespace dxvk { UINT StartInstanceLocation) { D3D10DeviceLock lock = LockContext(); + if (unlikely(!VertexCountPerInstance || !InstanceCount)) + return; + VkDrawIndirectCommand draw = { }; draw.vertexCount = VertexCountPerInstance; draw.instanceCount = InstanceCount; @@ -1092,6 +1101,9 @@ namespace dxvk { UINT StartInstanceLocation) { D3D10DeviceLock lock = LockContext(); + if (unlikely(!IndexCountPerInstance || !InstanceCount)) + return; + VkDrawIndexedIndirectCommand draw = { }; draw.indexCount = IndexCountPerInstance; draw.instanceCount = InstanceCount; @@ -1186,6 +1198,9 @@ namespace dxvk { UINT ThreadGroupCountZ) { D3D10DeviceLock lock = LockContext(); + if (unlikely(!ThreadGroupCountX || !ThreadGroupCountY || !ThreadGroupCountZ)) + return; + if (unlikely(HasDirtyComputeBindings())) ApplyDirtyComputeBindings();