Skip to main content

Crate vulkane_derive

Crate vulkane_derive 

Source
Expand description

Derive macros for the vulkane Vulkan bindings crate.

§#[derive(Vertex)]

Automatically generates VertexInputBinding and VertexInputAttribute descriptors from a #[repr(C)] struct, so you never have to manually compute strides, offsets, or format enums again.

ⓘ
use vulkane_derive::Vertex;

#[derive(Vertex, Clone, Copy)]
#[repr(C)]
struct MyVertex {
    position: [f32; 3],  // R32G32B32_SFLOAT, location 0
    normal:   [f32; 3],  // R32G32B32_SFLOAT, location 1
    uv:       [f32; 2],  // R32G32_SFLOAT,    location 2
}

// Use in pipeline builder:
let bindings = [MyVertex::binding(0)];
let attributes = MyVertex::attributes(0);
builder.vertex_input(&bindings, &attributes)

§Supported field types

Rust typeVulkan format
f32R32_SFLOAT
[f32; 2]R32G32_SFLOAT
[f32; 3]R32G32B32_SFLOAT
[f32; 4]R32G32B32A32_SFLOAT
u32R32_UINT
[u32; 2]R32G32_UINT
[u32; 3]R32G32B32_UINT
[u32; 4]R32G32B32A32_UINT
i32R32_SINT
[i32; 2]R32G32_SINT
[i32; 3]R32G32B32_SINT
[i32; 4]R32G32B32A32_SINT
[u8; 4]R8G8B8A8_UINT
u16R16_UINT
i16R16_SINT

Derive Macros§

Vertex
Derive the Vertex trait, generating binding() and attributes() methods that produce the VertexInputBinding and VertexInputAttribute arrays needed by GraphicsPipelineBuilder::vertex_input.