Avoid recomputing the shaderblend setup in ComputeFragmentShaderID.
This commit is contained in:
parent
0fe064d970
commit
fd6ab4c495
3 changed files with 11 additions and 10 deletions
|
@ -1085,7 +1085,6 @@ void ConvertBlendState(GenericBlendState &blendState, bool allowFramebufferRead,
|
||||||
blendState.applyFramebufferRead = false;
|
blendState.applyFramebufferRead = false;
|
||||||
blendState.dirtyShaderBlendFixValues = false;
|
blendState.dirtyShaderBlendFixValues = false;
|
||||||
blendState.useBlendColor = false;
|
blendState.useBlendColor = false;
|
||||||
blendState.replaceAlphaWithStencil = REPLACE_ALPHA_NO;
|
|
||||||
|
|
||||||
ReplaceBlendType replaceBlend = ReplaceBlendWithShader(allowFramebufferRead, gstate_c.framebufFormat);
|
ReplaceBlendType replaceBlend = ReplaceBlendWithShader(allowFramebufferRead, gstate_c.framebufFormat);
|
||||||
if (forceReplaceBlend) {
|
if (forceReplaceBlend) {
|
||||||
|
@ -1094,6 +1093,8 @@ void ConvertBlendState(GenericBlendState &blendState, bool allowFramebufferRead,
|
||||||
blendState.replaceBlend = replaceBlend;
|
blendState.replaceBlend = replaceBlend;
|
||||||
|
|
||||||
ReplaceAlphaType replaceAlphaWithStencil = ReplaceAlphaWithStencil(replaceBlend);
|
ReplaceAlphaType replaceAlphaWithStencil = ReplaceAlphaWithStencil(replaceBlend);
|
||||||
|
blendState.replaceAlphaWithStencil = replaceAlphaWithStencil;
|
||||||
|
|
||||||
bool usePreSrc = false;
|
bool usePreSrc = false;
|
||||||
|
|
||||||
bool blueToAlpha = false;
|
bool blueToAlpha = false;
|
||||||
|
@ -1115,7 +1116,6 @@ void ConvertBlendState(GenericBlendState &blendState, bool allowFramebufferRead,
|
||||||
blendState.blendEnabled = true;
|
blendState.blendEnabled = true;
|
||||||
blendState.applyFramebufferRead = true;
|
blendState.applyFramebufferRead = true;
|
||||||
blendState.resetFramebufferRead = false;
|
blendState.resetFramebufferRead = false;
|
||||||
blendState.replaceAlphaWithStencil = replaceAlphaWithStencil;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REPLACE_BLEND_PRE_SRC:
|
case REPLACE_BLEND_PRE_SRC:
|
||||||
|
|
|
@ -263,15 +263,15 @@ void ComputeFragmentShaderID(FShaderID *id_out, const ComputedPipelineState &pip
|
||||||
bool doFlatShading = gstate.getShadeMode() == GE_SHADE_FLAT;
|
bool doFlatShading = gstate.getShadeMode() == GE_SHADE_FLAT;
|
||||||
bool useShaderDepal = gstate_c.useShaderDepal;
|
bool useShaderDepal = gstate_c.useShaderDepal;
|
||||||
bool useSmoothedDepal = gstate_c.useSmoothedShaderDepal;
|
bool useSmoothedDepal = gstate_c.useSmoothedShaderDepal;
|
||||||
bool colorWriteMask = IsColorWriteMaskComplex(gstate_c.allowFramebufferRead);
|
bool colorWriteMask = pipelineState.maskState.applyFramebufferRead;
|
||||||
|
|
||||||
// Note how we here recompute some of the work already done in state mapping.
|
ReplaceBlendType replaceBlend = pipelineState.blendState.replaceBlend;
|
||||||
// Not ideal! At least we share the code.
|
ReplaceAlphaType stencilToAlpha = pipelineState.blendState.replaceAlphaWithStencil;
|
||||||
ReplaceBlendType replaceBlend = ReplaceBlendWithShader(gstate_c.allowFramebufferRead, gstate_c.framebufFormat);
|
|
||||||
if (colorWriteMask) {
|
// For debugging, can probably delete soon.
|
||||||
replaceBlend = REPLACE_BLEND_READ_FRAMEBUFFER;
|
// _assert_(colorWriteMask == IsColorWriteMaskComplex(gstate_c.allowFramebufferRead));
|
||||||
}
|
// _assert_(replaceBlend == ReplaceBlendWithShader(gstate_c.allowFramebufferRead, gstate_c.framebufFormat);
|
||||||
ReplaceAlphaType stencilToAlpha = ReplaceAlphaWithStencil(replaceBlend);
|
// _assert_(stencilToAlpha == ReplaceAlphaWithStencil(replaceBlend));
|
||||||
|
|
||||||
// All texfuncs except replace are the same for RGB as for RGBA with full alpha.
|
// All texfuncs except replace are the same for RGB as for RGBA with full alpha.
|
||||||
// Note that checking this means that we must dirty the fragment shader ID whenever textureFullAlpha changes.
|
// Note that checking this means that we must dirty the fragment shader ID whenever textureFullAlpha changes.
|
||||||
|
|
|
@ -169,6 +169,7 @@ void DrawEngineVulkan::ConvertStateToVulkanKey(FramebufferManagerVulkan &fbManag
|
||||||
if (blendState.applyFramebufferRead || maskState.applyFramebufferRead) {
|
if (blendState.applyFramebufferRead || maskState.applyFramebufferRead) {
|
||||||
ApplyFramebufferRead(&fboTexNeedsBind_);
|
ApplyFramebufferRead(&fboTexNeedsBind_);
|
||||||
// The shader takes over the responsibility for blending, so recompute.
|
// The shader takes over the responsibility for blending, so recompute.
|
||||||
|
// We might still end up using blend to write something to alpha.
|
||||||
ApplyStencilReplaceAndLogicOpIgnoreBlend(blendState.replaceAlphaWithStencil, blendState);
|
ApplyStencilReplaceAndLogicOpIgnoreBlend(blendState.replaceAlphaWithStencil, blendState);
|
||||||
dirtyRequiresRecheck_ |= DIRTY_FRAGMENTSHADER_STATE;
|
dirtyRequiresRecheck_ |= DIRTY_FRAGMENTSHADER_STATE;
|
||||||
gstate_c.Dirty(DIRTY_FRAGMENTSHADER_STATE);
|
gstate_c.Dirty(DIRTY_FRAGMENTSHADER_STATE);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue