mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
ShaderBlend and FramebufferRead are separate concepts. Reflect that in naming.
The former has forms that don't need to read the framebuffer. This exposes that some logic is wrong...
This commit is contained in:
parent
2aa9ee97f4
commit
3d289594f9
9 changed files with 65 additions and 64 deletions
|
@ -253,7 +253,7 @@ StencilValueType ReplaceAlphaWithStencilType() {
|
|||
return STENCIL_VALUE_KEEP;
|
||||
}
|
||||
|
||||
ReplaceBlendType ReplaceBlendWithShader(bool allowShaderBlend, GEBufferFormat bufferFormat) {
|
||||
ReplaceBlendType ReplaceBlendWithShader(bool allowFramebufferRead, GEBufferFormat bufferFormat) {
|
||||
if (!gstate.isAlphaBlendEnabled() || gstate.isModeClear()) {
|
||||
return REPLACE_BLEND_NO;
|
||||
}
|
||||
|
@ -262,14 +262,14 @@ ReplaceBlendType ReplaceBlendWithShader(bool allowShaderBlend, GEBufferFormat bu
|
|||
// Let's get the non-factor modes out of the way first.
|
||||
switch (eq) {
|
||||
case GE_BLENDMODE_ABSDIFF:
|
||||
return !allowShaderBlend ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
|
||||
return !allowFramebufferRead ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
|
||||
|
||||
case GE_BLENDMODE_MIN:
|
||||
case GE_BLENDMODE_MAX:
|
||||
if (gstate_c.Supports(GPU_SUPPORTS_BLEND_MINMAX)) {
|
||||
return REPLACE_BLEND_STANDARD;
|
||||
} else {
|
||||
return !allowShaderBlend ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
|
||||
return !allowFramebufferRead ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
|
||||
}
|
||||
|
||||
default:
|
||||
|
@ -292,19 +292,19 @@ ReplaceBlendType ReplaceBlendWithShader(bool allowShaderBlend, GEBufferFormat bu
|
|||
return REPLACE_BLEND_2X_ALPHA;
|
||||
// Can't double, we need the source color to be correct.
|
||||
// Doubling only alpha would clamp the src alpha incorrectly.
|
||||
return !allowShaderBlend ? REPLACE_BLEND_2X_ALPHA : REPLACE_BLEND_COPY_FBO;
|
||||
return !allowFramebufferRead ? REPLACE_BLEND_2X_ALPHA : REPLACE_BLEND_COPY_FBO;
|
||||
|
||||
case GE_DSTBLEND_DOUBLEDSTALPHA:
|
||||
case GE_DSTBLEND_DOUBLEINVDSTALPHA:
|
||||
if (bufferFormat == GE_FORMAT_565)
|
||||
return REPLACE_BLEND_2X_ALPHA;
|
||||
return !allowShaderBlend ? REPLACE_BLEND_2X_ALPHA : REPLACE_BLEND_COPY_FBO;
|
||||
return !allowFramebufferRead ? REPLACE_BLEND_2X_ALPHA : REPLACE_BLEND_COPY_FBO;
|
||||
|
||||
case GE_DSTBLEND_DOUBLESRCALPHA:
|
||||
// We can't technically do this correctly (due to clamping) without reading the dst color.
|
||||
// Using a copy isn't accurate either, though, when there's overlap.
|
||||
if (gstate_c.Supports(GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH))
|
||||
return !allowShaderBlend ? REPLACE_BLEND_PRE_SRC_2X_ALPHA : REPLACE_BLEND_COPY_FBO;
|
||||
return !allowFramebufferRead ? REPLACE_BLEND_PRE_SRC_2X_ALPHA : REPLACE_BLEND_COPY_FBO;
|
||||
return REPLACE_BLEND_PRE_SRC_2X_ALPHA;
|
||||
|
||||
case GE_DSTBLEND_DOUBLEINVSRCALPHA:
|
||||
|
@ -331,7 +331,7 @@ ReplaceBlendType ReplaceBlendWithShader(bool allowShaderBlend, GEBufferFormat bu
|
|||
return REPLACE_BLEND_STANDARD;
|
||||
}
|
||||
// Can't double, we need the source color to be correct.
|
||||
return !allowShaderBlend ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
|
||||
return !allowFramebufferRead ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
|
||||
|
||||
case GE_DSTBLEND_DOUBLEDSTALPHA:
|
||||
case GE_DSTBLEND_DOUBLEINVDSTALPHA:
|
||||
|
@ -340,7 +340,7 @@ ReplaceBlendType ReplaceBlendWithShader(bool allowShaderBlend, GEBufferFormat bu
|
|||
// Doubling will have no effect here.
|
||||
return REPLACE_BLEND_STANDARD;
|
||||
}
|
||||
return !allowShaderBlend ? REPLACE_BLEND_2X_SRC : REPLACE_BLEND_COPY_FBO;
|
||||
return !allowFramebufferRead ? REPLACE_BLEND_2X_SRC : REPLACE_BLEND_COPY_FBO;
|
||||
|
||||
case GE_DSTBLEND_DOUBLESRCALPHA:
|
||||
case GE_DSTBLEND_DOUBLEINVSRCALPHA:
|
||||
|
@ -349,7 +349,7 @@ ReplaceBlendType ReplaceBlendWithShader(bool allowShaderBlend, GEBufferFormat bu
|
|||
}
|
||||
// Double both src (for dst alpha) and alpha (for dst factor.)
|
||||
// But to be accurate (clamping), we need to read the dst color.
|
||||
return !allowShaderBlend ? REPLACE_BLEND_PRE_SRC_2X_ALPHA : REPLACE_BLEND_COPY_FBO;
|
||||
return !allowFramebufferRead ? REPLACE_BLEND_PRE_SRC_2X_ALPHA : REPLACE_BLEND_COPY_FBO;
|
||||
|
||||
case GE_DSTBLEND_SRCALPHA:
|
||||
case GE_DSTBLEND_INVSRCALPHA:
|
||||
|
@ -361,7 +361,7 @@ ReplaceBlendType ReplaceBlendWithShader(bool allowShaderBlend, GEBufferFormat bu
|
|||
return REPLACE_BLEND_STANDARD;
|
||||
}
|
||||
// We can't technically do this correctly (due to clamping) without reading the dst alpha.
|
||||
return !allowShaderBlend ? REPLACE_BLEND_2X_SRC : REPLACE_BLEND_COPY_FBO;
|
||||
return !allowFramebufferRead ? REPLACE_BLEND_2X_SRC : REPLACE_BLEND_COPY_FBO;
|
||||
}
|
||||
|
||||
case GE_SRCBLEND_DOUBLEINVDSTALPHA:
|
||||
|
@ -375,14 +375,14 @@ ReplaceBlendType ReplaceBlendWithShader(bool allowShaderBlend, GEBufferFormat bu
|
|||
if (bufferFormat == GE_FORMAT_565) {
|
||||
return REPLACE_BLEND_STANDARD;
|
||||
}
|
||||
return !allowShaderBlend ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
|
||||
return !allowFramebufferRead ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
|
||||
|
||||
case GE_DSTBLEND_DOUBLESRCALPHA:
|
||||
case GE_DSTBLEND_DOUBLEINVSRCALPHA:
|
||||
if (bufferFormat == GE_FORMAT_565) {
|
||||
return REPLACE_BLEND_2X_ALPHA;
|
||||
}
|
||||
return !allowShaderBlend ? REPLACE_BLEND_2X_ALPHA : REPLACE_BLEND_COPY_FBO;
|
||||
return !allowFramebufferRead ? REPLACE_BLEND_2X_ALPHA : REPLACE_BLEND_COPY_FBO;
|
||||
|
||||
case GE_DSTBLEND_SRCALPHA:
|
||||
case GE_DSTBLEND_INVSRCALPHA:
|
||||
|
@ -393,7 +393,7 @@ ReplaceBlendType ReplaceBlendWithShader(bool allowShaderBlend, GEBufferFormat bu
|
|||
if (bufferFormat == GE_FORMAT_565) {
|
||||
return REPLACE_BLEND_STANDARD;
|
||||
}
|
||||
return !allowShaderBlend ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
|
||||
return !allowFramebufferRead ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
|
||||
}
|
||||
|
||||
case GE_SRCBLEND_FIXA:
|
||||
|
@ -401,7 +401,7 @@ ReplaceBlendType ReplaceBlendWithShader(bool allowShaderBlend, GEBufferFormat bu
|
|||
switch (funcB) {
|
||||
case GE_DSTBLEND_DOUBLESRCALPHA:
|
||||
// Can't safely double alpha, will clamp.
|
||||
return !allowShaderBlend ? REPLACE_BLEND_2X_ALPHA : REPLACE_BLEND_COPY_FBO;
|
||||
return !allowFramebufferRead ? REPLACE_BLEND_2X_ALPHA : REPLACE_BLEND_COPY_FBO;
|
||||
|
||||
case GE_DSTBLEND_DOUBLEINVSRCALPHA:
|
||||
// Doubling alpha is safe for the inverse, will clamp to zero either way.
|
||||
|
@ -412,7 +412,7 @@ ReplaceBlendType ReplaceBlendWithShader(bool allowShaderBlend, GEBufferFormat bu
|
|||
if (bufferFormat == GE_FORMAT_565) {
|
||||
return REPLACE_BLEND_STANDARD;
|
||||
}
|
||||
return !allowShaderBlend ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
|
||||
return !allowFramebufferRead ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
|
||||
|
||||
case GE_DSTBLEND_FIXB:
|
||||
default:
|
||||
|
@ -446,14 +446,14 @@ ReplaceBlendType ReplaceBlendWithShader(bool allowShaderBlend, GEBufferFormat bu
|
|||
if (funcA == GE_SRCBLEND_SRCALPHA || funcA == GE_SRCBLEND_INVSRCALPHA) {
|
||||
// Can't safely double alpha, will clamp. However, a copy may easily be worse due to overlap.
|
||||
if (gstate_c.Supports(GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH))
|
||||
return !allowShaderBlend ? REPLACE_BLEND_PRE_SRC_2X_ALPHA : REPLACE_BLEND_COPY_FBO;
|
||||
return !allowFramebufferRead ? REPLACE_BLEND_PRE_SRC_2X_ALPHA : REPLACE_BLEND_COPY_FBO;
|
||||
return REPLACE_BLEND_PRE_SRC_2X_ALPHA;
|
||||
} else {
|
||||
// This means dst alpha/color is used in the src factor.
|
||||
// Unfortunately, copying here causes overlap problems in Silent Hill games (it seems?)
|
||||
// We will just hope that doubling alpha for the dst factor will not clamp too badly.
|
||||
if (gstate_c.Supports(GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH))
|
||||
return !allowShaderBlend ? REPLACE_BLEND_2X_ALPHA : REPLACE_BLEND_COPY_FBO;
|
||||
return !allowFramebufferRead ? REPLACE_BLEND_2X_ALPHA : REPLACE_BLEND_COPY_FBO;
|
||||
return REPLACE_BLEND_2X_ALPHA;
|
||||
}
|
||||
|
||||
|
@ -470,7 +470,7 @@ ReplaceBlendType ReplaceBlendWithShader(bool allowShaderBlend, GEBufferFormat bu
|
|||
if (bufferFormat == GE_FORMAT_565) {
|
||||
return REPLACE_BLEND_STANDARD;
|
||||
}
|
||||
return !allowShaderBlend ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
|
||||
return !allowFramebufferRead ? REPLACE_BLEND_STANDARD : REPLACE_BLEND_COPY_FBO;
|
||||
|
||||
default:
|
||||
return REPLACE_BLEND_STANDARD;
|
||||
|
@ -958,7 +958,7 @@ void ApplyStencilReplaceAndLogicOp(ReplaceAlphaType replaceAlphaWithStencil, Gen
|
|||
|
||||
// Called even if AlphaBlendEnable == false - it also deals with stencil-related blend state.
|
||||
|
||||
void ConvertBlendState(GenericBlendState &blendState, bool allowShaderBlend) {
|
||||
void ConvertBlendState(GenericBlendState &blendState, bool allowFramebufferRead) {
|
||||
// Blending is a bit complex to emulate. This is due to several reasons:
|
||||
//
|
||||
// * Doubled blend modes (src, dst, inversed) aren't supported in OpenGL.
|
||||
|
@ -969,25 +969,25 @@ void ConvertBlendState(GenericBlendState &blendState, bool allowShaderBlend) {
|
|||
//
|
||||
// If we can't apply blending, we make a copy of the framebuffer and do it manually.
|
||||
|
||||
blendState.applyShaderBlending = false;
|
||||
blendState.dirtyShaderBlend = false;
|
||||
blendState.applyFramebufferRead = false;
|
||||
blendState.dirtyShaderBlendFixValues = false;
|
||||
blendState.useBlendColor = false;
|
||||
blendState.replaceAlphaWithStencil = REPLACE_ALPHA_NO;
|
||||
|
||||
ReplaceBlendType replaceBlend = ReplaceBlendWithShader(allowShaderBlend, gstate.FrameBufFormat());
|
||||
ReplaceBlendType replaceBlend = ReplaceBlendWithShader(allowFramebufferRead, gstate.FrameBufFormat());
|
||||
ReplaceAlphaType replaceAlphaWithStencil = ReplaceAlphaWithStencil(replaceBlend);
|
||||
bool usePreSrc = false;
|
||||
|
||||
switch (replaceBlend) {
|
||||
case REPLACE_BLEND_NO:
|
||||
blendState.resetShaderBlending = true;
|
||||
blendState.resetFramebufferRead = true;
|
||||
// We may still want to do something about stencil -> alpha.
|
||||
ApplyStencilReplaceAndLogicOp(replaceAlphaWithStencil, blendState);
|
||||
return;
|
||||
|
||||
case REPLACE_BLEND_COPY_FBO:
|
||||
blendState.applyShaderBlending = true;
|
||||
blendState.resetShaderBlending = false;
|
||||
blendState.applyFramebufferRead = true;
|
||||
blendState.resetFramebufferRead = false;
|
||||
blendState.replaceAlphaWithStencil = replaceAlphaWithStencil;
|
||||
break;
|
||||
|
||||
|
@ -1003,7 +1003,7 @@ void ConvertBlendState(GenericBlendState &blendState, bool allowShaderBlend) {
|
|||
}
|
||||
|
||||
blendState.enabled = true;
|
||||
blendState.resetShaderBlending = true;
|
||||
blendState.resetFramebufferRead = true;
|
||||
|
||||
const GEBlendMode blendFuncEq = gstate.getBlendEq();
|
||||
GEBlendSrcFactor blendFuncA = gstate.getBlendFuncA();
|
||||
|
@ -1071,7 +1071,7 @@ void ConvertBlendState(GenericBlendState &blendState, bool allowShaderBlend) {
|
|||
glBlendFuncA = BlendFactor::ONE;
|
||||
// Need to pull in the fixed color. TODO: If it hasn't changed, no need to dirty.
|
||||
if (blendFuncA == GE_SRCBLEND_FIXA) {
|
||||
blendState.dirtyShaderBlend = true;
|
||||
blendState.dirtyShaderBlendFixValues = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -121,9 +121,9 @@ enum class BlendEq : uint8_t {
|
|||
|
||||
struct GenericBlendState {
|
||||
bool enabled;
|
||||
bool resetShaderBlending;
|
||||
bool applyShaderBlending;
|
||||
bool dirtyShaderBlend;
|
||||
bool resetFramebufferRead;
|
||||
bool applyFramebufferRead;
|
||||
bool dirtyShaderBlendFixValues;
|
||||
ReplaceAlphaType replaceAlphaWithStencil;
|
||||
|
||||
BlendFactor srcColor;
|
||||
|
|
|
@ -240,7 +240,7 @@ void ComputeFragmentShaderID(FShaderID *id_out, const Draw::Bugs &bugs) {
|
|||
bool doFlatShading = gstate.getShadeMode() == GE_SHADE_FLAT;
|
||||
bool useShaderDepal = gstate_c.useShaderDepal;
|
||||
|
||||
ReplaceBlendType replaceBlend = ReplaceBlendWithShader(gstate_c.allowShaderBlend, gstate.FrameBufFormat());
|
||||
ReplaceBlendType replaceBlend = ReplaceBlendWithShader(gstate_c.allowFramebufferRead, gstate.FrameBufFormat());
|
||||
ReplaceAlphaType stencilToAlpha = ReplaceAlphaWithStencil(replaceBlend);
|
||||
|
||||
// All texfuncs except replace are the same for RGB as for RGBA with full alpha.
|
||||
|
|
|
@ -160,7 +160,7 @@ private:
|
|||
|
||||
void ApplyDrawState(int prim);
|
||||
void ApplyDrawStateLate(bool applyStencilRef, uint8_t stencilRef);
|
||||
void ResetShaderBlending();
|
||||
void ResetFramebufferRead();
|
||||
|
||||
ID3D11InputLayout *SetupDecFmtForDraw(D3D11VertexShader *vshader, const DecVtxFormat &decFmt, u32 pspFmt);
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ static const D3D11_LOGIC_OP logicOps[] = {
|
|||
D3D11_LOGIC_OP_SET,
|
||||
};
|
||||
|
||||
void DrawEngineD3D11::ResetShaderBlending() {
|
||||
void DrawEngineD3D11::ResetFramebufferRead() {
|
||||
if (fboTexBound_) {
|
||||
ID3D11ShaderResourceView *srv = nullptr;
|
||||
context_->PSSetShaderResources(0, 1, &srv);
|
||||
|
@ -144,7 +144,7 @@ void DrawEngineD3D11::ApplyDrawState(int prim) {
|
|||
bool useBufferedRendering = framebufferManager_->UseBufferedRendering();
|
||||
// Blend
|
||||
if (gstate_c.IsDirty(DIRTY_BLEND_STATE)) {
|
||||
gstate_c.SetAllowShaderBlend(!g_Config.bDisableSlowFramebufEffects);
|
||||
gstate_c.SetAllowFramebufferRead(!g_Config.bDisableSlowFramebufEffects);
|
||||
if (gstate.isModeClear()) {
|
||||
keys_.blend.value = 0; // full wipe
|
||||
keys_.blend.blendEnable = false;
|
||||
|
@ -157,18 +157,18 @@ void DrawEngineD3D11::ApplyDrawState(int prim) {
|
|||
keys_.blend.value = 0;
|
||||
// Set blend - unless we need to do it in the shader.
|
||||
GenericBlendState blendState;
|
||||
ConvertBlendState(blendState, gstate_c.allowShaderBlend);
|
||||
if (blendState.applyShaderBlending) {
|
||||
ConvertBlendState(blendState, gstate_c.allowFramebufferRead);
|
||||
if (blendState.applyFramebufferRead) {
|
||||
if (ApplyShaderBlending()) {
|
||||
// We may still want to do something about stencil -> alpha.
|
||||
ApplyStencilReplaceAndLogicOp(blendState.replaceAlphaWithStencil, blendState);
|
||||
} else {
|
||||
// Until next time, force it off.
|
||||
ResetShaderBlending();
|
||||
gstate_c.SetAllowShaderBlend(false);
|
||||
ResetFramebufferRead();
|
||||
gstate_c.SetAllowFramebufferRead(false);
|
||||
}
|
||||
} else if (blendState.resetShaderBlending) {
|
||||
ResetShaderBlending();
|
||||
} else if (blendState.resetFramebufferRead) {
|
||||
ResetFramebufferRead();
|
||||
}
|
||||
|
||||
if (blendState.enabled) {
|
||||
|
@ -180,7 +180,7 @@ void DrawEngineD3D11::ApplyDrawState(int prim) {
|
|||
keys_.blend.srcAlpha = d3d11BlendFactorLookup[(size_t)blendState.srcAlpha];
|
||||
keys_.blend.destColor = d3d11BlendFactorLookup[(size_t)blendState.dstColor];
|
||||
keys_.blend.destAlpha = d3d11BlendFactorLookup[(size_t)blendState.dstAlpha];
|
||||
if (blendState.dirtyShaderBlend) {
|
||||
if (blendState.dirtyShaderBlendFixValues) {
|
||||
gstate_c.Dirty(DIRTY_SHADERBLEND);
|
||||
}
|
||||
dynState_.useBlendColor = blendState.useBlendColor;
|
||||
|
|
|
@ -115,8 +115,8 @@ void DrawEngineDX9::ApplyDrawState(int prim) {
|
|||
|
||||
if (gstate_c.IsDirty(DIRTY_BLEND_STATE)) {
|
||||
gstate_c.Clean(DIRTY_BLEND_STATE);
|
||||
// Unfortunately, this isn't implemented yet.
|
||||
gstate_c.SetAllowShaderBlend(false);
|
||||
// Unfortunately, this isn't implemented on DX9 yet.
|
||||
gstate_c.SetAllowFramebufferRead(false);
|
||||
if (gstate.isModeClear()) {
|
||||
dxstate.blend.disable();
|
||||
|
||||
|
@ -127,18 +127,18 @@ void DrawEngineDX9::ApplyDrawState(int prim) {
|
|||
} else {
|
||||
// Set blend - unless we need to do it in the shader.
|
||||
GenericBlendState blendState;
|
||||
ConvertBlendState(blendState, gstate_c.allowShaderBlend);
|
||||
ConvertBlendState(blendState, gstate_c.allowFramebufferRead);
|
||||
|
||||
if (blendState.applyShaderBlending) {
|
||||
if (blendState.applyFramebufferRead) {
|
||||
if (ApplyShaderBlending()) {
|
||||
// We may still want to do something about stencil -> alpha.
|
||||
ApplyStencilReplaceAndLogicOp(blendState.replaceAlphaWithStencil, blendState);
|
||||
} else {
|
||||
// Until next time, force it off.
|
||||
ResetShaderBlending();
|
||||
gstate_c.SetAllowShaderBlend(false);
|
||||
gstate_c.SetAllowFramebufferRead(false);
|
||||
}
|
||||
} else if (blendState.resetShaderBlending) {
|
||||
} else if (blendState.resetFramebufferRead) {
|
||||
ResetShaderBlending();
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ void DrawEngineDX9::ApplyDrawState(int prim) {
|
|||
dxstate.blendFunc.set(
|
||||
dxBlendFactorLookup[(size_t)blendState.srcColor], dxBlendFactorLookup[(size_t)blendState.dstColor],
|
||||
dxBlendFactorLookup[(size_t)blendState.srcAlpha], dxBlendFactorLookup[(size_t)blendState.dstAlpha]);
|
||||
if (blendState.dirtyShaderBlend) {
|
||||
if (blendState.dirtyShaderBlendFixValues) {
|
||||
gstate_c.Dirty(DIRTY_SHADERBLEND);
|
||||
}
|
||||
if (blendState.useBlendColor) {
|
||||
|
|
|
@ -156,7 +156,7 @@ void DrawEngineGLES::ApplyDrawState(int prim) {
|
|||
|
||||
if (gstate_c.IsDirty(DIRTY_BLEND_STATE)) {
|
||||
gstate_c.Clean(DIRTY_BLEND_STATE);
|
||||
gstate_c.SetAllowShaderBlend(!g_Config.bDisableSlowFramebufEffects);
|
||||
gstate_c.SetAllowFramebufferRead(!g_Config.bDisableSlowFramebufEffects);
|
||||
|
||||
if (gstate.isModeClear()) {
|
||||
// Color Test
|
||||
|
@ -167,9 +167,9 @@ void DrawEngineGLES::ApplyDrawState(int prim) {
|
|||
// Do the large chunks of state conversion. We might be able to hide these two behind a dirty-flag each,
|
||||
// to avoid recomputing heavy stuff unnecessarily every draw call.
|
||||
GenericBlendState blendState;
|
||||
ConvertBlendState(blendState, gstate_c.allowShaderBlend);
|
||||
ConvertBlendState(blendState, gstate_c.allowFramebufferRead);
|
||||
|
||||
if (blendState.applyShaderBlending) {
|
||||
if (blendState.applyFramebufferRead) {
|
||||
if (ApplyShaderBlending()) {
|
||||
// We may still want to do something about stencil -> alpha.
|
||||
ApplyStencilReplaceAndLogicOp(blendState.replaceAlphaWithStencil, blendState);
|
||||
|
@ -191,14 +191,15 @@ void DrawEngineGLES::ApplyDrawState(int prim) {
|
|||
} else {
|
||||
// Until next time, force it off.
|
||||
ResetShaderBlending();
|
||||
gstate_c.SetAllowShaderBlend(false);
|
||||
gstate_c.SetAllowFramebufferRead(false);
|
||||
}
|
||||
} else if (blendState.resetShaderBlending) {
|
||||
} else if (blendState.resetFramebufferRead) {
|
||||
ResetShaderBlending();
|
||||
}
|
||||
|
||||
if (blendState.enabled) {
|
||||
if (blendState.dirtyShaderBlend) {
|
||||
if (blendState.dirtyShaderBlendFixValues) {
|
||||
// Not quite sure how necessary this is.
|
||||
gstate_c.Dirty(DIRTY_SHADERBLEND);
|
||||
}
|
||||
if (blendState.useBlendColor) {
|
||||
|
|
|
@ -540,9 +540,9 @@ struct GPUStateCache {
|
|||
Dirty(DIRTY_TEXCLAMP);
|
||||
}
|
||||
}
|
||||
void SetAllowShaderBlend(bool allow) {
|
||||
if (allowShaderBlend != allow) {
|
||||
allowShaderBlend = allow;
|
||||
void SetAllowFramebufferRead(bool allow) {
|
||||
if (allowFramebufferRead != allow) {
|
||||
allowFramebufferRead = allow;
|
||||
Dirty(DIRTY_FRAGMENTSHADER_STATE);
|
||||
}
|
||||
}
|
||||
|
@ -564,7 +564,7 @@ struct GPUStateCache {
|
|||
|
||||
bool bgraTexture;
|
||||
bool needShaderTexClamp;
|
||||
bool allowShaderBlend;
|
||||
bool allowFramebufferRead;
|
||||
|
||||
float morphWeights[8];
|
||||
u32 deferredVertTypeDirty;
|
||||
|
|
|
@ -135,7 +135,7 @@ void DrawEngineVulkan::ConvertStateToVulkanKey(FramebufferManagerVulkan &fbManag
|
|||
bool useBufferedRendering = framebufferManager_->UseBufferedRendering();
|
||||
|
||||
if (gstate_c.IsDirty(DIRTY_BLEND_STATE)) {
|
||||
gstate_c.SetAllowShaderBlend(!g_Config.bDisableSlowFramebufEffects);
|
||||
gstate_c.SetAllowFramebufferRead(!g_Config.bDisableSlowFramebufEffects);
|
||||
if (gstate.isModeClear()) {
|
||||
key.logicOpEnable = false;
|
||||
key.logicOp = VK_LOGIC_OP_CLEAR;
|
||||
|
@ -163,20 +163,20 @@ void DrawEngineVulkan::ConvertStateToVulkanKey(FramebufferManagerVulkan &fbManag
|
|||
|
||||
// Set blend - unless we need to do it in the shader.
|
||||
GenericBlendState blendState;
|
||||
ConvertBlendState(blendState, gstate_c.allowShaderBlend);
|
||||
ConvertBlendState(blendState, gstate_c.allowFramebufferRead);
|
||||
|
||||
if (blendState.applyShaderBlending) {
|
||||
if (blendState.applyFramebufferRead) {
|
||||
if (ApplyShaderBlending()) {
|
||||
// We may still want to do something about stencil -> alpha.
|
||||
ApplyStencilReplaceAndLogicOp(blendState.replaceAlphaWithStencil, blendState);
|
||||
} else {
|
||||
// Until next time, force it off.
|
||||
ResetShaderBlending();
|
||||
gstate_c.SetAllowShaderBlend(false);
|
||||
gstate_c.SetAllowFramebufferRead(false);
|
||||
// Make sure we recompute the fragment shader ID to one that doesn't try to use shader blending.
|
||||
gstate_c.Dirty(DIRTY_FRAGMENTSHADER_STATE);
|
||||
}
|
||||
} else if (blendState.resetShaderBlending) {
|
||||
} else if (blendState.resetFramebufferRead) {
|
||||
ResetShaderBlending();
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ void DrawEngineVulkan::ConvertStateToVulkanKey(FramebufferManagerVulkan &fbManag
|
|||
key.srcAlpha = vkBlendFactorLookup[(size_t)blendState.srcAlpha];
|
||||
key.destColor = vkBlendFactorLookup[(size_t)blendState.dstColor];
|
||||
key.destAlpha = vkBlendFactorLookup[(size_t)blendState.dstAlpha];
|
||||
if (blendState.dirtyShaderBlend) {
|
||||
if (blendState.dirtyShaderBlendFixValues) {
|
||||
gstate_c.Dirty(DIRTY_SHADERBLEND);
|
||||
}
|
||||
dynState.useBlendColor = blendState.useBlendColor;
|
||||
|
|
Loading…
Add table
Reference in a new issue