Skip to main content

Renderer

Struct Renderer 

Source
pub struct Renderer {
    pub surface: Surface<'static>,
    pub instance: Instance,
    pub adapter: Adapter,
    pub device: Device,
    pub queue: Queue,
    pub config: SurfaceConfiguration,
    /* private fields */
}

Fields§

§surface: Surface<'static>§instance: Instance

Kept so that a replacement surface is created from the same instance (and therefore the same backend) as device. Android re-creates the ANativeWindow on every activity stop, and a surface built from a fresh instance may land on a different backend (GLES instead of Vulkan), which makes Surface::configure fail validation against the existing device.

§adapter: Adapter

The adapter device came from, kept so a replacement surface can be checked against the configuration before it is applied.

§device: Device§queue: Queue§config: SurfaceConfiguration

Implementations§

Source§

impl Renderer

Source

pub fn adapter_name(&self) -> String

Human-readable presentation adapter used by the VM’s compatibility variable. Platform renderers expose the same method without exposing their native graphics object to the host.

Source

pub async fn new<W>(window: W) -> Result<Self>
where W: Deref<Target = dyn Window> + Into<SurfaceTarget<'static>>,

Source

pub unsafe fn replace_surface_from_raw_handles( &mut self, raw_display_handle: RawDisplayHandle, raw_window_handle: RawWindowHandle, width: u32, height: u32, ) -> Result<()>

Re-attach a new platform surface to the existing device/queue.

Android destroys the ANativeWindow whenever the activity stops, so a background/foreground round trip hands us a new window while the engine state (VM, decoded resources) has to survive. The surface format is fixed by the platform, so the current configuration is reused and only the size changes; callers re-apply their logical viewport afterwards, exactly as they do after resize.

§Safety

Both handles must be valid and identify the same display/window pair. Their underlying native objects must remain valid until the replacement surface is dropped. Call on a thread permitted by the windowing platform.

Source

pub fn set_wait_display_vsync(&mut self, wait_display_vsync: bool)

Match tnm_set_wait_display_vsync() from the original engine.

The script-side SET_VSYNC_WAIT_OFF_FLAG only changes local engine state; eng_frame.cpp applies the resulting total state once per frame. Reconfigure the surface only when that desired state changes, matching the original change-on-difference behavior.

Source

pub fn scale_factor(&self) -> f32

Source

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

Source

pub fn resize(&mut self, width: u32, height: u32)

Source

pub fn resize_with_scale(&mut self, width: u32, height: u32, scale_factor: f32)

Source

pub fn resize_with_logical_viewport( &mut self, surface_width: u32, surface_height: u32, scale_factor: f32, logical_width: u32, logical_height: u32, viewport_x: u32, viewport_y: u32, viewport_width: u32, viewport_height: u32, )

Source

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

Source

pub fn render_sprites( &mut self, images: &ImageManager, sprites: &[RenderSprite], ) -> Result<()>

Source

pub fn render_frame( &mut self, images: &ImageManager, frame_plan: &RenderFrame, ) -> Result<()>

Source

pub fn debug_render_chain_texture_metadata(&self) -> Vec<RendererDebugTexture>

Metadata-only view of the current render-chain textures. This is safe to call every HUD frame: it never submits GPU work, maps a buffer or waits on the device. rgba is intentionally empty; F3 requests an explicit snapshot.

Source

pub fn debug_read_render_chain_textures( &self, ) -> Result<Vec<RendererDebugTexture>>

Explicit debug snapshot used only on user request. Unlike the metadata path above, this performs GPU->CPU copies and waits for completion.

Source

pub fn clear_runtime_image_textures(&mut self)

Drop GPU textures that are keyed by runtime ImageKey.

Scene restart reinitializes ImageManager and reuses ImageKey indices from 0. Keeping the old GPU cache would make a newly decoded image with the same ImageKey/version sample the previous scene’s texture. External path based textures are intentionally kept because their keys are stable resource paths.

Source

pub fn texture_cache_bytes(&self) -> u64

Source

pub fn debug_memory_stats(&self) -> RendererMemoryStats

Low-overhead renderer allocation accounting for the HUD. This only inspects sizes already stored by the renderer; it never maps or copies a GPU resource. Texture sizes include the same 4/3 mip estimate used by texture_cache_bytes().

Trait Implementations§

Source§

impl Debug for Renderer

Source§

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

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

impl FrameCaptureBackend for Renderer

Source§

fn capture_render_frame( &mut self, images: &ImageManager, frame: &RenderFrame, logical_width: u32, logical_height: u32, ) -> Result<RgbaImage>

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
§

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

§

fn downcast(&self) -> &T

§

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<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

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.

§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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,

§

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