[][src]Struct emu_core::compile::SpirvBuilder

pub struct SpirvBuilder<P: BorrowMut<[u32]>> { /* fields omitted */ }

A builder for constructing a Spirv

You can use it in the case where you are starting from either u8 bytes or 4-byte u32 words.

let kernel: Vec<u8> = vec![
    // Magic number.           Version number: 1.0.
    0x03, 0x02, 0x23, 0x07,    0x00, 0x00, 0x01, 0x00,
    // Generator number: 0.    Bound: 0.
    0x00, 0x00, 0x00, 0x00,    0x00, 0x00, 0x00, 0x00,
    // Reserved word: 0.
    0x00, 0x00, 0x00, 0x00,
    // OpMemoryModel.          Logical.
    0x0e, 0x00, 0x03, 0x00,    0x00, 0x00, 0x00, 0x00,
    // GLSL450.
    0x01, 0x00, 0x00, 0x00];

// if we actually compile to a `DeviceFnMut` later on with `finish`, it will panic
// at runtime because our SPIR-V doesn't actually include a main function
let spirv: Spirv<Vec<u32>> = SpirvBuilder::new()
    .set_entry_point_name("main")
    .add_param_mut::<[f32]>()
    .add_param::<[f32]>()
    .set_code_with_u8(Cursor::new(kernel))?
    .build();

Methods

impl<P: BorrowMut<[u32]>> SpirvBuilder<P>[src]

pub fn new() -> Self[src]

Creates a new builder

pub fn set_entry_point_name(self, name: impl Into<String>) -> Self[src]

Sets the name of the point in this chunk of SPIR-V where it should be entered

If you are compiling from GLSL, for example, your entry point name might be "main" if you have a "void main" function.

pub fn add_param<T: ?Sized>(self) -> Self[src]

Appends a new constant parameter to the kernel in this SPIR-V

pub fn add_param_mut<T: ?Sized>(self) -> Self[src]

Appends a new mutable parameter to the kernel in this SPIR-V

pub fn set_code_with_u32(self, code: P) -> Result<Self, Error>[src]

Set the actual code itself using an owned or borrowed slice of u32

pub fn build(self) -> Spirv<P>[src]

Finish building

impl SpirvBuilder<Vec<u32>>[src]

pub fn set_code_with_u8(self, code: impl Read + Seek) -> Result<Self, Error>[src]

Set the actual code itself using an owned `Vec``

Auto Trait Implementations

impl<P> RefUnwindSafe for SpirvBuilder<P> where
    P: RefUnwindSafe

impl<P> Send for SpirvBuilder<P> where
    P: Send

impl<P> Sync for SpirvBuilder<P> where
    P: Sync

impl<P> Unpin for SpirvBuilder<P> where
    P: Unpin

impl<P> UnwindSafe for SpirvBuilder<P> where
    P: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, U> AsDeviceBoxed<T> for U where
    T: AsBytes + ?Sized,
    U: Borrow<T>, 
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.