Skip to main content

Builder

Struct Builder 

Source
pub struct Builder { /* private fields */ }
Expand description

Accumulates SPIR-V words per section and hands out result ids.

Implementations§

Source§

impl Builder

Source

pub fn new() -> Self

Source

pub fn id(&mut self) -> u32

A fresh result <id>. Ids start at 1; 0 is never valid.

Source

pub fn inst(&mut self, s: Section, op: u16, operands: &[u32])

Emit one instruction with no result id.

Source

pub fn typed( &mut self, s: Section, op: u16, result_type: u32, rest: &[u32], ) -> u32

Emit one instruction whose operands are [result_type, result_id, ..rest] and return result_id.

Source

pub fn result(&mut self, s: Section, op: u16, rest: &[u32]) -> u32

Emit one instruction whose only leading operand is its result id (OpTypeInt, OpLabel, …) and return that id.

Source

pub fn inst_str( &mut self, s: Section, op: u16, head: &[u32], text: &str, tail: &[u32], )

Emit an instruction that carries a trailing SPIR-V literal string (OpName, OpEntryPoint).

Source

pub fn finish(self) -> Vec<u32>

The finished module: header followed by every section in layout order.

Trait Implementations§

Source§

impl Default for Builder

Source§

fn default() -> Builder

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.