BESL language reference
The Byte Engine Shader Language, from what a shader file declares to the intrinsics it can call.
Use the Byte Engine Shader Language (BESL) to write shader source that works with the material pipeline, resource reflection, render-model generation, and platform shader generation.
BESL uses Rust-inspired syntax, but it's a separate language. Byte Engine parses the source, resolves it into a semantic graph, applies render-model transformations, and emits code for the active graphics backend.
Check backend support
Byte Engine generates GLSL, HLSL, and MSL. Most BESL is portable, but task stages, image atomics, subgroup operations, and half precision have specific backend or stage requirements. See stage and backend support.
BESL files
A BESL file contains declarations for structs, constants, resource bindings,
helper functions, and a main function. Raster entry points declare their
stage interface in the parameters and return type.
Instance: struct {
position: vec3f,
sprite_id: u32,
}
sprites: descriptor<{ type: Texture2DArray, binding: 0, access: read }>;
instances: descriptor<{ type: Instance[], binding: 1, access: read }>;
main: fn (
input: StageInput,
pipeline_input: interface { instance_index: u32, uv: vec2f },
) -> output { color: vec4f } {
let instance: Instance = instances[pipeline_input.instance_index];
let color: vec4f = sample(sprites[instance.sprite_id], pipeline_input.uv);
return { color };
}The parser records the source structure. The lexer then resolves names, types, members, intrinsics, and references.
Separate fields in structs, interface and output types, and returned records
with commas. You can add a trailing comma. Semicolons still end declarations
and statements, but they aren't valid field separators.
Use this reference
- Language covers declarations, values, and control flow.
- Interface covers stage inputs, outputs, descriptors, shared storage, and stage metadata.
- Intrinsics lists built-in math, texture, image, atomic, compute, task, and mesh operations.
How Byte Engine links, optimizes, reflects, and executes a program is a Contribute design note: Compilation and reflection.