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
impl SurfaceBackend
Sourcepub fn new(
create_surface: impl FnOnce(&Instance) -> Result<Surface<'static>, String>,
framebuffer_size: Size,
cap_frame_rate: bool,
) -> Result<SurfaceBackend, String>
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.
Sourcepub fn from_host(
instance: Instance,
device: Device,
queue: Queue,
surface: Surface<'static>,
format: TextureFormat,
framebuffer_size: Size,
) -> SurfaceBackend
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.
pub fn webgpu_backend(&self) -> &RendererBackend
Sourcepub fn get_adapter_info(&self) -> &AdapterInfo
pub fn get_adapter_info(&self) -> &AdapterInfo
The adapter in use (name, backend, driver).
Sourcepub fn get_swap_chain_format(&self) -> TextureFormat
pub fn get_swap_chain_format(&self) -> TextureFormat
The swapchain format picked from the surface capabilities.
Sourcepub fn get_framebuffer_size(&self) -> Size
pub fn get_framebuffer_size(&self) -> Size
getFramebufferSize()
Sourcepub fn set_framebuffer_size(&self, new_size: Size)
pub fn set_framebuffer_size(&self, new_size: Size)
setFramebufferSize(Size)
Sourcepub fn process_events(&self)
pub fn process_events(&self)
processEvents()
Sourcepub fn acquire_next_texture(&self) -> bool
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.
Sourcepub fn request_readback(&self)
pub fn request_readback(&self)
Port-only: copy the next presented frame (see take_readback).
Sourcepub fn take_readback(&self) -> Option<PremultipliedImage>
pub fn take_readback(&self) -> Option<PremultipliedImage>
Port-only: the frame copied after request_readback, once presented.
Sourcepub fn get_device(&self) -> Device
pub fn get_device(&self) -> Device
The device, for tests and tools.
Trait Implementations§
Source§impl Drop for SurfaceBackend
impl Drop for SurfaceBackend
Source§impl Renderable for SurfaceBackend
impl Renderable for SurfaceBackend
fn renderable_base(&self) -> &RenderableBase
fn get_size(&self) -> Size
Source§fn get_resource(&self) -> Option<Rc<dyn RenderableResource>>
fn get_resource(&self) -> Option<Rc<dyn RenderableResource>>
getResource<T>() without the cast: the caller downcasts.fn has_resource(&self) -> bool
fn set_resource(&self, resource: Option<Rc<dyn RenderableResource>>)
fn wait(&self)
Source§fn set_renderable_size(&self, size: Size)
fn set_renderable_size(&self, size: Size)
setRenderableSize (protected in C++).Source§fn is_same_renderable(&self, other: &dyn Renderable) -> bool
fn is_same_renderable(&self, other: &dyn Renderable) -> bool
operator!=: compares the resource pointers.Source§impl RendererBackend for SurfaceBackend
impl RendererBackend for SurfaceBackend
fn renderer_backend_base(&self) -> &RendererBackendBase
fn as_any(&self) -> &dyn Any
Source§fn get_default_renderable(&self) -> &dyn Renderable
fn get_default_renderable(&self) -> &dyn Renderable
Source§fn init_shaders(
&self,
registry: &ShaderRegistry,
parameters: &ProgramParameters,
)
fn init_shaders( &self, registry: &ShaderRegistry, parameters: &ProgramParameters, )
Source§fn create_context(&self) -> Rc<dyn GfxContext>
fn create_context(&self) -> Rc<dyn GfxContext>
friend class BackendScope in C++).fn activate(&self)
fn deactivate(&self)
Source§fn get_context(&self) -> &(dyn Context + 'static)
fn get_context(&self) -> &(dyn Context + 'static)
std::call_once).
Must be called inside a BackendScope.Source§fn get_context_ptr(&self) -> &Rc<dyn Context>
fn get_context_ptr(&self) -> &Rc<dyn Context>
Rcs instead of
references).