Merge pull request #4913 from raven02/patch-25

Set alpha mask based on ReplaceAlphaWithStencil()
This commit is contained in:
Henrik Rydgård 2013-12-29 02:19:34 -08:00
commit acf4562130
2 changed files with 23 additions and 13 deletions

View File

@ -1285,10 +1285,9 @@ void GLES_GPU::ExecuteOpInternal(u32 op, u32 diff) {
break;
//////////////////////////////////////////////////////////////////
// Z/STENCIL TESTING
// DEPTH TESTING
//////////////////////////////////////////////////////////////////
case GE_CMD_STENCILTESTENABLE:
case GE_CMD_ZTESTENABLE:
case GE_CMD_ZTEST:
case GE_CMD_ZWRITEDISABLE:
@ -1427,12 +1426,18 @@ void GLES_GPU::ExecuteOpInternal(u32 op, u32 diff) {
break;
#endif
// Handled in StateMapping.
//////////////////////////////////////////////////////////////////
// STENCIL TESTING
//////////////////////////////////////////////////////////////////
case GE_CMD_STENCILTEST:
// Handled in StateMapping.
if (diff) {
shaderManager_->DirtyUniform(DIRTY_STENCILREPLACEVALUE);
}
break;
case GE_CMD_STENCILTESTENABLE:
case GE_CMD_STENCILOP:
break;

View File

@ -193,7 +193,7 @@ void TransformDrawEngine::ApplyDrawState(int prim) {
if (blendFuncB > GE_DSTBLEND_FIXB) blendFuncB = GE_DSTBLEND_FIXB;
float constantAlpha = 1.0f;
ReplaceAlphaType replaceAlphaWithStencil = gstate.isStencilTestEnabled() ? ReplaceAlphaWithStencil() : REPLACE_ALPHA_NO;
ReplaceAlphaType replaceAlphaWithStencil = ReplaceAlphaWithStencil();
if (gstate.isStencilTestEnabled() && replaceAlphaWithStencil == REPLACE_ALPHA_NO) {
if (ReplaceAlphaWithStencilType() == STENCIL_VALUE_UNIFORM) {
constantAlpha = (float) gstate.getStencilTestRef() * (1.0f / 255.0f);
@ -407,18 +407,23 @@ void TransformDrawEngine::ApplyDrawState(int prim) {
bool rmask = (gstate.pmskc & 0xFF) < 128;
bool gmask = ((gstate.pmskc >> 8) & 0xFF) < 128;
bool bmask = ((gstate.pmskc >> 16) & 0xFF) < 128;
bool amask = (gstate.pmska & 0xFF) < 128;
// Let's not write to alpha if stencil isn't enabled.
if (!gstate.isStencilTestEnabled()) {
bool amask;
ReplaceAlphaType stencilToAlpha = ReplaceAlphaWithStencil();
switch (stencilToAlpha) {
case REPLACE_ALPHA_DUALSOURCE:
amask = (gstate.pmska & 0xFF) < 128;
break;
case REPLACE_ALPHA_YES:
amask = true;
break;
case REPLACE_ALPHA_NO:
amask = false;
} else {
// If the stencil type is set to KEEP, we shouldn't write to the stencil/alpha channel.
if (ReplaceAlphaWithStencilType() == STENCIL_VALUE_KEEP) {
amask = false;
}
break;
}
glstate.colorMask.set(rmask, gmask, bmask, amask);
// Stencil Test