diff --git a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp index cf904e2db..34a55e8b6 100644 --- a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp +++ b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp @@ -684,7 +684,7 @@ void CxbxInitWindow(bool bFullInit) ImGui_ImplWin32_Shutdown(); }); - g_ShaderSources.Update(); + (void) g_ShaderSources.Update(); g_ShaderSources.InitShaderHotloading(); } diff --git a/src/core/hle/D3D8/Direct3D9/Shader.cpp b/src/core/hle/D3D8/Direct3D9/Shader.cpp index 305cc34c4..63a7228e7 100644 --- a/src/core/hle/D3D8/Direct3D9/Shader.cpp +++ b/src/core/hle/D3D8/Direct3D9/Shader.cpp @@ -263,7 +263,7 @@ void ShaderSources::LoadShadersFromDisk() { } void ShaderSources::InitShaderHotloading() { - static std::thread fsWatcherThread; + static std::jthread fsWatcherThread; if (fsWatcherThread.joinable()) { EmuLog(LOG_LEVEL::ERROR2, "Ignoring request to start shader file watcher - it has already been started."); @@ -272,13 +272,11 @@ void ShaderSources::InitShaderHotloading() { EmuLog(LOG_LEVEL::DEBUG, "Starting shader file watcher..."); - fsWatcherThread = std::thread([]{ + fsWatcherThread = std::jthread([]{ // Determine the filename and directory for the fixed function shader char cxbxExePath[MAX_PATH]; GetModuleFileName(GetModuleHandle(nullptr), cxbxExePath, MAX_PATH); - auto hlslDir = std::filesystem::path(cxbxExePath) - .parent_path() - .append("hlsl/"); + auto hlslDir = std::filesystem::path(cxbxExePath).parent_path().append("hlsl/"); HANDLE changeHandle = FindFirstChangeNotification(hlslDir.string().c_str(), false, FILE_NOTIFY_CHANGE_LAST_WRITE); @@ -303,7 +301,8 @@ void ShaderSources::InitShaderHotloading() { } EmuLog(LOG_LEVEL::DEBUG, "Change detected in shader folder"); - g_ShaderSources.shaderVersionOnDisk += 1; + + g_ShaderSources.shaderVersionOnDisk++; } else { EmuLog(LOG_LEVEL::ERROR2, "Shader filewatcher failed to get the next notification"); diff --git a/src/core/hle/D3D8/Direct3D9/Shader.h b/src/core/hle/D3D8/Direct3D9/Shader.h index ff13c2e57..3f9c21db1 100644 --- a/src/core/hle/D3D8/Direct3D9/Shader.h +++ b/src/core/hle/D3D8/Direct3D9/Shader.h @@ -1,5 +1,6 @@ #pragma once +#include #include // std::string #include // ID3DBlob (via d3d9.h > d3d11shader.h > d3dcommon.h) @@ -38,7 +39,7 @@ private: void LoadShadersFromDisk(); // counts upwards on every change detected to the shader source files at runtime - volatile int shaderVersionOnDisk = 0; + std::atomic_int shaderVersionOnDisk = 0; // current loaded shader version // Initialized to < shaderVersionOnDisk int shaderVersionLoadedFromDisk = -1; diff --git a/src/core/hle/D3D8/Direct3D9/VertexShader.cpp b/src/core/hle/D3D8/Direct3D9/VertexShader.cpp index e9e8aba08..c030f9e5a 100644 --- a/src/core/hle/D3D8/Direct3D9/VertexShader.cpp +++ b/src/core/hle/D3D8/Direct3D9/VertexShader.cpp @@ -297,7 +297,7 @@ extern HRESULT EmuCompileVertexShader hlsl_stream << g_ShaderSources.vertexShaderTemplateHlsl[1]; // Finish with the HLSL template footer std::string hlsl_str = hlsl_stream.str(); - auto notionalSourceName = "CxbxVertexShaderTemplate.hlsl"; + const char* notionalSourceName = "CxbxVertexShaderTemplate.hlsl"; HRESULT hRet = EmuCompileShader(hlsl_str, g_vs_model, ppHostShader, notionalSourceName); if (FAILED(hRet) && (g_vs_model != vs_model_3_0)) {