diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index cb5e3df8..c39d350a 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -1433,8 +1433,7 @@ namespace dxvk { ID3D11Buffer* pBufferForArgs, UINT AlignedByteOffsetForArgs) { D3D10DeviceLock lock = LockContext(); - - SetDrawBuffer(pBufferForArgs); + SetDrawBuffers(pBufferForArgs, nullptr); // If possible, batch up multiple indirect draw calls of // the same type into one single multiDrawIndirect call @@ -1465,8 +1464,7 @@ namespace dxvk { ID3D11Buffer* pBufferForArgs, UINT AlignedByteOffsetForArgs) { D3D10DeviceLock lock = LockContext(); - - SetDrawBuffer(pBufferForArgs); + SetDrawBuffers(pBufferForArgs, nullptr); // If possible, batch up multiple indirect draw calls of // the same type into one single multiDrawIndirect call @@ -1512,8 +1510,7 @@ namespace dxvk { ID3D11Buffer* pBufferForArgs, UINT AlignedByteOffsetForArgs) { D3D10DeviceLock lock = LockContext(); - - SetDrawBuffer(pBufferForArgs); + SetDrawBuffers(pBufferForArgs, nullptr); EmitCs([cOffset = AlignedByteOffsetForArgs] (DxvkContext* ctx) { @@ -3194,14 +3191,14 @@ namespace dxvk { } - void D3D11DeviceContext::BindDrawBuffer( - D3D11Buffer* pBuffer) { + void D3D11DeviceContext::BindDrawBuffers( + D3D11Buffer* pBufferForArgs, + D3D11Buffer* pBufferForCount) { EmitCs([ - cBufferSlice = pBuffer != nullptr - ? pBuffer->GetBufferSlice() - : DxvkBufferSlice() + cArgBuffer = pBufferForArgs ? pBufferForArgs->GetBufferSlice() : DxvkBufferSlice(), + cCntBuffer = pBufferForCount ? pBufferForCount->GetBufferSlice() : DxvkBufferSlice() ] (DxvkContext* ctx) { - ctx->bindDrawBuffers(cBufferSlice, DxvkBufferSlice()); + ctx->bindDrawBuffers(cArgBuffer, cCntBuffer); }); } @@ -3365,13 +3362,18 @@ namespace dxvk { } - void D3D11DeviceContext::SetDrawBuffer( - ID3D11Buffer* pBuffer) { - auto buffer = static_cast(pBuffer); + void D3D11DeviceContext::SetDrawBuffers( + ID3D11Buffer* pBufferForArgs, + ID3D11Buffer* pBufferForCount) { + auto argBuffer = static_cast(pBufferForArgs); + auto cntBuffer = static_cast(pBufferForCount); - if (m_state.id.argBuffer != buffer) { - m_state.id.argBuffer = buffer; - BindDrawBuffer(buffer); + if (m_state.id.argBuffer != argBuffer + || m_state.id.cntBuffer != cntBuffer) { + m_state.id.argBuffer = argBuffer; + m_state.id.cntBuffer = cntBuffer; + + BindDrawBuffers(argBuffer, cntBuffer); } } @@ -3577,8 +3579,9 @@ namespace dxvk { ApplyViewportState(); ApplyUnusedState(); - BindDrawBuffer( - m_state.id.argBuffer.ptr()); + BindDrawBuffers( + m_state.id.argBuffer.ptr(), + m_state.id.cntBuffer.ptr()); BindIndexBuffer( m_state.ia.indexBuffer.buffer.ptr(), diff --git a/src/d3d11/d3d11_context.h b/src/d3d11/d3d11_context.h index 6c152914..5727232e 100644 --- a/src/d3d11/d3d11_context.h +++ b/src/d3d11/d3d11_context.h @@ -688,8 +688,9 @@ namespace dxvk { void BindFramebuffer( BOOL Spill); - void BindDrawBuffer( - D3D11Buffer* pBuffer); + void BindDrawBuffers( + D3D11Buffer* pBufferForArgs, + D3D11Buffer* pBufferForCount); void BindVertexBuffer( UINT Slot, @@ -731,8 +732,9 @@ namespace dxvk { void DiscardTexture( D3D11CommonTexture* pTexture); - void SetDrawBuffer( - ID3D11Buffer* pBuffer); + void SetDrawBuffers( + ID3D11Buffer* pBufferForArgs, + ID3D11Buffer* pBufferForCount); void SetConstantBuffers( DxbcProgramType ShaderStage, diff --git a/src/d3d11/d3d11_context_ext.cpp b/src/d3d11/d3d11_context_ext.cpp index 5ca872e3..fd335eea 100644 --- a/src/d3d11/d3d11_context_ext.cpp +++ b/src/d3d11/d3d11_context_ext.cpp @@ -32,7 +32,7 @@ namespace dxvk { UINT ByteOffsetForArgs, UINT ByteStrideForArgs) { D3D10DeviceLock lock = m_ctx->LockContext(); - m_ctx->SetDrawBuffer(pBufferForArgs); + m_ctx->SetDrawBuffers(pBufferForArgs, nullptr); m_ctx->EmitCs([ cCount = DrawCount, @@ -50,7 +50,7 @@ namespace dxvk { UINT ByteOffsetForArgs, UINT ByteStrideForArgs) { D3D10DeviceLock lock = m_ctx->LockContext(); - m_ctx->SetDrawBuffer(pBufferForArgs); + m_ctx->SetDrawBuffers(pBufferForArgs, nullptr); m_ctx->EmitCs([ cCount = DrawCount, diff --git a/src/d3d11/d3d11_context_state.h b/src/d3d11/d3d11_context_state.h index fda4fb5c..f9e929f0 100644 --- a/src/d3d11/d3d11_context_state.h +++ b/src/d3d11/d3d11_context_state.h @@ -104,6 +104,7 @@ namespace dxvk { struct D3D11ContextStateID { Com argBuffer = nullptr; + Com cntBuffer = nullptr; };