Yotsuba Shader
Documentation

Reference

HLSL syntax attributes

Every attribute of the HLSL syntax: system-value semantics such as SV_Position and numthreads, plus cbuffer and register for resources.

Overview#

The HLSL syntax is inspired by HLSL (Direct3D). It contains 31 attributes in the YotsubaShader.HlslSyntax package, whose namespace has the same name. They are generated below from its sources.

C#
using YotsubaShader.HlslSyntax;

public struct VertexOutput
{
    [SV_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.HlslSyntax;

public struct InputExamples
{
    // Barycentric coordinates
    [SV_Barycentrics] public Vector4 BarycentricCoordinates;
    // Global invocation id
    [SV_DispatchThreadID] public UInt3 GlobalInvocationId;
    // Workgroup id
    [SV_GroupID] public UInt3 WorkgroupId;
    // Local invocation index
    [SV_GroupIndex] public uint LocalInvocationIndex;
    // Local invocation id
    [SV_GroupThreadID] public UInt3 LocalInvocationId;
    // Instance index
    [SV_InstanceID] public uint InstanceIndex;
    // Front-facing flag
    [SV_IsFrontFace] public bool FrontFacingFlag;
    // Primitive index
    [SV_PrimitiveID] public uint PrimitiveIndex;
    // Sample index
    [SV_SampleIndex] public uint SampleIndex;
    // Base instance
    [SV_StartInstanceLocation] public uint BaseInstance;
    // Base vertex
    [SV_StartVertexLocation] public uint BaseVertex;
    // Vertex index
    [SV_VertexID] public uint VertexIndex;
}

Input and output attributes#

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

InputOutput.cs
using YotsubaShader.Language;
using YotsubaShader.HlslSyntax;

public struct InputOutputExamples
{
    [BINORMAL] public Vector4 Value1;
    [COLOR] public Vector4 Value2;
    [NORMAL] public Vector4 Value3;
    [POSITION] public Vector4 Value4;
    [SV_ClipDistanceN] public Vector4 Value5;
    // Sample mask
    [SV_Coverage] public uint SampleMask;
    // Clip-space position (vertex output)
    [SV_Position] public Vector4 ClipSpacePosition;
    // Render target layer
    [SV_RenderTargetArrayIndex] public uint RenderTargetLayer;
    // Viewport index
    [SV_ViewportArrayIndex] public uint ViewportIndex;
    [TANGENT] public Vector4 Value10;
    [TEXCOORD] public Vector4 Value11;
}

Output attributes#

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

Output.cs
using YotsubaShader.Language;
using YotsubaShader.HlslSyntax;

public struct OutputExamples
{
    // 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;
    [SV_Target] public Vector4 Value5;
}

Method attributes#

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

Method.cs
using YotsubaShader.Language;
using YotsubaShader.HlslSyntax;

public class MethodExamples
{
    [ShaderStage(Stage.Compute)]
    [numthreads(8, 8, 1)]
    public void NumthreadsExample() { }
}

Resource attributes#

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

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

public class ResourceExamples
{
    [cbuffer] public float Value1;
    [register(RegisterPrefix.b, 0)] public float Value2;

    // The string overload: letter + number
    [register("b1")]
    public float Value3;
}

Supporting types#

Structs, classes and enums used together with the attributes.

Type.cs
using YotsubaShader.Language;
using YotsubaShader.HlslSyntax;

public class Types
{
    public YotsubaShader.HlslSyntax.Resources.ConstantBuffer<float> ConstantBufferGenericValue;
    public YotsubaShader.HlslSyntax.Resources.RegisterPrefix RegisterPrefixValue;
    public YotsubaShader.HlslSyntax.Resources.RWStructuredBuffer<float> RWStructuredBufferGenericValue;
    public YotsubaShader.HlslSyntax.Resources.Types.SamplerComparisonState SamplerComparisonStateValue;
    public YotsubaShader.HlslSyntax.Resources.Types.SamplerState SamplerStateValue;
    public YotsubaShader.HlslSyntax.Resources.StructuredBuffer<float> StructuredBufferGenericValue;
    public YotsubaShader.HlslSyntax.Resources.Types.Texture1D Texture1DValue;
    public YotsubaShader.HlslSyntax.Resources.Types.Texture1D<float> Texture1DGenericValue;
    public YotsubaShader.HlslSyntax.Resources.Types.Texture2D Texture2DValue;
    public YotsubaShader.HlslSyntax.Resources.Types.Texture2D<float> Texture2DGenericValue;
    public YotsubaShader.HlslSyntax.Resources.Types.Texture2DArray Texture2DArrayValue;
    public YotsubaShader.HlslSyntax.Resources.Types.Texture2DArray<float> Texture2DArrayGenericValue;
    public YotsubaShader.HlslSyntax.Resources.Types.Texture2DMS<float> Texture2DMSGenericValue;
    public YotsubaShader.HlslSyntax.Resources.Types.Texture3D Texture3DValue;
    public YotsubaShader.HlslSyntax.Resources.Types.Texture3D<float> Texture3DGenericValue;
    public YotsubaShader.HlslSyntax.Resources.Types.TextureCube TextureCubeValue;
    public YotsubaShader.HlslSyntax.Resources.Types.TextureCube<float> TextureCubeGenericValue;
    public YotsubaShader.HlslSyntax.Resources.Types.TextureCubeArray TextureCubeArrayValue;
    public YotsubaShader.HlslSyntax.Resources.Types.TextureCubeArray<float> TextureCubeArrayGenericValue;
}
Copyright © 2026 Yotsuba Shader contributors · Licensing · GitHub