use super::*;
#[cfg(not(target_arch = "wasm32"))]
#[derive(Debug, Default)]
pub(crate) struct Engine3dWorkerSlot {
pub(crate) epoch: AtomicUsize,
pub(crate) parked: AtomicUsize,
pub(crate) lock: Mutex<()>,
pub(crate) wake: Condvar,
}
#[cfg(not(target_arch = "wasm32"))]
#[derive(Debug)]
pub(crate) struct Engine3dPoolShared {
pub(crate) active_job: AtomicUsize,
pub(crate) active_workers: AtomicUsize,
pub(crate) caller_parked: AtomicUsize,
pub(crate) caller_lock: Mutex<()>,
pub(crate) wake_caller: Condvar,
pub(crate) slots: Vec<Engine3dWorkerSlot>,
}
#[cfg(not(target_arch = "wasm32"))]
#[derive(Debug)]
pub(crate) struct Engine3dJob {
pub(crate) trampoline: Engine3dChunkFn,
pub(crate) ctx_ptr: usize,
pub(crate) total_items: usize,
pub(crate) chunk_size: usize,
pub(crate) total_chunks: usize,
pub(crate) next_chunk: AtomicUsize,
pub(crate) workers_done: AtomicUsize,
}
#[cfg(not(target_arch = "wasm32"))]
#[derive(Debug)]
pub(crate) struct Engine3dWorkerPool {
pub(crate) worker_count: usize,
pub(crate) dispatch_lock: Mutex<()>,
pub(crate) shared: Arc<Engine3dPoolShared>,
}
#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
pub struct RenderStats3D {
#[get(type(copy))]
pub(crate) render_width: u32,
#[get(type(copy))]
pub(crate) render_height: u32,
#[get(type(copy))]
pub(crate) visible_objects: usize,
#[get(type(copy))]
pub(crate) culled_objects: usize,
#[get(type(copy))]
pub(crate) instanced_batches: usize,
#[get(type(copy))]
pub(crate) triangles_drawn: usize,
#[get(type(copy))]
pub(crate) rays_traced: usize,
#[get(type(copy))]
pub(crate) bvh_nodes: usize,
#[get(type(copy))]
pub(crate) lod_simplified_objects: usize,
#[get(type(copy))]
pub(crate) meshlets_drawn: usize,
#[get(type(copy))]
pub(crate) meshlets_culled: usize,
}
#[derive(Clone, Copy, Debug)]
pub(crate) struct GShadeTri {
pub(crate) shade_n: Vec3,
pub(crate) mat_base: Vec3,
pub(crate) mat_emissive: Vec3,
pub(crate) ambient_sky: Vec3,
pub(crate) f0: Vec3,
pub(crate) n_dot_l: f32,
pub(crate) alpha2: f32,
pub(crate) diffuse_scale: f32,
pub(crate) mat_refl: f32,
pub(crate) metallic: f32,
pub(crate) do_refl: bool,
pub(crate) surface_detail: SurfaceDetailMode,
}
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct RtProbeSample {
pub(crate) shadow: f32,
pub(crate) refl_r: f32,
pub(crate) refl_g: f32,
pub(crate) refl_b: f32,
pub(crate) gi_r: f32,
pub(crate) gi_g: f32,
pub(crate) gi_b: f32,
pub(crate) ao: f32,
pub(crate) depth: f32,
pub(crate) nx: f32,
pub(crate) ny: f32,
pub(crate) nz: f32,
pub(crate) valid: u8,
}
#[derive(Clone, Copy, Debug)]
pub(crate) struct DeferredFrameCtx {
pub(crate) w: usize,
pub(crate) h: usize,
pub(crate) gw: usize,
pub(crate) gh: usize,
pub(crate) bw: usize,
pub(crate) rt_step: usize,
pub(crate) inv_w_f: f32,
pub(crate) inv_h_f: f32,
pub(crate) cam_pos: Vec3,
pub(crate) cam_fwd: Vec3,
pub(crate) cam_right_scaled: Vec3,
pub(crate) cam_up_scaled: Vec3,
pub(crate) sun: DirectionalLight3D,
pub(crate) inv_sun_dir: Vec3,
pub(crate) soft_shadow_rays: GiRayQuad,
pub(crate) rt_mode: RayTracingMode,
pub(crate) reflection_bounces: u8,
pub(crate) fog_on: bool,
pub(crate) inv_fog_dist: f32,
pub(crate) exposure_scale: f32,
pub(crate) bloom_on: bool,
}
#[derive(Clone, Data, Debug, Default)]
pub struct Renderer3D {
pub(crate) color_buffer: Vec<u8>,
pub(crate) aa_buffer: Vec<u8>,
pub(crate) depth_buffer: Vec<f32>,
#[get(skip)]
#[get_mut(skip)]
#[set(skip)]
pub(crate) g_tri_idx: Vec<u32>,
#[get(skip)]
#[get_mut(skip)]
#[set(skip)]
pub(crate) luma_buffer: Vec<u8>,
#[get(skip)]
#[get_mut(skip)]
#[set(skip)]
pub(crate) shaded_tris: Vec<GShadeTri>,
#[get(skip)]
#[get_mut(skip)]
#[set(skip)]
pub(crate) gi_rays_scratch: Vec<GiRayQuad>,
#[get(skip)]
#[get_mut(skip)]
#[set(skip)]
pub(crate) rgba_scratch: Vec<u8>,
#[get(skip)]
#[get_mut(skip)]
#[set(skip)]
pub(crate) rt_probes: Vec<RtProbeSample>,
#[get(skip)]
#[get_mut(skip)]
#[set(skip)]
pub(crate) rt_probes_denoised: Vec<RtProbeSample>,
#[get(skip)]
#[get_mut(skip)]
#[set(skip)]
pub(crate) bloom_a: Vec<[f32; 3]>,
#[get(skip)]
#[get_mut(skip)]
#[set(skip)]
pub(crate) bloom_b: Vec<[f32; 3]>,
#[get(skip)]
#[get_mut(skip)]
#[set(skip)]
pub(crate) bloom_tile_active: Vec<u8>,
#[get(skip)]
#[get_mut(skip)]
#[set(skip)]
pub(crate) visible_scratch: Vec<(f32, usize)>,
#[get(skip)]
#[get_mut(skip)]
#[set(skip)]
pub(crate) cluster_ranges_scratch: Vec<(usize, usize)>,
#[get(skip)]
#[get_mut(skip)]
#[set(skip)]
pub(crate) projected_verts_scratch: Vec<([f32; 4], Vec3)>,
#[get(skip)]
#[get_mut(skip)]
#[set(skip)]
pub(crate) unique_meshes_scratch: HashSet<usize>,
#[get(skip)]
#[get_mut(skip)]
#[set(skip)]
pub(crate) has_taa_history: bool,
#[get(skip)]
#[get_mut(skip)]
#[set(skip)]
pub(crate) prev_vp_m0: f32,
#[get(skip)]
#[get_mut(skip)]
#[set(skip)]
pub(crate) frame_index: u32,
#[get(type(copy))]
pub(crate) last_world_revision: u64,
#[get(skip)]
#[get_mut(skip)]
#[set(skip)]
pub(crate) last_quality_fingerprint: u64,
#[get(type(copy))]
pub(crate) taa_accumulated_frames: u32,
#[get(type(copy))]
pub(crate) cached_world_reuses: u64,
#[get(type(copy))]
pub(crate) width: u32,
#[get(type(copy))]
pub(crate) height: u32,
#[get(type(copy))]
pub(crate) last_stats: RenderStats3D,
}