More correctly blend when hitting the frame cap.

If we hit too many blits per frame, fall back correctly in the shader.
This commit is contained in:
Unknown W. Brackets 2014-08-03 19:56:53 -07:00
parent 422db25277
commit a43c3771a3
3 changed files with 15 additions and 12 deletions

View File

@ -242,14 +242,14 @@ ReplaceBlendType ReplaceBlendWithShader() {
// Let's get the non-factor modes out of the way first.
switch (eq) {
case GE_BLENDMODE_ABSDIFF:
return g_Config.bDisableSlowFramebufEffects ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
return !gstate_c.allowShaderBlend ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
case GE_BLENDMODE_MIN:
case GE_BLENDMODE_MAX:
if (gl_extensions.EXT_blend_minmax || gl_extensions.GLES3) {
return REPLACE_BLEND_STANDARD;
} else {
return g_Config.bDisableSlowFramebufEffects ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
return !gstate_c.allowShaderBlend ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
}
default:
@ -265,11 +265,11 @@ ReplaceBlendType ReplaceBlendWithShader() {
case GE_DSTBLEND_SRCCOLOR:
case GE_DSTBLEND_INVSRCCOLOR:
// Can't double, we need the source color to be correct.
return g_Config.bDisableSlowFramebufEffects ? REPLACE_BLEND_2X_ALPHA : REPLACE_BLEND_COPY_FBO;
return !gstate_c.allowShaderBlend ? REPLACE_BLEND_2X_ALPHA : REPLACE_BLEND_COPY_FBO;
case GE_DSTBLEND_DOUBLEDSTALPHA:
case GE_DSTBLEND_DOUBLEINVDSTALPHA:
return g_Config.bDisableSlowFramebufEffects ? REPLACE_BLEND_2X_ALPHA : REPLACE_BLEND_COPY_FBO;
return !gstate_c.allowShaderBlend ? REPLACE_BLEND_2X_ALPHA : REPLACE_BLEND_COPY_FBO;
case GE_DSTBLEND_DOUBLESRCALPHA:
case GE_DSTBLEND_DOUBLEINVSRCALPHA:
@ -288,17 +288,17 @@ ReplaceBlendType ReplaceBlendWithShader() {
case GE_DSTBLEND_SRCCOLOR:
case GE_DSTBLEND_INVSRCCOLOR:
// Can't double, we need the source color to be correct.
return g_Config.bDisableSlowFramebufEffects ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
return !gstate_c.allowShaderBlend ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
case GE_DSTBLEND_DOUBLEDSTALPHA:
case GE_DSTBLEND_DOUBLEINVDSTALPHA:
case GE_DSTBLEND_DOUBLESRCALPHA:
case GE_DSTBLEND_DOUBLEINVSRCALPHA:
return g_Config.bDisableSlowFramebufEffects ? REPLACE_BLEND_2X_SRC : REPLACE_BLEND_COPY_FBO;
return !gstate_c.allowShaderBlend ? REPLACE_BLEND_2X_SRC : REPLACE_BLEND_COPY_FBO;
default:
// We can't technically do this correctly (due to clamping) without reading the dst alpha.
return g_Config.bDisableSlowFramebufEffects ? REPLACE_BLEND_2X_SRC : REPLACE_BLEND_COPY_FBO;
return !gstate_c.allowShaderBlend ? REPLACE_BLEND_2X_SRC : REPLACE_BLEND_COPY_FBO;
}
case GE_SRCBLEND_FIXA:
@ -306,11 +306,11 @@ ReplaceBlendType ReplaceBlendWithShader() {
case GE_DSTBLEND_DOUBLESRCALPHA:
case GE_DSTBLEND_DOUBLEINVSRCALPHA:
// Can't safely double alpha, will clamp.
return g_Config.bDisableSlowFramebufEffects ? REPLACE_BLEND_2X_ALPHA : REPLACE_BLEND_COPY_FBO;
return !gstate_c.allowShaderBlend ? REPLACE_BLEND_2X_ALPHA : REPLACE_BLEND_COPY_FBO;
case GE_DSTBLEND_DOUBLEDSTALPHA:
case GE_DSTBLEND_DOUBLEINVDSTALPHA:
return g_Config.bDisableSlowFramebufEffects ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
return !gstate_c.allowShaderBlend ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
case GE_DSTBLEND_FIXB:
if (gstate.getFixA() == 0xFFFFFF && gstate.getFixB() == 0x000000) {
@ -334,11 +334,11 @@ ReplaceBlendType ReplaceBlendWithShader() {
// Can't safely double alpha, will clamp. However, a copy may easily be worse due to overlap.
return REPLACE_BLEND_PRE_SRC_2X_ALPHA;
}
return g_Config.bDisableSlowFramebufEffects ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
return !gstate_c.allowShaderBlend ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
case GE_DSTBLEND_DOUBLEDSTALPHA:
case GE_DSTBLEND_DOUBLEINVDSTALPHA:
return g_Config.bDisableSlowFramebufEffects ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
return !gstate_c.allowShaderBlend ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
default:
return REPLACE_BLEND_STANDARD;

View File

@ -218,6 +218,7 @@ void TransformDrawEngine::ApplyBlendState() {
// * The written output alpha should actually be the stencil value. Alpha is not written.
//
// If we can't apply blending, we make a copy of the framebuffer and do it manually.
gstate_c.allowShaderBlend = !g_Config.bDisableSlowFramebufEffects;
ReplaceBlendType replaceBlend = ReplaceBlendWithShader();
bool usePreSrc = false;
@ -234,7 +235,8 @@ void TransformDrawEngine::ApplyBlendState() {
glstate.blend.disable();
return;
}
// TODO: Otherwise, we probably apply shading wrong. Hmm.
// Until next time, force it off.
gstate_c.allowShaderBlend = false;
break;
case REPLACE_BLEND_PRE_SRC:

View File

@ -461,6 +461,7 @@ struct GPUStateCache
UVScale uv;
bool flipTexture;
bool needShaderTexClamp;
bool allowShaderBlend;
float morphWeights[8];