diff --git a/GPU/Directx9/ShaderManager.cpp b/GPU/Directx9/ShaderManager.cpp index 0084300598..aede525d11 100644 --- a/GPU/Directx9/ShaderManager.cpp +++ b/GPU/Directx9/ShaderManager.cpp @@ -633,6 +633,11 @@ LinkedShader *ShaderManager::ApplyShader(int prim) { const LinkedShaderCacheEntry entry(vs, fs, ls); linkedShaderCache_.push_back(entry); } else { + // If shader changed we need to update all uniforms + if (lastShader_ != ls) { + ls->dirtyUniforms = DIRTY_ALL; + } + ls->use(); } diff --git a/GPU/Directx9/VertexShaderGenerator.cpp b/GPU/Directx9/VertexShaderGenerator.cpp index 1f1e7d7e9a..e33b0bad58 100644 --- a/GPU/Directx9/VertexShaderGenerator.cpp +++ b/GPU/Directx9/VertexShaderGenerator.cpp @@ -149,17 +149,18 @@ void GenerateVertexShader(int prim, char *buffer, bool useHWTransform) { doLight[i] = LIGHT_FULL; } } + + + if (gstate.isModeThrough()) { + WRITE(p, "float4x4 u_proj_through;\n"); + } else { + WRITE(p, "float4x4 u_proj;\n"); + // Add all the uniforms we'll need to transform properly. + } if (enableFog) { WRITE(p, "float2 u_fogcoef;\n"); } - - if (gstate.isModeThrough()) { - WRITE(p, "float4x4 u_proj_through:register(c0);\n"); - } else { - WRITE(p, "float4x4 u_proj:register(c8);\n"); - // Add all the uniforms we'll need to transform properly. - } if (useHWTransform || !hasColor) WRITE(p, "float4 u_matambientalpha;\n"); // matambient + matalpha