1use std::io::Cursor;
5
6use crate::ByteSpan;
7use binrw::BinRead;
8use binrw::binread;
9
10#[binread]
11#[derive(Debug, Clone, Copy)]
12#[repr(C)]
13pub enum ShaderStage {
14 #[br(magic = 0u8)]
15 Vertex,
16 #[br(magic = 1u8)]
17 Pixel,
18}
19
20#[binread]
21#[derive(Debug)]
22#[brw(little)]
23#[allow(dead_code)]
24struct SchdHeader {
25 magic: i32, #[br(count = 3)]
28 #[bw(pad_size_to = 3)]
29 #[bw(map = |x : &String | x.as_bytes())]
30 #[br(map = | x: Vec<u8> | String::from_utf8(x).unwrap().trim_matches(char::from(0)).to_string())]
31 version: String,
32
33 stage: ShaderStage,
34
35 dxc_magic: u32, file_length: i32,
38 shader_offset: u32,
39 parameter_offset: u32,
40}
41
42#[derive(Debug)]
43pub struct Schd {}
44
45impl Schd {
46 pub fn from_existing(buffer: ByteSpan) -> Option<Self> {
48 let mut cursor = Cursor::new(buffer);
49 SchdHeader::read(&mut cursor).ok()?;
50
51 Some(Schd {})
52 }
53}