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

View File

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