diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 8dc5fcc0..6c70ef4e 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -61,20 +61,24 @@ namespace dxvk { return E_NOINTERFACE; } - void STDMETHODCALLTYPE D3D11DeviceContext::DiscardResource(ID3D11Resource * pResource) { - static bool s_errorShown = false; - - if (!std::exchange(s_errorShown, true)) - Logger::err("D3D11DeviceContext::DiscardResource: Not implemented"); + + void STDMETHODCALLTYPE D3D11DeviceContext::DiscardResource(ID3D11Resource* pResource) { + D3D11_RESOURCE_DIMENSION resType = D3D11_RESOURCE_DIMENSION_UNKNOWN; + pResource->GetType(&resType); + + // We don't support the Discard API for images + if (resType == D3D11_RESOURCE_DIMENSION_BUFFER) + DiscardBuffer(reinterpret_cast(pResource)); } - void STDMETHODCALLTYPE D3D11DeviceContext::DiscardView(ID3D11View * pResourceView) { - static bool s_errorShown = false; - - if (!std::exchange(s_errorShown, true)) - Logger::err("D3D11DeviceContext::DiscardView: Not implemented"); + + void STDMETHODCALLTYPE D3D11DeviceContext::DiscardView(ID3D11View* pResourceView) { + // Ignore. We don't do Discard for images or image + // subresources, and for buffers we could only really + // do this if the view covers the entire buffer. } + void STDMETHODCALLTYPE D3D11DeviceContext::DiscardView1( ID3D11View* pResourceView, const D3D11_RECT* pRects, @@ -2711,6 +2715,15 @@ namespace dxvk { } + void D3D11DeviceContext::DiscardBuffer( + D3D11Buffer* pBuffer) { + EmitCs([cBuffer = pBuffer->GetBuffer()] (DxvkContext* ctx) { + ctx->invalidateBuffer(cBuffer, + cBuffer->allocPhysicalSlice()); + }); + } + + void D3D11DeviceContext::SetConstantBuffers( DxbcProgramType ShaderStage, D3D11ConstantBufferBindings& Bindings, diff --git a/src/d3d11/d3d11_context.h b/src/d3d11/d3d11_context.h index 2a920a84..844a1d7c 100644 --- a/src/d3d11/d3d11_context.h +++ b/src/d3d11/d3d11_context.h @@ -703,6 +703,9 @@ namespace dxvk { UINT CtrSlot, D3D11UnorderedAccessView* pUav); + void DiscardBuffer( + D3D11Buffer* pBuffer); + void SetConstantBuffers( DxbcProgramType ShaderStage, D3D11ConstantBufferBindings& Bindings, diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index 6541fa3d..91f0652c 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -1603,7 +1603,7 @@ namespace dxvk { auto info = static_cast(pFeatureSupportData); info->OutputMergerLogicOp = features.core.features.logicOp; info->UAVOnlyRenderingForcedSampleCount = FALSE; - info->DiscardAPIsSeenByDriver = FALSE; + info->DiscardAPIsSeenByDriver = TRUE; info->FlagsForUpdateAndCopySeenByDriver = FALSE; info->ClearView = FALSE; info->CopyWithOverlap = FALSE;