pub struct Gpu { /* private fields */ }Expand description
A device, a queue, and the one pipeline every frame is drawn with.
Built once per device and kept; Gpu::painter hands out a painter per
frame.
Implementations§
Source§impl Gpu
impl Gpu
Sourcepub fn new(device: Device, queue: Queue, format: TextureFormat) -> Self
pub fn new(device: Device, queue: Queue, format: TextureFormat) -> Self
Wraps a device the caller already has, drawing into textures of format.
format is what GpuPainter::finish will be handed views of — a
swapchain’s, typically. Prefer a non-sRGB format: Denise’s colours are
bytes meant for the screen, and an sRGB target forces a conversion that
the software rasteriser never does.
Sourcepub fn headless() -> Result<Self, Error>
pub fn headless() -> Result<Self, Error>
Any adapter wgpu can find, drawing into Rgba8Unorm.
For tests, tools and --snapshot paths: no window, no surface. Fails
with Error::NoAdapter where there is nothing to draw with, which a
test should treat as “skip”, not “fail”.
Sourcepub fn read_texture(&self, texture: &Texture) -> Result<Vec<u32>, Error>
pub fn read_texture(&self, texture: &Texture) -> Result<Vec<u32>, Error>
Reads a texture back as 0xAARRGGBB words, row after row with no
padding — the layout a denise::Frame uses.
The texture must carry COPY_SRC and
this device’s format. Blocks until the GPU is done; for
tests, snapshots and tools.
Sourcepub fn page_uploads(&self) -> u64
pub fn page_uploads(&self) -> u64
How many glyph atlas pages this device has uploaded, in total.
A page is uploaded once per AtlasPage::version, so for a text engine
whose glyphs have all been seen this stops moving; a number that keeps
climbing means an atlas too small for its working set, which the
engine’s own resets will confirm.
Sourcepub fn image_uploads(&self) -> u64
pub fn image_uploads(&self) -> u64
How many images this device has uploaded, in total.
An image is uploaded once per ImageRef::version: a picture that has
been drawn before costs a quad, and only replacing its pixels costs an
upload.
Sourcepub fn format(&self) -> TextureFormat
pub fn format(&self) -> TextureFormat
The texture format GpuPainter::finish expects its target to have.
Sourcepub fn painter(&self, size: Size) -> GpuPainter<'_>
pub fn painter(&self, size: Size) -> GpuPainter<'_>
A painter for one frame of size pixels.