pub struct ShaderSource {
pub name: String,
pub wgsl: String,
pub workgroup_size: [u32; 3],
pub placeholders: Vec<String>,
}Expand description
A raw WGSL shader source with associated metadata.
Fields§
§name: StringHuman-readable identifier (must be unique in the registry).
wgsl: StringRaw WGSL text (may contain {{PLACEHOLDER}} tokens).
workgroup_size: [u32; 3]Suggested workgroup size [x, y, z].
placeholders: Vec<String>List of placeholder names this source accepts.
Implementations§
Source§impl ShaderSource
impl ShaderSource
Sourcepub fn new(
name: impl Into<String>,
wgsl: impl Into<String>,
workgroup_size: [u32; 3],
) -> Self
pub fn new( name: impl Into<String>, wgsl: impl Into<String>, workgroup_size: [u32; 3], ) -> Self
Create a new shader source.
Sourcepub fn instantiate(&self, defines: &HashMap<String, String>) -> String
pub fn instantiate(&self, defines: &HashMap<String, String>) -> String
Instantiate this source by substituting {{KEY}} tokens with values.
Unknown keys are left untouched. Returns the instantiated WGSL string.
Sourcepub fn threads_per_group(&self) -> u32
pub fn threads_per_group(&self) -> u32
Return the total thread count per workgroup.
Trait Implementations§
Source§impl Clone for ShaderSource
impl Clone for ShaderSource
Source§fn clone(&self) -> ShaderSource
fn clone(&self) -> ShaderSource
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ShaderSource
impl RefUnwindSafe for ShaderSource
impl Send for ShaderSource
impl Sync for ShaderSource
impl Unpin for ShaderSource
impl UnsafeUnpin for ShaderSource
impl UnwindSafe for ShaderSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more