pub mod buffer;
pub mod offscreen;
pub mod sdf_pipeline;
pub mod types;
pub use buffer::{ChunkSpan, chunk_budget, partition_chunks, rebase_chunk_meta};
pub use offscreen::{
gpu_scissor_px, scissor_intersection, OffscreenColorDepth, ScissorPx, BLIT_WGSL, DEPTH_FORMAT,
OFFSCREEN_FORMAT,
};
pub use sdf_pipeline::{
GpuSdfHeadless, GpuSdfRenderer, SdfUniforms, offscreen_render, LINE_WGSL, SDF_WGSL,
};
pub use types::{
DrawIndirectArgs, DrawUniforms, GpuWayMeta, Vertex, ViewportCull, color32_to_f32,
};
pub const CULL_WGSL: &str = include_str!("cull.wgsl");
pub const DRAW_WGSL: &str = include_str!("draw.wgsl");
pub fn install_renderer<R, F>(render_state: &egui_wgpu::RenderState, make: F) -> bool
where
R: 'static + Send + Sync,
F: FnOnce(&wgpu::Device, wgpu::TextureFormat) -> R,
{
if render_state.renderer.read().callback_resources.get::<R>().is_some() {
return false; }
let renderer = make(&render_state.device, render_state.target_format);
render_state.renderer.write().callback_resources.insert(renderer);
true
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn shaders_are_byte_identical_to_facett_map() {
let map_cull = include_str!("../../../../facett-map/src/gpu/cull.wgsl");
let map_draw = include_str!("../../../../facett-map/src/gpu/draw.wgsl");
assert_eq!(CULL_WGSL, map_cull, "cull.wgsl byte-identical to facett-map");
assert_eq!(DRAW_WGSL, map_draw, "draw.wgsl byte-identical to facett-map");
assert!(CULL_WGSL.contains("const VPV: u32 = 6u;"));
assert!(CULL_WGSL.contains("@workgroup_size(64)"));
}
}