mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Add a conservative check that prevents alpha testing in a few cases.
This will become really powerful if we add some code to the vertex decoder to check for non-full alpha in the vertices, and set gstate_c.vertexFullAlpha if none is found (probably want to do the reverse, set it to true and clear if any non-255 alpha is found). Alpha testing is a performance killer on many mobile GPUs so big efforts to avoid it can be worth it.
This commit is contained in:
parent
20d480a374
commit
b174996c1c
3 changed files with 20 additions and 2 deletions
|
@ -71,12 +71,24 @@ static bool IsAlphaTestTriviallyTrue() {
|
||||||
case GE_COMP_NOTEQUAL:
|
case GE_COMP_NOTEQUAL:
|
||||||
case GE_COMP_GREATER:
|
case GE_COMP_GREATER:
|
||||||
{
|
{
|
||||||
return (!gstate.isStencilTestEnabled() &&
|
#if 0
|
||||||
|
// Easy way to check the values in the debugger without ruining && early-out
|
||||||
|
bool doTextureAlpha = gstate.isTextureAlphaUsed();
|
||||||
|
bool stencilTest = gstate.isStencilTestEnabled();
|
||||||
|
bool depthTest = gstate.isDepthTestEnabled();
|
||||||
|
GEComparison depthTestFunc = gstate.getDepthTestFunction();
|
||||||
|
int alphaRef = gstate.getAlphaTestRef();
|
||||||
|
int blendA = gstate.getBlendFuncA();
|
||||||
|
bool blendEnabled = gstate.isAlphaBlendEnabled();
|
||||||
|
int blendB = gstate.getBlendFuncA();
|
||||||
|
#endif
|
||||||
|
return (gstate_c.vertexFullAlpha && (gstate_c.textureFullAlpha || !gstate.isTextureAlphaUsed())) || (
|
||||||
|
(!gstate.isStencilTestEnabled() &&
|
||||||
!gstate.isDepthTestEnabled() &&
|
!gstate.isDepthTestEnabled() &&
|
||||||
gstate.getAlphaTestRef() == 0 &&
|
gstate.getAlphaTestRef() == 0 &&
|
||||||
gstate.isAlphaBlendEnabled() &&
|
gstate.isAlphaBlendEnabled() &&
|
||||||
gstate.getBlendFuncA() == GE_SRCBLEND_SRCALPHA &&
|
gstate.getBlendFuncA() == GE_SRCBLEND_SRCALPHA &&
|
||||||
safeDestFactors[(int)gstate.getBlendFuncB()]);
|
safeDestFactors[(int)gstate.getBlendFuncB()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
case GE_COMP_LEQUAL:
|
case GE_COMP_LEQUAL:
|
||||||
|
|
|
@ -265,6 +265,11 @@ void TransformDrawEngine::SetupVertexDecoder(u32 vertType) {
|
||||||
if (vertTypeID != lastVType_) {
|
if (vertTypeID != lastVType_) {
|
||||||
dec_ = GetVertexDecoder(vertTypeID);
|
dec_ = GetVertexDecoder(vertTypeID);
|
||||||
lastVType_ = vertTypeID;
|
lastVType_ = vertTypeID;
|
||||||
|
|
||||||
|
// TODO: Add functionality to VertexDecoder to scan for non-full alpha in the two other formats,
|
||||||
|
// which are quite common.
|
||||||
|
int colorType = vertTypeID & GE_VTYPE_COL_MASK;
|
||||||
|
gstate_c.vertexFullAlpha = colorType == GE_VTYPE_COL_NONE || colorType == GE_VTYPE_COL_565;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -441,6 +441,7 @@ struct GPUStateCache
|
||||||
|
|
||||||
bool textureChanged;
|
bool textureChanged;
|
||||||
bool textureFullAlpha;
|
bool textureFullAlpha;
|
||||||
|
bool vertexFullAlpha;
|
||||||
bool framebufChanged;
|
bool framebufChanged;
|
||||||
|
|
||||||
int skipDrawReason;
|
int skipDrawReason;
|
||||||
|
|
Loading…
Add table
Reference in a new issue