pub struct WGPUBackend {
pub device: Device,
pub queue: Queue,
pub surface: Surface<'static>,
pub config: SurfaceConfiguration,
}Expand description
The wgpu-backed Backend implementation. Inserted as a resource
once init finishes (see the Backend trait docs for
how that’s driven); everything in super that uploads to the GPU
(Res<WGPUBackend> in an Asset::upload
impl) reads device/queue directly off this.
Fields§
§device: Device§queue: Queue§surface: Surface<'static>§config: SurfaceConfigurationImplementations§
Source§impl WGPUBackend
impl WGPUBackend
Sourcepub fn readback_buffer(&self, src: &Buffer) -> impl SpawnableFuture<Vec<u8>>
pub fn readback_buffer(&self, src: &Buffer) -> impl SpawnableFuture<Vec<u8>>
Copies src into a temporary staging buffer, begins a GPU readback,
and returns a future that resolves to the copied bytes once it’s
done.
The copy is submitted eagerly, right away — do not call mid-frame;
call after present or outside of frame encoding. Only the wait
for the GPU to finish mapping it is deferred into the returned
future.
This doesn’t run itself — drive it with
AsyncEventWriter::spawn to get the
result delivered as an event, or
BackgroundTasks::spawn_async
directly if you’d rather hold onto a
TaskHandle and poll it yourself.
Sourcepub fn readback_buffer_as<T: Pod + Send + 'static>(
&self,
src: &Buffer,
) -> impl SpawnableFuture<Vec<T>>
pub fn readback_buffer_as<T: Pod + Send + 'static>( &self, src: &Buffer, ) -> impl SpawnableFuture<Vec<T>>
Same as readback_buffer but the resolved
bytes are cast to T.
Trait Implementations§
Source§impl Asset<WGPUBackend> for GPUCompute
impl Asset<WGPUBackend> for GPUCompute
Source§type Source = ComputeDescriptor<'static>
type Source = ComputeDescriptor<'static>
Assets.Source§type Deps<'a> = ()
type Deps<'a> = ()
B itself) required to perform the conversion.
Use () when there are no extra dependencies.Source§fn upload<'a>(
source: &ComputeDescriptor<'_>,
backend: &WGPUBackend,
_deps: &(),
) -> Option<Self>
fn upload<'a>( source: &ComputeDescriptor<'_>, backend: &WGPUBackend, _deps: &(), ) -> Option<Self>
Source§impl Asset<WGPUBackend> for GPUCubemap
impl Asset<WGPUBackend> for GPUCubemap
Source§type Source = CubemapDescriptor
type Source = CubemapDescriptor
Assets.Source§type Deps<'a> = Res<'a, MipmapGenerator>
type Deps<'a> = Res<'a, MipmapGenerator>
B itself) required to perform the conversion.
Use () when there are no extra dependencies.Source§fn upload<'a>(
source: &CubemapDescriptor,
backend: &WGPUBackend,
mipmap_generator: &Res<'a, MipmapGenerator>,
) -> Option<Self>
fn upload<'a>( source: &CubemapDescriptor, backend: &WGPUBackend, mipmap_generator: &Res<'a, MipmapGenerator>, ) -> Option<Self>
Source§impl<T> Asset<WGPUBackend> for GPUBindingInstance<T>
impl<T> Asset<WGPUBackend> for GPUBindingInstance<T>
Source§type Source = BindingInstanceDescriptor<T>
type Source = BindingInstanceDescriptor<T>
Assets.Source§type Deps<'a> = (Res<'a, ProcessedAssets<T>>, Res<'a, ProcessedAssets<GPUTexture>>, Res<'a, ProcessedAssets<GPUTextureArray>>, Res<'a, ProcessedAssets<GPUCubemap>>, Res<'a, GlobalSamplers>)
type Deps<'a> = (Res<'a, ProcessedAssets<T>>, Res<'a, ProcessedAssets<GPUTexture>>, Res<'a, ProcessedAssets<GPUTextureArray>>, Res<'a, ProcessedAssets<GPUCubemap>>, Res<'a, GlobalSamplers>)
B itself) required to perform the conversion.
Use () when there are no extra dependencies.Source§impl Asset<WGPUBackend> for GPUMaterial
impl Asset<WGPUBackend> for GPUMaterial
Source§type Source = MaterialDescriptor<'static>
type Source = MaterialDescriptor<'static>
Assets.Source§type Deps<'a> = ()
type Deps<'a> = ()
B itself) required to perform the conversion.
Use () when there are no extra dependencies.Source§fn upload<'a>(
source: &MaterialDescriptor<'_>,
backend: &WGPUBackend,
_deps: &(),
) -> Option<Self>
fn upload<'a>( source: &MaterialDescriptor<'_>, backend: &WGPUBackend, _deps: &(), ) -> Option<Self>
Source§impl Asset<WGPUBackend> for GPUMesh
impl Asset<WGPUBackend> for GPUMesh
Source§type Source = MeshDescriptor
type Source = MeshDescriptor
Assets.Source§type Deps<'a> = ()
type Deps<'a> = ()
B itself) required to perform the conversion.
Use () when there are no extra dependencies.Source§fn upload<'a>(
source: &MeshDescriptor,
backend: &WGPUBackend,
_deps: &(),
) -> Option<Self>
fn upload<'a>( source: &MeshDescriptor, backend: &WGPUBackend, _deps: &(), ) -> Option<Self>
Source§impl Asset<WGPUBackend> for GPUTextureArray
impl Asset<WGPUBackend> for GPUTextureArray
Source§type Source = TextureArrayDescriptor
type Source = TextureArrayDescriptor
Assets.Source§type Deps<'a> = Res<'a, MipmapGenerator>
type Deps<'a> = Res<'a, MipmapGenerator>
B itself) required to perform the conversion.
Use () when there are no extra dependencies.Source§fn upload<'a>(
source: &TextureArrayDescriptor,
backend: &WGPUBackend,
mipmap_generator: &Res<'a, MipmapGenerator>,
) -> Option<Self>
fn upload<'a>( source: &TextureArrayDescriptor, backend: &WGPUBackend, mipmap_generator: &Res<'a, MipmapGenerator>, ) -> Option<Self>
Source§impl Asset<WGPUBackend> for GPUTexture
impl Asset<WGPUBackend> for GPUTexture
Source§type Source = TextureDescriptor
type Source = TextureDescriptor
Assets.Source§type Deps<'a> = Res<'a, MipmapGenerator>
type Deps<'a> = Res<'a, MipmapGenerator>
B itself) required to perform the conversion.
Use () when there are no extra dependencies.Source§fn upload<'a>(
source: &TextureDescriptor,
backend: &WGPUBackend,
mipmap_generator: &Res<'a, MipmapGenerator>,
) -> Option<Self>
fn upload<'a>( source: &TextureDescriptor, backend: &WGPUBackend, mipmap_generator: &Res<'a, MipmapGenerator>, ) -> Option<Self>
Source§impl Backend for WGPUBackend
impl Backend for WGPUBackend
Source§fn init(
handle: impl GPUSurfaceHandle,
width: u32,
height: u32,
sender: InitSender<Self>,
)
fn init( handle: impl GPUSurfaceHandle, width: u32, height: u32, sender: InitSender<Self>, )
Native blocks the calling thread on init_async
via pollster::block_on (fine here — this only runs once, during
App::build, and there’s no other work
competing for the thread yet). Web can’t block its single thread, so
it hands init_async to wasm_bindgen_futures::spawn_local instead
and returns immediately — GraphicsPlugin
polls the resulting sender/InitReceiver
pair every tick either way, so callers don’t need to know which path
ran. A second Backend implementation should follow the same
split if it also needs to run on both targets.
Source§fn resize(&mut self, width: u32, height: u32)
fn resize(&mut self, width: u32, height: u32)
Source§impl LazyResource<WGPUBackend> for MipmapGenerator
impl LazyResource<WGPUBackend> for MipmapGenerator
Source§impl LazyResource<WGPUBackend> for GlobalSamplers
impl LazyResource<WGPUBackend> for GlobalSamplers
Auto Trait Implementations§
impl !Freeze for WGPUBackend
impl !RefUnwindSafe for WGPUBackend
impl !UnwindSafe for WGPUBackend
impl Send for WGPUBackend
impl Sync for WGPUBackend
impl Unpin for WGPUBackend
impl UnsafeUnpin for WGPUBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> Component for T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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