diff options
| author | NeoBrainX <NeoBrainX@gmail.com> | 2013-03-29 20:33:28 +0100 |
|---|---|---|
| committer | NeoBrainX <NeoBrainX@gmail.com> | 2013-03-29 20:35:31 +0100 |
| commit | 3c02f227db1e02f233f3aac8dc42476bd0b17f7a (patch) | |
| tree | 27a762745f9aae2902f5cb8bd0a290b1fd7e8959 /Source/Core/VideoCommon | |
| parent | b2517c0308e992c7e3c13e0fe17140e422ae770d (diff) | |
PixelShaderManager: Disable constant cache (won't work in the non-UBO path of the opengl backend).
ShaderGen: Replace typeid usage with more general code.
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/Src/LightingShaderGen.h | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/PixelShaderGen.cpp | 15 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/PixelShaderManager.cpp | 24 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/ShaderGenCommon.h | 5 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/VertexShaderGen.cpp | 12 |
5 files changed, 27 insertions, 31 deletions
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<class T,class UidType> 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 <cmath> #include <assert.h> #include <locale.h> -#include <typeinfo> #include "LightingShaderGen.h" #include "PixelShaderGen.h" @@ -271,13 +270,12 @@ template<class T> 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<<i) && constant_profile.ConstantIsUsed(C_TEXDIMS+i)) + if ((s_nTexDimsChanged & (1<<i)) && constant_profile.ConstantIsUsed(C_TEXDIMS+i)) { ++necessary_updates; SetPSTextureDims(i); diff --git a/Source/Core/VideoCommon/Src/ShaderGenCommon.h b/Source/Core/VideoCommon/Src/ShaderGenCommon.h index d41a9c6c46..a2616e0a6c 100644 --- a/Source/Core/VideoCommon/Src/ShaderGenCommon.h +++ b/Source/Core/VideoCommon/Src/ShaderGenCommon.h @@ -33,7 +33,7 @@ public: const char* GetBuffer() { return NULL; } void SetBuffer(char* buffer) { } inline void SetConstantsUsed(unsigned int first_index, unsigned int last_index) {} - uid_data& GetUidData() { return *(uid_data*)NULL; } + uid_data& GetUidData() { return *(uid_data*)NULL; } // TODO: can be moved out, just make this GetUidData<T> instead }; template<class uid_data> @@ -122,7 +122,8 @@ public: inline bool ConstantIsUsed(unsigned int index) { - return constant_usage[index]; + return true; +// return constant_usage[index]; } private: std::vector<bool> constant_usage; // TODO: Is vector<bool> 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 <math.h> #include <locale.h> -#include <typeinfo> #include "NativeVertexFormat.h" @@ -85,14 +84,11 @@ template<class T> 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 } |
