Struct Gpu

Source
pub struct Gpu { /* private fields */ }
Expand description

A struct that wraps over Rc<Gpu> which can be passed around by clone. Because this is a Rc, it will automatically be freed when there are no more references to it. It follows that any struct with a GpuHandle will be always be guaranteed a valid reference to the Gpu.

Implementations§

Source§

impl Gpu

Source

pub fn new_viewport(&self, window: Window) -> ViewportBuilder

Create a Viewport for displaying to the given window.

Source

pub fn create_viewport(&self, window: Window) -> Viewport

Source

pub fn new_buffer<'a>(&self, label: &'a str) -> BufferBuilder<'a>

Source

pub fn new_pipeline<'a>(&self, label: &'a str) -> PipelineBuilder<'a>

Source

pub fn create_command_encoder(&self, label: &str) -> CommandEncoder

Source

pub fn total_statistics(&self) -> Result<[u64; 5], GpuError>

Source

pub fn timestamp_report(&self) -> Vec<(String, f32)>

Source

pub fn builder<'a>() -> GpuBuilder<'a>

Source§

impl Gpu

Source

pub fn create_bind_group(&self, bindings: &[Binding<'_>]) -> BindGroup

Source§

impl Gpu

Source

pub fn new_sampler<'a, 'gpu>( &'gpu self, label: &'a str, ) -> SamplerBuilder<'a, 'gpu>

Source§

impl Gpu

Source

pub fn new_texture<'a>(&self, label: &'a str) -> TextureBuilder<'a>

Source§

impl Gpu

Methods from Deref<Target = Device>§

Source

pub fn poll(&self, maintain: Maintain)

Check for resource cleanups and mapping callbacks.

no-op on the web, device is automatically polled.

Source

pub fn features(&self) -> Features

List all features that may be used with this device.

Functions may panic if you use unsupported features.

Source

pub fn limits(&self) -> Limits

List all limits that were requested of this device.

If any of these limits are exceeded, functions may panic.

Source

pub fn create_shader_module( &self, desc: &ShaderModuleDescriptor<'_>, ) -> ShaderModule

Creates a shader module from either SPIR-V or WGSL source code.

Source

pub unsafe fn create_shader_module_unchecked( &self, desc: &ShaderModuleDescriptor<'_>, ) -> ShaderModule

Creates a shader module from either SPIR-V or WGSL source code without runtime checks.

§Safety

In contrast with create_shader_module this function creates a shader module without runtime checks which allows shaders to perform operations which can lead to undefined behavior like indexing out of bounds, thus it’s the caller responsibility to pass a shader which doesn’t perform any of this operations.

This has no effect on web.

Source

pub unsafe fn create_shader_module_spirv( &self, desc: &ShaderModuleDescriptorSpirV<'_>, ) -> ShaderModule

Creates a shader module from SPIR-V binary directly.

§Safety

This function passes binary data to the backend as-is and can potentially result in a driver crash or bogus behaviour. No attempt is made to ensure that data is valid SPIR-V.

See also include_spirv_raw! and util::make_spirv_raw.

Source

pub fn create_command_encoder( &self, desc: &CommandEncoderDescriptor<Option<&str>>, ) -> CommandEncoder

Creates an empty CommandEncoder.

Source

pub fn create_render_bundle_encoder( &self, desc: &RenderBundleEncoderDescriptor<'_>, ) -> RenderBundleEncoder<'_>

Creates an empty RenderBundleEncoder.

Source

pub fn create_bind_group(&self, desc: &BindGroupDescriptor<'_>) -> BindGroup

Creates a new BindGroup.

Source

pub fn create_bind_group_layout( &self, desc: &BindGroupLayoutDescriptor<'_>, ) -> BindGroupLayout

Creates a BindGroupLayout.

Source

pub fn create_pipeline_layout( &self, desc: &PipelineLayoutDescriptor<'_>, ) -> PipelineLayout

Creates a PipelineLayout.

Source

pub fn create_render_pipeline( &self, desc: &RenderPipelineDescriptor<'_>, ) -> RenderPipeline

Creates a RenderPipeline.

Source

pub fn create_compute_pipeline( &self, desc: &ComputePipelineDescriptor<'_>, ) -> ComputePipeline

Creates a ComputePipeline.

Source

pub fn create_buffer(&self, desc: &BufferDescriptor<Option<&str>>) -> Buffer

Creates a Buffer.

Source

pub fn create_texture(&self, desc: &TextureDescriptor<Option<&str>>) -> Texture

Creates a new Texture.

desc specifies the general format of the texture.

Source

pub unsafe fn create_texture_from_hal<A>( &self, hal_texture: <A as Api>::Texture, desc: &TextureDescriptor<Option<&str>>, ) -> Texture
where A: HalApi,

Creates a Texture from a wgpu-hal Texture.

§Safety
  • hal_texture must be created from this device internal handle
  • hal_texture must be created respecting desc
  • hal_texture must be initialized
Source

pub fn create_sampler(&self, desc: &SamplerDescriptor<'_>) -> Sampler

Creates a new Sampler.

desc specifies the behavior of the sampler.

Source

pub fn create_query_set( &self, desc: &QuerySetDescriptor<Option<&str>>, ) -> QuerySet

Creates a new QuerySet.

Source

pub fn on_uncaptured_error(&self, handler: impl UncapturedErrorHandler)

Set a callback for errors that are not handled in error scopes.

Source

pub fn push_error_scope(&self, filter: ErrorFilter)

Push an error scope.

Source

pub fn pop_error_scope(&self) -> impl Future<Output = Option<Error>> + Send

Pop an error scope.

Source

pub fn start_capture(&self)

Starts frame capture.

Source

pub fn stop_capture(&self)

Stops frame capture.

Source

pub unsafe fn as_hal<A, F, R>(&self, hal_device_callback: F) -> R
where A: HalApi, F: FnOnce(Option<&<A as Api>::Device>) -> R,

Returns the inner hal Device using a callback. The hal device will be None if the backend type argument does not match with this wgpu Device

§Safety
  • The raw handle obtained from the hal Device must not be manually destroyed

Trait Implementations§

Source§

impl Clone for Gpu

Source§

fn clone(&self) -> Gpu

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Gpu

Source§

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

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

impl Deref for Gpu

Source§

type Target = GpuCtx

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl Freeze for Gpu

§

impl !RefUnwindSafe for Gpu

§

impl !Send for Gpu

§

impl !Sync for Gpu

§

impl Unpin for Gpu

§

impl !UnwindSafe 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<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> 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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> Upcast<T> for T

Source§

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

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