Expand description
SPIR-V emission target.
Unlike the other native targets (HLSL/MSL/PTX/CUDA-C), which print source in
the foreign language, the SPIR-V target produces a binary SPIR-V module by
reusing the deterministic WGSL the emit_wgsl path already generates,
parsing it back into a naga::Module, validating it with the same
capabilities as crate::wgsl_forge::validate::validate_wgsl
(RAY_QUERY | COOPERATIVE_MATRIX | SHADER_FLOAT16), then lowering it through
naga’s spv-out backend.
§Word encoding in GeneratedShader::source
GeneratedShader::source is a String, but SPIR-V is a sequence of 32-bit
words. We serialize the Vec<u32> as ;-joined decimal words (e.g.
"119734787;65536;..."). Decimal (rather than hex) keeps it unambiguous and
trivially round-trippable with split(';') + u32::from_str; the first word
is always the SPIR-V magic number 0x07230203 = 119734787 decimal.
Constants§
- SPIRV_
WORD_ SEPARATOR - Separator between decimal SPIR-V words in
GeneratedShader::source.
Functions§
- decode_
spirv_ words - Decode a
;-joined decimal SPIR-V word string back intoVec<u32>. - emit_
spirv - Emit a validated SPIR-V module for
kernel/schedule. - emit_
spirv_ patched - Emit SPIR-V and patch the workgroup size to
schedule.workgroup_size. - patch_
spirv_ workgroup_ size - Patch the workgroup size in a SPIR-V binary to
(x, 1, 1).