Skip to main content

Crate cranpose_render_wgpu

Crate cranpose_render_wgpu 

Source
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.

Re-exports§

pub use offscreen::COMPOSITION_BYTES_PER_PIXEL;

Modules§

pipeline_disk_cache
The file in which the driver’s compiled pipelines, and a record of the pipelines the first screen drew with, are kept between launches.

Structs§

CapturedFrame
CPU-readable RGBA frame captured from the renderer output.
GpuPassTimingEntry
One label’s aggregate inside the current print window.
GpuPassTimingReport
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.
GpuTarget
The device a renderer draws with, the surface format it presents and what the adapter behind the device supports.
HitRegion
A hit target in window space: the node’s geometry, clips and pointer handlers.
PresentTimings
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 in RenderReturns so 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.
RenderStatsSnapshot
The counters of one drawn frame, from WgpuRenderer::last_frame_stats. Pixel counts are in device pixels.
Scene
The retained render graph of a window together with the hit targets built from it.
WgpuRenderer
WGPU-based renderer for GPU-accelerated 2D rendering.
WgpuTextSystem
The fonts a WgpuRenderer hands the app its text lays out and draws with.
WindowRects
Up to four rects of window pixels that share no pixel, each as [x, y, width, height].

Enums§

FrameDamage
The window pixels a frame changes against the frame the renderer’s composition target kept.
PublishOutcome
What WgpuRenderer::publish_frame did.
WgpuRendererError
Why a WgpuRenderer call failed.

Constants§

COMPOSITION_BYTES_PER_PIXEL
Bytes one pixel of a composition target holds: every renderer composites in an 8-bit format.

Traits§

PresentObserver
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 view to color and submits the work, through the same WgpuFrameGraph every other command encoder and submission in this crate is required to go through (enforced by render_contract.rs’s wgpu_command_buffers_are_owned_by_frame_graph_executor) — a fresh, one-shot WgpuFrameGraphExecutor, 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 call wgpu::SurfaceTexture::present themselves, exactly as a real content frame would.
clear_to_default_background
Clears view to the framework’s default background; see clear_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
How many frames this process has drawn and presented since it started.
optional_device_features
The optional device features the renderer exploits when the adapter offers them: pipeline caching (see pipeline_disk_cache), the timestamp queries behind CRANPOSE_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’s request_device passes 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. role names the thread in the log line so an A/B trace shows who pinned where.
pipelines_created
The pipelines this process has built on a thread that draws, since it started. A count that grows during an interaction names a shader compile a frame waited for.
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.
shader_stages_flattened
The folded stages this process also flattened: every call inlined and every struct variable split into its members.
shader_stages_folded
The pipeline stages this process built specialized and folded, each carrying only the code its override constants keep.

Type Aliases§

DeviceLostHandler
What a host runs when the device it handed a WgpuRenderer is lost, after the loss is logged. It may run on any thread.