diff --git a/Source/Core/VideoCommon/Src/LightingShaderGen.h b/Source/Core/VideoCommon/Src/LightingShaderGen.h index 5945bc09ca..a58809942a 100644 --- a/Source/Core/VideoCommon/Src/LightingShaderGen.h +++ b/Source/Core/VideoCommon/Src/LightingShaderGen.h @@ -28,7 +28,7 @@ template void GenerateLightShader(T& object, int index, int litchan_index, const char* lightsName, int coloralpha) { -#define SetUidField(name, value) if (typeid(T) == typeid(UidType)) { object.GetUidData().name = value; }; +#define SetUidField(name, value) if (&object.GetUidData() != NULL) { object.GetUidData().name = value; }; const LitChannel& chan = (litchan_index > 1) ? xfregs.alpha[litchan_index-2] : xfregs.color[litchan_index]; const char* swizzle = "xyzw"; if (coloralpha == 1 ) swizzle = "xyz"; diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index 6ee5a72994..49b77274a8 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include "LightingShaderGen.h" #include "PixelShaderGen.h" @@ -271,13 +270,12 @@ template void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components) { // TODO: Can be optimized if using alpha pass -#define SetUidField(name, value) if (typeid(T) == typeid(PixelShaderUid)) {out.GetUidData().name = value; }; -#define OR_UidField(name, value) if (typeid(T) == typeid(PixelShaderUid)) {out.GetUidData().name |= value; }; - if (typeid(T) == typeid(PixelShaderCode)) - { +#define SetUidField(name, value) if (&out.GetUidData() != NULL) {out.GetUidData().name = value; }; +#define OR_UidField(name, value) if (&out.GetUidData() != NULL) {out.GetUidData().name |= value; }; + out.SetBuffer(text); + if (out.GetBuffer() != NULL) setlocale(LC_NUMERIC, "C"); // Reset locale for compilation - out.SetBuffer(text); - } + /// text[sizeof(text) - 1] = 0x7C; // canary unsigned int numStages = bpmem.genMode.numtevstages + 1; @@ -669,7 +667,8 @@ void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u /// if (text[sizeof(text) - 1] != 0x7C) /// PanicAlert("PixelShader generator - buffer too small, canary has been eaten!"); - setlocale(LC_NUMERIC, ""); // restore locale + if (out.GetBuffer() != NULL) + setlocale(LC_NUMERIC, ""); // restore locale } diff --git a/Source/Core/VideoCommon/Src/PixelShaderManager.cpp b/Source/Core/VideoCommon/Src/PixelShaderManager.cpp index 273d82ea7c..1aceafa17d 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderManager.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderManager.cpp @@ -46,9 +46,9 @@ static float s_constant_cache[C_PENVCONST_END*4]; inline void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) { - if (s_constant_cache[const_number*4] == f1 && s_constant_cache[const_number*4+1] == f2 && - s_constant_cache[const_number*4+2] == f3 && s_constant_cache[const_number*4+3] == f4) - return; +// if (s_constant_cache[const_number*4] == f1 && s_constant_cache[const_number*4+1] == f2 && +// s_constant_cache[const_number*4+2] == f3 && s_constant_cache[const_number*4+3] == f4) +// return; g_renderer->SetPSConstant4f(const_number, f1, f2, f3, f4); s_constant_cache[const_number*4] = f1; @@ -59,9 +59,9 @@ inline void SetPSConstant4f(unsigned int const_number, float f1, float f2, float inline void SetPSConstant4fv(unsigned int const_number, const float *f) { - if (s_constant_cache[const_number*4] == f[0] && s_constant_cache[const_number*4+1] == f[1] && - s_constant_cache[const_number*4+2] == f[2] && s_constant_cache[const_number*4+3] == f[3]) - return; +// if (s_constant_cache[const_number*4] == f[0] && s_constant_cache[const_number*4+1] == f[1] && +// s_constant_cache[const_number*4+2] == f[2] && s_constant_cache[const_number*4+3] == f[3]) +// return; g_renderer->SetPSConstant4fv(const_number, f); s_constant_cache[const_number*4] = f[0]; @@ -72,11 +72,11 @@ inline void SetPSConstant4fv(unsigned int const_number, const float *f) inline void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f) { - for (unsigned int i = 0; i < 4*count; ++i) - if (s_constant_cache[const_number*4+i] != f[i]) - break; - else if (i == 4*count-1) - return; +// for (unsigned int i = 0; i < 4*count; ++i) +// if (s_constant_cache[const_number*4+i] != f[i]) +// break; +// else if (i == 4*count-1) +// return; g_renderer->SetMultiPSConstant4fv(const_number, count, f); for (unsigned int i = 0; i < 4*count; ++i) @@ -149,7 +149,7 @@ void PixelShaderManager::SetConstants(u32 components) { for (int i = 0; i < 8; ++i) { - if (s_nTexDimsChanged & (1< instead }; template @@ -122,7 +122,8 @@ public: inline bool ConstantIsUsed(unsigned int index) { - return constant_usage[index]; + return true; +// return constant_usage[index]; } private: std::vector constant_usage; // TODO: Is vector appropriate here? diff --git a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp index 88fe24f627..869b84a4ed 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp @@ -17,7 +17,6 @@ #include #include -#include #include "NativeVertexFormat.h" @@ -85,14 +84,11 @@ template void GenerateVertexShader(T& out, u32 components, API_TYPE api_type) { #undef SetUidField -#define SetUidField(name, value) if (typeid(T) == typeid(VertexShaderUid)) {out.GetUidData().name = value; }; +#define SetUidField(name, value) if (&out.GetUidData() != NULL) {out.GetUidData().name = value; }; - if (typeid(T) == typeid(VertexShaderCode)) - { - out.SetBuffer(text); + out.SetBuffer(text); + if (out.GetBuffer() != NULL) setlocale(LC_NUMERIC, "C"); // Reset locale for compilation - } - // text[sizeof(text) - 1] = 0x7C; // canary @@ -523,7 +519,7 @@ void GenerateVertexShader(T& out, u32 components, API_TYPE api_type) /// if (text[sizeof(text) - 1] != 0x7C) /// PanicAlert("VertexShader generator - buffer too small, canary has been eaten!"); - if (typeid(T) == typeid(VertexShaderCode)) + if (out.GetBuffer() != NULL) setlocale(LC_NUMERIC, ""); // restore locale } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp index 79bcc1abbd..188145ebcf 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp @@ -201,9 +201,9 @@ SHADER* ProgramShaderCache::SetShader ( DSTALPHA_MODE dstAlphaMode, u32 componen return &last_entry->shader; } } - + last_uid = uid; - + // Check if shader is already in cache PCache::iterator iter = pshaders.find(uid); if (iter != pshaders.end()) @@ -215,17 +215,17 @@ SHADER* ProgramShaderCache::SetShader ( DSTALPHA_MODE dstAlphaMode, u32 componen last_entry->shader.Bind(); return &last_entry->shader; } - + // Make an entry in the table PCacheEntry& newentry = pshaders[uid]; last_entry = &newentry; newentry.in_cache = 0; - + VertexShaderCode vcode; PixelShaderCode pcode; GenerateVertexShaderCode(vcode, components, API_OPENGL); GeneratePixelShaderCode(pcode, dstAlphaMode, API_OPENGL, components); - + if (g_ActiveConfig.bEnableShaderDebugging) { newentry.shader.strvprog = vcode.GetBuffer(); @@ -260,7 +260,7 @@ bool ProgramShaderCache::CompileShader ( SHADER& shader, const char* vcode, cons { GLuint vsid = CompileSingleShader(GL_VERTEX_SHADER, vcode); GLuint psid = CompileSingleShader(GL_FRAGMENT_SHADER, pcode); - + if(!vsid || !psid) { glDeleteShader(vsid);