1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00

[d3d11] Support count buffer in Set|BindDrawBuffers

This commit is contained in:
Philip Rebohle 2019-04-24 21:58:20 +02:00
parent 117b7b1ba1
commit 492b7db07b
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
4 changed files with 32 additions and 26 deletions

View File

@ -1433,8 +1433,7 @@ namespace dxvk {
ID3D11Buffer* pBufferForArgs, ID3D11Buffer* pBufferForArgs,
UINT AlignedByteOffsetForArgs) { UINT AlignedByteOffsetForArgs) {
D3D10DeviceLock lock = LockContext(); D3D10DeviceLock lock = LockContext();
SetDrawBuffers(pBufferForArgs, nullptr);
SetDrawBuffer(pBufferForArgs);
// If possible, batch up multiple indirect draw calls of // If possible, batch up multiple indirect draw calls of
// the same type into one single multiDrawIndirect call // the same type into one single multiDrawIndirect call
@ -1465,8 +1464,7 @@ namespace dxvk {
ID3D11Buffer* pBufferForArgs, ID3D11Buffer* pBufferForArgs,
UINT AlignedByteOffsetForArgs) { UINT AlignedByteOffsetForArgs) {
D3D10DeviceLock lock = LockContext(); D3D10DeviceLock lock = LockContext();
SetDrawBuffers(pBufferForArgs, nullptr);
SetDrawBuffer(pBufferForArgs);
// If possible, batch up multiple indirect draw calls of // If possible, batch up multiple indirect draw calls of
// the same type into one single multiDrawIndirect call // the same type into one single multiDrawIndirect call
@ -1512,8 +1510,7 @@ namespace dxvk {
ID3D11Buffer* pBufferForArgs, ID3D11Buffer* pBufferForArgs,
UINT AlignedByteOffsetForArgs) { UINT AlignedByteOffsetForArgs) {
D3D10DeviceLock lock = LockContext(); D3D10DeviceLock lock = LockContext();
SetDrawBuffers(pBufferForArgs, nullptr);
SetDrawBuffer(pBufferForArgs);
EmitCs([cOffset = AlignedByteOffsetForArgs] EmitCs([cOffset = AlignedByteOffsetForArgs]
(DxvkContext* ctx) { (DxvkContext* ctx) {
@ -3194,14 +3191,14 @@ namespace dxvk {
} }
void D3D11DeviceContext::BindDrawBuffer( void D3D11DeviceContext::BindDrawBuffers(
D3D11Buffer* pBuffer) { D3D11Buffer* pBufferForArgs,
D3D11Buffer* pBufferForCount) {
EmitCs([ EmitCs([
cBufferSlice = pBuffer != nullptr cArgBuffer = pBufferForArgs ? pBufferForArgs->GetBufferSlice() : DxvkBufferSlice(),
? pBuffer->GetBufferSlice() cCntBuffer = pBufferForCount ? pBufferForCount->GetBufferSlice() : DxvkBufferSlice()
: DxvkBufferSlice()
] (DxvkContext* ctx) { ] (DxvkContext* ctx) {
ctx->bindDrawBuffers(cBufferSlice, DxvkBufferSlice()); ctx->bindDrawBuffers(cArgBuffer, cCntBuffer);
}); });
} }
@ -3365,13 +3362,18 @@ namespace dxvk {
} }
void D3D11DeviceContext::SetDrawBuffer( void D3D11DeviceContext::SetDrawBuffers(
ID3D11Buffer* pBuffer) { ID3D11Buffer* pBufferForArgs,
auto buffer = static_cast<D3D11Buffer*>(pBuffer); ID3D11Buffer* pBufferForCount) {
auto argBuffer = static_cast<D3D11Buffer*>(pBufferForArgs);
auto cntBuffer = static_cast<D3D11Buffer*>(pBufferForCount);
if (m_state.id.argBuffer != buffer) { if (m_state.id.argBuffer != argBuffer
m_state.id.argBuffer = buffer; || m_state.id.cntBuffer != cntBuffer) {
BindDrawBuffer(buffer); m_state.id.argBuffer = argBuffer;
m_state.id.cntBuffer = cntBuffer;
BindDrawBuffers(argBuffer, cntBuffer);
} }
} }
@ -3577,8 +3579,9 @@ namespace dxvk {
ApplyViewportState(); ApplyViewportState();
ApplyUnusedState(); ApplyUnusedState();
BindDrawBuffer( BindDrawBuffers(
m_state.id.argBuffer.ptr()); m_state.id.argBuffer.ptr(),
m_state.id.cntBuffer.ptr());
BindIndexBuffer( BindIndexBuffer(
m_state.ia.indexBuffer.buffer.ptr(), m_state.ia.indexBuffer.buffer.ptr(),

View File

@ -688,8 +688,9 @@ namespace dxvk {
void BindFramebuffer( void BindFramebuffer(
BOOL Spill); BOOL Spill);
void BindDrawBuffer( void BindDrawBuffers(
D3D11Buffer* pBuffer); D3D11Buffer* pBufferForArgs,
D3D11Buffer* pBufferForCount);
void BindVertexBuffer( void BindVertexBuffer(
UINT Slot, UINT Slot,
@ -731,8 +732,9 @@ namespace dxvk {
void DiscardTexture( void DiscardTexture(
D3D11CommonTexture* pTexture); D3D11CommonTexture* pTexture);
void SetDrawBuffer( void SetDrawBuffers(
ID3D11Buffer* pBuffer); ID3D11Buffer* pBufferForArgs,
ID3D11Buffer* pBufferForCount);
void SetConstantBuffers( void SetConstantBuffers(
DxbcProgramType ShaderStage, DxbcProgramType ShaderStage,

View File

@ -32,7 +32,7 @@ namespace dxvk {
UINT ByteOffsetForArgs, UINT ByteOffsetForArgs,
UINT ByteStrideForArgs) { UINT ByteStrideForArgs) {
D3D10DeviceLock lock = m_ctx->LockContext(); D3D10DeviceLock lock = m_ctx->LockContext();
m_ctx->SetDrawBuffer(pBufferForArgs); m_ctx->SetDrawBuffers(pBufferForArgs, nullptr);
m_ctx->EmitCs([ m_ctx->EmitCs([
cCount = DrawCount, cCount = DrawCount,
@ -50,7 +50,7 @@ namespace dxvk {
UINT ByteOffsetForArgs, UINT ByteOffsetForArgs,
UINT ByteStrideForArgs) { UINT ByteStrideForArgs) {
D3D10DeviceLock lock = m_ctx->LockContext(); D3D10DeviceLock lock = m_ctx->LockContext();
m_ctx->SetDrawBuffer(pBufferForArgs); m_ctx->SetDrawBuffers(pBufferForArgs, nullptr);
m_ctx->EmitCs([ m_ctx->EmitCs([
cCount = DrawCount, cCount = DrawCount,

View File

@ -104,6 +104,7 @@ namespace dxvk {
struct D3D11ContextStateID { struct D3D11ContextStateID {
Com<D3D11Buffer> argBuffer = nullptr; Com<D3D11Buffer> argBuffer = nullptr;
Com<D3D11Buffer> cntBuffer = nullptr;
}; };