pub struct ShaderBuilder {
    pub source_string: String,
    /* private fields */
}
Expand description

Wraps shader code, changes it and builds it into a wgpu::ShaderModuleDescriptor.

Fields

source_string: String

String with the current WGSL source. It is marked public for debugging purposes.

Implementations

Creates a new ShaderBuilder.

Arguments
  • source_path - Path to the root WGSL module. All includes will be relative to the parent directory of the root WGSL module. Code is generated recursively with attention to include and define statements. See “Examples” for more details on include and macro functionality.

Performs the WGSL’s parallel to C’s #define statement.

Arguments
  • name - Name of the constant; the string to replace in the code.
  • value - Value of the constant.

Calls ShaderBuilder::put_constant for every (key, value) pair in a given HashMap.

Defines a constant array of elements.

Arguments
  • name - Name of the array in the WGSL source.
  • array - Vector of WGSLType whose elements will be the elements in the array.

Builds a wgpu::ShaderModuleDescriptor from the shader. The label member of the built wgpu::ShaderModuleDescriptor is the name of the shader file without the postfix.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.