1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-18 02:52:10 +01:00

[d3d11] Implement DiscardResource for buffers

We don't suppor this for images, and we don't support DiscardView yet.
Buffers can be invalidated, which may in some cases be beneficial in
order to avoid synchronization on the GPU.
This commit is contained in:
Philip Rebohle 2018-08-03 11:10:40 +02:00
parent 8044ce6c7e
commit 3fee20dfec
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 27 additions and 11 deletions

View File

@ -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<D3D11Buffer*>(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,

View File

@ -703,6 +703,9 @@ namespace dxvk {
UINT CtrSlot,
D3D11UnorderedAccessView* pUav);
void DiscardBuffer(
D3D11Buffer* pBuffer);
void SetConstantBuffers(
DxbcProgramType ShaderStage,
D3D11ConstantBufferBindings& Bindings,

View File

@ -1603,7 +1603,7 @@ namespace dxvk {
auto info = static_cast<D3D11_FEATURE_DATA_D3D11_OPTIONS*>(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;