Yotsuba Shader
Documentation

Reference

Built-in values across syntaxes

The same built-in value, spelled in the HLSL, GLSL, MSL, SPIR-V and WGSL syntaxes.

Overview#

Every built-in value of a syntax, grouped by stage and written as C#. Pick the tab of your syntax. The comment above each member names the concept, so you can find the same value in any other tab.

BuiltIns.cs
using YotsubaShader.Language;
using YotsubaShader.HlslSyntax;

// Vertex stage
public struct VertexBuiltIns
{
    // Clip-space position (vertex output)
    [SV_Position] public Vector4 ClipSpacePosition;

    // Vertex index
    [SV_VertexID] public uint VertexIndex;

    // Instance index
    [SV_InstanceID] public uint InstanceIndex;

    // Base vertex
    [SV_StartVertexLocation] public uint BaseVertex;

    // Base instance
    [SV_StartInstanceLocation] public uint BaseInstance;

    // Clip distance
    [SV_ClipDistanceN] public float ClipDistance;

    // Render target layer
    [SV_RenderTargetArrayIndex] public uint RenderTargetLayer;

    // Viewport index
    [SV_ViewportArrayIndex] public uint ViewportIndex;
}

// Fragment stage
public struct FragmentBuiltIns
{
    // Fragment coordinate
    [SV_Position] public Vector4 FragmentCoordinate;

    // Front-facing flag
    [SV_IsFrontFace] public bool FrontFacingFlag;

    // Fragment depth (output)
    [SV_Depth] public float FragmentDepth;

    // Conservative depth
    [SV_DepthGreaterEqual] public float ConservativeDepth;

    // Conservative depth
    [SV_DepthLessEqual] public float ConservativeDepth2;

    // Stencil reference (output)
    [SV_StencilRef] public uint StencilReference;

    // Sample index
    [SV_SampleIndex] public uint SampleIndex;

    // Sample mask
    [SV_Coverage] public uint SampleMask;

    // Primitive index
    [SV_PrimitiveID] public uint PrimitiveIndex;

    // Barycentric coordinates
    [SV_Barycentrics] public Vector4 BarycentricCoordinates;
}

// Compute stage
public class ComputeBuiltIns
{
    // Global invocation id
    [SV_DispatchThreadID] public UInt3 GlobalInvocationId;

    // Local invocation id
    [SV_GroupThreadID] public UInt3 LocalInvocationId;

    // Local invocation index
    [SV_GroupIndex] public uint LocalInvocationIndex;

    // Workgroup id
    [SV_GroupID] public UInt3 WorkgroupId;

    // Workgroup size (method attribute)
    [ShaderStage(Stage.Compute)]
    [numthreads(8, 8, 1)]
    public void Compute() { }
}

For resources and binding slots, see Resource attributes across syntaxes.

Printable references#

The reference below describes declarations in this checkout; it does not certify backend compatibility.

Use the source-generated attribute pages below as the current reference. Earlier PDF guides and their source archive have not been updated for this API and are no longer linked as current documentation.

Copyright © 2026 Yotsuba Shader contributors · Licensing · GitHub