1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-15 07:29:17 +01:00

[d3d11] Implicitly flush when queueing an event query

Significantly improves GPU utilization in Quake Champions.
This commit is contained in:
Philip Rebohle 2018-10-17 17:22:52 +02:00
parent 5ecfbd8425
commit 5124fd87d5
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 25 additions and 8 deletions

View File

@ -48,6 +48,20 @@ namespace dxvk {
} }
void STDMETHODCALLTYPE D3D11ImmediateContext::End(
ID3D11Asynchronous* pAsync) {
D3D11DeviceContext::End(pAsync);
if (pAsync) {
D3D11_QUERY_DESC desc;
static_cast<D3D11Query*>(pAsync)->GetDesc(&desc);
if (desc.Query == D3D11_QUERY_EVENT)
FlushImplicit(TRUE);
}
}
HRESULT STDMETHODCALLTYPE D3D11ImmediateContext::GetData( HRESULT STDMETHODCALLTYPE D3D11ImmediateContext::GetData(
ID3D11Asynchronous* pAsync, ID3D11Asynchronous* pAsync,
void* pData, void* pData,
@ -75,7 +89,7 @@ namespace dxvk {
// If we're likely going to spin on the asynchronous object, // If we're likely going to spin on the asynchronous object,
// flush the context so that we're keeping the GPU busy // flush the context so that we're keeping the GPU busy
if (hr == S_FALSE) if (hr == S_FALSE)
FlushImplicit(); FlushImplicit(FALSE);
return hr; return hr;
} }
@ -116,7 +130,7 @@ namespace dxvk {
// As an optimization, flush everything if the // As an optimization, flush everything if the
// number of pending draw calls is high enough. // number of pending draw calls is high enough.
FlushImplicit(); FlushImplicit(FALSE);
// Dispatch command list to the CS thread and // Dispatch command list to the CS thread and
// restore the immediate context's state // restore the immediate context's state
@ -193,7 +207,7 @@ namespace dxvk {
UINT NumViews, UINT NumViews,
ID3D11RenderTargetView* const* ppRenderTargetViews, ID3D11RenderTargetView* const* ppRenderTargetViews,
ID3D11DepthStencilView* pDepthStencilView) { ID3D11DepthStencilView* pDepthStencilView) {
FlushImplicit(); FlushImplicit(FALSE);
D3D11DeviceContext::OMSetRenderTargets( D3D11DeviceContext::OMSetRenderTargets(
NumViews, ppRenderTargetViews, pDepthStencilView); NumViews, ppRenderTargetViews, pDepthStencilView);
@ -208,7 +222,7 @@ namespace dxvk {
UINT NumUAVs, UINT NumUAVs,
ID3D11UnorderedAccessView* const* ppUnorderedAccessViews, ID3D11UnorderedAccessView* const* ppUnorderedAccessViews,
const UINT* pUAVInitialCounts) { const UINT* pUAVInitialCounts) {
FlushImplicit(); FlushImplicit(FALSE);
D3D11DeviceContext::OMSetRenderTargetsAndUnorderedAccessViews( D3D11DeviceContext::OMSetRenderTargetsAndUnorderedAccessViews(
NumRTVs, ppRenderTargetViews, pDepthStencilView, NumRTVs, ppRenderTargetViews, pDepthStencilView,
@ -429,7 +443,7 @@ namespace dxvk {
// We don't have to wait, but misbehaving games may // We don't have to wait, but misbehaving games may
// still try to spin on `Map` until the resource is // still try to spin on `Map` until the resource is
// idle, so we should flush pending commands // idle, so we should flush pending commands
FlushImplicit(); FlushImplicit(FALSE);
return false; return false;
} else { } else {
// Make sure pending commands using the resource get // Make sure pending commands using the resource get
@ -452,10 +466,10 @@ namespace dxvk {
} }
void D3D11ImmediateContext::FlushImplicit() { void D3D11ImmediateContext::FlushImplicit(BOOL StrongHint) {
// Flush only if the GPU is about to go idle, in // Flush only if the GPU is about to go idle, in
// order to keep the number of submissions low. // order to keep the number of submissions low.
if (m_device->pendingSubmissions() <= MaxPendingSubmits) { if (StrongHint || m_device->pendingSubmissions() <= MaxPendingSubmits) {
auto now = std::chrono::high_resolution_clock::now(); auto now = std::chrono::high_resolution_clock::now();
// Prevent flushing too often in short intervals. // Prevent flushing too often in short intervals.

View File

@ -25,6 +25,9 @@ namespace dxvk {
UINT STDMETHODCALLTYPE GetContextFlags(); UINT STDMETHODCALLTYPE GetContextFlags();
void STDMETHODCALLTYPE End(
ID3D11Asynchronous* pAsync);
HRESULT STDMETHODCALLTYPE GetData( HRESULT STDMETHODCALLTYPE GetData(
ID3D11Asynchronous* pAsync, ID3D11Asynchronous* pAsync,
void* pData, void* pData,
@ -101,7 +104,7 @@ namespace dxvk {
void EmitCsChunk(DxvkCsChunkRef&& chunk); void EmitCsChunk(DxvkCsChunkRef&& chunk);
void FlushImplicit(); void FlushImplicit(BOOL StrongHint);
}; };