use core::mem::offset_of;
wgslender::wgsl_module!(pub scene, "tests/fixtures/layouts.wgsl");
fn main() {
println!("shader {} bytes, minified", scene::SOURCE.len());
println!(
"entry {} @workgroup_size{:?}",
scene::ENTRY_TICK,
scene::ENTRY_TICK_WORKGROUP_SIZE,
);
println!(
"uniform @group({}) @binding({})",
scene::bindings::SCENE.group,
scene::bindings::SCENE.binding,
);
println!(
"storage @group({}) @binding({})",
scene::bindings::INSTANCES.group,
scene::bindings::INSTANCES.binding,
);
println!();
let uniforms = scene::Scene::new(
IDENTITY,
[[1.0, 0.0], [0.0, 1.0]],
scene::Material::new([0.9, 0.8, 0.7], 1.5),
1,
0,
[1920.0, 1080.0],
);
println!("Scene {} bytes to upload", size_of_val(&uniforms));
for (field, at) in [
("view", offset_of!(scene::Scene, view)),
("scale", offset_of!(scene::Scene, scale)),
("material", offset_of!(scene::Scene, material)),
("count", offset_of!(scene::Scene, count)),
("kind", offset_of!(scene::Scene, kind)),
("offset", offset_of!(scene::Scene, offset)),
] {
println!(" {field:<9} at byte {at:>3}");
}
println!(" count reads back as {}", uniforms.count);
println!();
println!(
"Instances {} bytes of header, then as many `items` as you allocate, \
from byte {}",
size_of::<scene::Instances>(),
scene::Instances::ITEMS_OFFSET,
);
}
const IDENTITY: [[f32; 4]; 4] = [
[1.0, 0.0, 0.0, 0.0],
[0.0, 1.0, 0.0, 0.0],
[0.0, 0.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 1.0],
];