diff --git a/GPU/GLES/StateMapping.cpp b/GPU/GLES/StateMapping.cpp index 0904c1d9cd..87b158b24e 100644 --- a/GPU/GLES/StateMapping.cpp +++ b/GPU/GLES/StateMapping.cpp @@ -639,10 +639,6 @@ void TransformDrawEngine::ApplyDrawState(int prim) { } else { glstate.stencilTest.disable(); } - - if (gstate.isAlphaTestEnabled() || gstate.isColorTestEnabled()) { - fragmentTestCache_->BindTestTexture(GL_TEXTURE2); - } } bool throughmode = gstate.isModeThrough(); @@ -755,3 +751,13 @@ void TransformDrawEngine::ApplyDrawState(int prim) { glstate.depthRange.set(depthRangeMin, depthRangeMax); } } + +void TransformDrawEngine::ApplyDrawStateLate() { + // At this point, we know if the vertices are full alpha or not. + // TODO: Set the nearest/linear here (since we correctly know if alpha/color tests are needed)? + if (!gstate.isModeClear()) { + if (gstate.isAlphaTestEnabled() || gstate.isColorTestEnabled()) { + fragmentTestCache_->BindTestTexture(GL_TEXTURE2); + } + } +} diff --git a/GPU/GLES/TransformPipeline.cpp b/GPU/GLES/TransformPipeline.cpp index 2365ec9d5f..270780e4ed 100644 --- a/GPU/GLES/TransformPipeline.cpp +++ b/GPU/GLES/TransformPipeline.cpp @@ -723,6 +723,7 @@ rotateVBO: gstate_c.vertexFullAlpha = gstate_c.vertexFullAlpha && ((hasColor && (gstate.materialupdate & 1)) || gstate.getMaterialAmbientA() == 255) && (!gstate.isLightingEnabled() || gstate.getAmbientA() == 255); } + ApplyDrawStateLate(); LinkedShader *program = shaderManager_->ApplyFragmentShader(vshader, prim, lastVType_); SetupDecFmtForDraw(program, dec_->GetDecVtxFmt(), vbo ? 0 : decoded); @@ -748,6 +749,7 @@ rotateVBO: gstate_c.vertexFullAlpha = gstate_c.vertexFullAlpha && ((hasColor && (gstate.materialupdate & 1)) || gstate.getMaterialAmbientA() == 255) && (!gstate.isLightingEnabled() || gstate.getAmbientA() == 255); } + ApplyDrawStateLate(); LinkedShader *program = shaderManager_->ApplyFragmentShader(vshader, prim, lastVType_); gpuStats.numUncachedVertsDrawn += indexGen.VertexCount(); prim = indexGen.Prim(); diff --git a/GPU/GLES/TransformPipeline.h b/GPU/GLES/TransformPipeline.h index 514a0f1b7f..811679d3c1 100644 --- a/GPU/GLES/TransformPipeline.h +++ b/GPU/GLES/TransformPipeline.h @@ -179,6 +179,7 @@ private: void DoFlush(); void SoftwareTransformAndDraw(int prim, u8 *decoded, LinkedShader *program, int vertexCount, u32 vertexType, void *inds, int indexType, const DecVtxFormat &decVtxFormat, int maxIndex); void ApplyDrawState(int prim); + void ApplyDrawStateLate(); void ApplyBlendState(); void ApplyStencilReplaceOnly(); bool ApplyShaderBlending();