Skip to main content

Module display

Module display 

Source
Expand description

Display ABI: present modes, frame pacing, fullscreen and HDR metadata.

Host functions (module sg):

FunctionReturns
display_info(ptr, cap) -> i64JSON document (see DisplayInfo); its length, copied only if it fits
present_config(mode, latency) -> i32a status code; mode is a mode code or mode::KEEP, latency is 1..=3 or 0 to keep
frame_cap(fps: f64) -> i32a status code; 0.0 removes the cap, otherwise FPS_CAP_MIN..=FPS_CAP_MAX
fullscreen(mode) -> i32a status code; mode is a fullscreen code
hdr_metadata(ptr, len) -> i32a status code; len must be HDR_METADATA_SIZE
frame_stats(ptr, cap) -> i64JSON document (see FrameStats)

Requests are validated by the host; out-of-range values return status::INVALID, never trap. Only malformed calls (pointers outside guest memory, a wrong hdr_metadata length) trap. The user’s launch settings take precedence over every game request (status::LOCKED).

Modules§

fullscreen
Fullscreen codes.
mode
Present-mode codes (the repr of wgpu::PresentMode).
status
Return codes of the display functions.

Structs§

DisplayInfo
Field names of the display_info JSON document (for reference; the guest parses it with any JSON library):
FrameStats
Field names of the frame_stats JSON document: rolling statistics over the last 120 presented frames, in milliseconds.
HdrMetadata
Static HDR metadata (SMPTE ST 2086 mastering display + CTA-861.3 content light levels), as 12 little-endian f32s in this order.

Constants§

FPS_CAP_MAX
FPS_CAP_MIN
HDR_METADATA_SIZE
LATENCY_MAX
LATENCY_MIN