summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/RenderState.cpp
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2022-07-17 00:43:16 -0400
committerGitHub <noreply@github.com>2022-07-17 00:43:16 -0400
commit70b0b03c3cd65d90a74f16a5ddd38801da4dce9f (patch)
tree67b24413e6c29e8c530184f34fe3085c42820949 /Source/Core/VideoCommon/RenderState.cpp
parentf1d23ff9a48ce866f9cd391d32eacb4bfb1c244e (diff)
parentfb5648541ce93cf4938dd58e635f7c2d1a3a1569 (diff)
Merge pull request #10747 from tellowkrinkle/LateUIDFixup
Add a post-cache shader UID fixup pass
Diffstat (limited to 'Source/Core/VideoCommon/RenderState.cpp')
-rw-r--r--Source/Core/VideoCommon/RenderState.cpp34
1 files changed, 31 insertions, 3 deletions
diff --git a/Source/Core/VideoCommon/RenderState.cpp b/Source/Core/VideoCommon/RenderState.cpp
index 3b3554b4fe..7df51a1503 100644
--- a/Source/Core/VideoCommon/RenderState.cpp
+++ b/Source/Core/VideoCommon/RenderState.cpp
@@ -25,6 +25,34 @@ void DepthState::Generate(const BPMemory& bp)
func = bp.zmode.func.Value();
}
+static bool IsDualSrc(SrcBlendFactor factor)
+{
+ return factor == SrcBlendFactor::SrcAlpha || factor == SrcBlendFactor::InvSrcAlpha;
+}
+
+static bool IsDualSrc(DstBlendFactor factor)
+{
+ switch (factor)
+ {
+ case DstBlendFactor::SrcClr:
+ case DstBlendFactor::SrcAlpha:
+ case DstBlendFactor::InvSrcClr:
+ case DstBlendFactor::InvSrcAlpha:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool BlendingState::RequiresDualSrc() const
+{
+ bool requires_dual_src = false;
+ requires_dual_src |= IsDualSrc(srcfactor) || IsDualSrc(srcfactoralpha);
+ requires_dual_src |= IsDualSrc(dstfactor) || IsDualSrc(dstfactoralpha);
+ requires_dual_src &= blendenable && usedualsrc;
+ return requires_dual_src;
+}
+
// If the framebuffer format has no alpha channel, it is assumed to
// ONE on blending. As the backends may emulate this framebuffer
// configuration with an alpha channel, we just drop all references
@@ -92,12 +120,12 @@ void BlendingState::Generate(const BPMemory& bp)
// Start with everything disabled.
hex = 0;
- bool target_has_alpha = bp.zcontrol.pixel_format == PixelFormat::RGBA6_Z24;
- bool alpha_test_may_succeed = bp.alpha_test.TestResult() != AlphaTestResult::Fail;
+ const bool target_has_alpha = bp.zcontrol.pixel_format == PixelFormat::RGBA6_Z24;
+ const bool alpha_test_may_succeed = bp.alpha_test.TestResult() != AlphaTestResult::Fail;
colorupdate = bp.blendmode.colorupdate && alpha_test_may_succeed;
alphaupdate = bp.blendmode.alphaupdate && target_has_alpha && alpha_test_may_succeed;
- dstalpha = bp.dstalpha.enable && alphaupdate;
+ const bool dstalpha = bp.dstalpha.enable && alphaupdate;
usedualsrc = true;
// The subtract bit has the highest priority