pub mod caps;
pub mod bloom;
mod caption_pass;
#[cfg(feature = "ui")]
pub mod ui_pass;
#[cfg(feature = "ui")]
pub use ui_pass::{UiPass, UiPassStats};
pub mod colorspace;
pub mod downsample;
pub mod fullscreen;
mod gpu_mesh;
pub mod gpu_texture;
pub mod readback;
mod render_target;
pub(crate) mod yuv;
pub mod gpu_timer;
pub mod rgb_pack;
pub mod ssao;
pub mod ssao_composite;
pub mod viewport;
#[allow(clippy::module_inception)]
mod renderer;
pub mod material_maps;
mod pipeline_state;
mod custom_cache;
pub use custom_cache::CustomShaderStats;
pub(crate) use renderer::{
custom_preamble_lines, custom_shader_module_source, validate_custom_shader,
};
#[doc(hidden)]
pub mod shader;
#[cfg(not(target_arch = "wasm32"))]
pub mod headless;
pub mod warmup;
pub use warmup::{PipelineError, PipelineWarmup};
#[cfg(not(target_arch = "wasm32"))]
pub mod pipeline_cache;
#[cfg(not(target_arch = "wasm32"))]
pub use pipeline_cache::{
CallbackStore, FileStore, IntoPipelineCache, MemoryStore, PipelineCache, PipelineCacheStore,
};
#[cfg(not(target_arch = "wasm32"))]
pub mod surface;
#[cfg(not(target_arch = "wasm32"))]
pub use surface::{SurfaceGpu, SurfaceOptions, SurfaceRenderer};
#[cfg(any(winit_window, all(not(target_arch = "wasm32"), metal_backend)))]
pub mod window;
#[cfg(any(winit_window, all(not(target_arch = "wasm32"), metal_backend)))]
pub use window::{MarksFrame, WindowBackend, WindowRenderer};
cfg_metal! {
mod headless_metal;
}
cfg_apple! {
pub mod layer;
}
#[cfg(not(target_arch = "wasm32"))]
mod accumulate;
pub(crate) fn shader_applies_transfer(format: wgpu::TextureFormat) -> bool {
format != wgpu::TextureFormat::Rgba16Float && !format.is_srgb()
}
pub(crate) fn clear_value(
format: wgpu::TextureFormat,
color: crate::math::Color,
alpha: f32,
) -> wgpu::Color {
let c = |v: f32| {
if shader_applies_transfer(format) {
crate::utils::srgb::linear_to_srgb_f32(v) as f64
} else {
v as f64
}
};
wgpu::Color {
r: c(color.r),
g: c(color.g),
b: c(color.b),
a: alpha as f64,
}
}
pub use downsample::{DownsampleFilter, Downsampler};
pub use gpu_texture::GpuCubeTexture;
#[cfg(not(target_arch = "wasm32"))]
pub use headless::{HeadlessBuilder, HeadlessConfig, HeadlessRenderer};
cfg_apple! {
pub use layer::{LayerGpu, LayerRenderer};
}
pub use render_target::{CubeRenderTarget, RenderTarget};
#[allow(unused_imports)] pub(crate) use renderer::stored_clear;
pub use renderer::{halton, stratified_jitter, DEFAULT_CACHE_RETENTION};
pub use renderer::{OverlayInfo, PostFxCamera, Renderer, RendererOptions, ToneMapping};
pub use renderer::{PostFxBlend, PostFxNoise, PostFxOp, PostFxOutput};
pub use viewport::{PixelRect, ShadowMap, ViewportRect};
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum RenderBackend {
#[default]
Auto,
Wgpu,
Metal,
}
#[cfg(test)]
mod clear_value_tests {
use super::clear_value;
use crate::math::Color;
use wgpu::TextureFormat as F;
#[test]
fn a_hex_clear_lands_as_the_hex_on_canvas_formats() {
for hex in [0x20262c_u32, 0x0a0b0c, 0xff8800, 0x808080] {
let c = Color::from_hex(hex);
let want = [(hex >> 16) & 0xff, (hex >> 8) & 0xff, hex & 0xff];
let plain = clear_value(F::Bgra8Unorm, c, 1.0);
for (v, w) in [plain.r, plain.g, plain.b].into_iter().zip(want) {
assert!((v * 255.0 - w as f64).abs() < 0.01, "#{hex:06x}: {v}");
}
for f in [F::Bgra8UnormSrgb, F::Rgba16Float] {
let lin = clear_value(f, c, 1.0);
assert_eq!([lin.r, lin.g, lin.b], [c.r as f64, c.g as f64, c.b as f64]);
}
}
}
}