From 9bbb0fe1f6171316023c7df075edd5825a169aae Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Sat, 28 Feb 2015 10:57:00 +0100 Subject: [PATCH] gsdx: add atomic for texture upload V2: fix init of atomic flag object --- plugins/GSdx/GSTextureSW.cpp | 6 +++--- plugins/GSdx/GSTextureSW.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/GSdx/GSTextureSW.cpp b/plugins/GSdx/GSTextureSW.cpp index 8f9f712412..99e1a9aa31 100644 --- a/plugins/GSdx/GSTextureSW.cpp +++ b/plugins/GSdx/GSTextureSW.cpp @@ -24,8 +24,8 @@ #include "GSPng.h" GSTextureSW::GSTextureSW(int type, int width, int height) - : m_mapped(0) { + m_mapped.clear(); m_size = GSVector2i(width, height); m_type = type; m_format = 0; @@ -68,7 +68,7 @@ bool GSTextureSW::Map(GSMap& m, const GSVector4i* r) if(m_data != NULL && r2.left >= 0 && r2.right <= m_size.x && r2.top >= 0 && r2.bottom <= m_size.y) { - if(!_interlockedbittestandset(&m_mapped, 0)) + while(m_mapped.test_and_set()) {} { m.bits = (uint8*)m_data + ((m_pitch * r2.top + r2.left) << 2); m.pitch = m_pitch; @@ -82,7 +82,7 @@ bool GSTextureSW::Map(GSMap& m, const GSVector4i* r) void GSTextureSW::Unmap() { - m_mapped = 0; + m_mapped.clear(); } #ifndef _WIN32 diff --git a/plugins/GSdx/GSTextureSW.h b/plugins/GSdx/GSTextureSW.h index b6f8a7f041..8cba020ff5 100644 --- a/plugins/GSdx/GSTextureSW.h +++ b/plugins/GSdx/GSTextureSW.h @@ -29,7 +29,7 @@ class GSTextureSW : public GSTexture int m_pitch; void* m_data; - long m_mapped; + std::atomic_flag m_mapped; public: GSTextureSW(int type, int width, int height);