pub unsafe trait Vertex: BufferContents + Sized {
    // Required methods
    fn per_vertex() -> VertexBufferDescription;
    fn per_instance() -> VertexBufferDescription;
    fn per_instance_with_divisor(divisor: u32) -> VertexBufferDescription;
}
Expand description

Describes an individual Vertex. In other words a collection of attributes that can be read from a vertex shader.

At this stage, the vertex is in a “raw” format. For example a [f32; 4] can match both a vec4 or a float[4]. The way the things are bound depends on the shader.

The vertex trait can be derived and the format has to be specified using the format field-level attribute:

use vulkano::{buffer::BufferContents, pipeline::graphics::vertex_input::Vertex};

#[derive(BufferContents, Vertex)]
#[repr(C)]
struct MyVertex {
    // Every field needs to explicitly state the desired shader input format
    #[format(R32G32B32_SFLOAT)]
    pos: [f32; 3],
    // The `name` attribute can be used to specify shader input names to match.
    // By default the field-name is used.
    #[name("in_proj", "cam_proj")]
    #[format(R32G32B32_SFLOAT)]
    proj: [f32; 16],
}

Required Methods§

Object Safety§

This trait is not object safe.

Implementors§