Skip to main content

Module gfx

Module gfx 

Source
Expand description

The client’s render layer. The backend-agnostic render-prep helpers (record builders, render graph, trait seam, CPU-side render math, plus the GPU-free cursor / sprite / text / lights / streaming layout helpers) now live in concinnity-render and are re-exported below under the historical crate::gfx::<module> paths so the rest of the client and the device backends keep resolving. What remains declared here are the game/runtime render systems (the renderer driver, animation, camera controllers, draw list) and the client-only settings/quality-preset resolution.

The GPU data layouts and render math (camera, frustum, post-process settings) and the CPU kernels over them (mesh payloads, pose blending, IK, line expansion, the animation cursor) both live in concinnity-core, re-exported here so the crate::gfx::<module> paths keep resolving. pub so the editor crate can reach them through concinnity_engine::gfx::* (e.g. shader-layout reflection); chunk_coord is named only by the chunk-streaming drive, so it stays crate-private.

Modules§

anim_graph
The animation state machine: what an AnimationGraph asset compiles into, the blendspace members a state can play, and the cursor that walks it.
animation
Skeletal animation playback. Internal system, constructed by World::start when the world declares any Animation; produces per-frame skinning matrices. pub so the editor crate can drive the clip hot-reload through the AnimationSystem setter API.
auto_exposure
Auto-exposure: the tunables the post-process config resolves into, the luminance histogram the backends measure a frame with, and the running EMA that turns that measurement into the next frame’s exposure.
backend
RenderBackend trait: the union of methods every graphics backend implements, dispatched dynamically by GraphicsSystem so the per-frame step + setup logic lives in one cfg-free copy instead of three.
backend_init
Grouped construction inputs for the render backends, plus the requirements derivation that trims scene-scoped features when a world has no 3D content. GraphicsSystem init assembles a BackendInit from the drained world assets, calls resolve_requirements(), and hands it to the backend constructor selected at compile time (Metal / DirectX / Vulkan). Every backend receives the same struct; each reads the fields its feature set consumes.
camera
Pure math for a right-handed first-person camera. All functions are stateless – callers own position, yaw, and pitch directly (e.g. on Camera3D) and pass them in as needed.
camera_controller
First-person / fly-through camera controller. Internal system, constructed by World::start from a Camera3D’s controller settings. pub so the editor crate can zero the controller’s velocity behind an externally driven pose.
decal
Backend-agnostic decal helpers. Owns the per-decal model / inverse-model matrix math the projected-decal pass needs at runtime, plus the DecalRecord the backends consume. Decals are stamped onto the scene depth buffer by drawing a unit-box volume per decal: the fragment shader reconstructs the world-space point of each rasterised pixel from depth and tests whether it lies inside the box.
draw_preview
Live reassignment of a running world’s draw slots (their material and cull distance), for an editor previewing a Prop edit without a rebuild.
draw_slot
Free-list allocator for backend draw-object slots. A backend appends draw objects into a single Vec and stores raw indices into it on each entity’s RenderHandle, so a despawned object’s slot cannot be compacted away without invalidating every later index. Instead the allocator hands out a vacated slot before growing the vec: retire pushes a freed index, the next runtime spawn pops it. Streamed chunks were the first consumer (one freed chunk’s slot reused by the next); runtime entity spawn/despawn is the second. All three backends (Metal, DirectX, Vulkan) route their draw-slot allocation through this.
error
The typed error vocabulary of the RenderBackend boundary. Backends map their native failure codes (VkResult, HRESULT, MTLCommandBuffer status) into these classes at the detection sites; the frame loop dispatches recovery policy on the class, never on prose. Other carries legacy string errors so interior call sites can migrate incrementally.
feedback
The render half’s per-frame report back to the simulation: the sampled window input, the frame’s render stats, what the snapshot’s op replay produced, and the consumed snapshot returned for buffer reuse. The counterpart of RenderSnapshot on the pipelined driver’s return channel.
font
Per-glyph metrics of a compiled font atlas: where a glyph sits in the atlas texture and how the pen moves across it. Shared by the build-time rasteriser that writes the payload, the decoder that reads it back, and the text layout that turns it into quads, none of which owns the layout.
frustum
Backend-agnostic frustum culling.
graphics_system
The renderer driver. An internal system (not a declarable asset), constructed by World::start when the world declares a GraphicsConfig.
ik
Analytic two-bone inverse kinematics: bend a root-mid-end joint chain (a leg or an arm) so the end joint lands on a target, with a pole vector picking the bend side. Operates on the sampled local pose matrices after blending and before skinning_matrices, so the solve composes with any animation. Pure math, no ECS or backend types.
input
Backend-agnostic input snapshot returned by RenderBackend::take_input. Each backend was previously carrying its own structurally-identical InputState; this single type replaces those duplicates.
lighting_preview
Live application of the world’s lighting assets to a running world, for an editor previewing sun / fog / shadow / post-process edits without a rebuild.
lines
The world-space line segment any system can submit for a frame: a trajectory arc, a tether or beam, a patrol path, the editor’s origin axes. Lines are scene geometry, not overlay, so the depth-tested pass occludes them behind whatever is in front of them.
lod
Level of detail: baking the alternate index lists a mesh is drawn from, and picking between them per draw.
mesh_payload
Canonical vertex type and the binary serialisation format shared between the build step (build_mesh.rs writes) and GraphicsSystem (reads).
mesh_seed
Shrinkable seed VRAM: planning + buffer compaction for streamed mesh geometry.
morph_weights
Composition of a pose’s static morph base layer with the weights a clip samples each frame.
ops
Recorded backend effects: simulation systems queue their GPU mutations as ops instead of calling the backend directly, and the submit path replays them in record order before the frame’s draw. Ordering across systems is preserved by the single queue, so the GPU-visible result matches the old direct calls exactly. Ops own their payloads, so a queue can cross a thread boundary with the snapshot that carries it.
particles
Backend-agnostic resolution of ParticleEmitter components into the ParticleEmitterRecords the backends consume. Each record carries the clamped emitter tunables, the resolved texture pool slot, and the per-frame uniform builder the GPU compute + render passes share. Pure CPU; the per-emitter GPU buffers themselves are allocated by the backend at init.
pose_blend
Pose blending: combining several sampled poses into one set of local joint matrices. The blend runs in TRS space, the same interpolation a single clip uses between keyframes, so a blended pose is continuous with a clip’s own sampling.
pose_scratch
Reusable per-target scratch buffers for the pose sampling chain.
profile
Per-frame profiling data. Backend-agnostic: World::step records each system’s CPU step time here, the active render backend writes its draw / GPU stats here, and StatHud reads it back to drive the on-screen HUD. The debug server’s profile command also reports it for headless verification.
proportions
Per-joint proportion changes applied to a posed skeleton: a uniform scale on a joint’s local matrix and a length offset pushing its children along the bone. The bind pose and inverse bind matrices stay as authored, so the change rides under every clip sampled on the skeleton.
render_types
Shared GPU data types used by all rendering backends. Defined here (no #cfg gate) so a future Vulkan backend can import them without pulling in Metal-specific code. metal.rs imports from this module rather than defining its own copies.
root_motion
Root-motion track: the character-displacement curve stripped out of a clip’s root joint at build time. The pose keeps the root anchored in place; the runtime samples this track’s frame-to-frame delta instead and feeds it to whatever moves the character (a physics capsule, or the mesh transform directly). Pure math, unit-tested here.
rt_reflections
Hardware ray-traced reflection configuration. Backend-agnostic resolve of the authored PostProcessConfig fields into clamped settings, plus the per-frame GPU uniform. The acceleration-structure build and the inline ray-trace itself live in the backend (Metal); this module owns only the parameter math so it can be unit-tested without a GPU.
scene_flow
Platform-agnostic active-scene state and transition logic. Scenes are pure content groupings; changes are imperative jumps (UI actions, Behaviors), so this module tracks only which scene is active and drives fade transitions. The SceneControl trait decouples this module from any specific backend; callers supply a concrete backend that implements the two mutation methods.
scene_residency
Scene residency bookkeeping: which scenes are pinned (their streamed content wanted on the GPU), which of each scene’s members are currently resident, and the derived per-scene load state and progress. Pure bookkeeping against core + alloc only, like the streaming policy core: the driver applies pin changes to the stream planners as blocked flags and reports residency transitions back here.
shape_preview
Live re-resolution of a CharacterShape against a running world’s poses, for an editor previewing slider edits without a rebuild.
skeleton
The skeletal-animation vocabulary: a joint hierarchy with its bind pose, the keyframe tracks a clip animates it with, and the sampling that turns a clip time into one local matrix per joint.
snapshot
The owned per-frame snapshot the extraction phase fills from world state and the submission phase consumes. Self-contained by construction: no borrows into component storage, resources, or the backend, so a frame’s draw inputs can outlive the world borrow that produced them and later cross a thread boundary. Buffers keep their capacity across frames; a steady-state extraction allocates nothing.
ssao
Screen-space ambient occlusion (GTAO) configuration. Backend-agnostic resolve of the authored PostProcessConfig SSAO fields into clamped settings, plus the per-frame GPU uniform. The horizon-search arc integral itself lives in each backend’s shader; this module owns only the parameter math so it can be unit-tested without a GPU.
ssgi
Screen-space global illumination (SSGI) configuration. Backend-agnostic resolve of the authored PostProcessConfig SSGI fields into clamped settings, plus the per-frame GPU uniform. SSGI is a refinement of SSR: it reuses the same depth + normal pre-pass G-buffer and screen-space ray-march, but integrates bounced radiance over a cosine-weighted hemisphere instead of along a single reflection vector, and adds the result on top of the IBL ambient term. The hemisphere gather itself lives in each backend’s shader; this module owns only the parameter math so it can be unit-tested without a GPU.
ssr
Screen-space reflection (SSR) configuration. Backend-agnostic resolve of the authored PostProcessConfig SSR fields into clamped settings, plus the per-frame GPU uniform. The screen-space ray-march itself lives in each backend’s shader; this module owns only the parameter math so it can be unit-tested without a GPU.
streaming_system
Asset-streaming drive (texture / mesh / voxel-world chunk pools) + the camera-relative view publish. Internal system, constructed alongside GraphicsSystem (same gate) and scheduled immediately before it. pub so the editor’s debug server can name StreamingStats (its state lives in the parked StreamingState resource, read via World::streaming_stats).
transform
The engine’s transform convention, in one place: the column-major 4x4 layout every renderer uniform is written in, the multiply and the two inverses over it, the T * R(YXZ) * S composition joints and props both build their matrix through, and the quaternion conversions that let a rotation be interpolated along the shorter arc rather than component-wise through its Euler angles.
transform_propagation
Resolving each entity’s world matrix from its Transform and its Parent chain, and writing the result back to its GlobalTransform. A host with a renderer runs this every frame before it builds a draw list.
view_modes
Viewport view-mode and show-flag state: backend-agnostic per-frame render selection. The mode picks what the final image shows (the lit scene, a flat shading, or one G-buffer channel); the flags switch individual feature passes off for the frame without touching their resources. Consumed by the render graph (masking pass gates) and each backend’s composite.
volumetric_fog
Backend-agnostic resolution of the authored VolumetricFog asset into a clamped settings struct plus the per-frame FogParams uniform the Metal fog fragment shader consumes. Pure CPU; unit-testable without a GPU.