diff options
author | gdkchan <gab.dark.100@gmail.com> | 2021-10-18 18:38:04 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-18 18:38:04 -0300 |
commit | d512ce122cb1c9a7fe7cb40d3f85d642ee37f897 (patch) | |
tree | bd20273250bf8066fa4df4b67c0de2ab9eac8092 /Ryujinx.Graphics.Shader/Translation/Translator.cs | |
parent | 7603dbe3c8b45c8563f320f17ce784151cb1f0a8 (diff) |
Initial tessellation shader support (#2534)
* Initial tessellation shader support
* Nits
* Re-arrange built-in table
* This is not needed anymore
* PR feedback
Diffstat (limited to 'Ryujinx.Graphics.Shader/Translation/Translator.cs')
-rw-r--r-- | Ryujinx.Graphics.Shader/Translation/Translator.cs | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/Ryujinx.Graphics.Shader/Translation/Translator.cs b/Ryujinx.Graphics.Shader/Translation/Translator.cs index 0a0ee4a7..0243eba1 100644 --- a/Ryujinx.Graphics.Shader/Translation/Translator.cs +++ b/Ryujinx.Graphics.Shader/Translation/Translator.cs @@ -216,27 +216,38 @@ namespace Ryujinx.Graphics.Shader.Translation return; } - void InitializeOutput(int baseAttr) + if (config.Stage == ShaderStage.Vertex) { - for (int c = 0; c < 4; c++) - { - context.Copy(Attribute(baseAttr + c * 4), ConstF(c == 3 ? 1f : 0f)); - } + InitializeOutput(context, AttributeConsts.PositionX, perPatch: false); } - if (config.Stage == ShaderStage.Vertex) + int usedAttributes = context.Config.UsedOutputAttributes; + while (usedAttributes != 0) { - InitializeOutput(AttributeConsts.PositionX); + int index = BitOperations.TrailingZeroCount(usedAttributes); + + InitializeOutput(context, AttributeConsts.UserAttributeBase + index * 16, perPatch: false); + + usedAttributes &= ~(1 << index); } - int usedAttribtes = context.Config.UsedOutputAttributes; - while (usedAttribtes != 0) + int usedAttributesPerPatch = context.Config.UsedOutputAttributesPerPatch; + while (usedAttributesPerPatch != 0) { - int index = BitOperations.TrailingZeroCount(usedAttribtes); + int index = BitOperations.TrailingZeroCount(usedAttributesPerPatch); - InitializeOutput(AttributeConsts.UserAttributeBase + index * 16); + InitializeOutput(context, AttributeConsts.UserAttributeBase + index * 16, perPatch: true); - usedAttribtes &= ~(1 << index); + usedAttributesPerPatch &= ~(1 << index); + } + } + + private static void InitializeOutput(EmitterContext context, int baseAttr, bool perPatch) + { + for (int c = 0; c < 4; c++) + { + int attrOffset = baseAttr + c * 4; + context.Copy(perPatch ? AttributePerPatch(attrOffset) : Attribute(attrOffset), ConstF(c == 3 ? 1f : 0f)); } } |