aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/IoMap.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ryujinx.Graphics.Shader/CodeGen/Spirv/IoMap.cs')
-rw-r--r--src/Ryujinx.Graphics.Shader/CodeGen/Spirv/IoMap.cs39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/IoMap.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/IoMap.cs
index 8a610323..08d403e2 100644
--- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/IoMap.cs
+++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/IoMap.cs
@@ -1,5 +1,6 @@
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
using Ryujinx.Graphics.Shader.Translation;
+using System;
using static Spv.Specification;
namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
@@ -80,5 +81,43 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
return false;
}
+
+ public static bool IsPerVertexBuiltIn(IoVariable ioVariable)
+ {
+ switch (ioVariable)
+ {
+ case IoVariable.Position:
+ case IoVariable.PointSize:
+ case IoVariable.ClipDistance:
+ return true;
+ }
+
+ return false;
+ }
+
+ public static bool IsPerVertexArrayBuiltIn(StorageKind storageKind, ShaderStage stage)
+ {
+ if (storageKind == StorageKind.Output)
+ {
+ return stage == ShaderStage.TessellationControl;
+ }
+ else
+ {
+ return stage == ShaderStage.TessellationControl ||
+ stage == ShaderStage.TessellationEvaluation ||
+ stage == ShaderStage.Geometry;
+ }
+ }
+
+ public static int GetPerVertexStructFieldIndex(IoVariable ioVariable)
+ {
+ return ioVariable switch
+ {
+ IoVariable.Position => 0,
+ IoVariable.PointSize => 1,
+ IoVariable.ClipDistance => 2,
+ _ => throw new ArgumentException($"Invalid built-in variable {ioVariable}.")
+ };
+ }
}
}