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.
source§impl ShaderBuilder
impl ShaderBuilder
sourcepub fn new(stage: ShaderStageFlags, spirv: Vec<u8>) -> Self
pub fn new(stage: ShaderStageFlags, spirv: Vec<u8>) -> Self
Specifies a shader with the given stage
and shader code values.
sourcepub fn image_sampler(
self,
binding: impl Into<DescriptorBinding>,
info: impl Into<SamplerInfo>
) -> Self
pub fn image_sampler( self, binding: impl Into<DescriptorBinding>, info: impl Into<SamplerInfo> ) -> Self
Specifies a manually-defined image sampler.
Sampled images, by default, use reflection to automatically assign image samplers. Each
sampled image may use a suffix such as _llr
or _nne
for common linear/linear repeat or
nearest/nearest clamp-to-edge samplers, respectively.
See the main documentation for more information about automatic image samplers.
Descriptor bindings may be specified as (1, 2)
for descriptor set index 1
and binding
index 2
, or if the descriptor set index is 0
simply specify 2
for the same case.
NOTE: When defining image samplers which are used in multiple stages of a single pipeline you must only call this function on one of the shader stages, it does not matter which one.
§Panics
Panics if two shader stages of the same pipeline define individual calls to image_sampler
.
sourcepub fn vertex_input(
self,
bindings: &[VertexInputBindingDescription],
attributes: &[VertexInputAttributeDescription]
) -> Self
pub fn vertex_input( self, bindings: &[VertexInputBindingDescription], attributes: &[VertexInputAttributeDescription] ) -> Self
Specifies a manually-defined vertex input layout.
The vertex input layout, by default, uses reflection to automatically define vertex binding
and attribute descriptions. Each vertex location is inferred to have 32-bit channels and be
tightly packed in the vertex buffer. In this mode, a location with _ibind_0
or _vbind3
suffixes is inferred to use instance-rate on vertex buffer binding 0
or vertex rate on
binding 3
, respectively.
See the main documentation for more information about automatic vertex input layout.
Trait Implementations§
source§impl Clone for ShaderBuilder
impl Clone for ShaderBuilder
source§fn clone(&self) -> ShaderBuilder
fn clone(&self) -> ShaderBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ShaderBuilder
impl Debug for ShaderBuilder
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
Auto Trait Implementations§
impl RefUnwindSafe for ShaderBuilder
impl Send for ShaderBuilder
impl Sync for ShaderBuilder
impl Unpin for ShaderBuilder
impl UnwindSafe for ShaderBuilder
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.