pub struct ShaderBuilder { /* private fields */ }
Expand description

Builder for Shader.

Implementations

The name of the entrypoint which will be executed by this shader.

The default value is main.

Data about Vulkan specialization constants.

Examples

Basic usage (GLSL):

#version 460 core

// Defaults to 6 if not set using ComputePipelineInfo.specialization_info!
layout(constant_id = 0) const uint MY_COUNT = 6;

layout(set = 0, binding = 0) uniform sampler2D my_samplers[MY_COUNT];

void main()
{
    // Code uses MY_COUNT number of my_samplers here
}
// We instead specify 42 for MY_COUNT:
let shader = Shader::new_fragment(my_shader_code.as_slice())
    .specialization_info(SpecializationInfo::new(
        [vk::SpecializationMapEntry {
            constant_id: 0,
            offset: 0,
            size: 4,
        }],
        42u32.to_ne_bytes()
    ));

Shader code.

Although SPIR-V code is specified as u32 values, this field uses u8 in order to make loading from file simpler. You should always have a SPIR-V code length which is a multiple of four bytes, or a panic will happen during pipeline creation.

The shader stage this structure applies to.

Specifies a shader with the given stage and shader code values.

Builds a new Shader.

Trait Implementations

Returns the “default value” for a type. Read more
Converts to this type from the input type.

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.