aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
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/CodeGen/Glsl/Declarations.cs
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/CodeGen/Glsl/Declarations.cs')
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs36
1 files changed, 26 insertions, 10 deletions
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
index 2a93be32..7b26801a 100644
--- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
+++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
@@ -402,14 +402,23 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
private static void DeclareInputAttributes(CodeGenContext context, StructuredProgramInfo info)
{
- int usedAttribtes = context.Config.UsedInputAttributes;
- while (usedAttribtes != 0)
+ if (context.Config.UsedFeatures.HasFlag(FeatureFlags.IaIndexing))
{
- int index = BitOperations.TrailingZeroCount(usedAttribtes);
+ string suffix = context.Config.Stage == ShaderStage.Geometry ? "[]" : string.Empty;
- DeclareInputAttribute(context, info, index);
+ context.AppendLine($"layout (location = 0) in vec4 {DefaultNames.IAttributePrefix}{suffix}[{Constants.MaxAttributes}];");
+ }
+ else
+ {
+ int usedAttributes = context.Config.UsedInputAttributes;
+ while (usedAttributes != 0)
+ {
+ int index = BitOperations.TrailingZeroCount(usedAttributes);
+
+ DeclareInputAttribute(context, info, index);
- usedAttribtes &= ~(1 << index);
+ usedAttributes &= ~(1 << index);
+ }
}
}
@@ -448,14 +457,21 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
private static void DeclareOutputAttributes(CodeGenContext context, StructuredProgramInfo info)
{
- int usedAttribtes = context.Config.UsedOutputAttributes;
- while (usedAttribtes != 0)
+ if (context.Config.UsedFeatures.HasFlag(FeatureFlags.OaIndexing))
{
- int index = BitOperations.TrailingZeroCount(usedAttribtes);
+ context.AppendLine($"layout (location = 0) out vec4 {DefaultNames.OAttributePrefix}[{Constants.MaxAttributes}];");
+ }
+ else
+ {
+ int usedAttributes = context.Config.UsedOutputAttributes;
+ while (usedAttributes != 0)
+ {
+ int index = BitOperations.TrailingZeroCount(usedAttributes);
- DeclareOutputAttribute(context, index);
+ DeclareOutputAttribute(context, index);
- usedAttribtes &= ~(1 << index);
+ usedAttributes &= ~(1 << index);
+ }
}
}