Struct screen_13::driver::shader::ShaderBuilder
source · pub struct ShaderBuilder { /* private fields */ }Expand description
Builder for Shader.
Implementations§
source§impl ShaderBuilder
impl ShaderBuilder
sourcepub fn entry_name(self, value: String) -> Self
pub fn entry_name(self, value: String) -> Self
The name of the entry point which will be executed by this shader.
The default value is main.
sourcepub fn specialization_info(self, value: SpecializationInfo) -> Self
pub fn specialization_info(self, value: SpecializationInfo) -> Self
Data about Vulkan specialization constants.
Examples
Basic usage (GLSL):
#version 460 core
// Defaults to 6 if not set using Shader 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()
));sourcepub fn spirv(self, value: Vec<u8>) -> Self
pub fn spirv(self, value: Vec<u8>) -> Self
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.
sourcepub fn stage(self, value: ShaderStageFlags) -> Self
pub fn stage(self, value: ShaderStageFlags) -> Self
The shader stage this structure applies to.
pub fn entry_point(self, value: EntryPoint) -> Self
Trait Implementations§
source§impl Default for ShaderBuilder
impl Default for ShaderBuilder
source§impl From<ShaderBuilder> for Shader
impl From<ShaderBuilder> for Shader
source§fn from(shader: ShaderBuilder) -> Self
fn from(shader: ShaderBuilder) -> Self
Converts to this type from the input type.