Skip to main content

Gpu

Struct Gpu 

Source
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

Source

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.

Source

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

Source

pub fn device(&self) -> &Device

The device frames are drawn with.

Source

pub fn queue(&self) -> &Queue

The queue frames are submitted to.

Source

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.

Source

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.

Source

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.

Source

pub fn format(&self) -> TextureFormat

The texture format GpuPainter::finish expects its target to have.

Source

pub fn painter(&self, size: Size) -> GpuPainter<'_>

A painter for one frame of size pixels.

Auto Trait Implementations§

§

impl !Freeze for Gpu

§

impl !RefUnwindSafe for Gpu

§

impl !Sync for Gpu

§

impl !UnwindSafe for Gpu

§

impl Send for Gpu

§

impl Unpin for Gpu

§

impl UnsafeUnpin for Gpu

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,