From 26a3eaf95906b047170a6871371fb6201d90d81b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 14 May 2015 12:33:19 -0400 Subject: Software: Convert most volatile variables to atomics --- Source/Core/VideoBackends/Software/SWRenderer.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'Source/Core/VideoBackends/Software/SWRenderer.cpp') diff --git a/Source/Core/VideoBackends/Software/SWRenderer.cpp b/Source/Core/VideoBackends/Software/SWRenderer.cpp index 8ec66d4ffb..9662e21b9d 100644 --- a/Source/Core/VideoBackends/Software/SWRenderer.cpp +++ b/Source/Core/VideoBackends/Software/SWRenderer.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include #include #include "Common/CommonTypes.h" @@ -26,7 +27,7 @@ static GLuint program; static u8 *s_xfbColorTexture[2]; static int s_currentColorTexture = 0; -static volatile bool s_bScreenshot; +static std::atomic s_bScreenshot; static std::mutex s_criticalScreenshot; static std::string s_sScreenshotName; @@ -37,7 +38,7 @@ static RasterFont* s_pfont = nullptr; void SWRenderer::Init() { - s_bScreenshot = false; + s_bScreenshot.store(false); } void SWRenderer::Shutdown() @@ -109,7 +110,7 @@ void SWRenderer::SetScreenshot(const char *_szFilename) { std::lock_guard lk(s_criticalScreenshot); s_sScreenshotName = _szFilename; - s_bScreenshot = true; + s_bScreenshot.store(true); } void SWRenderer::RenderText(const char* pstr, int left, int top, u32 color) @@ -222,13 +223,13 @@ void SWRenderer::DrawTexture(u8 *texture, int width, int height) // FIXME: This should add black bars when the game has set the VI to render less than the full xfb. // Save screenshot - if (s_bScreenshot) + if (s_bScreenshot.load()) { std::lock_guard lk(s_criticalScreenshot); TextureToPng(texture, width * 4, s_sScreenshotName, width, height, false); // Reset settings s_sScreenshotName.clear(); - s_bScreenshot = false; + s_bScreenshot.store(false); } GLsizei glWidth = (GLsizei)GLInterface->GetBackBufferWidth(); -- cgit v1.2.3