Skip to main content

GpuContextConfig

Struct GpuContextConfig 

Source
pub struct GpuContextConfig {
    pub backend: BackendPreference,
    pub power_preference: GpuPowerPreference,
    pub required_features: Features,
    pub required_limits: Option<Limits>,
    pub debug: bool,
    pub label: Option<String>,
}
Expand description

Configuration for GPU context initialization.

Fields§

§backend: BackendPreference

Backend preference for adapter selection.

§power_preference: GpuPowerPreference

Power preference for GPU selection.

§required_features: Features

Required GPU features.

§required_limits: Option<Limits>

Required GPU limits.

§debug: bool

Enable debug mode (validation layers).

§label: Option<String>

Label for the device (for debugging).

Implementations§

Source§

impl GpuContextConfig

Source

pub fn new() -> Self

Create a new GPU context configuration.

Source

pub fn with_backend(self, backend: BackendPreference) -> Self

Set backend preference.

Source

pub fn with_power_preference(self, power: GpuPowerPreference) -> Self

Set power preference.

Source

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

Set required features.

Source

pub fn with_limits(self, limits: Limits) -> Self

Set required limits.

Source

pub fn with_debug(self, debug: bool) -> Self

Enable debug mode.

Source

pub fn with_label(self, label: impl Into<String>) -> Self

Set device label.

Source

pub fn with_f16_support(self) -> Self

Request SHADER_F16 GPU feature support.

When this flag is set the context will require the adapter to expose wgpu::Features::SHADER_F16, which enables the enable f16; directive in WGSL shaders and allows native half-precision arithmetic on the GPU.

§Availability

Not all adapters support this feature. Check with GpuContext::supports_feature after context creation. If the adapter lacks support, context creation will fail — consider first checking via wgpu::Adapter::features or falling back to the widening path provided by crate::buffer::from_f16_slice_widening.

Source

pub fn with_push_constants(self) -> Self

Request IMMEDIATES GPU feature support (push constants).

When this flag is set the context will require the adapter to expose wgpu::Features::IMMEDIATES, which enables:

This corresponds to Vulkan push constants and is available on Vulkan, Metal, DX12, and WebGPU (as a proposal).

§Availability

Check adapter support before requesting this feature. If unsupported, use a uniform buffer to pass small per-dispatch constants instead.

Source

pub fn with_cooperative_matrix(self) -> Self

Request cooperative-matrix and subgroup GPU features.

When this flag is set the context will attempt to request:

Both flags are added to GpuContextConfig::required_features. If the adapter does not expose these features, context creation will fail. Use crate::cooperative_matrix::supports_cooperative_matrix after creating a context without this method to check availability before upgrading.

§Fallback

The workgroup-tiled GEMM path in crate::cooperative_matrix::build_cooperative_matrix_gemm_pipeline is correct on all adapters regardless of this flag. Requesting cooperative-matrix features is only necessary when the shader code explicitly uses subgroupMatrix* builtins.

Source

pub async fn build(self) -> GpuResult<GpuContext>

Build a GpuContext from this configuration.

Convenience async builder that calls GpuContext::with_config.

§Errors

Returns an error if no suitable GPU adapter is found or device request fails (e.g., a required feature is unsupported).

Trait Implementations§

Source§

impl Clone for GpuContextConfig

Source§

fn clone(&self) -> GpuContextConfig

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 Debug for GpuContextConfig

Source§

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

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

impl Default for GpuContextConfig

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more