Expand description
§Cranpose WGPU Renderer
cranpose-render-wgpu produces Cranpose scene output with wgpu.
Platform-shell authors connect the renderer to a device, queue and surface.
App authors usually select a renderer feature on
cranpose and use
AppLauncher.
WgpuRenderer::new accepts app font data. The host then supplies the WGPU
device, queue and surface format:
use cranpose_render_wgpu::WgpuRenderer;
static APP_FONTS: &[&[u8]] = &[];
let renderer = WgpuRenderer::new(APP_FONTS);Platform-shell authors call init_gpu and the render methods for GPU setup
and frame presentation. The
desktop shell
and web shell
show platform setup and surface presentation.
Default features are empty. backend-gles adds the GL-class
backend on native targets. Web builds include the WebGL fallback. The optional
embedded-default-font feature supplies the framework fallback font. App
projects select WGPU with the renderer-wgpu feature on cranpose; the
renderer-wgpu-gles feature also enables backend-gles for native builds.
See the WgpuRenderer API,
the renderer architecture guide,
the feature list
and the crate source.
Modules§
Structs§
- Captured
Frame - CPU-readable RGBA frame captured from the renderer output.
- Debug
Toggle - A debug toggle cached until an override changes. Unset values can be read without acquiring the cache lock.
- GpuPass
Timing Entry - One label’s aggregate inside the current print window.
- GpuPass
Timing Report - GPU time by pass label, aggregated since the last
[GPU-PASS]print. Check the invalid and dropped counters before comparing workloads; rejected frames contribute neither time nor passes to this report. - HitRegion
- Present
Timings - Present-stage timestamps for one consumed packet, in nanoseconds on the
clock the producer injected at runtime start (
0= stage did not run or no clock was injected). Carried back inRenderReturnsso the producer’s frame telemetry keeps recording acquire/render/present phases after those stages move to the present thread. Plain integers so the packet types stay clock-library-free on every target. - Render
Stats Snapshot - Scene
- Wgpu
Renderer - WGPU-based renderer for GPU-accelerated 2D rendering.
- Wgpu
Text System
Enums§
Constants§
- COMPOSITION_
BYTES_ PER_ PIXEL - Bytes one pixel of a composition target holds: every renderer composites in an 8-bit format.
Traits§
- Present
Observer - Platform code the present thread runs around every present to a surface, for what only the platform can do with its swapchain, such as asking the display when earlier frames reached the screen.
Functions§
- clear_
to_ background - Clears
viewtocolorand submits the work, through the sameWgpuFrameGraphevery other command encoder and submission in this crate is required to go through (enforced byrender_contract.rs’swgpu_command_buffers_are_owned_by_frame_graph_executor) — a fresh, one-shotWgpuFrameGraphExecutor, since a placeholder clear has no frame-to-frame state worth pooling. Does not present or acquire anything itself — callers that mean to show the clear on screen still acquire a frame and callwgpu::SurfaceTexture::presentthemselves, exactly as a real content frame would. - clear_
to_ default_ background - Clears
viewto the framework’s default background; seeclear_to_background. - frame_
clear_ color - What a frame clears to before it draws: nothing for a transparent window, the framework’s background for every other surface.
- frames_
presented - headless_
text_ measurer - Create an accurate WGPU text measurer for headless tests without launching a window.
- headless_
text_ measurer_ with_ fonts - Create an accurate WGPU text measurer for headless tests with explicit fonts.
- optional_
device_ features - The optional device features the renderer exploits when the adapter
offers them: pipeline caching (see
pipeline_disk_cache), the timestamp queries behindCRANPOSE_GPU_PASS_TIMING, and, on a GPU that shares the host’s memory, vertex and uniform buffers the CPU writes directly, so a frame’s uploads need no copy. Every platform’srequest_devicepasses this so a profiling toggle never needs a rebuilt binary; intersecting with the adapter’s own features keeps the request valid on adapters without them. - pin_
current_ thread_ to_ fast_ cores - Restricts the calling thread to the fast-capacity CPUs, when the
machine has distinguishable ones.
rolenames the thread in the log line so an A/B trace shows who pinned where. - pipelines_
created - pipelines_
created_ off_ frame - Pipelines built away from every frame, on the compiler thread.
- presentable_
root_ usages - The usages to ask of a presentable image: rendering, and whichever of the copies and sampling the surface offers. Sampling lets a frame whose backdrops read the page draw straight into the image too.