pub mod adapter_wgpu;
pub mod blur;
pub mod buffer;
pub mod graphcloud;
pub mod colorgrade;
pub mod label_collide;
pub mod msdf;
pub mod offscreen;
pub mod pass_clock;
pub mod oit;
pub mod picking;
pub mod pick_host;
pub mod particles;
pub mod readback;
pub mod sdf_pipeline;
pub mod taa;
pub mod types;
pub use adapter_wgpu::{
decide_for, facett_wgpu_options, facts_of, facts_of_all, kind_of, preferred_backends,
request_best_adapter, select_adapter,
};
pub use blur::{gaussian_taps, GaussianBlur, BLUR_WGSL};
pub use graphcloud::{
render_graph_offscreen, BloomParams, EdgeInstance, GraphGpu, GraphRender, GraphScene,
NodeInstance,
};
pub use buffer::{
ChunkSpan, chunk_budget, chunk_budget_stride, partition_chunks, partition_chunks_stride,
rebase_chunk_meta,
};
pub use colorgrade::{
agx_tonemap, ign, srgb_oetf, vignette_factor, ColorGrade, ColorGradeParams, COLORGRADE_WGSL,
};
pub use label_collide::{
LabelCollider, LabelStats, LABEL_COLLIDE_WGSL, LABEL_DRAW_WGSL, LABEL_GLYPH_CAPACITY,
};
pub use msdf::{
coverage, disk_msdf_atlas, median3, screen_px_range, GlyphInstance, MsdfText, MSDF_WGSL,
};
pub use particles::{
advect_cpu, step_cpu, DrawParams, FlowGeometry, GpuParticles, Particle, ParticleBuffers,
SimParams, PARTICLES_WGSL,
};
pub use offscreen::{
gpu_scissor_px, scissor_intersection, OffscreenColorDepth, ScissorPx, BLIT_WGSL, DEPTH_FORMAT,
OFFSCREEN_FORMAT,
};
pub use oit::{
OitBatch, OitPass, OitVertex, OIT_DEFAULT_LAYERS, OIT_MAX_LAYERS, OIT_NODE_SIZE,
OIT_VERTEX_STRIDE, OIT_WGSL,
};
pub use pass_clock::{PassClock, PassClockSlot, PASS_CLOCK_FEATURES};
pub use pick_host::{install_pick_host, pick_at, pick_host_installed, pick_passes_run, PickHost};
pub use readback::{map_read_all, read_buffer_range, read_texture_region, strip_row_padding};
pub use taa::{
halton, history_weight, jitter_px, TaaPass, TAA_FEEDBACK_CAP, TAA_PHASES, TAA_WGSL,
};
pub use picking::{
logical_to_texel, painter_depth, PickBatch, PickPass, PickTarget, PickVertex,
PICK_DEPTH_FORMAT, PICK_FORMAT, PICK_VERTEX_STRIDE, PICK_WGSL,
};
pub use sdf_pipeline::{
GpuSdfHeadless, GpuSdfRenderer, SdfUniforms, offscreen_render, LINE_WGSL, SDF_WGSL,
};
pub use types::{
DrawIndirectArgs, DrawUniforms, GpuWayMeta, Vertex, ViewportCull, color32_to_f32,
rebase_vertex_origin,
};
pub const COMMON_WGSL: &str = include_str!("common.wgsl");
#[must_use]
pub fn wgsl(body: &str) -> String {
let mut s = String::with_capacity(COMMON_WGSL.len() + body.len() + 1);
s.push_str(COMMON_WGSL);
s.push('\n');
s.push_str(body);
s
}
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,
{
crate::render::lane::note_installed(std::any::type_name::<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 cull_shader_keeps_its_per_way_contract() {
assert!(CULL_WGSL.contains("override VPV: u32 = 6u;"), "VPV is overridable and still defaults to 6");
assert!(!CULL_WGSL.contains("const VPV"), "VPV must not go back to a baked const — that forces a twin shader");
assert!(CULL_WGSL.contains("@workgroup_size(64)"));
}
#[test]
fn every_shared_shader_takes_its_maths_from_the_one_prelude() {
for (name, body) in
[("sdf", SDF_WGSL), ("line", LINE_WGSL), ("draw", DRAW_WGSL), ("oit", OIT_WGSL)]
{
assert!(
!body.contains("fn px_to_ndc"),
"{name}.wgsl re-declares px_to_ndc instead of using the prelude"
);
assert!(
!body.contains("fn coverage_from_sd"),
"{name}.wgsl re-declares coverage_from_sd instead of using the prelude"
);
assert!(body.contains("px_to_ndc("), "{name}.wgsl calls the shared px_to_ndc");
let composed = wgsl(body);
assert!(composed.starts_with(COMMON_WGSL), "{name}.wgsl is composed prelude-first");
assert!(composed.contains("fn px_to_ndc"), "the composed {name} module defines px_to_ndc once");
assert_eq!(
composed.matches("fn px_to_ndc").count(),
1,
"exactly ONE definition of px_to_ndc reaches the {name} shader module"
);
}
assert!(COMMON_WGSL.contains("fn resolve_line_width_px"));
assert!(COMMON_WGSL.contains("fn coverage_inside"));
}
}