pub struct WgpuBackend {
    pub instance: Arc<Instance>,
    pub adapter: Arc<Adapter>,
    pub device: Arc<Device>,
    pub queue: Arc<Queue>,
    pub painter: EguiPainter,
    pub surface_manager: SurfaceManager,
    pub command_encoders: Vec<CommandEncoder>,
}
Expand description

This provides a Gfx backend for egui using wgpu as the backend If you are making your own wgpu integration, then you can reuse the EguiPainter instead which contains only egui render specific data.

Fields§

§instance: Arc<Instance>

wgpu instance

§adapter: Arc<Adapter>

wgpu adapter

§device: Arc<Device>

wgpu device.

§queue: Arc<Queue>

wgpu queue. if you have commands that you would like to submit, instead push them into Self::command_encoders

§painter: EguiPainter

contains egui specific wgpu data like textures or buffers or pipelines etc..

§surface_manager: SurfaceManager§command_encoders: Vec<CommandEncoder>

this is where we store our command encoders. we will create one during the prepare_frame fn. users can just use this. or create new encoders, and push them into this vec. wgpu::Queue::submit is very expensive, so we will submit ALL command encoders at the same time during the present_frame method just before presenting the swapchain image (surface texture).

Implementations§

source§

impl WgpuBackend

source

pub async fn new_async( window_backend: &mut impl WindowBackend, config: <Self as GfxBackend>::Configuration ) -> Self

Trait Implementations§

source§

impl Drop for WgpuBackend

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl GfxBackend for WgpuBackend

§

type Configuration = WgpuConfig

similar to WindowBackendConfig. A custom config struct for the creation of GfxBackend
source§

fn new( window_backend: &mut impl WindowBackend, config: Self::Configuration ) -> Self

create a new GfxBackend using info from window backend and custom config struct WindowBackend trait provides the backend config, which can be used by the renderer to check for compatibility. Read more
source§

fn resume(&mut self, window_backend: &mut impl WindowBackend)

Android Only. called when app is resumed after suspension. On Android, window can only be created on resume event. so, you cannot create a Surface before entering the event loop. when this fn is called, we can create a new surface (swapchain) for the window. doesn’t apply on other platforms.
source§

fn prepare_frame(&mut self, window_backend: &mut impl WindowBackend)

prepare the surface / swapchain etc.. by acquiring an image for the current frame. use WindowBackend::get_live_physical_size_framebuffer fn to resize your swapchain if it is out of date.
source§

fn render_egui( &mut self, meshes: Vec<ClippedPrimitive>, textures_delta: TexturesDelta, logical_screen_size: [f32; 2] )

This is where the renderers will start creating renderpasses, issue draw calls etc.. using the data previously prepared.
source§

fn present(&mut self, _window_backend: &mut impl WindowBackend)

This is called at the end of the frame. after everything is drawn, you can now present on opengl, renderer might call WindowBackend::swap_buffers. on wgpu / vulkan, renderer might submit commands to queues, present swapchain image etc..
source§

fn resize_framebuffer(&mut self, window_backend: &mut impl WindowBackend)

called if framebuffer has been resized. use this to reconfigure your swapchain/surface/viewport..
source§

fn suspend(&mut self, _window_backend: &mut impl WindowBackend)

Android only. callend on app suspension, which destroys the window. so, will need to destroy the Surface and recreate during resume event. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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

impl<T> Upcast<T> for T

§

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
§

impl<T> WasmNotSend for Twhere T: Send,

§

impl<T> WasmNotSync for Twhere T: Sync,