rendy_shader

Trait Shader

Source
pub trait Shader {
    type Error: Debug;

    // Required methods
    fn spirv(&self) -> Result<Cow<'_, [u32]>, <Self as Shader>::Error>;
    fn entry(&self) -> &str;
    fn stage(&self) -> ShaderStageFlags;

    // Provided method
    unsafe fn module<B>(
        &self,
        factory: &Factory<B>,
    ) -> Result<B::ShaderModule, ShaderError>
       where B: Backend { ... }
}
Expand description

Interface to create shader modules from shaders. Implemented for static shaders via [compile_to_spirv!] macro.

Required Associated Types§

Source

type Error: Debug

The error type returned by the spirv function of this shader.

Required Methods§

Source

fn spirv(&self) -> Result<Cow<'_, [u32]>, <Self as Shader>::Error>

Get spirv bytecode.

Source

fn entry(&self) -> &str

Get the entry point of the shader.

Source

fn stage(&self) -> ShaderStageFlags

Get the rendy_core::hal representation of this shaders kind/stage.

Provided Methods§

Source

unsafe fn module<B>( &self, factory: &Factory<B>, ) -> Result<B::ShaderModule, ShaderError>
where B: Backend,

Create shader module.

Spir-V bytecode must adhere valid usage on this Vulkan spec page: https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkShaderModuleCreateInfo.html

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§