[−][src]Struct emu_core::compile_impls::Glsl
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() .set_entry_point_name("main") .add_param_mut::<[f32]>() .add_param::<f32>() .set_code_with_glsl(r#" #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`
Methods
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]
fn compile_to_spirv(src: Glsl) -> Result<Spirv<Vec<u32>>, CompileError>
[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,
[src]
T: 'static + ?Sized,
impl<T, U> AsDeviceBoxed<T> for U where
T: AsBytes + ?Sized,
U: Borrow<T>,
[src]
T: AsBytes + ?Sized,
U: Borrow<T>,
fn as_device_boxed(&Self) -> Result<DeviceBox<T>, NoDeviceError>
[src]
fn as_device_boxed_mut(&Self) -> Result<DeviceBox<T>, NoDeviceError>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,