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: InstanceKept 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: AdapterThe adapter device came from, kept so a replacement surface can be
checked against the configuration before it is applied.
device: Device§queue: Queue§config: SurfaceConfigurationImplementations§
Source§impl Renderer
impl Renderer
Sourcepub fn adapter_name(&self) -> String
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.
pub async fn new<W>(window: W) -> Result<Self>
Sourcepub unsafe fn replace_surface_from_raw_handles(
&mut self,
raw_display_handle: RawDisplayHandle,
raw_window_handle: RawWindowHandle,
width: u32,
height: u32,
) -> Result<()>
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.
Sourcepub fn set_wait_display_vsync(&mut self, wait_display_vsync: bool)
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.
pub fn scale_factor(&self) -> f32
pub fn surface_viewport(&self) -> (u32, u32, u32, u32)
pub fn resize(&mut self, width: u32, height: u32)
pub fn resize_with_scale(&mut self, width: u32, height: u32, scale_factor: f32)
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, )
pub fn logical_size(&self) -> (u32, u32)
pub fn render_sprites( &mut self, images: &ImageManager, sprites: &[RenderSprite], ) -> Result<()>
pub fn render_frame( &mut self, images: &ImageManager, frame_plan: &RenderFrame, ) -> Result<()>
Sourcepub fn debug_render_chain_texture_metadata(&self) -> Vec<RendererDebugTexture>
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.
Sourcepub fn debug_read_render_chain_textures(
&self,
) -> Result<Vec<RendererDebugTexture>>
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.
Sourcepub fn clear_runtime_image_textures(&mut self)
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.
pub fn texture_cache_bytes(&self) -> u64
Sourcepub fn debug_memory_stats(&self) -> RendererMemoryStats
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 FrameCaptureBackend for Renderer
impl FrameCaptureBackend for Renderer
fn capture_render_frame( &mut self, images: &ImageManager, frame: &RenderFrame, logical_width: u32, logical_height: u32, ) -> Result<RgbaImage>
Auto Trait Implementations§
impl !Freeze for Renderer
impl !RefUnwindSafe for Renderer
impl !UnwindSafe for Renderer
impl Send for Renderer
impl Sync for Renderer
impl Unpin for Renderer
impl UnsafeUnpin for Renderer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.