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
This commit is contained in:
gdkchan
2023-08-16 18:16:25 -03:00
committed by GitHub
parent 0c445184c1
commit 17354d59d1
6 changed files with 176 additions and 3 deletions

View File

@@ -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}.")
};
}
}
}