[][src]Struct emu_core::compile_impls::Glsl

pub struct Glsl { /* fields omitted */ }

A wrapper of GLSL code with methods to help progressively wrap your GLSL

This wrapper includes some extra information that is important, such as the name of the entry point of the GLSL chunk (e.g. - "main"), the mutability of each parameter buffer, and the GLSL code itself.

You can construct a GLSL kernel and compile it with GlslCompile as follows.

let kernel: Glsl = Glsl::new()
#version 450
layout(local_size_x = 1) in;

layout(set = 0, binding = 0) buffer Data {
    float[] data;

// if you are passing in multiple arguments of primitive types,
// you may want to store each argument in a field of a structure and
// then pass that structure into a buffer in a GLSL kernel
layout(set = 0, binding = 1) buffer Scalar {
    float scalar;

void main() {
    uint index = gl_GlobalInvocationID.x;
    data[index] = data[index] * scalar;
let spirv_or_finished = compile::<Glsl, GlslCompile, _, GlobalCache>(kernel)?;
// now at this point you can call `.finish` to turn `spirv_or_finished` into
// a finished `DeviceFnMut`


impl Glsl[src]

pub fn new() -> Self[src]

Creates a new GLSL builder

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

Sets the name of the point in this chunk of GLSL where it should be entered

For example, your code's entry point name might be "main" if you have a "void main" function.

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

Declares an additional parameter - that is constant - to the compute kernel in this GLSL

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

Declares an additional parameter - that is mutable - to the compute kernel in this GLSL

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

Use the given string as the GLSL source code

Trait Implementations

impl CompileToSpirv<Glsl, Vec<u32>> for GlslCompile[src]

impl Hash for Glsl[src]

Auto Trait Implementations

impl RefUnwindSafe for Glsl

impl Send for Glsl

impl Sync for Glsl

impl Unpin for Glsl

impl UnwindSafe for Glsl

Blanket Implementations

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

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

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

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

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

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.