Uniformity analysis
Bento proves how widely every value is shared and checks derivatives, simdgroup operations, and bindless indices against it.
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.
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,
}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
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.
Bento proves how widely every value is shared and checks derivatives, simdgroup operations, and bindless indices against it.
Bento inserts a barrier wherever workgroup memory written by one thread is read by another.
Built-in values are available at any depth of the call chain through checked with clauses, without any globals.
Generics have built-in bounds and structural interfaces, are type checked once, and can be exported through bytecode.
Every reference type includes its memory space. Buffers and workgroup memory can be passed to functions.
Arithmetic is strict IEEE 754 by default and can be loosened with math flags for any block, any function, or the whole shader.
| Bento | Slang | GLSL, HLSL, WGSL | |
|---|---|---|---|
| Output | Lowered by Shokado straight to SPIR-V, AIR, DXIL, or GLSL | SPIR-V directly, DXIL through DXC, and MSL, HLSL, GLSL, or WGSL source | glslang, DXC, Tint, or a transpiler in between |
| Reuse | Modules, imports, and a linker | Modules, precompiled modules, and #include | #include |
| Variants | Features with checked requires clauses, const if, const for, and generics | Generics, interfaces, link-time specialization, and preprocessor macros | Preprocessor macros |
| Uniformity | Proven for every value and checked across modules | Opt-in checks of values marked dynamic_uniform by hand | Unchecked in GLSL and HLSL but checked for derivatives and barriers in WGSL |
| Barriers | Inserted automatically | Written by hand | Written by hand |
| Built-ins | Context parameters checked per stage | Semantics as in HLSL | Globals or semantics |
| Buffers in functions | References with a memory space | Resource parameters and pointers | Not allowed in GLSL |
| Results | Multiple return values | out parameters and tuples | out parameters |
| Embedding | One C library without dependencies | Large C++ code base, with DXC for DXIL | Large C++ code bases |
| Access | Every stage public, down to the IR | Reflection API, IR internal | Source in, code out |