Skip to main content

WgpuSharedExportRenderer

Struct WgpuSharedExportRenderer 

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

跨框架零拷贝显存共享导出渲染器(无锁三缓冲邮箱 + 3 帧脏区合并 + 预乘 Alpha HUD + 延迟回收)。

Implementations§

Source§

impl WgpuSharedExportRenderer

Source

pub fn new( width: u32, height: u32, adapter_luid: Option<[u8; 8]>, device_uuid: Option<[u8; 16]>, ) -> Option<Self>

按宿主物理显卡 LUID / UUID 对齐并初始化三缓冲共享导出渲染器。

默认使用 Bgra8Unorm(Windows/macOS/Linux 原生合成格式)与 wgpu::Color::TRANSPARENT 预乘透明清屏, 直接支持镂空悬浮 HUD 叠放至外部窗口上方。

Source

pub fn from_context( ctx: PreparedWgpuContext, width: u32, height: u32, format: TextureFormat, ) -> Self

从已有的 PreparedWgpuContext(支持与外部渲染器共享同一 wgpu::Device)创建三缓冲共享导出渲染器。

Source

pub fn set_clear_color(&mut self, color: Color)

设置清屏背景色(默认 wgpu::Color::TRANSPARENT,供镂空悬浮 HUD 预乘 Alpha 合成)。

Source

pub const fn generation_id(&self) -> u32

返回当前共享表面重建代数 generation_id。

Source

pub const fn size(&self) -> (u32, u32)

返回当前共享目标物理像素尺寸 (width, height)。

Source

pub const fn format(&self) -> TextureFormat

返回当前像素格式。

Source

pub fn device(&self) -> &Device

返回底层 wgpu::Device 引用(可用于同设备创建外部纹理并注册零拷贝导入)。

Source

pub fn queue(&self) -> &Queue

返回底层 wgpu::Queue 引用。

Source

pub fn adapter_info(&self) -> (&str, &'static str)

返回物理适配器名称与图形 API 名称。

Source

pub const fn adapter_luid(&self) -> Option<[u8; 8]>

返回当前匹配到的 Windows DX12 物理显卡 LUID(若可用)。

Source

pub const fn device_uuid(&self) -> Option<[u8; 16]>

返回当前匹配到的 Vulkan 物理显卡 UUID(若可用)。

Source

pub fn sync_handle(&self) -> ExternalSyncHandle

返回跨平台共享 GPU 同步栅栏句柄。

Source

pub fn renderer_mut(&mut self) -> &mut WgpuRenderer

返回内部 WgpuRenderer 可变引用。

Source

pub fn register_external_texture( &mut self, view: TextureView, sampler: Option<Sampler>, ) -> ExternalTextureId

注册外部零拷贝 GPU 纹理(支持“导入外部海图 -> Velox 叠加毛玻璃 HUD -> 导出共享句柄”全链路闭环)。

Source

pub fn update_external_texture( &mut self, id: ExternalTextureId, view: TextureView, ) -> bool

原地更新已注册的外部零拷贝 GPU 纹理视图。

Source

pub fn unregister_external_texture(&mut self, id: ExternalTextureId) -> bool

注销外部零拷贝纹理。

Source

pub fn retired_pool_count(&self) -> usize

返回待延迟销毁的旧代数池数量(用于验证 Resize 后的延迟回收机制)。

Source

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

调整导出表面物理尺寸:重建三缓冲并递增 generation_id,将旧槽位移入延迟回收队列防悬垂。

Source

pub fn gc_retired_pools(&mut self)

回收宿主已释放且 GPU 栅栏已完成的旧代数共享池。

Source

pub fn render_draw_ops( &mut self, ops: &[DrawOp<'_>], viewport: Region, scale_factor: f32, dirty_regions: &[Region], ) -> u64

将当前帧 DrawOp 渲染并零拷贝发布到三缓冲邮箱的 Ready 槽位,返回该帧对应的 GPU 栅栏值。

Source

pub fn step_and_render( &mut self, engine: &mut VeloxEngine, dt_ms: u16, ) -> Option<u64>

推进一帧 VeloxEngine 并在有脏区(或首帧)时渲染发布至共享三缓冲邮箱。

Source

pub fn acquire_shared_frame(&self) -> SharedFrameLease

宿主合成线程无锁获取最新就绪的共享显存帧句柄(若无新帧则返回当前 read 槽位且 is_fresh = false)。

Source

pub fn release_shared_frame(&mut self, generation_id: u32, _slot_index: u8)

宿主完成采样后归还帧租约;若为旧代数租约则标记为可安全回收并触发延迟垃圾回收。

Source

pub fn wait_fence_cpu(&self, fence_value: u64, timeout_ms: u32) -> bool

阻塞等待指定栅栏值在 GPU 上执行完毕(主要供同步测试或同步宿主使用)。

Source

pub fn readback_slot_bytes(&self, slot_index: u8) -> Option<Vec<u8>>

测试与诊断辅助:将指定共享槽位的显存内容回读为直通 RGBA/BGRA 字节流(验证真实渲染像素与透明通道)。

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

Source§

fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self

当 condition 为 true 时执行闭包修饰自身,否则原样返回。
Source§

fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self

根据 condition 在两个修饰分支之间二选一。
Source§

fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self

当 option 为 Some(value) 时执行闭包修饰自身,否则原样返回。
Source§

fn when_none<O>( self, option: &Option<O>, then: impl FnOnce(Self) -> Self, ) -> Self

当 option 为 None 时执行闭包修饰自身,否则原样返回。
Source§

fn apply<U>(self, f: impl FnOnce(Self) -> U) -> U

通用管道映射变换(避免与 Iterator::map / Option::map 重名)。
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> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

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