Rust compiler workspace for the VSL 2.0 shader language, SPIR-V 1.6 backend, GLSL 460 oracle, and pack.vsl render-graph DSL targeting Vulkan 1.3+ shader packs in Hyaloclast (vulkanshaders-core).
- Owns shader-pack compilation (
extendandcustommodes): 16@hookstages, compute/vertex/fragment passes,pack.vslevaluation and scheduling,pack.tomlv2 desugaring, native SPIR-V 1.6 emission, andCompiledShaderUnitreflection. - Does not implement engine-core Tier 3 RT SBT pipelines (
rgen/rchit/rahit/rmiss),HitObject/SER, OMM, DXIL/MSL/WGSL/CUDA backends, or runtimespirv-opt. - Workspace enforces
unsafe_code = "forbid"andclippy::pedantic.
| Crate | Implemented Responsibilities |
|---|---|
vsl-diagnostics |
Byte-span tracking (FileId, Span), virtual SourceDatabase, DiagnosticBag, and terminal rendering via ariadne. |
vsl-syntax |
logos DFA lexer, recursive-descent/Pratt parser with error recovery, and shared AST for .vsl and pack.vsl. |
vsl-mc |
Engine contract: 4-set Vulkan ABI constants, 14 canonical passes, 41 RES_* built-in resources, 16 @hook stages (HookAbiRoute), static byte layouts for WorldUBO (544 B) / InstanceMetaSSBO / SharcConfigUBO / EmissiveLightSSBO / RestirReservoirSSBO, PackParamType/PackParamLayout/SpecConstantDefault, and CompiledShaderUnit reflection types. |
vsl-hir |
Arena-backed typed HIR (HirExpr/HirStmt/HirBlock with TypeId and SymbolId), typechecker (E0270–E0275), compile-time SPIR-V legality validator (E0214–E0264), scalar/std430/std140 layout engine, generic struct/function/impl<T: Trait> monomorphization, early tier/cap pruning, ModuleGraph with BLAKE3 L1/L2 hashing, and PackSchema. |
vsl-ir |
Typed structured SSA IR (IrType, Inst, StructuredStmt, IrLocalVar, IrWorkgroupVar, IrParam, IrStageIoVar, GPU intrinsics) and deterministic pass pipeline (SroaPass, Mem2RegPass, SelectiveInlinePass, UnrollLoopsPass, LowerBdaOffsetsPass, ConstFoldPass, CopyPropPass, SimplifyAndGvnPass, LicmPass, DeadStoreElimPass, PropagateNonUniformPass, DeadCodeEliminationPass). |
vsl-spirv |
Flat-arena SPIR-V 1.6 emitter using spirv 0.4 constants (no rspirv/naga): strict in-order block emission, O(1) constant lookup (IndexSet<u32>), Block-decorated UBO/SSBO/BDA structs, OpFunction/OpFunctionParameter/OpFunctionCall, PhysicalStorageBuffer64 + Vulkan memory model, SPV_KHR_ray_query, 64-bit/float/SSBO/workgroup/image atomics + OpMemoryBarrier, subgroup/quad ops, GLSL.std.450 + bit/derivative ops, vertex/fragment I/O + OpDemoteToHelperInvocation, OpSpecConstantOp, and LocalSizeId. |
vsl-pack |
Sandboxed pack.vsl evaluator (MAX_EVAL_STEPS = 100_000, MAX_LOOP_ITERS = 256, zero IO), Compute/Raster/Transfer pass nodes (transfer_pass, mip_pass), PassDispatch (ForTarget, Explicit, Indirect), topological DAG scheduler (SchedulePlan), validate_pass_bindings_against_shader descriptor cross-validation, and pack.toml v2 desugarer. |
vsl-glsl |
GLSL 460 oracle emitter with concrete free-function, generic struct and impl monomorphization, selected entry-point emission and Set 2 sampler2D bindless[4096] ABI, plus hook_bridge (emit_raster_gbuffer_hook_slot_with_schema) for vertex_displace/surface/gbuffer_pack. |
vsl-driver |
Compilation orchestrator: per-module ModuleExports symbol table (pub visibility, struct/const/fn/trait/impl, E0502/E0503), typed HIR-to-IR lowering with diagnostics (E0520–E0529), mc::* built-in lowering (reconstruct_world_pos, view_dir, sample_sky, typed param, spec, resources::*), native @hook chain dispatch with Porter-Duff alpha-over compositing for @hook(clouds), L1 in-memory + L2 in-memory/disk BLAKE3 cache, and parallel entry-point compilation (std::thread::scope). |
vsl-cli |
vslc binary with check, reflect, pack-eval, build-pack, emit-spv, and emit-glsl subcommands. |
vsl-lsp |
Language server (vsl-lsp) over stdio with Windows-safe URI normalization, bounded AnalysisCache, workspace multi-file analysis and pack.vsl schema re-validation via vsl-driver/vsl-hir, context-aware completion with prefix replacement text_edit, HIR-backed hover, goto_definition, references, rename, and semantic_tokens_full. |
| Set | Binding(s) | Layout / Type |
|---|---|---|
0 (DESCRIPTOR_SET_PER_PASS) |
0 |
WorldUBO (std140, 544 bytes; cur_view_proj/prev_view_proj/inv_proj/inv_view at 0..256, camera_pos_frac at 256, frame_index at 268, camera_delta at 272, game_time_sec at 284, sun_dir at 288, rain/thunder/eye_in_fluid/depth_far/held_light at 300..320, pack_params[12] at 320..512, held_light_position at 512, pack_params_bda: u64 at 528, wind_phase at 536, pack_params_bda_pad at 540) |
0 (DESCRIPTOR_SET_PER_PASS) |
1..=14 |
Pass-local textures, storage images, and buffers |
1 (DESCRIPTOR_SET_SCENE_GLOBALS) |
0 |
mc::tlas (AccelerationStructure) |
1 (DESCRIPTOR_SET_SCENE_GLOBALS) |
1 |
InstanceMetaSSBO (std430 runtime array of 144-byte InstanceMeta) |
1 (DESCRIPTOR_SET_SCENE_GLOBALS) |
2 |
SharcConfigUBO (std140, 48 bytes) |
1 (DESCRIPTOR_SET_SCENE_GLOBALS) |
3 |
EmissiveLightSSBO (std430 16-byte header + runtime array of 48-byte EmissiveLight) |
1 (DESCRIPTOR_SET_SCENE_GLOBALS) |
4 |
RestirReservoirSSBO (std430 16-byte header + runtime array of 48-byte RestirReservoir) |
2 (DESCRIPTOR_SET_BINDLESS) |
0 |
COMBINED_IMAGE_SAMPLER[4096] (BINDLESS_IMAGE_COUNT = 4096, no Set 0 default sampler) |
3 (DESCRIPTOR_SET_PACK_RESOURCES) |
0..=15 |
Pack resource texture slots (PACK_RESOURCE_SLOTS = 16) |
AbiProfile::Hyaloclast(default,--abi hyaloclast): enforces the 4-set Hyaloclast engine ABI above (WorldUBOat 0:0, Set 0 bindings1..=14, Set 1 scene globals, Set 2COMBINED_IMAGE_SAMPLER[4096], Set 3 pack resources).AbiProfile::Standalone(--abi standalone): targets generic Vulkan 1.3+ shaders without requiringmc::*orpack.vsl; omitsWorldUBOunless explicitly referenced, supports#[binding(set = N, binding = M)]on entry-point resource parameters (with deterministic auto-assignment starting at0:0when omitted and no1..=14cap), and emits standard unsizedRuntimeDescriptorArraybindings forTexture2D<f32>[].
- Rust
1.88+(Edition2024, Cargo resolver3) spirv-val(spirv-tools) for SPIR-V 1.6 / Vulkan 1.3 binary validation (enforced in CI viaVSL_REQUIRE_SPIRV_VAL=1)
cargo fmt --all -- --check
cargo clippy --workspace --all-targets -- -D warnings
VSL_REQUIRE_SPIRV_VAL=1 cargo test --workspace# Typecheck and validate a shader module
cargo run -p vsl-cli -- check examples/sunlit_vanilla/reflections.vsl --tier 2
# Emit CompiledShaderUnit reflection JSON
cargo run -p vsl-cli -- reflect examples/sunlit_vanilla/reflections.vsl --tier 2
# Emit SPIR-V 1.6 binaries
cargo run -p vsl-cli -- emit-spv examples/sunlit_vanilla/reflections.vsl --tier 2 -o reflections.spv
# Emit GLSL 460 oracle source
cargo run -p vsl-cli -- emit-glsl examples/sunlit_vanilla/tiled_lighting.vsl
# Evaluate and topologically schedule pack.vsl
cargo run -p vsl-cli -- pack-eval examples/sunlit_vanilla/pack.vsl --tier 2 --json
# Build a full shader pack (compile all modules, validate bindings, emit .spv + manifest.json)
cargo run -p vsl-cli -- build-pack examples/sunlit_vanilla --tier 2 --preset ultra -o target/sunlit_out --json
# Run the LSP server over stdio
cargo run -p vsl-lspThe driver exposes linked HIR through ProjectCompileOutput::hir_modules, keyed by original source file IDs. Imported declarations retain their defining spans. In-memory HIR cache keys include source identity so identical file contents or a renamed dependency cannot reuse another file's spans. The disk artifact cache remains content-addressed.
The language server resolves same-directory project imports against the linked HIR and uses open editor buffers ahead of disk contents. Go-to-definition and references use original file IDs. Cross-module rename supports indexed free functions, including explicit import names, and recompiles the proposed edited snapshot before returning edits. Type and method rename across modules is intentionally refused until all type and overload references can be indexed; ambiguous renames are rejected conservatively.
Run bash examples/compiler_validation/validate.sh for the non-RT compiler suite (both native SPIR-V and selected-entry GLSL, Vulkan 1.3 and 1.4). All generic fixtures are mandatory. See compiler validation for coverage and specialization limits, and RT compiler for ray tracing usage and verification.
Apache-2.0. See LICENSE.
VSL supports the following shader stages and hardware extension foundations across HIR, SSA IR, and SPIR-V 1.6 emission:
- Stages:
compute,vertex,fragment, Ray Tracing Pipeline (raygen,closest_hit,any_hit,miss,intersection,callable), Mesh Pipeline (task,mesh), and Legacy Geometry (tess_control,tess_eval,geometry). - RT Extensions: Shader Execution Reordering (
VK_NV_ray_tracing_invocation_reorder/VK_EXT_ray_tracing_invocation_reorder,HitObject), Opacity Micromaps (VK_KHR_opacity_micromap/VK_EXT_opacity_micromap), and Ray Position Fetch (VK_KHR_ray_tracing_position_fetch). - Matrix / Tensor Cores: Cooperative Matrix (
VK_KHR_cooperative_matrix/ Coop Matrix 2 types & ops). - Advanced Rasterization:
SubpassInput/VK_KHR_dynamic_rendering_local_read,Texture2DMS,SampleId/SamplePosition/SampleMask,OpDemoteToHelperInvocation, VRS (VK_KHR_fragment_shading_rate), Fragment Interlock (VK_EXT_fragment_shader_interlock), Multiview (ViewIndex),ClipDistance/CullDistance,FragDepth, andEarlyFragmentTests. - Compiler Base: Full subgroup operations (ballot, broadcast, shuffle/relative, arithmetic, bitwise/logical, clustered, quad), explicit per-call
Samplerbinding, and 1D / texel-buffer textures (Texture1D,RWImage1D,BufferView,RWBufferView). - GPU Debugging:
NonSemantic.Shader.DebugInfo.100(viaCompileOptions::emit_debug_info) anddebug_printf(NonSemantic.DebugPrintf).