Experiment: Use glBlendFuncSeparate to not change dest alpha when blending.

Fixes Persona blending issues.
This commit is contained in:
Henrik Rydgard 2013-08-22 19:14:04 +02:00
parent cbb7f025b8
commit 416f0c56e8
5 changed files with 32 additions and 9 deletions

View File

@ -130,6 +130,7 @@ void ComputeFragmentShaderID(FragmentShaderID *id) {
id->d[0] |= gstate.getTextureFunction() << 2;
id->d[0] |= (doTextureAlpha & 1) << 5; // rgb or rgba
}
id->d[0] |= (lmode & 1) << 7;
id->d[0] |= gstate.isAlphaTestEnabled() << 8;
if (enableAlphaTest)

View File

@ -217,7 +217,13 @@ void TransformDrawEngine::ApplyDrawState(int prim) {
}
// At this point, through all paths above, glBlendFuncA and glBlendFuncB will be set right somehow.
glstate.blendFunc.set(glBlendFuncA, glBlendFuncB);
#if 1
// Fixes some Persona 2 issues, may be correct? (that is, don't change dest alpha at all if blending)
// If this doesn't break anything else, it's likely to be right.
glstate.blendFuncSeparate.set(glBlendFuncA, glBlendFuncB, GL_ZERO, GL_ONE);
#else
glstate.blendFuncSeparate.set(glBlendFuncA, glBlendFuncB, glBlendFuncA, glBlendFuncB);
#endif
glstate.blendEquation.set(eqLookup[blendFuncEq]);
}

View File

@ -749,9 +749,26 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer) {
"unsupported1",
"unsupported2",
};
const char *blendFactors[] = {
"a",
"1.0 - a",
const char *blendFactorsA[16] = {
"dst",
"1.0 - dst",
"src.a",
"1.0 - src.a",
"dst.a",
"1.0 - dst.a",
"2.0 * src.a",
"1.0 - 2.0 * src.a",
"2.0 * dst.a",
"1.0 - 2.0 * dst.a",
"fixed",
"fixed2",
"fixed3",
"fixed4",
"fixed5",
};
const char *blendFactorsB[16] = {
"src",
"1.0 - src",
"src.a",
"1.0 - src.a",
"dst.a",
@ -765,11 +782,10 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer) {
"fixed3",
"fixed4",
"fixed5",
"fixed6",
};
const char *blendFactorA = blendFactors[(data >> 0) & 0xF];
const char *blendFactorB = blendFactors[(data >> 4) & 0xF];
const char *blendFactorA = blendFactorsA[(data >> 0) & 0xF];
const char *blendFactorB = blendFactorsB[(data >> 4) & 0xF];
const char *blendMode = blendModes[(data >> 8) & 0x7];
if (data & ~0xFF0007FF)

View File

@ -98,7 +98,7 @@ void UIShader_Prepare()
glstate.dither.enable();
glstate.blend.enable();
glstate.blendFunc.set(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glstate.blendFuncSeparate.set(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glstate.blendEquation.set(GL_FUNC_ADD);
glstate.depthWrite.set(GL_TRUE);

2
native

@ -1 +1 @@
Subproject commit a8b45a68b961d655b68c7166a798cb0b6447f039
Subproject commit 45d65225a6f2fe8b8befe43786d6e54b066a7fbf