[d3d11] Skip empty draws

Watch Dogs 2 likes to do this with graphics UAVs bound, which
introduces quite a bit of unnecessary GPU synchronization.
This commit is contained in:
Philip Rebohle 2025-03-01 11:26:43 +01:00
parent 11dc0e7ce8
commit b35e69b467

View file

@ -1037,6 +1037,9 @@ namespace dxvk {
UINT StartVertexLocation) { UINT StartVertexLocation) {
D3D10DeviceLock lock = LockContext(); D3D10DeviceLock lock = LockContext();
if (unlikely(!VertexCount))
return;
VkDrawIndirectCommand draw = { }; VkDrawIndirectCommand draw = { };
draw.vertexCount = VertexCount; draw.vertexCount = VertexCount;
draw.instanceCount = 1u; draw.instanceCount = 1u;
@ -1054,6 +1057,9 @@ namespace dxvk {
INT BaseVertexLocation) { INT BaseVertexLocation) {
D3D10DeviceLock lock = LockContext(); D3D10DeviceLock lock = LockContext();
if (unlikely(!IndexCount))
return;
VkDrawIndexedIndirectCommand draw = { }; VkDrawIndexedIndirectCommand draw = { };
draw.indexCount = IndexCount; draw.indexCount = IndexCount;
draw.instanceCount = 1u; draw.instanceCount = 1u;
@ -1073,6 +1079,9 @@ namespace dxvk {
UINT StartInstanceLocation) { UINT StartInstanceLocation) {
D3D10DeviceLock lock = LockContext(); D3D10DeviceLock lock = LockContext();
if (unlikely(!VertexCountPerInstance || !InstanceCount))
return;
VkDrawIndirectCommand draw = { }; VkDrawIndirectCommand draw = { };
draw.vertexCount = VertexCountPerInstance; draw.vertexCount = VertexCountPerInstance;
draw.instanceCount = InstanceCount; draw.instanceCount = InstanceCount;
@ -1092,6 +1101,9 @@ namespace dxvk {
UINT StartInstanceLocation) { UINT StartInstanceLocation) {
D3D10DeviceLock lock = LockContext(); D3D10DeviceLock lock = LockContext();
if (unlikely(!IndexCountPerInstance || !InstanceCount))
return;
VkDrawIndexedIndirectCommand draw = { }; VkDrawIndexedIndirectCommand draw = { };
draw.indexCount = IndexCountPerInstance; draw.indexCount = IndexCountPerInstance;
draw.instanceCount = InstanceCount; draw.instanceCount = InstanceCount;
@ -1186,6 +1198,9 @@ namespace dxvk {
UINT ThreadGroupCountZ) { UINT ThreadGroupCountZ) {
D3D10DeviceLock lock = LockContext(); D3D10DeviceLock lock = LockContext();
if (unlikely(!ThreadGroupCountX || !ThreadGroupCountY || !ThreadGroupCountZ))
return;
if (unlikely(HasDirtyComputeBindings())) if (unlikely(HasDirtyComputeBindings()))
ApplyDirtyComputeBindings(); ApplyDirtyComputeBindings();