aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/Translation
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2021-08-26 20:44:47 -0300
committerGitHub <noreply@github.com>2021-08-27 01:44:47 +0200
commitee1038e54255797a94b89091f4d59b77daad1a7b (patch)
tree5ea62d8a2bae97004a4abe2ebf0a21c634b912dc /Ryujinx.Graphics.Shader/Translation
parentec3e848d7998038ce22c41acdbf81032bf47991f (diff)
Initial support for shader attribute indexing (#2546)
* Initial support for shader attribute indexing * Support output indexing too, other improvements * Fix order * Address feedback
Diffstat (limited to 'Ryujinx.Graphics.Shader/Translation')
-rw-r--r--Ryujinx.Graphics.Shader/Translation/EmitterContextInsts.cs9
-rw-r--r--Ryujinx.Graphics.Shader/Translation/FeatureFlags.cs4
-rw-r--r--Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs10
-rw-r--r--Ryujinx.Graphics.Shader/Translation/TranslatorContext.cs12
4 files changed, 21 insertions, 14 deletions
diff --git a/Ryujinx.Graphics.Shader/Translation/EmitterContextInsts.cs b/Ryujinx.Graphics.Shader/Translation/EmitterContextInsts.cs
index e5ba04bc..113ece99 100644
--- a/Ryujinx.Graphics.Shader/Translation/EmitterContextInsts.cs
+++ b/Ryujinx.Graphics.Shader/Translation/EmitterContextInsts.cs
@@ -511,9 +511,9 @@ namespace Ryujinx.Graphics.Shader.Translation
return context.Add(Instruction.IsNan, Local(), a);
}
- public static Operand LoadAttribute(this EmitterContext context, Operand a, Operand b)
+ public static Operand LoadAttribute(this EmitterContext context, Operand a, Operand b, Operand c)
{
- return context.Add(Instruction.LoadAttribute, Local(), a, b);
+ return context.Add(Instruction.LoadAttribute, Local(), a, b, c);
}
public static Operand LoadConstant(this EmitterContext context, Operand a, Operand b)
@@ -617,6 +617,11 @@ namespace Ryujinx.Graphics.Shader.Translation
return context.Add(Instruction.ShuffleXor, (Local(), Local()), a, b, c);
}
+ public static Operand StoreAttribute(this EmitterContext context, Operand a, Operand b, Operand c)
+ {
+ return context.Add(Instruction.StoreAttribute, null, a, b, c);
+ }
+
public static Operand StoreGlobal(this EmitterContext context, Operand a, Operand b, Operand c)
{
return context.Add(Instruction.StoreGlobal, null, a, b, c);
diff --git a/Ryujinx.Graphics.Shader/Translation/FeatureFlags.cs b/Ryujinx.Graphics.Shader/Translation/FeatureFlags.cs
index b0c48410..1636afd3 100644
--- a/Ryujinx.Graphics.Shader/Translation/FeatureFlags.cs
+++ b/Ryujinx.Graphics.Shader/Translation/FeatureFlags.cs
@@ -17,6 +17,8 @@ namespace Ryujinx.Graphics.Shader.Translation
Bindless = 1 << 2,
InstanceId = 1 << 3,
- CbIndexing = 1 << 4
+ CbIndexing = 1 << 4,
+ IaIndexing = 1 << 5,
+ OaIndexing = 1 << 6
}
}
diff --git a/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs b/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs
index 02e995f9..f454ceea 100644
--- a/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs
+++ b/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs
@@ -219,6 +219,16 @@ namespace Ryujinx.Graphics.Shader.Translation
}
}
+ public void SetAllInputUserAttributes()
+ {
+ UsedInputAttributes |= Constants.AllAttributesMask;
+ }
+
+ public void SetAllOutputUserAttributes()
+ {
+ UsedOutputAttributes |= Constants.AllAttributesMask;
+ }
+
public void SetClipDistanceWritten(int index)
{
ClipDistancesWritten |= (byte)(1 << index);
diff --git a/Ryujinx.Graphics.Shader/Translation/TranslatorContext.cs b/Ryujinx.Graphics.Shader/Translation/TranslatorContext.cs
index 47cf0ac8..3c7b3c2b 100644
--- a/Ryujinx.Graphics.Shader/Translation/TranslatorContext.cs
+++ b/Ryujinx.Graphics.Shader/Translation/TranslatorContext.cs
@@ -103,17 +103,7 @@ namespace Ryujinx.Graphics.Shader.Translation
if (temp != null)
{
- // TODO: LoadAttribute should accept any integer value as first argument,
- // then we don't need special case here. Right now it expects the first
- // operand to be of type "attribute".
- if ((operation.Inst & Instruction.Mask) == Instruction.LoadAttribute)
- {
- operation.TurnIntoCopy(temp);
- }
- else
- {
- operation.SetSource(srcIndex, temp);
- }
+ operation.SetSource(srcIndex, temp);
}
}
}