diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index bcf12b67b..a939b688a 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -4147,12 +4147,7 @@ namespace dxvk { ] (DxvkContext* ctx) { ctx->invalidateBuffer(cImageBuffer, cBufferSlice); }); - } - else if ((managed && !m_d3d9Options.evictManagedOnUnlock) || scratch || systemmem) { - // Managed and scratch resources - // are meant to be able to provide readback without waiting. - // We always keep a copy of them in system memory for this reason. - // No need to wait as its not in use. + } else { physSlice = pResource->GetMappedSlice(Subresource); // We do not need to wait for the resource in the event the @@ -4160,24 +4155,13 @@ namespace dxvk { // or is reading. Remember! This will only trigger for MANAGED resources // that cannot get affected by GPU, therefore readonly is A-OK for NOT waiting. const bool usesStagingBuffer = pResource->DoesStagingBufferUploads(Subresource); - const bool skipWait = (scratch || managed || (systemmem && !needsReadback)) + const bool skipWait = (scratch || managed || systemmem) && !needsReadback && (usesStagingBuffer || readOnly); - if (alloced) { + if (alloced && !needsReadback) { std::memset(physSlice.mapPtr, 0, physSlice.length); } else if (!skipWait) { - if (!(Flags & D3DLOCK_DONOTWAIT) && !WaitForResource(mappedBuffer, pResource->GetMappingBufferSequenceNumber(Subresource), D3DLOCK_DONOTWAIT)) - pResource->EnableStagingBufferUploads(Subresource); - - if (!WaitForResource(mappedBuffer, pResource->GetMappingBufferSequenceNumber(Subresource), Flags)) - return D3DERR_WASSTILLDRAWING; - } - } - else { - physSlice = pResource->GetMappedSlice(Subresource); - - if (!alloced || needsReadback) { if (unlikely(needsReadback)) { Rc resourceImage = pResource->GetImage(); @@ -4247,16 +4231,12 @@ namespace dxvk { cPackedFormat); } }); + } else if (!(Flags & D3DLOCK_DONOTWAIT) && !WaitForResource(mappedBuffer, pResource->GetMappingBufferSequenceNumber(Subresource), D3DLOCK_DONOTWAIT)) { + pResource->EnableStagingBufferUploads(Subresource); } - if (!WaitForResource(mappedBuffer, DxvkCsThread::SynchronizeAll, Flags)) + if (!WaitForResource(mappedBuffer, pResource->GetMappingBufferSequenceNumber(Subresource), Flags)) return D3DERR_WASSTILLDRAWING; - } else { - // If we are a new alloc, and we weren't written by the GPU - // that means that we are a newly initialized - // texture, and hence can just memset -> 0 and - // avoid a wait here. - std::memset(physSlice.mapPtr, 0, physSlice.length); } }