review comments
This commit is contained in:
parent
93e36f7be3
commit
605271245c
|
@ -684,7 +684,7 @@ void CxbxInitWindow(bool bFullInit)
|
|||
ImGui_ImplWin32_Shutdown();
|
||||
});
|
||||
|
||||
g_ShaderSources.Update();
|
||||
(void) g_ShaderSources.Update();
|
||||
g_ShaderSources.InitShaderHotloading();
|
||||
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <string> // std::string
|
||||
#include <d3dcompiler.h> // 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;
|
||||
|
|
|
@ -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)) {
|
||||
|
|
Loading…
Reference in New Issue