From 672675ba7814ab22842fc684a080e855ba09ffaf Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Fri, 12 Jan 2018 15:38:07 +0100 Subject: [PATCH] [d3d11] Implemented OMSetRenderTargetsAndUnorderedAccessViews Note that this does *not* properly implement UAV rendering in the backend yet. For that, we need to add memory barriers. --- src/d3d11/d3d11_context.cpp | 26 +++++++++++++++++++++++--- src/d3d11/d3d11_context_state.h | 1 + src/d3d11/d3d11_include.h | 8 ++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index e24e14f6..ebec365c 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -1567,8 +1567,10 @@ namespace dxvk { m_state.om.depthStencilView = static_cast(pDepthStencilView); - // TODO unbind overlapping shader resource views - + // NOTE According to the Microsoft docs, we are supposed to + // unbind overlapping shader resource views. Since this comes + // with a large performance penalty we'll ignore this until an + // application actually relies on this behaviour. Rc framebuffer = nullptr; if (ppRenderTargetViews != nullptr || pDepthStencilView != nullptr) { @@ -1602,7 +1604,25 @@ namespace dxvk { UINT NumUAVs, ID3D11UnorderedAccessView* const* ppUnorderedAccessViews, const UINT* pUAVInitialCounts) { - Logger::err("D3D11DeviceContext::OMSetRenderTargetsAndUnorderedAccessViews: Not implemented"); + if (NumRTVs != D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL) + OMSetRenderTargets(NumRTVs, ppRenderTargetViews, pDepthStencilView); + + if (NumUAVs != D3D11_KEEP_UNORDERED_ACCESS_VIEWS) { + // UAVs are made available to all shader stages in + // the graphics pipeline even though this code may + // suggest that they are limited to the pixel shader. + // This behaviour is only required for FL_11_1. + BindUnorderedAccessViews( + DxbcProgramType::PixelShader, + m_state.ps.unorderedAccessViews, + UAVStartSlot, NumUAVs, + ppUnorderedAccessViews); + + if (pUAVInitialCounts != nullptr) { + InitUnorderedAccessViewCounters(NumUAVs, + ppUnorderedAccessViews, pUAVInitialCounts); + } + } } diff --git a/src/d3d11/d3d11_context_state.h b/src/d3d11/d3d11_context_state.h index 66ad097c..9a8032a8 100644 --- a/src/d3d11/d3d11_context_state.h +++ b/src/d3d11/d3d11_context_state.h @@ -65,6 +65,7 @@ namespace dxvk { D3D11ConstantBufferBindings constantBuffers; D3D11SamplerBindings samplers; D3D11ShaderResourceBindings shaderResources; + D3D11UnorderedAccessBindings unorderedAccessViews; }; diff --git a/src/d3d11/d3d11_include.h b/src/d3d11/d3d11_include.h index 0aefc526..30163c14 100644 --- a/src/d3d11/d3d11_include.h +++ b/src/d3d11/d3d11_include.h @@ -9,6 +9,14 @@ #define D3D11_1_UAV_SLOT_COUNT 64 #endif +#ifndef D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL +#define D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL 0xFFFFFFFF +#endif + +#ifndef D3D11_KEEP_UNORDERED_ACCESS_VIEWS +#define D3D11_KEEP_UNORDERED_ACCESS_VIEWS 0xFFFFFFFF +#endif + // Most of these were copied from d3d11.h // For some strange reason, we cannot use the structures // directly, although others from the same header work.