From 89d36e1d7f125bf66650e4d98c74ac6b7cb30b33 Mon Sep 17 00:00:00 2001 From: Robin Kertels Date: Sat, 15 Aug 2020 02:53:23 +0200 Subject: [PATCH] [d3d9] Handle edge cases around implicit discard --- src/d3d9/d3d9_common_buffer.h | 1 + src/d3d9/d3d9_device.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/d3d9/d3d9_common_buffer.h b/src/d3d9/d3d9_common_buffer.h index 0ea7a0cb..b6ad3de0 100644 --- a/src/d3d9/d3d9_common_buffer.h +++ b/src/d3d9/d3d9_common_buffer.h @@ -153,6 +153,7 @@ namespace dxvk { return --m_lockCount; } + uint32_t GetLockCount() const { return m_lockCount; } void MarkUploaded() { m_needsUpload = false; } void MarkNeedsUpload() { m_needsUpload = true; } diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 16ee6540..85668725 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -4004,7 +4004,7 @@ namespace dxvk { if (alloced) std::memset(physSlice.mapPtr, 0, physSlice.length); - else if ((managed || systemmem) && !skipWait) { + else if ((managed || (systemmem && !dirty)) && !(Flags & D3DLOCK_DONOTWAIT) && !skipWait) { 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 @@ -4350,7 +4350,7 @@ namespace dxvk { quickRead || (boundsCheck && !pResource->DirtyRange().Overlaps(pResource->LockRange())); if (!skipWait) { - if (IsPoolManaged(desc.Pool) || desc.Pool == D3DPOOL_SYSTEMMEM) { + if ((IsPoolManaged(desc.Pool) || desc.Pool == D3DPOOL_SYSTEMMEM) && !(Flags & D3DLOCK_DONOTWAIT) && pResource->GetLockCount() == 0) { 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