Expand description
Yes, these differ from crate::shaderprimitives.
Vertex buffers are packed a lot more tightly, requiring different alignment.
The naming convention also follows that of
wgpu::VertexFormat
rather than wgsl-looking types, because that’s what
wgpu::vertex_attr_array!
takes.
All these types are internally represented by arrays. For example
Float32x3 is just a unit struct over [f32; 3], but a single [Float32]
is also an array of length 1 ([f32; 1]). Of course you can deref them into
regular arrays, but keep in mind that’s not what they directly are.
// There shouldn't be a reason to construct these explicitly, just pass
// arrays into vertex struct constructors, but for the sake of the example
let mut float32_3: Float32x3 = [1.0, 2.0, 3.0].into();
*float32_3 = [3.0, 2.0, 1.0];
float32_3[2] = 0.0;
let bytes: &[u32] = float32_3.as_ref();Structs§
- Float16
- Float32
- Float64
- Float16x2
- Float16x4
- Float32x2
- Float32x3
- Float32x4
- Float64x2
- Float64x3
- Float64x4
- Sint8
- Sint8x2
- Sint8x4
- Sint16
- Sint32
- Sint16x2
- Sint16x4
- Sint32x2
- Sint32x3
- Sint32x4
- Snorm8
- Snorm8x2
- Snorm8x4
- Snorm16
- Snorm16x2
- Snorm16x4
- Uint8
- Uint8x2
- Uint8x4
- Uint16
- Uint32
- Uint16x2
- Uint16x4
- Uint32x2
- Uint32x3
- Uint32x4
- Unorm8
- Unorm8x2
- Unorm8x4
- Unorm16
- Unorm16x2
- Unorm16x4