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
macro_rules! define_vectors {
() => {
#[derive(Clone, Copy)]
pub struct Vec2(pub [f32; 2]);
#[derive(Clone, Copy)]
pub struct Vec3(pub [f32; 3]);
#[derive(Clone, Copy)]
pub struct Vec4(pub [f32; 4]);
impl_shader_layout_compat!(8, Vec2);
impl_shader_layout_compat!(16, Vec3);
impl_shader_layout_compat!(16, Vec4);
};
}
mod standard {
use const_shader_layout::{impl_shader_layout_array_element, impl_shader_layout_compat};
define_vectors!();
impl_shader_layout_array_element!(Vec2);
impl_shader_layout_array_element!(Vec3);
//~^ ERROR: Failed to implement `ShaderLayoutArrayElement`: `[Vec3; N]` size (12 * N) must be equal to its shader size (16 * N), i.e. the stride must be rounded up to `ALIGN` (16)
impl_shader_layout_array_element!(Vec4);
}
mod compat {
use const_shader_layout::{impl_shader_layout_compat, impl_shader_layout_compat_array_element};
define_vectors!();
impl_shader_layout_compat_array_element!(Vec2);
//~^ ERROR: Failed to implement `ShaderLayoutCompatArrayElement`: `[Vec2; N]` size (8 * N) must be equal to its shader size (16 * N), i.e. the stride must be rounded up to `ALIGN` (16) and 16
impl_shader_layout_compat_array_element!(Vec3);
//~^ ERROR: Failed to implement `ShaderLayoutArrayElement`: `[Vec3; N]` size (12 * N) must be equal to its shader size (16 * N), i.e. the stride must be rounded up to `ALIGN` (16)
//~| ERROR: Failed to implement `ShaderLayoutCompatArrayElement`: `[Vec3; N]` size (12 * N) must be equal to its shader size (16 * N), i.e. the stride must be rounded up to `ALIGN` (16) and 16
impl_shader_layout_compat_array_element!(Vec4);
}