Skip to content

Annotations

Annotations appear immediately before the declaration they annotate. Multiple annotations can be stacked.

@location

Specifies the layout location for interface block fields.

axsl
@location(0) vec3 a_pos;
@location(1) vec2 a_uv;

Emits:

glsl
layout(location = 0) vec3 a_pos;
layout(location = 1) vec2 a_uv;

Applies to: Interface block fields (inputs/outputs)

@binding

Specifies the binding point for uniforms and buffers.

axsl
@binding(0) uniform mat4 u_mvp;
@binding(1) uniform sampler2D u_texture;

Emits:

glsl
layout(binding = 0) uniform mat4 u_mvp;
layout(binding = 1) uniform sampler2D u_texture;

Applies to: Uniform declarations, uniform blocks, buffer blocks

@std430

Specifies the std430 memory layout for uniform/buffer blocks. This is the packed layout typically used for SSBOs (Shader Storage Buffer Objects).

axsl
@std430 @binding(0) buffer InstanceBuffer {
    mat4 models[];
} instances;

Emits:

glsl
layout(std430, binding = 0) buffer InstanceBuffer {
    mat4 models[];
} instances;

Applies to: Uniform blocks, buffer blocks

@std140

Specifies the std140 memory layout for uniform blocks. This is the standard layout with strict alignment rules, typically used for UBOs (Uniform Buffer Objects).

axsl
@std140 @binding(0) uniform CameraData {
    mat4 view;
    mat4 projection;
} camera;

Emits:

glsl
layout(std140, binding = 0) uniform CameraData {
    mat4 view;
    mat4 projection;
} camera;

Applies to: Uniform blocks, buffer blocks

@set

Reserved for Vulkan descriptor sets. Not currently emitted.

axsl
@set(0) @binding(1) uniform sampler2D u_tex;

Status: Reserved, not implemented

@push_constant

Reserved for Vulkan push constants. Not currently emitted.

axsl
@push_constant uniform PushConstants {
    mat4 model;
} push;

Status: Reserved, not implemented

Multiple Annotations

Annotations can be stacked in any order:

axsl
@std430
@binding(2)
buffer DataBuffer {
    float values[];
} data;

They are combined into a single layout(...) qualifier in the order they appear:

glsl
layout(std430, binding = 2) buffer DataBuffer {
    float values[];
} data;

Annotation Combination

Complete Annotation Flow

Annotation Order

The order of annotations matters when they are emitted to GLSL. By convention, memory layout qualifiers (@std430, @std140) should appear before binding qualifiers:

Recommended:

axsl
@std430 @binding(0)

Also valid:

axsl
@binding(0) @std430

Both emit valid GLSL, but the first form is more conventional.

Complete Example

axsl
@version 450;

@stage vertex {
    // Input attributes with locations
    in Attributes {
        @location(0) vec3 a_pos;
        @location(1) vec2 a_uv;
        @location(2) vec3 a_normal;
    } a;

    // Uniform with binding
    @binding(0) uniform mat4 u_mvp;

    // Buffer with layout and binding
    @std430 @binding(1) buffer InstanceBuffer {
        mat4 models[];
    } instances;

    void main() {
        gl_Position = u_mvp * instances.models[gl_InstanceID] * vec4(a.a_pos, 1.0);
    }
}