Skip to main content

Crate roxlap_gpu

Crate roxlap_gpu 

Source
Expand description

WGPU-backed compute-shader renderer scaffold for the roxlap voxel engine. GPU.1 in PORTING-GPU.md.

GPU.1’s job: stand up the device + surface + swapchain on a winit window, present a clear-to-colour frame each render call, and give the host a one-call opt-in. No voxel marching yet — the examples/probe.rs standalone holds the empirical FPS baseline from GPU.0.

Later sub-substages flesh GpuRenderer::render out: GPU.2 uploads voxel data, GPU.3 dispatches the inner-DDA compute shader, GPU.4 layers in chunk skipping, GPU.5 plugs the renderer into roxlap-scene::Scene, …

§Host integration shape (GPU.1)

use std::sync::Arc;
use roxlap_gpu::{GpuRenderer, GpuRendererSettings};
match GpuRenderer::new_blocking(w, GpuRendererSettings::default()) {
    Ok(r) => Some(r),
    Err(e) => {
        eprintln!("GPU init failed: {e}; falling back to CPU");
        None
    }
}

Re-exports§

pub use camera::Camera;
pub use decompress::decompress_chunk;
pub use decompress::ChunkUpload;
pub use decompress::BEDROCK_RGB;
pub use decompress::CHUNK_Z;
pub use grid::bounding_box_of;
pub use grid::GpuGridResident;
pub use grid::GridUpload;
pub use headless::HeadlessGpu;
pub use resident::GpuChunkResident;
pub use scene::GpuSceneResident;
pub use scene::GridRuntimeTransform;
pub use scene::GridStaticMeta;
pub use scene::RefreshOutcome;
pub use scene::SceneUpload;
pub use scene::MAX_SCENE_GRIDS;
pub use sprite_model::build_sprite_model;
pub use sprite_model::SpriteInstance;
pub use sprite_model::SpriteInstanceTransform;
pub use sprite_model::SpriteModel;
pub use sprite_model::SpriteModelRegistry;
pub use sprite_model::SpriteRegistryResident;

Modules§

camera
World-space camera state passed to crate::GpuRenderer::render_chunk.
decompress
GPU.2 — Vxl → (occupancy bitmap, colour offsets, packed colour array). Pure CPU; no wgpu deps in this module. Shape:
grid
GPU.4 — grid-of-chunks upload + storage layout.
headless
GPU.2 — headless device + queue for tests and offline tools.
resident
GPU.2 — chunk-resident storage buffers + debug read-back.
scene
GPU.5 — multi-grid scene upload + shared storage layout.
sprite_model
GPU.10 — KV6 sprite as a DDA-marchable voxel model.

Structs§

GpuRenderer
WGPU-backed renderer. Owns the device, queue, and surface bound to the host’s winit window. Self::render is the GPU.1 clear-to-colour path; Self::render_chunk is GPU.3’s single-chunk DDA marcher.
GpuRendererSettings
Caller-controllable knobs for GpuRenderer::new. Defaults target “highest-performance GPU, prefer Mailbox/Immediate over vsync” — i.e. the same configuration the GPU.0 probe used to measure the FPS ceiling.
HeadlessSceneRenderer
GPU.11 — headless scene-DDA renderer for tests + offline visual gates. Owns the scene_dda.wgsl compute pipeline with no surface and no blit pass; renders a GpuSceneResident to an in-memory RGBA framebuffer via texture readback. The per-substage visual gate (render reference scenes, diff PPMs) and the GPU.11.1 mip render-diff both ride on this.

Enums§

GpuInitError
Errors GpuRenderer::new surfaces to the host. The host’s expected flow is “try this, fall back to the CPU path on Err”.
PowerPreference