aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs
diff options
context:
space:
mode:
authorriperiperi <rhy3756547@hotmail.com>2022-05-12 14:47:13 +0100
committerGitHub <noreply@github.com>2022-05-12 10:47:13 -0300
commit43b4b34376cdea486906f8bb4058dda3be7e1bd8 (patch)
tree66e11982136335f0d7b180f9234b326ee5b3bf10 /Ryujinx.Graphics.Shader/Translation/EmitterContext.cs
parent92ca1cb0cbab228e5ef22645cd4f9d06b1da4766 (diff)
Implement Viewport Transform Disable (#3328)
* Initial implementation (no specialization) * Use specialization * Fix render scale, increase code gen version * Revert accidental change * Address Feedback
Diffstat (limited to 'Ryujinx.Graphics.Shader/Translation/EmitterContext.cs')
-rw-r--r--Ryujinx.Graphics.Shader/Translation/EmitterContext.cs49
1 files changed, 48 insertions, 1 deletions
diff --git a/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs b/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs
index 775f1217..ba3b551d 100644
--- a/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs
+++ b/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs
@@ -154,9 +154,56 @@ namespace Ryujinx.Graphics.Shader.Translation
return label;
}
+ public void PrepareForVertexReturn()
+ {
+ if (Config.GpuAccessor.QueryViewportTransformDisable())
+ {
+ Operand x = Attribute(AttributeConsts.PositionX | AttributeConsts.LoadOutputMask);
+ Operand y = Attribute(AttributeConsts.PositionY | AttributeConsts.LoadOutputMask);
+ Operand xScale = Attribute(AttributeConsts.SupportBlockViewInverseX);
+ Operand yScale = Attribute(AttributeConsts.SupportBlockViewInverseY);
+ Operand negativeOne = ConstF(-1.0f);
+
+ this.Copy(Attribute(AttributeConsts.PositionX), this.FPFusedMultiplyAdd(x, xScale, negativeOne));
+ this.Copy(Attribute(AttributeConsts.PositionY), this.FPFusedMultiplyAdd(y, yScale, negativeOne));
+ }
+ }
+
+ public void PrepareForVertexReturn(out Operand oldXLocal, out Operand oldYLocal, out Operand oldZLocal)
+ {
+ if (Config.GpuAccessor.QueryViewportTransformDisable())
+ {
+ oldXLocal = Local();
+ this.Copy(oldXLocal, Attribute(AttributeConsts.PositionX | AttributeConsts.LoadOutputMask));
+ oldYLocal = Local();
+ this.Copy(oldYLocal, Attribute(AttributeConsts.PositionY | AttributeConsts.LoadOutputMask));
+ }
+ else
+ {
+ oldXLocal = null;
+ oldYLocal = null;
+ }
+
+ // Will be used by Vulkan backend for depth mode emulation.
+ oldZLocal = null;
+
+ PrepareForVertexReturn();
+ }
+
public void PrepareForReturn()
{
- if (!IsNonMain && Config.Stage == ShaderStage.Fragment)
+ if (IsNonMain)
+ {
+ return;
+ }
+
+ if (Config.LastInVertexPipeline &&
+ (Config.Stage == ShaderStage.Vertex || Config.Stage == ShaderStage.TessellationEvaluation) &&
+ (Config.Options.Flags & TranslationFlags.VertexA) == 0)
+ {
+ PrepareForVertexReturn();
+ }
+ else if (Config.Stage == ShaderStage.Fragment)
{
if (Config.OmapDepth)
{