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
#[repr(align(4))]
pub struct WordAligned<Bytes: ?Sized>(pub Bytes);
pub fn make_spirv<'a>(data: &'a [u8]) -> super::ShaderModuleSource<'a> {
const MAGIC_NUMBER: u32 = 0x0723_0203;
let (pre, words, post) = unsafe { data.align_to::<u32>() };
assert_eq!(pre, &[], "data offset is not aligned to words!");
assert_eq!(post, &[], "data size is not aligned to words!");
assert_eq!(
words[0], MAGIC_NUMBER,
"wrong magic word {:x}. Make sure you are using a binary SPIRV file.",
words[0]
);
super::ShaderModuleSource::SpirV(words)
}