diff --git a/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp index 2be21a119a..bd8d8253f5 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp @@ -44,8 +44,6 @@ const PixelShaderCache::PSCacheEntry *PixelShaderCache::last_entry; static LinearDiskCache g_ps_disk_cache; static std::set unique_shaders; -static float lastPSconstants[C_COLORMATRIX+16][4]; - #define MAX_SSAA_SHADERS 3 static LPDIRECT3DPIXELSHADER9 s_ColorMatrixProgram[MAX_SSAA_SHADERS]; @@ -75,32 +73,18 @@ LPDIRECT3DPIXELSHADER9 PixelShaderCache::GetClearProgram() void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) { - if (lastPSconstants[const_number][0] != f1 || lastPSconstants[const_number][1] != f2 || - lastPSconstants[const_number][2] != f3 || lastPSconstants[const_number][3] != f4) - { - lastPSconstants[const_number][0] = f1; - lastPSconstants[const_number][1] = f2; - lastPSconstants[const_number][2] = f3; - lastPSconstants[const_number][3] = f4; - D3D::dev->SetPixelShaderConstantF(const_number, lastPSconstants[const_number], 1); - - } + float f[4] = { f1, f2, f3, f4 }; + D3D::dev->SetPixelShaderConstantF(const_number, f, 1); } void SetPSConstant4fv(unsigned int const_number, const float *f) { - if (memcmp(&lastPSconstants[const_number], f, sizeof(float) * 4)) { - memcpy(&lastPSconstants[const_number], f, sizeof(float) * 4); - D3D::dev->SetPixelShaderConstantF(const_number, f, 1); - } + D3D::dev->SetPixelShaderConstantF(const_number, f, 1); } void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f) { - if (memcmp(&lastPSconstants[const_number], f, count * sizeof(float) * 4)) { - memcpy(&lastPSconstants[const_number], f, count * sizeof(float) * 4); - D3D::dev->SetPixelShaderConstantF(const_number, f, count); - } + D3D::dev->SetPixelShaderConstantF(const_number, f, count); } class PixelShaderCacheInserter : public LinearDiskCacheReader { @@ -266,8 +250,6 @@ void PixelShaderCache::Clear() iter->second.Destroy(); PixelShaders.clear(); - for (int i = 0; i < C_PENVCONST_END * 4; i++) - lastPSconstants[i / 4][i % 4] = -100000000.0f; memset(&last_pixel_shader_uid, 0xFF, sizeof(last_pixel_shader_uid)); } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp b/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp index 2f90b11f99..18598be900 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp @@ -37,7 +37,6 @@ VertexShaderCache::VSCache VertexShaderCache::vshaders; const VertexShaderCache::VSCacheEntry *VertexShaderCache::last_entry; -static float GC_ALIGNED16(lastVSconstants[C_VENVCONST_END][4]); #define MAX_SSAA_SHADERS 3 static LPDIRECT3DVERTEXSHADER9 SimpleVertexShader[MAX_SSAA_SHADERS]; @@ -58,59 +57,31 @@ LPDIRECT3DVERTEXSHADER9 VertexShaderCache::GetClearVertexShader() void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) { - if (lastVSconstants[const_number][0] != f1 || - lastVSconstants[const_number][1] != f2 || - lastVSconstants[const_number][2] != f3 || - lastVSconstants[const_number][3] != f4) - { - lastVSconstants[const_number][0] = f1; - lastVSconstants[const_number][1] = f2; - lastVSconstants[const_number][2] = f3; - lastVSconstants[const_number][3] = f4; - D3D::dev->SetVertexShaderConstantF(const_number, lastVSconstants[const_number], 1); - } + const float f[4] = { f1, f2, f3, f4 }; + D3D::dev->SetVertexShaderConstantF(const_number, f, 1); } void SetVSConstant4fv(unsigned int const_number, const float *f) { - if (memcmp(&lastVSconstants[const_number], f, sizeof(float) * 4)) { - memcpy(&lastVSconstants[const_number], f, sizeof(float) * 4); - D3D::dev->SetVertexShaderConstantF(const_number, lastVSconstants[const_number], 1); - } + D3D::dev->SetVertexShaderConstantF(const_number, f, 1); } void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f) { - bool change = false; + float buf[4*C_VENVCONST_END]; for (unsigned int i = 0; i < count; i++) { - if (lastVSconstants[const_number + i][0] != f[0 + i*3] || - lastVSconstants[const_number + i][1] != f[1 + i*3] || - lastVSconstants[const_number + i][2] != f[2 + i*3]) - { - change = true; - break; - } - } - if (change) - { - for (unsigned int i = 0; i < count; i++) - { - lastVSconstants[const_number + i][0] = f[0 + i*3]; - lastVSconstants[const_number + i][1] = f[1 + i*3]; - lastVSconstants[const_number + i][2] = f[2 + i*3]; - lastVSconstants[const_number + i][3] = 0.0f; - } - D3D::dev->SetVertexShaderConstantF(const_number, lastVSconstants[const_number], count); + buf[4*i ] = *f++; + buf[4*i+1] = *f++; + buf[4*i+2] = *f++; + buf[4*i+3] = 0.f; } + D3D::dev->SetVertexShaderConstantF(const_number, buf, count); } void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f) { - if (memcmp(&lastVSconstants[const_number], f, count * sizeof(float) * 4)) { - memcpy(&lastVSconstants[const_number], f, count * sizeof(float) * 4); - D3D::dev->SetVertexShaderConstantF(const_number, lastVSconstants[const_number], count); - } + D3D::dev->SetVertexShaderConstantF(const_number, f, count); } class VertexShaderCacheInserter : public LinearDiskCacheReader { @@ -218,8 +189,6 @@ void VertexShaderCache::Clear() iter->second.Destroy(); vshaders.clear(); - for (int i = 0; i < (C_VENVCONST_END * 4); i++) - lastVSconstants[i / 4][i % 4] = -100000000.0f; memset(&last_vertex_shader_uid, 0xFF, sizeof(last_vertex_shader_uid)); } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp index 8bdab0f9a7..5387436d3a 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp @@ -42,41 +42,23 @@ GLuint PixelShaderCache::CurrentShader; bool PixelShaderCache::ShaderEnabled; static FRAGMENTSHADER* pShaderLast = NULL; -static float lastPSconstants[C_PENVCONST_END][4]; void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) { - if (lastPSconstants[const_number][0] != f1 || lastPSconstants[const_number][1] != f2 || - lastPSconstants[const_number][2] != f3 || lastPSconstants[const_number][3] != f4) - { - lastPSconstants[const_number][0] = f1; - lastPSconstants[const_number][1] = f2; - lastPSconstants[const_number][2] = f3; - lastPSconstants[const_number][3] = f4; - glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number, lastPSconstants[const_number]); - - } + float f[4] = { f1, f2, f3, f4 }; + glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number, f); } void SetPSConstant4fv(unsigned int const_number, const float *f) { - if (memcmp(&lastPSconstants[const_number], f, sizeof(float) * 4)) { - memcpy(&lastPSconstants[const_number], f, sizeof(float) * 4); - glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number, f); - } + glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number, f); } void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f) { - const float *f0 = f; - for (unsigned int i = 0; i < count ;i++,f0+=4) - { - if (memcmp(&lastPSconstants[const_number + i], f0, sizeof(float) * 4)) { - memcpy(&lastPSconstants[const_number + i], f0, sizeof(float) * 4); - glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number + i, lastPSconstants[const_number + i]); - } - } + for (unsigned int i = 0; i < count; i++,f+=4) + glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number + i, f); } void PixelShaderCache::Init() @@ -86,8 +68,6 @@ void PixelShaderCache::Init() CurrentShader = 0; GL_REPORT_ERRORD(); - for (unsigned int i = 0; i < (C_PENVCONST_END) * 4; i++) - lastPSconstants[i/4][i%4] = -100000000.0f; memset(&last_pixel_shader_uid, 0xFF, sizeof(last_pixel_shader_uid)); s_displayCompileAlert = true; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp index 27190a894e..d7cb7fb669 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp @@ -41,58 +41,34 @@ bool VertexShaderCache::ShaderEnabled; static VERTEXSHADER *pShaderLast = NULL; static int s_nMaxVertexInstructions; -static float GC_ALIGNED16(lastVSconstants[C_VENVCONST_END][4]); void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) { - if ( lastVSconstants[const_number][0] != f1 || - lastVSconstants[const_number][1] != f2 || - lastVSconstants[const_number][2] != f3 || - lastVSconstants[const_number][3] != f4) - { - lastVSconstants[const_number][0] = f1; - lastVSconstants[const_number][1] = f2; - lastVSconstants[const_number][2] = f3; - lastVSconstants[const_number][3] = f4; - glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, const_number, lastVSconstants[const_number]); - } + float f[4] = { f1, f2, f3, f4 }; + glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, const_number, f); } void SetVSConstant4fv(unsigned int const_number, const float *f) { - if (memcmp(&lastVSconstants[const_number], f, sizeof(float) * 4)) { - memcpy(&lastVSconstants[const_number], f, sizeof(float) * 4); - glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, const_number, lastVSconstants[const_number]); - } + glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, const_number, f); } void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f) { - const float *f0 = f; - for (unsigned int i = 0; i < count; i++,f0+=4) - { - if (memcmp(&lastVSconstants[const_number + i], f0, sizeof(float) * 4)) { - memcpy(&lastVSconstants[const_number + i], f0, sizeof(float) * 4); - glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, const_number + i, lastVSconstants[const_number + i]); - } - } + for (unsigned int i = 0; i < count; i++,f+=4) + glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, const_number + i, f); } void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f) { for (unsigned int i = 0; i < count; i++) { - if (lastVSconstants[const_number + i][0] != f[0 + i*3] || - lastVSconstants[const_number + i][1] != f[1 + i*3] || - lastVSconstants[const_number + i][2] != f[2 + i*3] || - lastVSconstants[const_number + i][3] != 0.0f) - { - lastVSconstants[const_number + i][0] = f[0 + i*3]; - lastVSconstants[const_number + i][1] = f[1 + i*3]; - lastVSconstants[const_number + i][2] = f[2 + i*3]; - lastVSconstants[const_number + i][3] = 0.0f; - glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, const_number + i, lastVSconstants[const_number + i]); - } + float buf[4]; + buf[0] = *f++; + buf[1] = *f++; + buf[2] = *f++; + buf[3] = 0.f; + glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, const_number + i, buf); } } @@ -102,8 +78,6 @@ void VertexShaderCache::Init() glEnable(GL_VERTEX_PROGRAM_ARB); ShaderEnabled = true; CurrentShader = 0; - for (int i = 0; i < (C_VENVCONST_END * 4); i++) - lastVSconstants[i / 4][i % 4] = -100000000.0f; memset(&last_vertex_shader_uid, 0xFF, sizeof(last_vertex_shader_uid)); s_displayCompileAlert = true;