diff options
author | gdkchan <gab.dark.100@gmail.com> | 2022-11-11 13:22:49 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-11 13:22:49 -0300 |
commit | 51a27032f01826e0cec56c53da4359fd2c38c8f3 (patch) | |
tree | bc1b27d9a72ec51e6df2a75536885f0292dfc006 /Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs | |
parent | a6a67a2b7add9a9dc8c4f0bab730957b8ebaf6e8 (diff) |
Fix VertexId and InstanceId on Vulkan (#3833)1.1.341
* Fix VertexId and InstanceId on Vulkan
* Shader cache version bump
Diffstat (limited to 'Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs')
-rw-r--r-- | Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs b/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs index 7edf5deb..2f75d248 100644 --- a/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs +++ b/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs @@ -51,7 +51,7 @@ namespace Ryujinx.Graphics.Shader.Instructions offset |= AttributeConsts.LoadOutputMask; } - Operand src = op.P ? AttributePerPatch(offset) : Attribute(offset); + Operand src = op.P ? AttributePerPatch(offset) : CreateInputAttribute(context, offset); context.Copy(Register(rd), src); } @@ -312,5 +312,22 @@ namespace Ryujinx.Graphics.Shader.Instructions return attr; } + + private static Operand CreateInputAttribute(EmitterContext context, int attr) + { + if (context.Config.Options.TargetApi == TargetApi.Vulkan) + { + if (attr == AttributeConsts.InstanceId) + { + return context.ISubtract(Attribute(AttributeConsts.InstanceIndex), Attribute(AttributeConsts.BaseInstance)); + } + else if (attr == AttributeConsts.VertexId) + { + return Attribute(AttributeConsts.VertexIndex); + } + } + + return Attribute(attr); + } } }
\ No newline at end of file |