Module vulkano::pipeline::vertex [] [src]

Vertex sources definition

When you create a graphics pipeline object, you need to pass an object which indicates the layout of the vertex buffer(s) that will serve as input for the vertex shader. This is done by passing an implementation of the Definition trait.

In addition to this, the object that you pass when you create the graphics pipeline must also implement the Source trait. This trait has a template parameter which corresponds to the list of vertex buffers.

The vulkano library provides some structs that already implement these traits. The most common situation is a single vertex buffer and no instancing, in which case you can pass a SingleBufferDefinition when you create the pipeline.

Implementing Vertex

The implementations of the Definition trait that are provided by vulkano (like SingleBufferDefinition) require you to use a buffer whose content is [V] where V implements the Vertex trait.

The Vertex trait is unsafe, but can be implemented on a struct with the impl_vertex! macro.

Example

use vulkano::buffer::Buffer;
use vulkano::buffer::Usage as BufferUsage;
use vulkano::memory::HostVisible;
use vulkano::pipeline::vertex::;
 
struct Vertex {
    position: [f32; 2]
}
 
impl_vertex!(Vertex, position);
 
let usage = BufferUsage {
    vertex_buffer: true,
    .. BufferUsage::none()
};
 
let vertex_buffer = Buffer::<[Vertex], _>::array(&device, 128, &usage, HostVisible, &queue)
                                                    .expect("failed to create buffer");
 
// TODO: finish exampleRun

Structs

AttributeInfo

Information about a single attribute within a vertex. TODO: change that API

OneVertexOneInstanceDefinition

Unstable.

SingleBufferDefinition

Implementation of Definition for a single vertex buffer.

TwoBuffersDefinition

Unstable.

VertexMemberInfo

Information about a member of a vertex struct.

Enums

IncompatibleVertexDefinitionError

Error that can happen when the vertex definition doesn't match the input of the vertex shader.

InputRate

How the vertex source should be unrolled.

VertexMemberTy

Type of a member of a vertex struct.

Traits

Definition

Trait for types that describe the definition of the vertex input used by a graphics pipeline.

Source

Extension trait of Definition. The L parameter is an acceptable vertex source for this vertex definition.

Vertex

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

VertexMember

Trait for data types that can be used as vertex members. Used by the impl_vertex! macro.