Skip to main content

SurfaceBackend

Struct SurfaceBackend 

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

GLFWWebGPUBackend without the window: a webgpu::RendererBackend and gfx::Renderable presenting to a surface.

Implementations§

Source§

impl SurfaceBackend

Source

pub fn new( create_surface: impl FnOnce(&Instance) -> Result<Surface<'static>, String>, framebuffer_size: Size, cap_frame_rate: bool, ) -> Result<SurfaceBackend, String>

The constructor of GLFWWebGPUBackend(window, capFrameRate) from the instance on: adapter, device, surface (made by create_surface from the window’s handles), format selection and configuration.

Source

pub fn from_host( instance: Instance, device: Device, queue: Queue, surface: Surface<'static>, format: TextureFormat, framebuffer_size: Size, ) -> SurfaceBackend

Port-only: a backend on a device and surface that the host created, as maplibre-native-ffi’s mln_map_attach_web_gpu_surface passes them (wrapped by mln_wgpu_webgpu_h::wrap_host_objects). There is no adapter: the surface is configured with format, for rendering only, and presents in FIFO order, which every surface supports.

Source

pub fn webgpu_backend(&self) -> &RendererBackend

Source

pub fn get_adapter_info(&self) -> &AdapterInfo

The adapter in use (name, backend, driver).

Source

pub fn get_swap_chain_format(&self) -> TextureFormat

The swapchain format picked from the surface capabilities.

Source

pub fn get_framebuffer_size(&self) -> Size

getFramebufferSize()

Source

pub fn set_framebuffer_size(&self, new_size: Size)

setFramebufferSize(Size)

Source

pub fn swap(&self)

swap()

Source

pub fn process_events(&self)

processEvents()

Source

pub fn acquire_next_texture(&self) -> bool

Port-only: acquires the next swapchain texture ahead of a frame; false when the surface has none right now (timeout, occluded, outdated). The caller skips the frame: a render pass without a color attachment trips the drawables’ debug assertions.

Source

pub fn request_readback(&self)

Port-only: copy the next presented frame (see take_readback).

Source

pub fn take_readback(&self) -> Option<PremultipliedImage>

Port-only: the frame copied after request_readback, once presented.

Source

pub fn get_device(&self) -> Device

The device, for tests and tools.

Trait Implementations§

Source§

impl Drop for SurfaceBackend

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Renderable for SurfaceBackend

Source§

fn renderable_base(&self) -> &RenderableBase

Source§

fn get_size(&self) -> Size

Source§

fn get_resource(&self) -> Option<Rc<dyn RenderableResource>>

getResource<T>() without the cast: the caller downcasts.
Source§

fn has_resource(&self) -> bool

Source§

fn set_resource(&self, resource: Option<Rc<dyn RenderableResource>>)

Source§

fn wait(&self)

Source§

fn set_renderable_size(&self, size: Size)

setRenderableSize (protected in C++).
Source§

fn is_same_renderable(&self, other: &dyn Renderable) -> bool

operator!=: compares the resource pointers.
Source§

impl RendererBackend for SurfaceBackend

Source§

fn renderer_backend_base(&self) -> &RendererBackendBase

Source§

fn as_any(&self) -> &dyn Any

Source§

fn get_default_renderable(&self) -> &dyn Renderable

Returns a reference to the default surface that should be rendered on.
Source§

fn init_shaders( &self, registry: &ShaderRegistry, parameters: &ProgramParameters, )

One-time shader initialization
Source§

fn create_context(&self) -> Rc<dyn GfxContext>

Called when the backend’s GL context needs to be made active or inactive (protected + friend class BackendScope in C++).
Source§

fn activate(&self)

Source§

fn deactivate(&self)

Source§

fn get_context(&self) -> &(dyn Context + 'static)

Returns the device’s context, created on first use (std::call_once). Must be called inside a BackendScope.
Source§

fn get_context_ptr(&self) -> &Rc<dyn Context>

The context as a shared pointer (the C++ context is owned by the backend; passes and resources in the port hold Rcs instead of references).
Source§

fn context_is_shared(&self) -> bool

Source§

fn unique_id(&self) -> SimpleIdentity

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> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

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> 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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>