Skip to main content

Module spirv

Module spirv 

Source
Expand description

SPIR-V utilities for the Level Zero compute backend.

This module provides a minimal SPIR-V module builder and a pre-encoded placeholder compute shader. The placeholder is a valid “do nothing” void main() with LocalSize(1,1,1) that satisfies Level Zero requirements for module creation, even though all compute operations in this backend currently return Unsupported.

§SPIR-V binary format

SPIR-V is a sequence of 32-bit words (little-endian on all current platforms). Each instruction is encoded as:

word[0] = (word_count << 16) | opcode
word[1..n] = operands

The module header is always five words:

0x07230203  magic
version     e.g. 0x00010500 = 1.5
generator   arbitrary; we use 0x000D_0002
bound       highest ID used + 1
schema      reserved (0)

Structs§

SpvModule
Lightweight SPIR-V word-stream builder.

Constants§

SPIRV_GENERATOR
Generator magic — OxiCUDA Level Zero backend.
SPIRV_MAGIC
SPIR-V magic number (identifies a binary as SPIR-V).
SPIRV_VERSION_1_2
SPIR-V version 1.2 (widely supported, no ray-tracing extras needed).

Functions§

trivial_compute_shader
Build a minimal valid compute shader: void main() {} with LocalSize(1,1,1).
trivial_compute_shader_bytes
Return the trivial compute shader as a byte slice suitable for passing to Level Zero module creation.