diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index a6b300fea..090d30948 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -4067,7 +4067,8 @@ namespace dxvk { if (alloced) std::memset(physSlice.mapPtr, 0, physSlice.length); - else if ((managed || (systemmem && !dirty)) && !(Flags & D3DLOCK_DONOTWAIT) && !skipWait) { + else if ((managed || (systemmem && !dirty)) && !(Flags & D3DLOCK_DONOTWAIT) && !skipWait + && m_d3d9Options.allowImplicitDiscard) { if (!WaitForResource(mappedBuffer, D3DLOCK_DONOTWAIT)) { // if the mapped buffer is currently being copied to image // we can just avoid a stall by allocating a new slice and copying the existing contents @@ -4413,7 +4414,8 @@ namespace dxvk { quickRead || (boundsCheck && !pResource->DirtyRange().Overlaps(pResource->LockRange())); if (!skipWait) { - if ((IsPoolManaged(desc.Pool) || desc.Pool == D3DPOOL_SYSTEMMEM) && !(Flags & D3DLOCK_DONOTWAIT) && pResource->GetLockCount() == 0) { + if ((IsPoolManaged(desc.Pool) || desc.Pool == D3DPOOL_SYSTEMMEM) && !(Flags & D3DLOCK_DONOTWAIT) && pResource->GetLockCount() == 0 + && m_d3d9Options.allowImplicitDiscard) { if (!WaitForResource(mappingBuffer, D3DLOCK_DONOTWAIT)) { // if the mapped buffer is currently being copied to the primary buffer // we can just avoid a stall by allocating a new slice and copying the existing contents diff --git a/src/d3d9/d3d9_options.cpp b/src/d3d9/d3d9_options.cpp index ac2de14ee..c024906c5 100644 --- a/src/d3d9/d3d9_options.cpp +++ b/src/d3d9/d3d9_options.cpp @@ -76,6 +76,7 @@ namespace dxvk { this->apitraceMode = config.getOption("d3d9.apitraceMode", false); this->deviceLocalConstantBuffers = config.getOption("d3d9.deviceLocalConstantBuffers", false); + this->allowImplicitDiscard = config.getOption("d3d9.allowImplicitDiscard", true); // If we are not Nvidia, enable general hazards. this->generalHazards = adapter == nullptr || !adapter->matchesDriver(DxvkGpuVendor::Nvidia, VK_DRIVER_ID_NVIDIA_PROPRIETARY_KHR, 0, 0); diff --git a/src/d3d9/d3d9_options.h b/src/d3d9/d3d9_options.h index 8ff661dab..fbfac70f8 100644 --- a/src/d3d9/d3d9_options.h +++ b/src/d3d9/d3d9_options.h @@ -157,6 +157,10 @@ namespace dxvk { /// Use device local memory for constant buffers. bool deviceLocalConstantBuffers; + + /// Allow implicit discard of resources in contested situations. + /// Some naughty apps write to pointers outside of lock boundaries. + bool allowImplicitDiscard; }; } \ No newline at end of file