Skip to main content

Crate vyre_emit_spirv

Crate vyre_emit_spirv 

Source
Expand description

SPIR-V binary emitter for vyre KernelDescriptor.

Substrate parity strategy: route the descriptor through vyre-emit-naga to get a naga::Module, then use naga::back::spv::Writer to produce a SPIR-V binary. This shares the lossless lowering work with the wgpu/naga path - both backends see the exact same naga::Module - and avoids forking a second KernelOp → SPIR-V translation table.

§Op coverage

Inherits from vyre-emit-naga. Anything that emit-naga refuses also fails here. Anything emit-naga accepts gets converted to a valid SPIR-V binary if naga’s spv-out can lower it (essentially everything except SPIR-V-specific extensions naga doesn’t model).

§Validation gate

naga::valid::Validator runs before naga::back::spv::Writer, so any invalid module is rejected at the boundary. The emitted SPIR-V binary is guaranteed to satisfy SPIR-V’s structural requirements per naga’s spec compliance. Optional external spirv-val validation sits in the integration-test surface (added when CI has spirv-tools).

Re-exports§

pub use anchor_dfa_offload::SpirvAnchorDfaOffloadEvidence;
pub use anchor_dfa_offload::SPIRV_ANCHOR_DFA_OFFLOAD_SCHEMA_VERSION;

Modules§

anchor_dfa_offload
SPIR-V anchor-DFA offload evidence. SPIR-V anchor-DFA offload evidence.
patterns
SPIR-V-specific emit-time patterns.

Enums§

EmitError

Constants§

SPIRV_MAGIC
SPIR-V magic number - 0x07230203 per the spec. Useful for integration tests and consumer-side sanity checks.

Functions§

emit
Emit a SPIR-V binary from a KernelDescriptor.
emit_bytes
Convenience: emit SPIR-V as raw little-endian bytes (the form most runtime loaders accept directly).
emit_from_naga_module
Lower-level entry: emit SPIR-V from a pre-built naga::Module. Useful when callers want to apply naga-level analyses or rewrites between vyre-emit-naga::emit and SPIR-V conversion.
emit_optimized
Emit a SPIR-V binary from an optimized form of desc - runs the full vyre rewrite stack before lowering. Recommended over emit for production use.
emit_optimized_bytes
Like emit_bytes but runs the optimization pipeline first. Recommended for production loaders that want minimal SPIR-V binary size + already-optimized contents.
emit_optimized_bytes_with_stats
Combined optimization + bytes + stats.
emit_optimized_with_stats
Like emit_optimized but also returns vyre_lower::rewrites::OptimizationStats.