Skip to main content

SpirVModule

Struct SpirVModule 

Source
pub struct SpirVModule {
Show 15 fields pub version: u32, pub generator: u32, pub bound: u32, pub capabilities: Vec<SpirVCapability>, pub extensions: Vec<String>, pub ext_inst_imports: HashMap<String, u32>, pub memory_model: (AddressingModel, MemoryModel), pub entry_points: Vec<(ExecutionModel, u32, String, Vec<u32>)>, pub execution_modes: Vec<(u32, ExecutionMode)>, pub debug_names: HashMap<u32, String>, pub decorations: HashMap<u32, Vec<Decoration>>, pub types: Vec<SpirVInstruction>, pub constants: Vec<SpirVInstruction>, pub global_vars: Vec<SpirVInstruction>, pub functions: Vec<SpirVFunction>,
}
Expand description

A complete SPIR-V module.

Contains all declarations required to produce a valid SPIR-V binary: capabilities, extensions, memory model, entry points, type declarations, global variables, constants, and function bodies.

Fields§

§version: u32

SPIR-V version (encoded as major<<16 | minor<<8)

§generator: u32

Generator magic number

§bound: u32

Bound (next available ID)

§capabilities: Vec<SpirVCapability>

Declared capabilities

§extensions: Vec<String>

Extension strings

§ext_inst_imports: HashMap<String, u32>

Extended instruction set imports (name -> id)

§memory_model: (AddressingModel, MemoryModel)

Addressing and memory model

§entry_points: Vec<(ExecutionModel, u32, String, Vec<u32>)>

Entry points: (execution_model, function_id, name, interface_vars)

§execution_modes: Vec<(u32, ExecutionMode)>

Execution modes per entry point

§debug_names: HashMap<u32, String>

Debug names (id -> name)

§decorations: HashMap<u32, Vec<Decoration>>

Decorations (id -> list of decorations)

§types: Vec<SpirVInstruction>

Type instructions (ordered by dependency)

§constants: Vec<SpirVInstruction>

Constants

§global_vars: Vec<SpirVInstruction>

Global variables

§functions: Vec<SpirVFunction>

Function definitions

Implementations§

Source§

impl SpirVModule

Source

pub fn new() -> Self

Create a new empty SPIR-V module targeting SPIR-V 1.6.

Source

pub fn fresh_id(&mut self) -> u32

Allocate a fresh ID.

Source

pub fn add_capability(&mut self, cap: SpirVCapability)

Add a capability.

Source

pub fn add_extension(&mut self, ext: impl Into<String>)

Add an extension.

Source

pub fn import_ext_inst(&mut self, name: impl Into<String>) -> u32

Import an extended instruction set and return its ID.

Source

pub fn add_entry_point( &mut self, model: ExecutionModel, func_id: u32, name: impl Into<String>, interface_vars: Vec<u32>, )

Add an entry point.

Source

pub fn add_execution_mode(&mut self, func_id: u32, mode: ExecutionMode)

Add an execution mode for an entry point function.

Source

pub fn set_name(&mut self, id: u32, name: impl Into<String>)

Assign a debug name to an ID.

Source

pub fn decorate(&mut self, id: u32, decoration: Decoration)

Add a decoration to an ID.

Source

pub fn add_type(&mut self, instr: SpirVInstruction)

Add a type instruction.

Source

pub fn add_constant(&mut self, instr: SpirVInstruction)

Add a constant instruction.

Source

pub fn add_global_var(&mut self, instr: SpirVInstruction)

Add a global variable.

Source

pub fn add_function(&mut self, func: SpirVFunction)

Add a function definition.

Source

pub fn emit_text(&self) -> String

Emit the module as SPIR-V assembly text.

Source

pub fn estimate_word_count(&self) -> u32

Estimate the total word count of the module binary.

Trait Implementations§

Source§

impl Clone for SpirVModule

Source§

fn clone(&self) -> SpirVModule

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SpirVModule

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SpirVModule

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.