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 type | Vulkan format |
|---|---|
f32 | R32_SFLOAT |
[f32; 2] | R32G32_SFLOAT |
[f32; 3] | R32G32B32_SFLOAT |
[f32; 4] | R32G32B32A32_SFLOAT |
u32 | R32_UINT |
[u32; 2] | R32G32_UINT |
[u32; 3] | R32G32B32_UINT |
[u32; 4] | R32G32B32A32_UINT |
i32 | R32_SINT |
[i32; 2] | R32G32_SINT |
[i32; 3] | R32G32B32_SINT |
[i32; 4] | R32G32B32A32_SINT |
[u8; 4] | R8G8B8A8_UINT |
u16 | R16_UINT |
i16 | R16_SINT |
Derive Macros§
- Vertex
- Derive the
Vertextrait, generatingbinding()andattributes()methods that produce theVertexInputBindingandVertexInputAttributearrays needed byGraphicsPipelineBuilder::vertex_input.