Yotsuba Shader
Documentation

Reference

GLSL syntax attributes

Every attribute of the GLSL syntax: gl_* built-ins, layout(set, binding), uniform and buffer.

Overview#

The GLSL syntax is inspired by GLSL (OpenGL / Vulkan GLSL). It contains 35 attributes in the YotsubaShader.GlslSyntax package, whose namespace has the same name. They are generated below from its sources.

C#
using YotsubaShader.GlslSyntax;

public struct VertexOutput
{
    [gl_Position]
    public Vector4 Position;
}

These pages list declared attributes. They do not imply that every concept is lowered by Roslyn or supported by every output target. Vector names in the listings require compatible project types.

See the same concepts side by side in Built-in values across syntaxes and Resource attributes across syntaxes.

Input attributes#

Apply to fields, parameters and properties that receive values from the pipeline.

Input.cs
using YotsubaShader.Language;
using YotsubaShader.GlslSyntax;

public struct InputExamples
{
    // Barycentric coordinates
    [gl_BaryCoordEXT] public Vector4 BarycentricCoordinates;
    // Barycentric coordinates (no perspective)
    [gl_BaryCoordNoPerspEXT]
    public Vector4 BarycentricCoordinates2;
    // Base instance
    [gl_BaseInstance] public int BaseInstance;
    // Base vertex
    [gl_BaseVertex] public int BaseVertex;
    // Fragment coordinate
    [gl_FragCoord] public Vector4 FragmentCoordinate;
    // Front-facing flag
    [gl_FrontFacing] public bool FrontFacingFlag;
    // Global invocation id
    [gl_GlobalInvocationID] public UInt3 GlobalInvocationId;
    // Helper invocation
    [gl_HelperInvocation] public bool HelperInvocation;
    // Instance index
    [gl_InstanceIndex] public int InstanceIndex;
    // Local invocation id
    [gl_LocalInvocationID] public UInt3 LocalInvocationId;
    // Local invocation index
    [gl_LocalInvocationIndex] public uint LocalInvocationIndex;
    // Number of subgroups
    [gl_NumSubgroups] public uint NumberOfSubgroups;
    // Number of workgroups
    [gl_NumWorkGroups] public UInt3 NumberOfWorkgroups;
    // Primitive index
    [gl_PrimitiveID] public uint PrimitiveIndex;
    // Sample index
    [gl_SampleID] public uint SampleIndex;
    // Sample mask
    [gl_SampleMaskIn] public uint SampleMask;
    // Sample position
    [gl_SamplePosition] public Vector2 SamplePosition;
    // Subgroup id
    [gl_SubgroupID] public uint SubgroupId;
    // Subgroup invocation id
    [gl_SubgroupInvocationID] public UInt3 SubgroupInvocationId;
    // Subgroup size
    [gl_SubgroupSize] public uint SubgroupSize;
    // Vertex index
    [gl_VertexIndex] public int VertexIndex;
    // Workgroup id
    [gl_WorkGroupID] public UInt3 WorkgroupId;
    // Workgroup size (built-in value)
    [gl_WorkGroupSize] public UInt3 WorkgroupSize;
}

Input and output attributes#

Apply to values that can be received or produced, depending on the stage.

InputOutput.cs
using YotsubaShader.Language;
using YotsubaShader.GlslSyntax;

public struct InputOutputExamples
{
    // Render target layer
    [gl_Layer] public uint RenderTargetLayer;
    // Clip-space position (vertex output)
    [gl_Position] public Vector4 ClipSpacePosition;
    // Viewport index
    [gl_ViewportIndex] public uint ViewportIndex;
    [location(0)] public Vector4 Value4;
}

Output attributes#

Apply to fields, parameters and return values the stage produces.

Output.cs
using YotsubaShader.Language;
using YotsubaShader.GlslSyntax;

public struct OutputExamples
{
    // Clip distance
    [gl_ClipDistance] public float ClipDistance;
    // Fragment depth (output)
    [gl_FragDepth] public float FragmentDepth;
    // Stencil reference (output)
    [gl_FragStencilRefARB] public uint StencilReference;
    // Sample mask
    [gl_SampleMask] public uint SampleMask;
}

Method attributes#

Apply to methods, for example to set a compute workgroup size.

Method.cs
using YotsubaShader.Language;
using YotsubaShader.GlslSyntax;

public class MethodExamples
{
    [ShaderStage(Stage.Compute)]
    [layout_local_size(8)]
    public void Layout_local_sizeExample() { }
}

Resource attributes#

Declare uniforms, buffers, textures, samplers and binding slots.

Resource.cs
using YotsubaShader.Language;
using YotsubaShader.GlslSyntax;
using YotsubaShader.GlslSyntax.Resources;

public class ResourceExamples
{
    [buffer] public float Value1;
    [layout(0, 0)] public float Value2;
    [uniform] public float Value3;
}

Supporting types#

Structs, classes and enums used together with the attributes.

Type.cs
using YotsubaShader.Language;
using YotsubaShader.GlslSyntax;

public class Types
{
    public YotsubaShader.GlslSyntax.Resources.Types.sampler2Array Sampler2ArrayValue;
    public YotsubaShader.GlslSyntax.Resources.Types.sampler2D Sampler2DValue;
    public YotsubaShader.GlslSyntax.Resources.Types.sampler3D Sampler3DValue;
    public YotsubaShader.GlslSyntax.Resources.Types.samplerCube SamplerCubeValue;
}
Copyright © 2026 Yotsuba Shader contributors · Licensing · GitHub