From 6ee5e9011b82c37ad3cfe81828f3bc781f5a6942 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sat, 2 Jan 2016 11:16:50 -1000 Subject: [PATCH] D3D11 Buffer update fix --- include/boo/IWindow.hpp | 11 +++++++++++ lib/graphicsdev/D3D11.cpp | 12 ++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include/boo/IWindow.hpp b/include/boo/IWindow.hpp index f2dc6d5..9a1838e 100644 --- a/include/boo/IWindow.hpp +++ b/include/boo/IWindow.hpp @@ -34,6 +34,17 @@ struct SWindowRect { int location[2]; int size[2]; + + SWindowRect() {memset(this, 0, sizeof(SWindowRect));} + + SWindowRect(int x, int y, int w, int h) + { + location[0] = x; + location[1] = y; + size[0] = w; + size[1] = h; + } + bool operator!=(const SWindowRect& other) const { return location[0] != other.location[0] || diff --git a/lib/graphicsdev/D3D11.cpp b/lib/graphicsdev/D3D11.cpp index ef0acea..a3dc13f 100644 --- a/lib/graphicsdev/D3D11.cpp +++ b/lib/graphicsdev/D3D11.cpp @@ -34,7 +34,7 @@ static inline void ThrowIfFailed(HRESULT hr) struct D3D11Data : IGraphicsData { - std::atomic_size_t m_refCount = 4; + size_t m_deleteCountdown = 4; std::vector> m_SPs; std::vector> m_SBinds; std::vector> m_SBufs; @@ -47,10 +47,10 @@ struct D3D11Data : IGraphicsData bool decref() { - size_t res = std::atomic_fetch_sub(&m_refCount, 1); - if (!res) + if (!m_deleteCountdown) Log.report(LogVisor::FatalError, "Can't decrement 0-data"); - if (res == 1) + --m_deleteCountdown; + if (!m_deleteCountdown) { delete this; return true; @@ -1189,9 +1189,9 @@ void D3D11CommandQueue::ProcessDynamicLoads(ID3D11DeviceContext* ctx) for (D3D11Data* d : gfxF->m_committedData) { for (std::unique_ptr& b : d->m_DBufs) - b->update(ctx, m_fillBuf); + b->update(ctx, m_drawBuf); for (std::unique_ptr& t : d->m_DTexs) - t->update(ctx, m_fillBuf); + t->update(ctx, m_drawBuf); } }