From f97660e210111e19d774d8201a6c6e4efb60b94a Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Fri, 19 Aug 2022 19:48:26 +0200 Subject: [PATCH] [d3d11] Implement TiledResourceBarrier --- src/d3d11/d3d11_context.cpp | 56 +++++++++++++++++++++++++++++++++++++ src/d3d11/d3d11_context.h | 3 ++ 2 files changed, 59 insertions(+) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 36d79a899..414a9117a 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -2669,7 +2669,19 @@ namespace dxvk { void STDMETHODCALLTYPE D3D11CommonContext::TiledResourceBarrier( ID3D11DeviceChild* pTiledResourceOrViewAccessBeforeBarrier, ID3D11DeviceChild* pTiledResourceOrViewAccessAfterBarrier) { + DxvkGlobalPipelineBarrier srcBarrier = GetTiledResourceDependency(pTiledResourceOrViewAccessBeforeBarrier); + DxvkGlobalPipelineBarrier dstBarrier = GetTiledResourceDependency(pTiledResourceOrViewAccessAfterBarrier); + if (srcBarrier.stages && dstBarrier.stages) { + EmitCs([ + cSrcBarrier = srcBarrier, + cDstBarrier = dstBarrier + ] (DxvkContext* ctx) { + ctx->emitGraphicsBarrier( + cSrcBarrier.stages, cSrcBarrier.access, + cDstBarrier.stages, cDstBarrier.access); + }); + } } @@ -3885,6 +3897,50 @@ namespace dxvk { } + template + DxvkGlobalPipelineBarrier D3D11CommonContext::GetTiledResourceDependency( + ID3D11DeviceChild* pObject) { + if (!pObject) { + DxvkGlobalPipelineBarrier result; + result.stages = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT; + result.access = VK_ACCESS_MEMORY_WRITE_BIT | VK_ACCESS_MEMORY_READ_BIT; + return result; + } else { + Com resource; + + if (FAILED(pObject->QueryInterface(IID_PPV_ARGS(&resource)))) { + Com view; + + if (FAILED(pObject->QueryInterface(IID_PPV_ARGS(&view)))) + return DxvkGlobalPipelineBarrier(); + + view->GetResource(&resource); + } + + D3D11CommonTexture* texture = GetCommonTexture(resource.ptr()); + + if (texture) { + Rc image = texture->GetImage(); + + DxvkGlobalPipelineBarrier result; + result.stages = image->info().stages; + result.access = image->info().access; + return result; + } else { + Rc buffer = static_cast(resource.ptr())->GetBuffer(); + + if (buffer == nullptr) + return DxvkGlobalPipelineBarrier(); + + DxvkGlobalPipelineBarrier result; + result.stages = buffer->info().stages; + result.access = buffer->info().access; + return result; + } + } + } + + template D3D11MaxUsedBindings D3D11CommonContext::GetMaxUsedBindings() { D3D11MaxUsedBindings result; diff --git a/src/d3d11/d3d11_context.h b/src/d3d11/d3d11_context.h index 571871e0c..4df399139 100644 --- a/src/d3d11/d3d11_context.h +++ b/src/d3d11/d3d11_context.h @@ -912,6 +912,9 @@ namespace dxvk { UINT NumSamplers, ID3D11SamplerState** ppSamplers); + DxvkGlobalPipelineBarrier GetTiledResourceDependency( + ID3D11DeviceChild* pObject); + D3D11MaxUsedBindings GetMaxUsedBindings(); void ResetCommandListState();