From be5dc234c1a9072d3147d7d8e49ecb277d7703c9 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sat, 2 Nov 2019 13:10:59 +0100 Subject: [PATCH] [d3d11] Move common Begin/End implementation to immediate context --- src/d3d11/d3d11_context.cpp | 33 ------------------------------- src/d3d11/d3d11_context.h | 4 ---- src/d3d11/d3d11_context_imm.cpp | 35 +++++++++++++++++++++++++++++---- src/d3d11/d3d11_context_imm.h | 14 ++++++++----- 4 files changed, 40 insertions(+), 46 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index d9d81b945..53eb7fd57 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -243,39 +243,6 @@ namespace dxvk { } - void STDMETHODCALLTYPE D3D11DeviceContext::Begin(ID3D11Asynchronous *pAsync) { - D3D10DeviceLock lock = LockContext(); - - if (unlikely(!pAsync)) - return; - - Com query(static_cast(pAsync)); - - if (unlikely(!query->IsScoped())) - return; - - EmitCs([cQuery = std::move(query)] - (DxvkContext* ctx) { - cQuery->Begin(ctx); - }); - } - - - void STDMETHODCALLTYPE D3D11DeviceContext::End(ID3D11Asynchronous *pAsync) { - D3D10DeviceLock lock = LockContext(); - - if (unlikely(!pAsync)) - return; - - Com query(static_cast(pAsync)); - - EmitCs([cQuery = std::move(query)] - (DxvkContext* ctx) { - cQuery->End(ctx); - }); - } - - void STDMETHODCALLTYPE D3D11DeviceContext::SetPredication( ID3D11Predicate* pPredicate, BOOL PredicateValue) { diff --git a/src/d3d11/d3d11_context.h b/src/d3d11/d3d11_context.h index d4620c749..f8e95d8ab 100644 --- a/src/d3d11/d3d11_context.h +++ b/src/d3d11/d3d11_context.h @@ -44,10 +44,6 @@ namespace dxvk { void STDMETHODCALLTYPE ClearState(); - void STDMETHODCALLTYPE Begin(ID3D11Asynchronous *pAsync); - - void STDMETHODCALLTYPE End(ID3D11Asynchronous *pAsync); - void STDMETHODCALLTYPE SetPredication( ID3D11Predicate* pPredicate, BOOL PredicateValue); diff --git a/src/d3d11/d3d11_context_imm.cpp b/src/d3d11/d3d11_context_imm.cpp index 58fce7fd8..d55f97c6c 100644 --- a/src/d3d11/d3d11_context_imm.cpp +++ b/src/d3d11/d3d11_context_imm.cpp @@ -102,16 +102,43 @@ namespace dxvk { } - void STDMETHODCALLTYPE D3D11ImmediateContext::End(ID3D11Asynchronous* pAsync) { - D3D11DeviceContext::End(pAsync); + void STDMETHODCALLTYPE D3D11ImmediateContext::Begin(ID3D11Asynchronous* pAsync) { + D3D10DeviceLock lock = LockContext(); - auto query = static_cast(pAsync); - if (unlikely(query && query->IsEvent())) { + if (unlikely(!pAsync)) + return; + + Com query(static_cast(pAsync)); + + if (unlikely(!query->IsScoped())) + return; + + EmitCs([cQuery = std::move(query)] + (DxvkContext* ctx) { + cQuery->Begin(ctx); + }); + } + + + void STDMETHODCALLTYPE D3D11ImmediateContext::End(ID3D11Asynchronous* pAsync) { + D3D10DeviceLock lock = LockContext(); + + if (unlikely(!pAsync)) + return; + + Com query(static_cast(pAsync)); + + if (unlikely(query->IsEvent())) { query->NotifyEnd(); query->IsStalling() ? Flush() : FlushImplicit(TRUE); } + + EmitCs([cQuery = std::move(query)] + (DxvkContext* ctx) { + cQuery->End(ctx); + }); } diff --git a/src/d3d11/d3d11_context_imm.h b/src/d3d11/d3d11_context_imm.h index 8c98d79ba..6310d9f2d 100644 --- a/src/d3d11/d3d11_context_imm.h +++ b/src/d3d11/d3d11_context_imm.h @@ -27,12 +27,16 @@ namespace dxvk { UINT STDMETHODCALLTYPE GetContextFlags(); HRESULT STDMETHODCALLTYPE GetData( - ID3D11Asynchronous* pAsync, - void* pData, - UINT DataSize, - UINT GetDataFlags); + ID3D11Asynchronous* pAsync, + void* pData, + UINT DataSize, + UINT GetDataFlags); - void STDMETHODCALLTYPE End(ID3D11Asynchronous *pAsync); + void STDMETHODCALLTYPE Begin( + ID3D11Asynchronous* pAsync); + + void STDMETHODCALLTYPE End( + ID3D11Asynchronous* pAsync); void STDMETHODCALLTYPE Flush();