Skip to main content

WgpuRenderSystem

Struct WgpuRenderSystem 

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

The concrete, WGPU-based implementation of the [RenderSystem] trait.

This struct encapsulates all the state necessary to drive rendering with WGPU, including the graphics context, the logical device, GPU profiler, and complex state for handling window resizing gracefully.

It acts as the primary rendering backend for the engine when the WGPU feature is enabled.

Implementations§

Source§

impl WgpuRenderSystem

Source

pub fn new() -> Self

Creates a new, uninitialized WgpuRenderSystem.

The system is not usable until [RenderSystem::init] is called.

Source

pub fn create_viewport_target( &mut self, width: u32, height: u32, overlay: &mut EguiOverlay, ) -> Result<TextureId, RenderError>

Creates an offscreen render target for the editor viewport and registers it as an egui texture.

Returns the egui::TextureId that can be displayed via [UiBuilder::viewport_image].

Source

pub fn render_viewport_clear( &mut self, clear_color: LinearRgba, ) -> Result<(), RenderError>

Renders a clear pass to the offscreen viewport target.

Call this once per frame (after begin_frame(), before render_overlay()). The cleared image will be visible in the egui viewport panel.

Source

pub fn viewport_size(&self) -> (u32, u32)

Returns the current viewport dimensions (width, height) in pixels.

Source

pub fn create_editor_overlay( &self, event_loop: &ActiveEventLoop, shader_source: &str, ) -> Result<EguiOverlay, RenderError>

Creates an [EguiOverlay] backed by the current wgpu graphics context.

Must be called after [RenderSystem::init].

Source

pub fn create_editor_overlay_and_shell( &mut self, event_loop: &ActiveEventLoop, shader_source: &str, theme: UiTheme, viewport_handle: ViewportTextureHandle, ) -> Result<(EguiOverlay, EguiEditorShell), RenderError>

Creates an [EguiOverlay] and an [EguiEditorShell] that share the same egui::Context, plus an offscreen viewport target.

The overlay handles input / rendering while the shell manages the dock layout, menu bar, toolbar, and panel dispatch. The viewport target is an offscreen texture used to display the 3D scene inside an egui panel.

Trait Implementations§

Source§

impl Debug for WgpuRenderSystem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WgpuRenderSystem

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl RenderSystem for WgpuRenderSystem

Source§

fn init( &mut self, window: &dyn KhoraWindow, ) -> Result<Vec<Arc<dyn ResourceMonitor>>, RenderError>

Initializes the rendering system with a given window. Read more
Source§

fn resize(&mut self, new_width: u32, new_height: u32)

Notifies the rendering system that the output window has been resized.
Source§

fn prepare_frame(&mut self, view_info: &ViewInfo)

Prepares for a new frame. Read more
Source§

fn render( &mut self, renderables: &[RenderObject], _view_info: &ViewInfo, settings: &RenderSettings, ) -> Result<RenderStats, RenderError>

Renders a single frame from a flat list of render objects. Read more
Source§

fn begin_frame(&mut self) -> Result<FrameTargets, RenderError>

Begins a new visual frame by acquiring the swapchain (or viewport) texture. Read more
Source§

fn end_frame(&mut self) -> Result<RenderStats, RenderError>

Ends the current visual frame by presenting the swapchain texture. Read more
Source§

fn render_overlay( &mut self, overlay: &mut dyn EditorOverlay, screen: OverlayScreenDescriptor, ) -> Result<(), RenderError>

Renders an editor overlay on top of the current frame. Read more
Source§

fn get_last_frame_stats(&self) -> &RenderStats

Returns a reference to the statistics of the last successfully rendered frame.
Source§

fn supports_feature(&self, feature_name: &str) -> bool

Checks if a specific, optional rendering feature is supported by the backend.
Source§

fn shutdown(&mut self)

Cleans up and releases all graphics resources.
Source§

fn as_any(&self) -> &dyn Any

Allows downcasting to a concrete RenderSystem type.
Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Allows mutable downcasting to a concrete RenderSystem type.
Source§

fn render_to_viewport(&self) -> bool

Whether begin_frame targets an offscreen viewport instead of the swapchain. Read more
Source§

fn set_render_to_viewport(&mut self, enabled: bool)

Toggles whether begin_frame targets the offscreen viewport texture instead of the swapchain.
Source§

fn get_adapter_info(&self) -> Option<GraphicsAdapterInfo>

Returns information about the active graphics adapter (GPU).
Source§

fn graphics_device(&self) -> Arc<dyn GraphicsDevice>

Returns a shared, thread-safe reference to the underlying GraphicsDevice.
Source§

impl Send for WgpuRenderSystem

Source§

impl Sync for WgpuRenderSystem

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
§

impl<T> AppLifecycle for T
where T: ?Sized,

§

fn on_start(&mut self, ctx: &mut dyn AppContext)

Called once after the backend is up but before the first update. Apps install their theme / fonts here.
§

fn on_exit(&mut self)

Called once when the window is closing. Persist state here.
§

impl<T> AsAny for T
where T: Any,

§

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

Returns a reference to the inner value as &dyn Any.
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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

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

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

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

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

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

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

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

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

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

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSend for T
where T: Any + Send,

§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(value: T, _simd: S) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

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

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

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