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:
@@ -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}.")
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user