use core::mem::offset_of;
#[repr(C)]
#[derive(Copy, Clone, Debug, bytemuck::Pod, bytemuck::Zeroable)]
pub struct CameraUniform {
pub view_proj_inv: [f32; 16],
pub camera_pos: [f32; 3],
pub frame_index: u32,
pub screen_width: u32,
pub screen_height: u32,
pub max_bounces: u32,
pub gem_material_id: u32,
pub c_axis: [f32; 3],
pub env_intensity: f32,
}
const _: () = {
assert!(offset_of!(CameraUniform, view_proj_inv) == 0);
assert!(offset_of!(CameraUniform, camera_pos) == 64);
assert!(offset_of!(CameraUniform, frame_index) == 76);
assert!(offset_of!(CameraUniform, screen_width) == 80);
assert!(offset_of!(CameraUniform, screen_height) == 84);
assert!(offset_of!(CameraUniform, max_bounces) == 88);
assert!(offset_of!(CameraUniform, gem_material_id) == 92);
assert!(offset_of!(CameraUniform, c_axis) == 96);
assert!(offset_of!(CameraUniform, env_intensity) == 108);
assert!(size_of::<CameraUniform>() == 112);
};
#[repr(C)]
#[derive(Copy, Clone, Debug, bytemuck::Pod, bytemuck::Zeroable)]
pub struct GpuCameraParams {
pub origin: [f32; 3],
pub fov_tan: f32,
pub forward: [f32; 3],
pub width: f32,
pub right: [f32; 3],
pub height: f32,
pub up: [f32; 3],
pub num_samples: u32,
}
const _: () = {
assert!(offset_of!(GpuCameraParams, origin) == 0);
assert!(offset_of!(GpuCameraParams, fov_tan) == 12);
assert!(offset_of!(GpuCameraParams, forward) == 16);
assert!(offset_of!(GpuCameraParams, width) == 28);
assert!(offset_of!(GpuCameraParams, right) == 32);
assert!(offset_of!(GpuCameraParams, height) == 44);
assert!(offset_of!(GpuCameraParams, up) == 48);
assert!(offset_of!(GpuCameraParams, num_samples) == 60);
assert!(size_of::<GpuCameraParams>() == 64);
};
#[repr(C)]
#[derive(Copy, Clone, Debug, bytemuck::Pod, bytemuck::Zeroable)]
pub struct GpuRay {
pub origin: [f32; 3],
_pad0: f32,
pub dir: [f32; 3],
_pad1: f32,
}
impl GpuRay {
#[must_use]
pub const fn new(origin: [f32; 3], dir: [f32; 3]) -> Self {
Self {
origin,
_pad0: 0.0,
dir,
_pad1: 0.0,
}
}
}
const _: () = {
assert!(offset_of!(GpuRay, origin) == 0);
assert!(offset_of!(GpuRay, dir) == 16);
assert!(size_of::<GpuRay>() == 32);
};
#[repr(C)]
#[derive(Copy, Clone, Debug, bytemuck::Pod, bytemuck::Zeroable)]
pub struct GpuHitRecord {
pub t: f32,
pub facet_idx: i32,
pub hit: u32,
_pad0: u32,
pub normal: [f32; 3],
_pad1: f32,
}
impl GpuHitRecord {
#[must_use]
pub const fn miss() -> Self {
Self {
t: 0.0,
facet_idx: -1,
hit: 0,
_pad0: 0,
normal: [0.0, 0.0, 0.0],
_pad1: 0.0,
}
}
#[must_use]
pub const fn hit(t: f32, facet_idx: i32, normal: [f32; 3]) -> Self {
Self {
t,
facet_idx,
hit: 1,
_pad0: 0,
normal,
_pad1: 0.0,
}
}
}
const _: () = {
assert!(offset_of!(GpuHitRecord, t) == 0);
assert!(offset_of!(GpuHitRecord, facet_idx) == 4);
assert!(offset_of!(GpuHitRecord, hit) == 8);
assert!(offset_of!(GpuHitRecord, normal) == 16);
assert!(size_of::<GpuHitRecord>() == 32);
};