Bind the alphatest tex after we know vert alpha.

Before we sometimes thought alpha test was trivially true when it wasn't.
This commit is contained in:
Unknown W. Brackets 2014-09-10 23:43:48 -07:00
parent 2e0df244bc
commit 33ac30218a
3 changed files with 13 additions and 4 deletions

View File

@ -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);
}
}
}

View File

@ -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();

View File

@ -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();