From 3f57a3a8cca8c85db183ed73d2a7bf86251189d7 Mon Sep 17 00:00:00 2001 From: Robin Kertels Date: Wed, 17 Mar 2021 22:20:19 +0100 Subject: [PATCH] [d3d9] Use buffer DirtyRange to track managed uploads --- src/d3d9/d3d9_common_buffer.h | 9 ++++----- src/d3d9/d3d9_device.cpp | 7 +------ 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/d3d9/d3d9_common_buffer.h b/src/d3d9/d3d9_common_buffer.h index 7ea1c8a8..94d61d2f 100644 --- a/src/d3d9/d3d9_common_buffer.h +++ b/src/d3d9/d3d9_common_buffer.h @@ -168,9 +168,10 @@ namespace dxvk { } uint32_t GetLockCount() const { return m_lockCount; } - void MarkUploaded() { m_needsUpload = false; } - void MarkNeedsUpload() { m_needsUpload = true; } - bool NeedsUpload() const { return m_needsUpload; } + /** + * \brief Whether or not the staging buffer needs to be copied to the actual buffer + */ + bool NeedsUpload() { return m_desc.Pool != D3DPOOL_DEFAULT && !m_dirtyRange.IsDegenerate(); } void PreLoad(); @@ -206,8 +207,6 @@ namespace dxvk { uint32_t m_lockCount = 0; - bool m_needsUpload = false; - }; } \ No newline at end of file diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 46ee1303..47614cd8 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -4463,13 +4463,9 @@ namespace dxvk { // We need to remove the READONLY flags from the map flags // if there was ever a non-readonly upload. - if (!(Flags & D3DLOCK_READONLY)) { + if (!(Flags & D3DLOCK_READONLY)) oldFlags &= ~D3DLOCK_READONLY; - if (pResource->Desc()->Pool != D3DPOOL_DEFAULT) - pResource->MarkNeedsUpload(); - } - pResource->SetMapFlags(Flags | oldFlags); pResource->IncrementLockCount(); @@ -4496,7 +4492,6 @@ namespace dxvk { pResource->GPUReadingRange().Conjoin(pResource->DirtyRange()); pResource->DirtyRange().Clear(); - pResource->MarkUploaded(); return D3D_OK; }