diff options
| author | riperiperi <rhy3756547@hotmail.com> | 2022-05-12 14:47:13 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-12 10:47:13 -0300 |
| commit | 43b4b34376cdea486906f8bb4058dda3be7e1bd8 (patch) | |
| tree | 66e11982136335f0d7b180f9234b326ee5b3bf10 /Ryujinx.Graphics.Shader/Translation | |
| parent | 92ca1cb0cbab228e5ef22645cd4f9d06b1da4766 (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')
| -rw-r--r-- | Ryujinx.Graphics.Shader/Translation/AttributeConsts.cs | 3 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Shader/Translation/EmitterContext.cs | 49 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs | 7 |
3 files changed, 58 insertions, 1 deletions
diff --git a/Ryujinx.Graphics.Shader/Translation/AttributeConsts.cs b/Ryujinx.Graphics.Shader/Translation/AttributeConsts.cs index 370af009..ada60ab9 100644 --- a/Ryujinx.Graphics.Shader/Translation/AttributeConsts.cs +++ b/Ryujinx.Graphics.Shader/Translation/AttributeConsts.cs @@ -67,6 +67,9 @@ namespace Ryujinx.Graphics.Shader.Translation public const int FragmentOutputIsBgraBase = 0x1000100; public const int FragmentOutputIsBgraEnd = FragmentOutputIsBgraBase + 8 * 4; + public const int SupportBlockViewInverseX = 0x1000200; + public const int SupportBlockViewInverseY = 0x1000204; + public const int ThreadIdX = 0x2000000; public const int ThreadIdY = 0x2000004; public const int ThreadIdZ = 0x2000008; 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) { diff --git a/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs b/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs index 23b8b951..27d72cd5 100644 --- a/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs +++ b/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs @@ -14,6 +14,7 @@ namespace Ryujinx.Graphics.Shader.Translation public ShaderStage Stage { get; } public bool GpPassthrough { get; } + public bool LastInVertexPipeline { get; private set; } public int ThreadsPerInputPrimitive { get; } @@ -135,6 +136,7 @@ namespace Ryujinx.Graphics.Shader.Translation OmapSampleMask = header.OmapSampleMask; OmapDepth = header.OmapDepth; TransformFeedbackEnabled = gpuAccessor.QueryTransformFeedbackEnabled(); + LastInVertexPipeline = header.Stage < ShaderStage.Fragment; } public int GetDepthRegister() @@ -274,6 +276,11 @@ namespace Ryujinx.Graphics.Shader.Translation NextInputAttributesPerPatchComponents = config.ThisInputAttributesPerPatchComponents; NextUsesFixedFuncAttributes = config.UsedFeatures.HasFlag(FeatureFlags.FixedFuncAttr); MergeOutputUserAttributes(config.UsedInputAttributes, config.UsedInputAttributesPerPatch); + + if (config.Stage != ShaderStage.Fragment) + { + LastInVertexPipeline = false; + } } public void MergeOutputUserAttributes(int mask, int maskPerPatch) |
