Expand description
A wgpu custom backend that forwards to the host through the sg GPU API.
ⓘ
let instance = sg_guest::gpu::instance();
let surface = sg_guest::gpu::surface(&instance);
let adapter = instance.request_adapter(&Default::default()).await?; // resolves immediatelyObject handles are host ids. Command encoders, passes and bundles are
recorded here and shipped in one request when finished. Objects referenced
by a recording are kept alive until the host has the finished command
buffer. Futures returned by this backend are always already resolved, so a
trivial executor (see block_on) is enough. Callbacks (buffer mapping,
work-done, uncaptured errors, device loss) run from Device::poll /
pump, which the game should call once per frame, the way a browser runs
them from its event loop.
Structs§
- SgAdapter
- SgBind
Group - SgBind
Group Layout - SgBlas
- SgBuffer
- SgCommand
Buffer - SgCommand
Encoder - SgCompute
Pass - SgCompute
Pipeline - SgDevice
- SgExternal
Texture - SgInstance
- SgMapped
Range - SgPipeline
Cache - SgPipeline
Layout - SgQuery
Set - SgQueue
- SgRender
Bundle - SgRender
Bundle Encoder - SgRender
Pass - SgRender
Pipeline - SgSampler
- SgShader
Module - SgStaging
- SgSurface
- SgSurface
Detail - SgTexture
- SgTexture
View - SgTlas
Functions§
- block_
on - Runs a future that this backend returns (they are always ready).
- frame_
controls - Per-frame inputs for the host’s frame pass (DLSS5-NR when the user enabled it): call once
per frame before presenting.
motionis anRg32Floattexture of the surface’s size (COPY_SRC) of per-pixel offsets, in pixels, to the previous frame’s position (seesg_abi::gpu::FrameControls). Returns asg_abi::gpu::frame_controlsstatus. - instance
- Creates a
wgpu::Instancebacked by the host GPU. - pump
- Polls the host and runs completed callbacks. Call once per frame.
- raw_
request - Sends one raw sg-gpu request and returns the host’s reply. For tests and tools that need to speak the wire protocol directly (the sandbox tests send hostile requests with it); games use wgpu.
- surface
- Creates the game window’s surface.