1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-06-25 22:09:35 +00:00

Fix blending when CLR_ON_CVG flag is on.

Remove hack for Pilot Wings.
This commit is contained in:
Sergey Lipskiy 2017-09-21 22:20:05 +07:00
parent a70bc7411b
commit 81cc0854dc
7 changed files with 82 additions and 36 deletions

View File

@ -185,7 +185,6 @@ struct Config
#define hack_blurPauseScreen (1<<2) //Game copies frame buffer to depth buffer area, CPU blurs it. That image is used as background for pause screen.
#define hack_scoreboard (1<<3) //Copy data from RDRAM to auxilary frame buffer. Scoreboard in Mario Tennis.
#define hack_scoreboardJ (1<<4) //Copy data from RDRAM to auxilary frame buffer. Scoreboard in Mario Tennis (J).
#define hack_pilotWings (1<<5) //Special blend mode for PilotWings.
#define hack_subscreen (1<<6) //Fix subscreen delay in Zelda OOT and Doubutsu no Mori
#define hack_blastCorps (1<<7) //Blast Corps black polygons
#define hack_rectDepthBufferCopyPD (1<<9) //Copy depth buffer only when game need it. Optimized for PD

View File

@ -48,7 +48,7 @@ static const char *SegmentText[] =
static const char *AAEnableText = "AA_EN";
static const char *DepthCompareText = "Z_CMP";
static const char *DepthUpdateText = "Z_UPD";
static const char *ClearOnCvgText = "CLR_ON_CVG";
static const char *ColorOnCvgText = "CLR_ON_CVG";
static const char *CvgXAlphaText = "CVG_X_ALPHA";
static const char *AlphaCvgSelText = "ALPHA_CVG_SEL";
static const char *ForceBlenderText = "FORCE_BL";

View File

@ -468,21 +468,26 @@ public:
{
#if 1
m_part =
" muxPM[0] = clampedColor; \n"
" lowp vec4 vprobe = vec4(0.0, 1.0, 2.0, 3.0); \n"
" if (uForceBlendCycle1 != 0) { \n"
" muxA[0] = clampedColor.a; \n"
" lowp float muxa = dot(muxA, vec4(equal(vec4(uBlendMux1[1]), vprobe))); \n"
" muxB[0] = 1.0 - muxa; \n"
" lowp vec4 muxpm0 = muxPM * vec4(equal(vec4(uBlendMux1[0]), vprobe)); \n"
" lowp vec4 muxpm2 = muxPM * vec4(equal(vec4(uBlendMux1[2]), vprobe)); \n"
" lowp float muxb = dot(muxB, vec4(equal(vec4(uBlendMux1[3]), vprobe))); \n"
" lowp vec4 blend1 = (muxpm0 * muxa) + (muxpm2 * muxb); \n"
" clampedColor.rgb = clamp(blend1.rgb, 0.0, 1.0); \n"
" } else { \n"
" lowp vec4 muxpm0 = muxPM * vec4(equal(vec4(uBlendMux1[0]), vprobe)); \n"
" clampedColor.rgb = muxpm0.rgb; \n"
" } \n"
" muxPM[0] = clampedColor; \n"
" lowp vec4 vprobe = vec4(0.0, 1.0, 2.0, 3.0); \n"
" if (uForceBlendCycle1 != 0) { \n"
" muxA[0] = clampedColor.a; \n"
" lowp float muxa = dot(muxA, vec4(equal(vec4(uBlendMux1[1]), vprobe))); \n"
" muxB[0] = 1.0 - muxa; \n"
" lowp vec4 muxpm0 = muxPM * vec4(equal(vec4(uBlendMux1[0]), vprobe)); \n"
" lowp vec4 muxpm2 = muxPM * vec4(equal(vec4(uBlendMux1[2]), vprobe)); \n"
" lowp float muxb = dot(muxB, vec4(equal(vec4(uBlendMux1[3]), vprobe))); \n"
" lowp vec4 blend1 = (muxpm0 * muxa) + (muxpm2 * muxb); \n"
" clampedColor.rgb = clamp(blend1.rgb, 0.0, 1.0); \n"
" } else { \n"
" if (uColorOnCvg == 0) { \n"
" lowp vec4 muxpm0 = muxPM * vec4(equal(vec4(uBlendMux1[0]), vprobe)); \n"
" clampedColor.rgb = muxpm0.rgb; \n"
" } else { \n"
" lowp vec4 muxpm2 = muxPM * vec4(equal(vec4(uBlendMux1[2]), vprobe)); \n"
" clampedColor.rgb = muxpm2.rgb; \n"
" } \n"
" } \n"
;
#else
// Keep old code for reference
@ -526,8 +531,13 @@ public:
" lowp vec4 blend2 = muxpm0 * muxa + muxpm2 * muxb; \n"
" clampedColor.rgb = clamp(blend2.rgb, 0.0, 1.0); \n"
" } else { \n"
" lowp vec4 muxpm0 = muxPM * vec4(equal(vec4(uBlendMux2[0]), vprobe)); \n"
" clampedColor.rgb = muxpm0.rgb; \n"
" if (uColorOnCvg == 0) { \n"
" lowp vec4 muxpm0 = muxPM * vec4(equal(vec4(uBlendMux2[0]), vprobe)); \n"
" clampedColor.rgb = muxpm0.rgb; \n"
" } else { \n"
" lowp vec4 muxpm2 = muxPM * vec4(equal(vec4(uBlendMux2[2]), vprobe)); \n"
" clampedColor.rgb = muxpm2.rgb; \n"
" } \n"
" } \n"
;
#else
@ -706,6 +716,7 @@ public:
"uniform lowp int uEnableAlphaTest; \n"
"uniform lowp int uCvgXAlpha; \n"
"uniform lowp int uAlphaCvgSel; \n"
"uniform lowp int uColorOnCvg; \n"
"uniform lowp float uAlphaTestValue; \n"
"uniform mediump vec2 uScreenScale; \n"
;
@ -780,6 +791,7 @@ public:
"uniform lowp int uEnableAlphaTest; \n"
"uniform lowp int uCvgXAlpha; \n"
"uniform lowp int uAlphaCvgSel; \n"
"uniform lowp int uColorOnCvg; \n"
"uniform lowp float uAlphaTestValue; \n"
"uniform mediump vec2 uScreenScale; \n"
;

View File

@ -272,6 +272,7 @@ public:
UBlendMode1Cycle(GLuint _program) {
LocateUniform(uBlendMux1);
LocateUniform(uForceBlendCycle1);
LocateUniform(uColorOnCvg);
}
void update(bool _force) override
@ -281,14 +282,18 @@ public:
gDP.otherMode.c1_m2a,
gDP.otherMode.c1_m2b,
_force);
int forceBlend1 = gDP.otherMode.forceBlender;
const int forceBlend1 = (int)gDP.otherMode.forceBlender;
uForceBlendCycle1.set(forceBlend1, _force);
const int colorOnCvg = (int)gDP.otherMode.colorOnCvg;
uColorOnCvg.set(colorOnCvg, _force);
}
private:
i4Uniform uBlendMux1;
iUniform uForceBlendCycle1;
iUniform uColorOnCvg;
};
class UBlendMode2Cycle : public UniformGroup

View File

@ -403,9 +403,22 @@ void GraphicsDrawer::_legacySetBlendMode() const
gfxContext.enable(enable::BLEND, true);
gfxContext.setBlending(sfactor, dfactor);
} else if ((config.generalEmulation.hacks & hack_pilotWings) != 0 && (gDP.otherMode.l & 0x80) != 0) { //CLR_ON_CVG without FORCE_BL
gfxContext.enable(enable::BLEND, true);
gfxContext.setBlending(blend::ZERO, blend::ONE);
} else if (gDP.otherMode.colorOnCvg != 0) {
// CLR_ON_CVG - just use second mux of blender
bool useMemColor = false;
if (gDP.otherMode.cycleType == G_CYC_1CYCLE) {
if (gDP.otherMode.c1_m2a == 1)
useMemColor = true;
} else if (gDP.otherMode.cycleType == G_CYC_2CYCLE) {
if (gDP.otherMode.c2_m2a == 1)
useMemColor = true;
}
if (useMemColor) {
gfxContext.enable(enable::BLEND, true);
gfxContext.setBlending(blend::ZERO, blend::ONE);
} else {
gfxContext.enable(enable::BLEND, false);
}
} else if ((config.generalEmulation.hacks & hack_blastCorps) != 0 && gDP.otherMode.cycleType < G_CYC_COPY && gSP.texture.on == 0 && currentCombiner()->usesTexture()) { // Blast Corps
gfxContext.enable(enable::BLEND, true);
gfxContext.setBlending(blend::ZERO, blend::ONE);
@ -517,23 +530,42 @@ void GraphicsDrawer::_setBlendMode() const
}
gfxContext.enable(enable::BLEND, true);
gfxContext.setBlending(srcFactor, dstFactor);
}
else if ((config.generalEmulation.hacks & hack_pilotWings) != 0 && gDP.otherMode.clearOnCvg != 0) { //CLR_ON_CVG without FORCE_BL
} else if ((config.generalEmulation.hacks & hack_blastCorps) != 0 && gDP.otherMode.cycleType < G_CYC_COPY && gSP.texture.on == 0 && currentCombiner()->usesTexture()) { // Blast Corps
gfxContext.enable(enable::BLEND, true);
gfxContext.setBlending(blend::ZERO, blend::ONE);
}
else if ((config.generalEmulation.hacks & hack_blastCorps) != 0 && gDP.otherMode.cycleType < G_CYC_COPY && gSP.texture.on == 0 && currentCombiner()->usesTexture()) { // Blast Corps
gfxContext.enable(enable::BLEND, true);
gfxContext.setBlending(blend::ZERO, blend::ONE);
} else if ((gDP.otherMode.forceBlender == 0 && gDP.otherMode.cycleType < G_CYC_COPY)) {
if (gDP.otherMode.c1_m1a == 1 && gDP.otherMode.c1_m2a == 1) {
} else if (gDP.otherMode.colorOnCvg != 0) {
// CLR_ON_CVG - just use second mux of blender
bool useMemColor = false;
if (gDP.otherMode.cycleType == G_CYC_1CYCLE) {
if (gDP.otherMode.c1_m2a == 1)
useMemColor = true;
} else if (gDP.otherMode.cycleType == G_CYC_2CYCLE) {
if (gDP.otherMode.c2_m2a == 1)
useMemColor = true;
}
if (useMemColor) {
gfxContext.enable(enable::BLEND, true);
gfxContext.setBlending(blend::ZERO, blend::ONE);
} else {
gfxContext.enable(enable::BLEND, false);
}
}
else {
} else if ((gDP.otherMode.forceBlender == 0 && gDP.otherMode.cycleType < G_CYC_COPY)) {
// Just use first mux of blender
bool useMemColor = false;
if (gDP.otherMode.cycleType == G_CYC_1CYCLE) {
if (gDP.otherMode.c1_m1a == 1)
useMemColor = true;
} else if (gDP.otherMode.cycleType == G_CYC_2CYCLE) {
if (gDP.otherMode.c1_m2a == 1)
useMemColor = true;
}
if (useMemColor) {
gfxContext.enable(enable::BLEND, true);
gfxContext.setBlending(blend::ZERO, blend::ONE);
} else {
gfxContext.enable(enable::BLEND, false);
}
} else {
gfxContext.enable(enable::BLEND, false);
}
}

View File

@ -271,8 +271,6 @@ void RSP_Init()
config.generalEmulation.hacks |= hack_scoreboardJ;
else if (strstr(RSP.romname, (const char *)"MarioTennis") != nullptr)
config.generalEmulation.hacks |= hack_scoreboard;
else if (strstr(RSP.romname, (const char *)"Pilot Wings64") != nullptr)
config.generalEmulation.hacks |= hack_pilotWings;
else if (strstr(RSP.romname, (const char *)"THE LEGEND OF ZELDA") != nullptr ||
strstr(RSP.romname, (const char *)"ZELDA MASTER QUEST") != nullptr ||
strstr(RSP.romname, (const char *)"DOUBUTSUNOMORI") != nullptr ||

View File

@ -134,7 +134,7 @@ struct gDPInfo
unsigned int depthCompare : 1;
unsigned int depthUpdate : 1;
unsigned int imageRead : 1;
unsigned int clearOnCvg : 1;
unsigned int colorOnCvg : 1;
unsigned int cvgDest : 2;
unsigned int depthMode : 2;