Skip to main content

GpuConfig

Struct GpuConfig 

Source
#[non_exhaustive]
pub struct GpuConfig { pub label: &'static str, pub copy_src: CopySrc, pub present_mode: PresentMode, pub optional_features: Features, pub surface_retry_budget: Duration, }
Expand description

Everything Gpu::new needs beyond the window handle.

Build one with GpuConfig::new (or Default) and the with_* setters rather than a struct literal — the struct is #[non_exhaustive] so new knobs can be added without a breaking release:

use agg_gui_wgpu::{CopySrc, GpuConfig};
let cfg = GpuConfig::new("my-app").with_copy_src(CopySrc::IfSupported);

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§label: &'static str

wgpu::DeviceDescriptor label — shows up in backend validation messages and GPU captures, so each shell names its own.

§copy_src: CopySrc

Surface read-back requirement, see CopySrc.

§present_mode: PresentMode

Present mode for the swap chain. AutoVsync for normal windows.

§optional_features: Features

Device features requested when the adapter offers them — the set is masked against adapter.features() before request_device, so an adapter that lacks one still yields a device (the app degrades instead of failing to start). For an app renderer that can use, e.g., FLOAT32_BLENDABLE when present and fall back when not.

§surface_retry_budget: Duration

How long the swap chain may stay continuously unconfigured — every Surface::configure retry failing — before Gpu::try_acquire_frame gives up with SurfaceError. Default 10 s. See GpuConfig::with_surface_retry_budget.

Measured from the first failure of the run and judged when a retry fails. Giving up also needs a minimum number of failed attempts (12, about 6.5 s of continuous retrying), so a caller that paused attempts past the budget — agg-gui-shell does while its window is minimized mid-run — still gets a real retry run afterwards rather than an error at its first failed retry.

Implementations§

Source§

impl GpuConfig

Source

pub fn new(label: &'static str) -> Self

Default configuration under a shell-specific device label.

Source

pub fn with_copy_src(self, copy_src: CopySrc) -> Self

Source

pub fn with_present_mode(self, present_mode: PresentMode) -> Self

Override the swap-chain present mode (default AutoVsync).

Source

pub fn with_optional_features(self, features: Features) -> Self

Request these device features when — and only when — the adapter offers them. See GpuConfig::optional_features.

Source

pub fn with_surface_retry_budget(self, budget: Duration) -> Self

Override how long a failing swap chain is retried before Gpu::try_acquire_frame reports SurfaceError (default 10 s). A minimum number of failed attempts is also required, so a very short budget still gets roughly 6.5 s of actual retrying. Duration::MAX retries forever. See GpuConfig::surface_retry_budget.

Trait Implementations§

Source§

impl Clone for GpuConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for GpuConfig

Source§

impl Debug for GpuConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for GpuConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,