use crate::components::sdf_volume::SDF_PARAMS_LEN;
pub const AUTO_EXPOSURE_PUSH_BYTES: u32 = 16;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct MainPush {
pub model: [[f32; 4]; 4],
pub roughness: f32,
pub metallic: f32,
pub _mpad0: f32,
pub _mpad1: f32,
pub tint: [f32; 3],
pub _mpad2: f32,
pub emissive: [f32; 3],
pub _mpad3: f32,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct CullParams {
pub planes: [[f32; 4]; 6],
pub cam_pos: [f32; 3],
pub object_count: u32,
pub bucket_count: u32,
pub bucket_stride: u32,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct CullHizParams {
pub prev_view_proj: [[f32; 4]; 4],
pub hiz_size: [f32; 2],
pub hiz_mip_count: u32,
pub hiz_enabled: u32,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct GbModelPush {
pub cur_model: [[f32; 4]; 4],
pub prev_model: [[f32; 4]; 4],
pub roughness: f32,
pub _pad: [f32; 3],
}
pub const GBUFFER_PREPASS_PUSH_BYTES: u32 = 144;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct RaymarchView {
pub vp: [[f32; 4]; 4],
pub inv_vp: [[f32; 4]; 4],
pub cam_pos: [f32; 3],
pub _pad0: f32,
pub viewport: [f32; 2],
pub time: f32,
pub prefilter_mip_count: f32,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct RaymarchVolumeUniforms {
pub centre: [f32; 3],
pub _pad0: f32,
pub extent: [f32; 3],
pub _pad1: f32,
pub cone_ratio: f32,
pub max_distance: f32,
pub max_steps: i32,
pub receive_shadows: i32,
pub params: [f32; SDF_PARAMS_LEN],
}
#[cfg(test)]
mod tests {
use super::*;
use core::mem::{offset_of, size_of};
#[test]
fn main_push_layout_matches_glsl() {
assert_eq!(size_of::<MainPush>(), 112);
assert_eq!(offset_of!(MainPush, model), 0);
assert_eq!(offset_of!(MainPush, roughness), 64);
assert_eq!(offset_of!(MainPush, metallic), 68);
assert_eq!(offset_of!(MainPush, _mpad0), 72);
assert_eq!(offset_of!(MainPush, _mpad1), 76);
assert_eq!(offset_of!(MainPush, tint), 80);
assert_eq!(offset_of!(MainPush, _mpad2), 92);
assert_eq!(offset_of!(MainPush, emissive), 96);
assert_eq!(offset_of!(MainPush, _mpad3), 108);
}
#[test]
fn cull_params_layout_matches_glsl() {
assert_eq!(size_of::<CullParams>(), 120);
assert_eq!(offset_of!(CullParams, planes), 0);
assert_eq!(offset_of!(CullParams, cam_pos), 96);
assert_eq!(offset_of!(CullParams, object_count), 108);
assert_eq!(offset_of!(CullParams, bucket_count), 112);
assert_eq!(offset_of!(CullParams, bucket_stride), 116);
}
#[test]
fn cull_hiz_params_layout_matches_glsl() {
assert_eq!(size_of::<CullHizParams>(), 80);
assert_eq!(offset_of!(CullHizParams, prev_view_proj), 0);
assert_eq!(offset_of!(CullHizParams, hiz_size), 64);
assert_eq!(offset_of!(CullHizParams, hiz_mip_count), 72);
assert_eq!(offset_of!(CullHizParams, hiz_enabled), 76);
}
#[test]
fn raymarch_view_layout_matches_glsl() {
assert_eq!(size_of::<RaymarchView>(), 160);
assert_eq!(offset_of!(RaymarchView, vp), 0);
assert_eq!(offset_of!(RaymarchView, inv_vp), 64);
assert_eq!(offset_of!(RaymarchView, cam_pos), 128);
assert_eq!(offset_of!(RaymarchView, viewport), 144);
assert_eq!(offset_of!(RaymarchView, time), 152);
assert_eq!(offset_of!(RaymarchView, prefilter_mip_count), 156);
}
#[test]
fn sdf_volume_uniforms_layout_matches_glsl() {
assert_eq!(size_of::<RaymarchVolumeUniforms>(), 176);
assert_eq!(offset_of!(RaymarchVolumeUniforms, centre), 0);
assert_eq!(offset_of!(RaymarchVolumeUniforms, extent), 16);
assert_eq!(offset_of!(RaymarchVolumeUniforms, cone_ratio), 32);
assert_eq!(offset_of!(RaymarchVolumeUniforms, max_distance), 36);
assert_eq!(offset_of!(RaymarchVolumeUniforms, max_steps), 40);
assert_eq!(offset_of!(RaymarchVolumeUniforms, receive_shadows), 44);
assert_eq!(offset_of!(RaymarchVolumeUniforms, params), 48);
}
}