Skip to main content

RecordingBackend

Struct RecordingBackend 

Source
pub struct RecordingBackend {
    pub calls: Vec<BackendCall>,
    pub last_frame: Option<Frame>,
    pub occluded: bool,
    pub fail_present: bool,
}
Expand description

只记录调用、不真正渲染的后端。

用途:断言“框架层产生了什么绘制指令“,与真实后端对拍。 它同时保存最近一帧的完整 Frame,便于逐实例比较。

Fields§

§calls: Vec<BackendCall>

按顺序记录的调用;测试用它断言“不该发生的调用确实没发生“(例如遮挡时不该有 Present)。

§last_frame: Option<Frame>

最近一帧的内容(供断言检查实例数、脏区)。

§occluded: bool

上次提交是否因被遮挡而跳过;mock 用它模拟遮挡场景。

§fail_present: bool

强制 present 返回 Err,用于测试“设备丢失“分支。

Implementations§

Source§

impl RecordingBackend

Source

pub fn new() -> Self

新建空的记录型后端(尚未 create,calls 为空)。

返回:可直接用于对拍的空实例。副作用:无。 注意:正常流程应走 RenderBackend::create(会记录一条 Create); 直接 new() 只用于“只想记录 present“的测试。

Source

pub fn presents(&self) -> impl Iterator<Item = &BackendCall>

所有 Present 记录。

Trait Implementations§

Source§

impl Debug for RecordingBackend

Source§

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

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

impl Default for RecordingBackend

Source§

fn default() -> Self

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

impl RenderBackend for RecordingBackend

Source§

fn create( _handle: PlatformWindowHandle, width: u32, height: u32, ) -> Result<Self, String>

创建后端并绑定窗口。 Read more
Source§

fn rebuild(&mut self, width: u32, height: u32) -> Result<(), String>

设备丢失后重建全部 GPU 资源(保留尺寸)。
Source§

fn resize(&mut self, width: u32, height: u32) -> Result<(), String>

调整渲染尺寸(交换链 / 后缓冲)。
Source§

fn present(&mut self, frame: &Frame) -> Result<(), String>

提交一帧。 Read more
Source§

fn is_occluded(&self) -> bool

上一次 present 是否返回被遮挡(如 D3D11 的 DXGI_STATUS_OCCLUDED)。 无参查询,因此是缓存值,不是实时状态。
Source§

fn instance_count(&self) -> usize

上次 present 的实例数(诊断用)。

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