diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2023-08-16 18:16:25 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-16 23:16:25 +0200 |
| commit | 17354d59d14680258186168c1c462654665ee8c7 (patch) | |
| tree | 0c92f76d961d6a0257fa4c56132b1f1520cfc590 /src/Ryujinx.Graphics.Shader/CodeGen/Spirv/IoMap.cs | |
| parent | 0c445184c185f6cd4b870d88b5eaad46c633b83b (diff) | |
Declare and use gl_PerVertex block for VTG per-vertex built-ins (#5576)
* Declare and use gl_PerVertex block for VTG per-vertex built-ins
* Shader cache version bump
Diffstat (limited to 'src/Ryujinx.Graphics.Shader/CodeGen/Spirv/IoMap.cs')
| -rw-r--r-- | src/Ryujinx.Graphics.Shader/CodeGen/Spirv/IoMap.cs | 39 |
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}.") + }; + } } } |
