diff options
author | gdkchan <gab.dark.100@gmail.com> | 2022-03-06 16:42:13 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-06 20:42:13 +0100 |
commit | 0bcbe32367eeada2a5aa7e6bb2edccc22cababa3 (patch) | |
tree | 08b9ac95b8db21a5f505493fdf099c7d80da0c4a /Ryujinx.Graphics.Shader/Translation/Translator.cs | |
parent | b97ff4da5eb67b68400fa1c187524f53407dbb71 (diff) |
Only initialize shader outputs that are actually used on the next stage (#3054)1.1.61
* Only initialize shader outputs that are actually used on the next stage
* Shader cache version bump
Diffstat (limited to 'Ryujinx.Graphics.Shader/Translation/Translator.cs')
-rw-r--r-- | Ryujinx.Graphics.Shader/Translation/Translator.cs | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/Ryujinx.Graphics.Shader/Translation/Translator.cs b/Ryujinx.Graphics.Shader/Translation/Translator.cs index 603b20d6..e594c818 100644 --- a/Ryujinx.Graphics.Shader/Translation/Translator.cs +++ b/Ryujinx.Graphics.Shader/Translation/Translator.cs @@ -214,24 +214,24 @@ namespace Ryujinx.Graphics.Shader.Translation InitializeOutput(context, AttributeConsts.PositionX, perPatch: false); } - int usedAttributes = context.Config.UsedOutputAttributes; - while (usedAttributes != 0) + UInt128 usedAttributes = context.Config.NextInputAttributesComponents; + while (usedAttributes != UInt128.Zero) { - int index = BitOperations.TrailingZeroCount(usedAttributes); + int index = usedAttributes.TrailingZeroCount(); - InitializeOutput(context, AttributeConsts.UserAttributeBase + index * 16, perPatch: false); + InitializeOutputComponent(context, AttributeConsts.UserAttributeBase + index * 4, perPatch: false); - usedAttributes &= ~(1 << index); + usedAttributes &= ~UInt128.Pow2(index); } - int usedAttributesPerPatch = context.Config.UsedOutputAttributesPerPatch; - while (usedAttributesPerPatch != 0) + UInt128 usedAttributesPerPatch = context.Config.NextInputAttributesPerPatchComponents; + while (usedAttributesPerPatch != UInt128.Zero) { - int index = BitOperations.TrailingZeroCount(usedAttributesPerPatch); + int index = usedAttributesPerPatch.TrailingZeroCount(); - InitializeOutput(context, AttributeConsts.UserAttributeBase + index * 16, perPatch: true); + InitializeOutputComponent(context, AttributeConsts.UserAttributeBase + index * 4, perPatch: true); - usedAttributesPerPatch &= ~(1 << index); + usedAttributesPerPatch &= ~UInt128.Pow2(index); } if (config.NextUsesFixedFuncAttributes) @@ -260,6 +260,12 @@ namespace Ryujinx.Graphics.Shader.Translation } } + private static void InitializeOutputComponent(EmitterContext context, int attrOffset, bool perPatch) + { + int c = (attrOffset >> 2) & 3; + context.Copy(perPatch ? AttributePerPatch(attrOffset) : Attribute(attrOffset), ConstF(c == 3 ? 1f : 0f)); + } + private static void EmitOps(EmitterContext context, Block block) { for (int opIndex = 0; opIndex < block.OpCodes.Count; opIndex++) |