Skip to main content

Renderer

Struct Renderer 

Source
pub struct Renderer {
    pub gpu_profiler: Option<GpuProfiler>,
    /* private fields */
}

Fields§

§gpu_profiler: Option<GpuProfiler>

阶段 B4:GPU 端 timestamp profiler(None = 设备不支持 TIMESTAMP_QUERY)

Implementations§

Source§

impl Renderer

Source

pub fn register_image( &mut self, device: &Device, queue: &Queue, texture_id: u32, data: &ImageData, )

阶段 6(图片):注册图片数据并上传 GPU(幂等,已存在则跳过)。

调用时机:应用在构造 ImageWidget 之后、首帧渲染前调一次 (img.texture_id + img.image 都是 pub 字段);数据由调用方持有, GPU 侧只留纹理(注册后应用可释放 ImageData)。

Source§

impl Renderer

Source

pub fn render_to_rgba( &mut self, device: &Device, queue: &Queue, frame_paint: &FramePaint, logical_size: Size, scale_factor: f32, ) -> Result<Vec<u8>, String>

离屏渲染整帧并读回 straight RGBA8。

GPU 侧与窗口路径共用同一个 render()(同 layer 合成/effects),只是把 View 换成离屏纹理;用于黄金测试/截图导出。注意 Pass2 会按窗口背景色 clear,输出 alpha 为 1;需要透明背景请自行绘制背景或使用软件光栅器。

Source

pub fn render( &mut self, device: &Device, queue: &Queue, view: &TextureView, frame_paint: &FramePaint, screen_size: (f32, f32), physical_size: (u32, u32), )

Source§

impl Renderer

Source

pub fn shared_resources(&self) -> RendererShared

克隆可跨窗口复用的 pipeline / layout / sampler 句柄。

Source

pub fn new_with_shared(device: &Device, shared: &RendererShared) -> Self

复用另一个窗口的 pipeline/layout/sampler,只初始化本窗口缓存。

Source

pub fn new(device: &Device, format: TextureFormat) -> Self

Source§

impl Renderer

Source

pub fn last_stats(&self) -> RenderStats

P2-1.5:上一帧绘制统计(draw calls / segment / scratch 内存)

Source

pub fn image_texture_stats(&self) -> ImageTextureStats

当前图片纹理数量/字节数与预算

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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>