gsdx: add atomic for texture upload

V2: fix init of atomic flag object
This commit is contained in:
Gregory Hainaut 2015-02-28 10:57:00 +01:00
parent 1db5e0c0bf
commit 9bbb0fe1f6
2 changed files with 4 additions and 4 deletions

View File

@ -24,8 +24,8 @@
#include "GSPng.h" #include "GSPng.h"
GSTextureSW::GSTextureSW(int type, int width, int height) GSTextureSW::GSTextureSW(int type, int width, int height)
: m_mapped(0)
{ {
m_mapped.clear();
m_size = GSVector2i(width, height); m_size = GSVector2i(width, height);
m_type = type; m_type = type;
m_format = 0; 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(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.bits = (uint8*)m_data + ((m_pitch * r2.top + r2.left) << 2);
m.pitch = m_pitch; m.pitch = m_pitch;
@ -82,7 +82,7 @@ bool GSTextureSW::Map(GSMap& m, const GSVector4i* r)
void GSTextureSW::Unmap() void GSTextureSW::Unmap()
{ {
m_mapped = 0; m_mapped.clear();
} }
#ifndef _WIN32 #ifndef _WIN32

View File

@ -29,7 +29,7 @@ class GSTextureSW : public GSTexture
int m_pitch; int m_pitch;
void* m_data; void* m_data;
long m_mapped; std::atomic_flag m_mapped;
public: public:
GSTextureSW(int type, int width, int height); GSTextureSW(int type, int width, int height);