1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
use std::mem;

use super::{ResourceIndex, ShaderBinding, VertexFormat};

pub trait HasShaderBinding {
    const TYPE: ShaderBinding;
}
impl<T: bytemuck::Pod> HasShaderBinding for T {
    const TYPE: ShaderBinding = ShaderBinding::Plain {
        size: mem::size_of::<T>() as u32,
    };
}
impl HasShaderBinding for super::TextureView {
    const TYPE: ShaderBinding = ShaderBinding::Texture;
}
impl HasShaderBinding for super::Sampler {
    const TYPE: ShaderBinding = ShaderBinding::Sampler;
}
impl HasShaderBinding for super::BufferPiece {
    const TYPE: ShaderBinding = ShaderBinding::Buffer;
}
impl<'a, const N: ResourceIndex> HasShaderBinding for &'a super::BufferArray<N> {
    const TYPE: ShaderBinding = ShaderBinding::BufferArray { count: N };
}
impl<'a, const N: ResourceIndex> HasShaderBinding for &'a super::TextureArray<N> {
    const TYPE: ShaderBinding = ShaderBinding::TextureArray { count: N };
}
impl HasShaderBinding for super::AccelerationStructure {
    const TYPE: ShaderBinding = ShaderBinding::AccelerationStructure;
}

pub trait HasVertexAttribute {
    const FORMAT: VertexFormat;
}

impl HasVertexAttribute for f32 {
    const FORMAT: VertexFormat = VertexFormat::F32;
}
impl HasVertexAttribute for [f32; 2] {
    const FORMAT: VertexFormat = VertexFormat::F32Vec2;
}
impl HasVertexAttribute for [f32; 3] {
    const FORMAT: VertexFormat = VertexFormat::F32Vec3;
}
impl HasVertexAttribute for [f32; 4] {
    const FORMAT: VertexFormat = VertexFormat::F32Vec4;
}
impl HasVertexAttribute for u32 {
    const FORMAT: VertexFormat = VertexFormat::U32;
}
impl HasVertexAttribute for [u32; 2] {
    const FORMAT: VertexFormat = VertexFormat::U32Vec2;
}
impl HasVertexAttribute for [u32; 3] {
    const FORMAT: VertexFormat = VertexFormat::U32Vec3;
}
impl HasVertexAttribute for [u32; 4] {
    const FORMAT: VertexFormat = VertexFormat::U32Vec4;
}
impl HasVertexAttribute for i32 {
    const FORMAT: VertexFormat = VertexFormat::I32;
}
impl HasVertexAttribute for [i32; 2] {
    const FORMAT: VertexFormat = VertexFormat::I32Vec2;
}
impl HasVertexAttribute for [i32; 3] {
    const FORMAT: VertexFormat = VertexFormat::I32Vec3;
}
impl HasVertexAttribute for [i32; 4] {
    const FORMAT: VertexFormat = VertexFormat::I32Vec4;
}

impl HasVertexAttribute for mint::Vector2<f32> {
    const FORMAT: VertexFormat = VertexFormat::F32Vec2;
}
impl HasVertexAttribute for mint::Vector3<f32> {
    const FORMAT: VertexFormat = VertexFormat::F32Vec3;
}
impl HasVertexAttribute for mint::Vector4<f32> {
    const FORMAT: VertexFormat = VertexFormat::F32Vec4;
}
impl HasVertexAttribute for mint::Vector2<u32> {
    const FORMAT: VertexFormat = VertexFormat::U32Vec2;
}
impl HasVertexAttribute for mint::Vector3<u32> {
    const FORMAT: VertexFormat = VertexFormat::U32Vec3;
}
impl HasVertexAttribute for mint::Vector4<u32> {
    const FORMAT: VertexFormat = VertexFormat::U32Vec4;
}
impl HasVertexAttribute for mint::Vector2<i32> {
    const FORMAT: VertexFormat = VertexFormat::I32Vec2;
}
impl HasVertexAttribute for mint::Vector3<i32> {
    const FORMAT: VertexFormat = VertexFormat::I32Vec3;
}
impl HasVertexAttribute for mint::Vector4<i32> {
    const FORMAT: VertexFormat = VertexFormat::I32Vec4;
}