A shading language that understands the GPU.

Bento is a fresh take on what a shading language could look like if we got to start over and actually learnt from past mistakes. It compiles to Shokado IR and inherits every target, tool, and optimization Shokado has.

Language tour Getting started Uber shaders

enum Model { Lambert, Phong, Toon }
domain SampleCount : u32 { 1, 2, 4, 8 }
domain PassCount : u32 { 1..=4 }

feature Lighting {
	Shadows:  b32,
	Cascades: b32 requires Shadows,
	Specular: b32,
}

feature Quality {
	Shading: Model,
	Samples: SampleCount,
	Passes:  PassCount requires Passes == 1 || Lighting.Shadows,
}

Language

Barriers, subgroups, uniformity, and uber shaders are concepts built into the language rather than thinly typed intrinsics and macros bolted onto C. Language tour, Uber shaders

Uber shaders

Features are declared once and read as constants anywhere. Bento checks every variant the requires clauses allow when the source is compiled and builds exactly those variants, from IR that is compiled only once.

Uniformity analysis

Bento proves how widely every value is shared and checks derivatives, simdgroup operations, and bindless indices against it.

Automatic barriers

Bento inserts a barrier wherever workgroup memory written by one thread is read by another.

Context parameters

Built-in values are available at any depth of the call chain through checked with clauses, without any globals.

Generics

Generics have built-in bounds and structural interfaces, are type checked once, and can be exported through bytecode.

Memory spaces

Every reference type includes its memory space. Buffers and workgroup memory can be passed to functions.

Floating point that works

Arithmetic is strict IEEE 754 by default and can be loosened with math flags for any block, any function, or the whole shader.

Comparison with GLSL, HLSL, WGSL, and Slang

BentoSlangGLSL, HLSL, WGSL
OutputLowered by Shokado straight to SPIR-V, AIR, DXIL, or GLSLSPIR-V directly, DXIL through DXC, and MSL, HLSL, GLSL, or WGSL sourceglslang, DXC, Tint, or a transpiler in between
ReuseModules, imports, and a linkerModules, precompiled modules, and #include#include
VariantsFeatures with checked requires clauses, const if, const for, and genericsGenerics, interfaces, link-time specialization, and preprocessor macrosPreprocessor macros
UniformityProven for every value and checked across modulesOpt-in checks of values marked dynamic_uniform by handUnchecked in GLSL and HLSL but checked for derivatives and barriers in WGSL
BarriersInserted automaticallyWritten by handWritten by hand
Built-insContext parameters checked per stageSemantics as in HLSLGlobals or semantics
Buffers in functionsReferences with a memory spaceResource parameters and pointersNot allowed in GLSL
ResultsMultiple return valuesout parameters and tuplesout parameters
EmbeddingOne C library without dependenciesLarge C++ code base, with DXC for DXILLarge C++ code bases
AccessEvery stage public, down to the IRReflection API, IR internalSource in, code out

Rationale

“What's frustrating about shading languages today is how little of the GPU is actually reflected in the language design.”

The rationale is about the lessons from past mistakes and why Bento is built on infrastructure of its own. Status is on the roadmap.