Trait luminance::backend::shader::Uniformable[][src]

pub unsafe trait Uniformable<'a, T>: Shader {
    type Target: 'a;

    const SIZE: usize;

    unsafe fn ty() -> UniformType;
unsafe fn update(
        program: &mut Self::ProgramRepr,
        uniform: &'a Uniform<T>,
        value: Self::Target
    ); }
Expand description

Backend support for uniforms.

When a backend implements Uniformable, it adds support for the type parameter as being a recognized uniform type and then can be mapped in a uniform interface via Uniform.

Implementing such a trait is relatively trivial:

  • You must implement Uniformable::ty, which reifies the type of the uniform using UniformType. If your uniform type is not supported in UniformType, it means the API doesn’t know about it and then that type cannot be supported.
  • You must implement Uniformable::update, which updates the value of the Uniform in a given shader program. For indirect values such as bound resources (textures, shader data, etc.), uploading will most of the time be a binding update on the backend side.
  • You must provide an associated type that will be the actual type users will pass. This is needed because some uniform types cannot be expressed directly, such as existentials (think of types with lifetimes, for instance).

Associated Types

Associated Constants

Return the size of the uniform.

For regular uniform variables, this should be 1. For arrays, it should be the length of the array. For anything that is not sized, such as texture bindings, shader data, etc., set it to 0.

Required methods

Reify the type of the uniform as a UniformType.

Update the associated value of the Uniform in the given shader program.

Implementors