Rename shaderhlsl to shadersources

and updateshaders to update
This commit is contained in:
Anthony 2023-11-10 23:02:28 +13:00
parent a7bc6a307d
commit 93e36f7be3
7 changed files with 23 additions and 23 deletions

View File

@ -684,8 +684,8 @@ void CxbxInitWindow(bool bFullInit)
ImGui_ImplWin32_Shutdown(); ImGui_ImplWin32_Shutdown();
}); });
g_ShaderHlsl.UpdateShaders(); g_ShaderSources.Update();
g_ShaderHlsl.InitShaderHotloading(); g_ShaderSources.InitShaderHotloading();
} }

View File

@ -289,7 +289,7 @@ bool IsTextureSampled(DecodedRegisterCombiner* pShader, int reg)
void BuildShader(DecodedRegisterCombiner* pShader, std::stringstream& hlsl) void BuildShader(DecodedRegisterCombiner* pShader, std::stringstream& hlsl)
{ {
hlsl << g_ShaderHlsl.pixelShaderTemplateHlsl[0]; // Start with the HLSL template header hlsl << g_ShaderSources.pixelShaderTemplateHlsl[0]; // Start with the HLSL template header
hlsl << "\n#define ALPHAKILL {" hlsl << "\n#define ALPHAKILL {"
<< (pShader->AlphaKill[0] ? "true, " : "false, ") << (pShader->AlphaKill[0] ? "true, " : "false, ")
@ -338,7 +338,7 @@ void BuildShader(DecodedRegisterCombiner* pShader, std::stringstream& hlsl)
OutputDefineFlag(hlsl, pShader->FinalCombiner.ClampSum, "PS_FINALCOMBINERSETTING_CLAMP_SUM"); OutputDefineFlag(hlsl, pShader->FinalCombiner.ClampSum, "PS_FINALCOMBINERSETTING_CLAMP_SUM");
hlsl << '\n'; hlsl << '\n';
hlsl << g_ShaderHlsl.pixelShaderTemplateHlsl[1]; hlsl << g_ShaderSources.pixelShaderTemplateHlsl[1];
// Generate all four texture stages // Generate all four texture stages
for (unsigned i = 0; i < PSH_XBOX_MAX_T_REGISTER_COUNT; i++) { for (unsigned i = 0; i < PSH_XBOX_MAX_T_REGISTER_COUNT; i++) {
@ -385,7 +385,7 @@ void BuildShader(DecodedRegisterCombiner* pShader, std::stringstream& hlsl)
FinalCombinerStageHlsl(hlsl, pShader->FinalCombiner, pShader->hasFinalCombiner); FinalCombinerStageHlsl(hlsl, pShader->FinalCombiner, pShader->hasFinalCombiner);
hlsl << g_ShaderHlsl.pixelShaderTemplateHlsl[2]; // Finish with the HLSL template footer hlsl << g_ShaderSources.pixelShaderTemplateHlsl[2]; // Finish with the HLSL template footer
} }
// recompile xbox pixel shader function // recompile xbox pixel shader function

View File

@ -39,7 +39,7 @@
#include <thread> #include <thread>
//#include <sstream> //#include <sstream>
ShaderHlsl g_ShaderHlsl; ShaderSources g_ShaderSources;
std::string DebugPrependLineNumbers(std::string shaderString) { std::string DebugPrependLineNumbers(std::string shaderString) {
std::stringstream shader(shaderString); std::stringstream shader(shaderString);
@ -166,7 +166,7 @@ std::ifstream OpenWithRetry(const std::string& path) {
return fstream; return fstream;
} }
int ShaderHlsl::UpdateShaders() { int ShaderSources::Update() {
int versionOnDisk = shaderVersionOnDisk; int versionOnDisk = shaderVersionOnDisk;
if (shaderVersionLoadedFromDisk != versionOnDisk) { if (shaderVersionLoadedFromDisk != versionOnDisk) {
LoadShadersFromDisk(); LoadShadersFromDisk();
@ -176,7 +176,7 @@ int ShaderHlsl::UpdateShaders() {
return shaderVersionLoadedFromDisk; return shaderVersionLoadedFromDisk;
} }
void ShaderHlsl::LoadShadersFromDisk() { void ShaderSources::LoadShadersFromDisk() {
const auto hlslDir = std::filesystem::path(szFilePath_CxbxReloaded_Exe) const auto hlslDir = std::filesystem::path(szFilePath_CxbxReloaded_Exe)
.parent_path() .parent_path()
.append("hlsl"); .append("hlsl");
@ -262,7 +262,7 @@ void ShaderHlsl::LoadShadersFromDisk() {
} }
} }
void ShaderHlsl::InitShaderHotloading() { void ShaderSources::InitShaderHotloading() {
static std::thread fsWatcherThread; static std::thread fsWatcherThread;
if (fsWatcherThread.joinable()) { if (fsWatcherThread.joinable()) {
@ -303,7 +303,7 @@ void ShaderHlsl::InitShaderHotloading() {
} }
EmuLog(LOG_LEVEL::DEBUG, "Change detected in shader folder"); EmuLog(LOG_LEVEL::DEBUG, "Change detected in shader folder");
g_ShaderHlsl.shaderVersionOnDisk += 1; g_ShaderSources.shaderVersionOnDisk += 1;
} }
else { else {
EmuLog(LOG_LEVEL::ERROR2, "Shader filewatcher failed to get the next notification"); EmuLog(LOG_LEVEL::ERROR2, "Shader filewatcher failed to get the next notification");

View File

@ -11,7 +11,7 @@ extern HRESULT EmuCompileShader
const char* pSourceName = nullptr const char* pSourceName = nullptr
); );
struct ShaderHlsl { struct ShaderSources {
// Pixel Shader // Pixel Shader
std::string pixelShaderTemplateHlsl[3]; std::string pixelShaderTemplateHlsl[3];
@ -29,7 +29,7 @@ struct ShaderHlsl {
// Load shaders from disk (if out-of-date) // Load shaders from disk (if out-of-date)
// and return the current loaded shader version // and return the current loaded shader version
int UpdateShaders(); int Update();
// Start a thread to watch for changes in the shader folder // Start a thread to watch for changes in the shader folder
void InitShaderHotloading(); void InitShaderHotloading();
@ -44,4 +44,4 @@ private:
int shaderVersionLoadedFromDisk = -1; int shaderVersionLoadedFromDisk = -1;
}; };
extern ShaderHlsl g_ShaderHlsl; extern ShaderSources g_ShaderSources;

View File

@ -292,9 +292,9 @@ extern HRESULT EmuCompileVertexShader
// Combine the shader template with the shader program // Combine the shader template with the shader program
auto hlsl_stream = std::stringstream(); auto hlsl_stream = std::stringstream();
hlsl_stream << g_ShaderHlsl.vertexShaderTemplateHlsl[0]; // Start with the HLSL template header hlsl_stream << g_ShaderSources.vertexShaderTemplateHlsl[0]; // Start with the HLSL template header
BuildShader(pIntermediateShader, hlsl_stream); BuildShader(pIntermediateShader, hlsl_stream);
hlsl_stream << g_ShaderHlsl.vertexShaderTemplateHlsl[1]; // Finish with the HLSL template footer hlsl_stream << g_ShaderSources.vertexShaderTemplateHlsl[1]; // Finish with the HLSL template footer
std::string hlsl_str = hlsl_stream.str(); std::string hlsl_str = hlsl_stream.str();
auto notionalSourceName = "CxbxVertexShaderTemplate.hlsl"; auto notionalSourceName = "CxbxVertexShaderTemplate.hlsl";
@ -312,10 +312,10 @@ extern HRESULT EmuCompileVertexShader
extern void EmuCompileFixedFunction(ID3DBlob** ppHostShader) extern void EmuCompileFixedFunction(ID3DBlob** ppHostShader)
{ {
EmuCompileShader(g_ShaderHlsl.fixedFunctionVertexShaderHlsl, g_vs_model, ppHostShader, g_ShaderHlsl.fixedFunctionVertexShaderPath.c_str()); EmuCompileShader(g_ShaderSources.fixedFunctionVertexShaderHlsl, g_vs_model, ppHostShader, g_ShaderSources.fixedFunctionVertexShaderPath.c_str());
}; };
extern void EmuCompileXboxPassthrough(ID3DBlob** ppHostShader) extern void EmuCompileXboxPassthrough(ID3DBlob** ppHostShader)
{ {
EmuCompileShader(g_ShaderHlsl.vertexShaderPassthroughHlsl, g_vs_model, ppHostShader, g_ShaderHlsl.vertexShaderPassthroughPath.c_str()); EmuCompileShader(g_ShaderSources.vertexShaderPassthroughHlsl, g_vs_model, ppHostShader, g_ShaderSources.vertexShaderPassthroughPath.c_str());
} }

View File

@ -39,7 +39,7 @@
#include "core\kernel\support\Emu.h" #include "core\kernel\support\Emu.h"
#include "core\hle\D3D8\Direct3D9\Direct3D9.h" // For g_pD3DDevice, g_pXbox_PixelShader #include "core\hle\D3D8\Direct3D9\Direct3D9.h" // For g_pD3DDevice, g_pXbox_PixelShader
#include "core\hle\D3D8\Direct3D9\Shader.h" // For g_ShaderHlsl #include "core\hle\D3D8\Direct3D9\Shader.h" // For g_ShaderSources
#include "core\hle\D3D8\XbPixelShader.h" #include "core\hle\D3D8\XbPixelShader.h"
#include "core\hle\D3D8\Direct3D9\PixelShader.h" // EmuCompilePixelShader #include "core\hle\D3D8\Direct3D9\PixelShader.h" // EmuCompilePixelShader
#include "core\hle\D3D8\XbD3D8Logging.h" // For D3DErrorString() #include "core\hle\D3D8\XbD3D8Logging.h" // For D3DErrorString()
@ -766,7 +766,7 @@ IDirect3DPixelShader9* GetFixedFunctionShader()
// Support hotloading hlsl // Support hotloading hlsl
static int pixelShaderVersion = -1; static int pixelShaderVersion = -1;
int shaderVersion = g_ShaderHlsl.UpdateShaders(); int shaderVersion = g_ShaderSources.Update();
if (pixelShaderVersion != shaderVersion) { if (pixelShaderVersion != shaderVersion) {
pixelShaderVersion = shaderVersion; pixelShaderVersion = shaderVersion;
g_pD3DDevice->SetPixelShader(nullptr); g_pD3DDevice->SetPixelShader(nullptr);
@ -861,7 +861,7 @@ IDirect3DPixelShader9* GetFixedFunctionShader()
} }
// Build and compile a new shader // Build and compile a new shader
std::string hlslTemplate = g_ShaderHlsl.fixedFunctionPixelShaderHlsl; std::string hlslTemplate = g_ShaderSources.fixedFunctionPixelShaderHlsl;
// In D3D9 it seems we need to know hardcode if we're doing a 2D or 3D lookup // In D3D9 it seems we need to know hardcode if we're doing a 2D or 3D lookup
const std::string sampleTypePattern = "TEXTURE_SAMPLE_TYPE;"; const std::string sampleTypePattern = "TEXTURE_SAMPLE_TYPE;";
@ -1030,7 +1030,7 @@ void DxbxUpdateActivePixelShader() // NOPATCH
// Support hotloading hlsl // Support hotloading hlsl
static int pixelShaderVersion = -1; static int pixelShaderVersion = -1;
int shaderVersion = g_ShaderHlsl.UpdateShaders(); int shaderVersion = g_ShaderSources.Update();
if (pixelShaderVersion != shaderVersion) { if (pixelShaderVersion != shaderVersion) {
pixelShaderVersion = shaderVersion; pixelShaderVersion = shaderVersion;
g_pD3DDevice->SetPixelShader(nullptr); g_pD3DDevice->SetPixelShader(nullptr);

View File

@ -35,7 +35,7 @@
#include "core\hle\D3D8\Direct3D9\Direct3D9.h" // For g_Xbox_VertexShader_Handle #include "core\hle\D3D8\Direct3D9\Direct3D9.h" // For g_Xbox_VertexShader_Handle
#include "core\hle\D3D8\Direct3D9\RenderStates.h" // For XboxRenderStateConverter #include "core\hle\D3D8\Direct3D9\RenderStates.h" // For XboxRenderStateConverter
#include "core\hle\D3D8\Direct3D9\VertexShaderCache.h" // For g_VertexShaderCache #include "core\hle\D3D8\Direct3D9\VertexShaderCache.h" // For g_VertexShaderCache
#include "core\hle\D3D8\Direct3D9\Shader.h" // For g_ShaderHlsl #include "core\hle\D3D8\Direct3D9\Shader.h" // For g_ShaderSources
#include "core\hle\D3D8\XbVertexBuffer.h" // For CxbxImpl_SetVertexData4f #include "core\hle\D3D8\XbVertexBuffer.h" // For CxbxImpl_SetVertexData4f
#include "core\hle\D3D8\XbVertexShader.h" #include "core\hle\D3D8\XbVertexShader.h"
#include "core\hle\D3D8\XbD3D8Logging.h" // For DEBUG_D3DRESULT #include "core\hle\D3D8\XbD3D8Logging.h" // For DEBUG_D3DRESULT
@ -1148,7 +1148,7 @@ void CxbxUpdateHostVertexShader()
static IDirect3DVertexShader* passthroughShader = nullptr; static IDirect3DVertexShader* passthroughShader = nullptr;
static int vertexShaderVersion = -1; static int vertexShaderVersion = -1;
int shaderVersion = g_ShaderHlsl.UpdateShaders(); int shaderVersion = g_ShaderSources.Update();
if (vertexShaderVersion != shaderVersion) { if (vertexShaderVersion != shaderVersion) {
vertexShaderVersion = shaderVersion; vertexShaderVersion = shaderVersion;
g_pD3DDevice->SetVertexShader(nullptr); g_pD3DDevice->SetVertexShader(nullptr);