Skip to main content

Wgpu3DRenderer

Struct Wgpu3DRenderer 

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

Hardware-accelerated wgpu 3D renderer capable of rendering directly into any TextureView (swapchain surface) or offscreen RGBA target.

Implementations§

Source§

impl Wgpu3DRenderer

Source

pub fn new_headless(color_format: TextureFormat) -> Result<Self, String>

Creates a headless Wgpu3DRenderer using any available hardware or software Vulkan/GL adapter.

Source

pub fn from_device( device: Arc<Device>, queue: Arc<Queue>, color_format: TextureFormat, ) -> Self

Creates a Wgpu3DRenderer bound to an existing wgpu::Device & wgpu::Queue (e.g., from a window surface).

Source

pub fn device(&self) -> &Arc<Device> ⓘ

Source

pub fn queue(&self) -> &Arc<Queue> ⓘ

Source

pub fn color_format(&self) -> TextureFormat

Source

pub fn cached_geo_mesh_count(&self) -> usize

Number of currently cached GPU geodetic object mesh buffers.

Source

pub fn cached_geo_texture_count(&self) -> usize

Number of currently cached GPU geodetic object albedo textures.

Source

pub fn poll_gpu_timestamps(&mut self)

Polls any completed asynchronous GPU timestamp query readbacks without stalling.

Source

pub fn last_gpu_pass_timings(&self) -> GpuPassTimings

Returns the most recently resolved hardware GPU pass timings (or supported: false when wgpu::Features::TIMESTAMP_QUERY is unavailable on the active adapter).

Source

pub fn gpu_memory_bytes(&self) -> u64

Total GPU buffer, texture atlas, and render-target memory allocated by this 3D renderer.

Source

pub fn create_overlay_bind_group(&self, overlay_view: &TextureView) -> BindGroup

Creates an RGBA wgpu::BindGroup for compositing a 2D UI HUD texture over a 3D frame.

Source

pub fn render_scene_to_view( &mut self, scene: &Scene3D, target_view: &TextureView, target_width: u32, target_height: u32, viewport: Option<[f32; 4]>, unlimited_upload_budget: bool, )

Draws scene (or its [RetainedScene3D] / RetainedTerrainFrame) directly into target_view.

When viewport is Some([x, y, w, h]), restricts rendering to that sub-rectangle of the render target and uses w/h as the projection aspect ratio.

Source

pub fn render_scene_and_overlay_to_view( &mut self, scene: &Scene3D, target_view: &TextureView, target_width: u32, target_height: u32, viewport: Option<[f32; 4]>, unlimited_upload_budget: bool, overlay_bind_group: Option<&BindGroup>, )

Draws scene and optionally composites the cached 2D HUD overlay_bind_group into target_view using a single CommandEncoder and a single queue.submit.

Source

pub fn render_scene_preserving_color_to_view( &mut self, scene: &Scene3D, target_view: &TextureView, target_width: u32, target_height: u32, viewport: Option<[f32; 4]>, unlimited_upload_budget: bool, )

Renders scene into target_view inside viewport without clearing prior color pixels, allowing previously rendered 2D UI layers behind the 3D viewport to remain intact.

Source

pub fn render_viewports_and_overlay_to_view( &mut self, viewports: &[([f32; 4], &Scene3D)], target_view: &TextureView, target_width: u32, target_height: u32, unlimited_upload_budget: bool, overlay_bind_group: Option<&BindGroup>, )

Renders multiple 3D viewports ((viewport_rect, scene)) sequentially into target_view without clearing prior viewports, and composites overlay_bind_group once on the final pass.

Source

pub fn composite_overlay_to_view( &self, target_view: &TextureView, overlay_bind_group: &BindGroup, )

Composites a GPU 2D UI HUD overlay bind group on top of target_view (preserving alpha).

Source

pub fn composite_cached_scene_and_overlay_to_view( &mut self, target_view: &TextureView, cached_scene_bind_group: &BindGroup, overlay_bind_group: Option<&BindGroup>, )

Blits a cached offscreen 3D scene color attachment into target_view and composites an optional 2D UI overlay on top in a single lightweight fullscreen render pass.

Source

pub fn render_offscreen( &mut self, scene: &Scene3D, width: u32, height: u32, readback: bool, unlimited_upload_budget: bool, ) -> Result<Vec<u8>, String>

Renders scene into a persistent offscreen texture and performs GPU->CPU readback only when readback is true (pure GPU timing benchmarks pass readback = false).

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> 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> 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> IntoInitialState<T> for T

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>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,