49aa9e48fd
Creates the GPU resource layer for particles per ARCHI §3.2/§6, without simulation: the pool owns all buffers/pipeline/bind group but draws nothing (indirect args zeroed → no-op) until a driver is attached (Étape B). New: - resources/particle.rs: Particle (80 B, #[repr(C)], no padding — D19), SIZE/ZERO consts + offset/layout unit tests - shaders/particle_billboard.wgsl: camera-facing billboard, empty vertex layout (quad via vertex_index), instance slot via storage binding compact_index (D17), uv_rect atlas support (D15/D18) - core/particles.rs: ParticlePoolConfig, BlendingMode, ParticleDriver trait (D3), ParticlePool (4 buffers + pipeline + bind group), default disc texture (D11), unit tests Wired: - Scene: SceneGpu keeps queue/sample_count; particle_pools registry + create_particle_pool() (default disc when no texture given) - utils::conf PARTICLE_BILLBOARD_SHADER, module re-exports, prelude - tests/wgsl_validate.rs: particle billboard naga validation (2 entry points) Docs: DRAFT call-site/tree synced with the final code; AGENTS.md test count (138) + wgpu 30 API drift gotcha (contents/DeviceExt/ALPHA_BLENDING, DepthStencilState no Default, NonZero min_binding_size, const Zeroable). cargo test -p wsg-lib: 138 pass (121 lib + 10 wgsl + 7), 0 warnings.
wsg-lib Source Directory
Overview
This is the source tree for wsg-lib, a Rust library wrapping wgpu for simple 3D drawing operations. The crate follows a layered architecture organized into eight modules (plus the shaders/ asset directory):
| Module | Responsibility |
|---|---|
| core | Manager (Context) + Executor (Renderer) layers — GPU lifecycle and draw call orchestration (incl. the GPU-driven compute passes + opt-in frustum culling); also InputState (unified keyboard/mouse input, Step 15.B) |
| resources | Data types: Vertex (CPU-side), Mesh (GPU geometry + bounding box, multi-level LOD via packed vertex/index buffers), Material (appearance descriptor), Texture, Lights, Camera + CameraController, and the uniform slot types (TransformSlot/MatSlot/BBoxSlot/DrawSlot/CullUniforms/LodRow/LodTable) |
| pipeline | PipelineCache — WGSL shader loading and RenderPipeline compilation cache |
| shaders | Embedded WGSL sources (standard, shadow, gpu_driven) loaded via the include_str! fallback in utils::conf |
| scene | Scene — resource depot and slot-based entity graph for declarative rendering setup (Step 17) |
| math | Transform, Geometry (per-attribute mesh data + AABB, quadric edge collapse decimated/generate_lod_levels), Frustum (Gribb–Hartmann, WebGPU [0,1] z), lod (per-frame level selection: projected_radius_px + lod_level with asymmetric hysteresis) and primitives (procedural mesh generators) |
| utils | Configuration constants and WsgError type |
| app | App facade — high-level application orchestration with window lifecycle, event loop, and render automation |
| handler | AppHandler trait — user-defined game logic interface injected into the render loop |
Architecture Pattern
The library supports two workflows:
- Declarative (recommended): Use
Sceneto register resources and associate entities before the render loop begins. This is the "App facade" pattern described in ARCHI_APP. - Manual: Manipulate Context, Renderer, and PipelineCache directly for fine-grained control.
Dependency Flow
scene → core → pipeline → utils
↘→ resources → utils (via Vertex offsets)
↗
scene (consumes)
Each submodule's mod.rs re-exports its public types so consumers import through the module level rather than deep paths.