summaryrefslogtreecommitdiff
path: root/bindgen/rust/examples/shaders.rs
blob: 842a8d2c04bb02f06bea4f408772ecafc3bf191b (plain)
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
use celeritas::ral::{ShaderData, ShaderDataLayout};
use celeritas_sys::{
    Mat4, ShaderVisibility_VISIBILITY_COMPUTE, ShaderVisibility_VISIBILITY_FRAGMENT,
    ShaderVisibility_VISIBILITY_VERTEX,
};

struct MVP {
    model: Mat4,
    view: Mat4,
    proj: Mat4,
}

fn shader_vis_all() -> u32 {
    ShaderVisibility_VISIBILITY_VERTEX
        | ShaderVisibility_VISIBILITY_FRAGMENT
        | ShaderVisibility_VISIBILITY_COMPUTE
}

impl ShaderData for MVP {
    fn layout() -> ShaderDataLayout {
        let mut bindings = [ShaderBinding::default(); 8];
        // bindings[0] = ShaderBinding {
        //     label: unsafe { CStr::from_bytes_with_nul_unchecked(b"MVP\0").as_ptr() },
        //     kind: ShaderBindingKind_BINDING_BYTES,
        //     vis: shader_vis_all(),
        //     data: ShaderBinding__bindgen_ty_1 {
        //         bytes: ShaderBinding__bindgen_ty_1__bindgen_ty_1 {
        //             size: std::mem::size_of::<MVP>() as u32,
        //             data: ptr::null_mut(),
        //         },
        //     },
        // };
        ShaderDataLayout {
            bindings: todo!(),
            binding_count: 1,
        }
    }

    fn bind(&self) {
        let layout = Self::layout();
        for i in 0..layout.binding_count {
            let binding = &layout.bindings[i];
            // match binding.kind {}
        }
    }
}

fn main() {}