Current declarations#
namespace YotsubaShader.Language;
public enum Stage
{
Vertex,
Fragment,
Compute
}
namespace YotsubaShader.Language;
[AttributeUsage(AttributeTargets.Method)]
public class ShaderStageAttribute(Stage stage) : YotsubaShaderAttribute
{
public Stage Stage = stage;
}
The public authoring enum contains only Vertex, Fragment, and Compute. Other stages mentioned in the roadmap are not current enum values. Declaring a stage does not imply that its complete body can be compiled.
using Microsoft.Xna.Framework;
using YotsubaShader.Language;
using YotsubaShader.HlslSyntax;
public class BasicColorShader
{
public struct VS_Input
{
[POSITION]
public Vector2 Position;
[COLOR]
public Vector4 Color;
}
public struct VS_Output
{
[SV_Position]
public Vector4 Position;
[COLOR]
public Vector4 Color;
}
[ShaderStage(Stage.Vertex)]
public VS_Output VS(VS_Input input)
{
VS_Output output = new VS_Output();
output.Position = new Vector4(
input.Position.X,
input.Position.Y,
0.0f,
1.0f
);
output.Color = input.Color;
return output;
}
[ShaderStage(Stage.Fragment)]
[return: SV_Target(0)]
public Vector4 FS(VS_Output input)
{
return input.Color;
}
}
Compute declarations#
using YotsubaShader.Language;
using YotsubaShader.HlslSyntax;
public class ComputeShader
{
[ShaderStage(Stage.Compute)]
[numthreads(8, 8, 1)]
public void Main() { }
}
The HLSL, GLSL, and WGSL vocabularies declare numthreads, layout_local_size, and workgroup_size respectively. A declared built-in or workgroup attribute may still lack processing support.
