Skip to main content

Crate awsm_renderer

Crate awsm_renderer 

Source
Expand description

High-level renderer API and shared modules.

§The scene-schema feature (optional schema → runtime bridge)

awsm-renderer-scene is the pure-data, on-disk authoring format (EditorProject, saved as project.json). The renderer holds the runtime equivalents of those types. Enabling the scene-schema feature pulls in awsm-renderer-scene (an optional dep) and compiles a set of From<awsm_renderer_scene::*> impls so a consumer can convert authored data into renderer config with a single .into():

let project: awsm_renderer_scene::EditorProject = serde_json::from_str(&text)?;
renderer.set_shadows_config(project.shadows.into());

It is off by default: a bare runtime consumer never pays for the schema crate, and the editor frontends keep their own bridges. It exists mainly for standalone players that load EditorProject bundles and want first-party conversion that lives next to the runtime structs (so it can never drift).

§Adding more conversions

This is an extension point, not a one-off. Today the only bridge is shadows (shadows::schema_convert, gated by #[cfg(feature = "scene-schema")]). To bridge another subsystem (environment, lights, materials, …), add a feature-gated schema_convert module beside that subsystem’s runtime types and write the From impls there, following shadows::schema_convert as the template. Keeping each bridge next to the structs it maps is what stops the conversions from rotting.

Re-exports§

pub use dynamic_materials::BucketConfig;
pub use load_phase::LoadPhase;
pub use loading::LoadPhase as CommitLoadPhase;
pub use loading::LoadingStats;

Modules§

animation
anti_alias
Anti-aliasing configuration.
bind_group_layout
Bind group layout caching.
bind_groups
Bind group recreation coordination.
bounds
Axis-aligned bounding boxes.
buffer
camera
Camera buffers and matrices.
cameras
Per-camera parameter store.
cluster_lod
Runtime cluster-LOD (Phase B): the loaded cluster DAG + the LOD-cut selection. The CPU select_cut here is the reference spec for the GPU compute pass (B.2) — the same per-cluster rule runs on-device against the uploaded cluster pages. Inert unless the virtual_geometry feature loads a cluster mesh.
core
coverage
Last-frame pixel coverage per mesh.
debug
Debug helpers and logging flags.
decals
Projection decals.
dynamic_materials
Unified material variant registry (the specialize-only design).
environment
Environment and skybox helpers.
error
Renderer error types and results.
features
Opt-in renderer features picked at construction time.
frame_globals
Renderer-wide per-frame state — time, delta_time, frame_count, resolution.
frustum
Frustum extraction and culling helpers.
instances
GPU instancing data and buffers.
light_buckets
Per-light → per-mesh AABB-overlap buckets + GPU upload, used by the visibility-buffer-native lighting path.
lights
Lighting data and GPU uploads.
load_phase
Coarse load-time progress phases a scene/asset loader reports so a host can show “what’s happening now” while a bundle or model materializes.
loading
The load-transaction progress surface.
lod
Discrete level-of-detail: per-mesh simplified level chains + screen-error level selection.
materials
Material storage + GPU upload management.
mesh_pack
The single GPU-buffer packer for the visibility + transparency geometry streams (see docs/buffers.md).
meshes
Mesh storage and GPU buffer management.
opaque_mipgen
Per-frame box-filter mipmap generator for the opaque render target.
optimization_policy
Adaptive runtime policy on top of the build-time RendererFeatures.
picker
GPU picking support for mesh selection.
pipeline_layouts
Pipeline layout caching.
pipeline_scheduler
Pipeline-readiness scheduler.
pipelines
Pipeline caches for render and compute passes.
post_process
Post-processing configuration and updates.
profile
Coarse-grained renderer profile — one knob that flips a coordinated set of defaults across anti-aliasing, shadows, post-processing, features, optimization policy, edge-budget, scene-spatial cadence, and depth format.
raw_mesh
Public raw-mesh upload API.
render
Render entry points and render context.
render_passes
Render pass orchestration and initialization.
render_textures
Render texture allocation and management.
renderable
Renderable collection and draw helpers.
scene_spatial
Spatial index for renderer-owned scene queries.
shaders
Shader cache and template helpers.
shadows
Shadow mapping subsystem.
textures
Texture management and GPU uploads.
transforms
Transform hierarchy and GPU upload.
update
web_global
Runtime-global picking helpers — bridges the main-thread web_sys::Window and worker web_sys::DedicatedWorkerGlobalScope APIs behind a single call surface so the same renderer source works in both contexts (the web_sys::OffscreenCanvas worker-mode deployment shipped in Phase 4.4 needs the worker side of every navigator / performance / requestAnimationFrame call).
workers
Library-wide worker-job infrastructure.

Structs§

AwsmRenderer
Main renderer state and GPU resources.
AwsmRendererBuilder
Builder for AwsmRenderer.
ClusterCutReadback
Verification of the Phase B per-cluster GPU cut+compaction: reads draw_args.index_count back and logs the drawn cut size (a sanity check vs the tested select_cut_per_cluster). inflight single-buffers the mapAsync. Re-fires on a cadence (frame 5, then every 30) — NOT one-shot — so the drawn cut is observable as the camera/scene change (Gap-B paging A2 + the A3 cut-vs-source numbers); the async handler logs only when the value changes (last_value, init -1).
CoverageReadbackState
Per-frame state for the GPU coverage readback loop.
EdgeOverflowReadbackState
Per-frame state for the MSAA edge-budget overflow readback loop.
FroxelOverflowReadbackState
Mirror of EdgeOverflowReadbackState for the GPU light-culling per-froxel capacity auto-grow loop. The cull shader atomic-adds into LightCullingBuffers::overflow_buffer every time it bumps a froxel’s count past max_per_froxel_capacity; the host records a copy_buffer_to_buffer into the per-frame command encoder, then mapAsync’s the staging copy. When the resolved value is non-zero, the next render preamble calls crate::AwsmRenderer::set_max_per_froxel_capacity(current * 2) so subsequent frames have headroom. Single-buffered (inflight gates the next kick).
RendererConfigSpec
Immutable snapshot of every build-time config knob the embedder chose — the declare→commit-for-config analog of the load transaction. Captured at build() and stored on AwsmRenderer; AwsmRenderer::remove_all rebuilds straight from it via AwsmRendererBuilder::from_spec, so a scene-data wipe can NEVER silently drop a config (the historical hand-copy in remove_all repeatedly did — bucket cap, shadow-K, brdf-lut, env colors).

Enums§

AwsmRendererGpuBuilderKind
WebGPU builder input for AwsmRendererBuilder.
RendererLoadingPhase
Coarse-grained stages the renderer passes through during AwsmRendererBuilder::build. Subscribers passed via AwsmRendererBuilder::with_phase_handler get a callback at each transition; consumer UIs can map these to whatever progress message they want to show.

Statics§

COMPATIBITLIY_REQUIREMENTS
Compatibility requirements for this renderer.

Functions§

edge_resolve_supported
Returns true if the device can host the Stage 3 / Priority 3 per-shader-id MSAA edge-resolve pipelines.

Type Aliases§

RendererLoadingPhaseHandler
Boxed phase-transition callback handed to the builder via AwsmRendererBuilder::with_phase_handler. wasm is single-threaded so we don’t need Send + Sync.