From 0e4fb11a2da515b2c9d2ce2435c9170e423ce720 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Mon, 30 Jan 2017 16:01:00 +0100 Subject: [PATCH] If we can predict that the texcoord.z will always be 1.0 after the matrix, skip texture projection. Should help #9189 --- GPU/Common/ShaderId.cpp | 6 +++++- GPU/GLES/ShaderManagerGLES.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/GPU/Common/ShaderId.cpp b/GPU/Common/ShaderId.cpp index 1f19d2f085..290f54f800 100644 --- a/GPU/Common/ShaderId.cpp +++ b/GPU/Common/ShaderId.cpp @@ -149,6 +149,10 @@ void ComputeVertexShaderID(ShaderID *id_out, u32 vertType, bool useHWTransform) static const char *alphaTestFuncs[] = { "NEVER", "ALWAYS", "==", "!=", "<", "<=", ">", ">=" }; +static bool MatrixNeedsProjection(const float m[12]) { + return m[2] != 0.0f || m[5] != 0.0f || m[8] != 0.0f || m[11] != 1.0f; +} + std::string FragmentShaderDesc(const ShaderID &id) { std::stringstream desc; desc << StringFromFormat("%08x:%08x ", id.d[1], id.d[0]); @@ -224,7 +228,7 @@ void ComputeFragmentShaderID(ShaderID *id_out) { bool enableAlphaTest = gstate.isAlphaTestEnabled() && !IsAlphaTestTriviallyTrue() && !g_Config.bDisableAlphaTest; bool enableColorTest = gstate.isColorTestEnabled() && !IsColorTestTriviallyTrue(); bool enableColorDoubling = gstate.isColorDoublingEnabled() && gstate.isTextureMapEnabled(); - bool doTextureProjection = gstate.getUVGenMode() == GE_TEXMAP_TEXTURE_MATRIX; + bool doTextureProjection = (gstate.getUVGenMode() == GE_TEXMAP_TEXTURE_MATRIX && MatrixNeedsProjection(gstate.tgenMatrix)); bool doTextureAlpha = gstate.isTextureAlphaUsed(); bool doFlatShading = gstate.getShadeMode() == GE_SHADE_FLAT; diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index 1756dfae29..66de7a075f 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -993,7 +993,7 @@ std::string ShaderManagerGLES::DebugGetShaderString(std::string id, DebugShaderT // as sometimes these features might have an effect on the ID bits. #define CACHE_HEADER_MAGIC 0x83277592 -#define CACHE_VERSION 2 +#define CACHE_VERSION 3 struct CacheHeader { uint32_t magic; uint32_t version;