pub struct WgpuSharedExportRenderer { /* private fields */ }Expand description
跨框架零拷贝显存共享导出渲染器(无锁三缓冲邮箱 + 3 帧脏区合并 + 预乘 Alpha HUD + 延迟回收)。
Implementations§
Sourcepub fn new(
width: u32,
height: u32,
adapter_luid: Option<[u8; 8]>,
device_uuid: Option<[u8; 16]>,
) -> Option<Self>
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 叠放至外部窗口上方。
Sourcepub fn from_context(
ctx: PreparedWgpuContext,
width: u32,
height: u32,
format: TextureFormat,
) -> Self
pub fn from_context( ctx: PreparedWgpuContext, width: u32, height: u32, format: TextureFormat, ) -> Self
从已有的 PreparedWgpuContext(支持与外部渲染器共享同一 wgpu::Device)创建三缓冲共享导出渲染器。
Sourcepub fn set_clear_color(&mut self, color: Color)
pub fn set_clear_color(&mut self, color: Color)
设置清屏背景色(默认 wgpu::Color::TRANSPARENT,供镂空悬浮 HUD 预乘 Alpha 合成)。
Sourcepub const fn generation_id(&self) -> u32
pub const fn generation_id(&self) -> u32
返回当前共享表面重建代数 generation_id。
Sourcepub const fn format(&self) -> TextureFormat
pub const fn format(&self) -> TextureFormat
返回当前像素格式。
Sourcepub fn adapter_info(&self) -> (&str, &'static str)
pub fn adapter_info(&self) -> (&str, &'static str)
返回物理适配器名称与图形 API 名称。
Sourcepub const fn adapter_luid(&self) -> Option<[u8; 8]>
pub const fn adapter_luid(&self) -> Option<[u8; 8]>
返回当前匹配到的 Windows DX12 物理显卡 LUID(若可用)。
Sourcepub const fn device_uuid(&self) -> Option<[u8; 16]>
pub const fn device_uuid(&self) -> Option<[u8; 16]>
返回当前匹配到的 Vulkan 物理显卡 UUID(若可用)。
Sourcepub fn sync_handle(&self) -> ExternalSyncHandle
pub fn sync_handle(&self) -> ExternalSyncHandle
返回跨平台共享 GPU 同步栅栏句柄。
Sourcepub fn renderer_mut(&mut self) -> &mut WgpuRenderer
pub fn renderer_mut(&mut self) -> &mut WgpuRenderer
返回内部 WgpuRenderer 可变引用。
Sourcepub fn register_external_texture(
&mut self,
view: TextureView,
sampler: Option<Sampler>,
) -> ExternalTextureId
pub fn register_external_texture( &mut self, view: TextureView, sampler: Option<Sampler>, ) -> ExternalTextureId
注册外部零拷贝 GPU 纹理(支持“导入外部海图 -> Velox 叠加毛玻璃 HUD -> 导出共享句柄”全链路闭环)。
Sourcepub fn update_external_texture(
&mut self,
id: ExternalTextureId,
view: TextureView,
) -> bool
pub fn update_external_texture( &mut self, id: ExternalTextureId, view: TextureView, ) -> bool
原地更新已注册的外部零拷贝 GPU 纹理视图。
Sourcepub fn unregister_external_texture(&mut self, id: ExternalTextureId) -> bool
pub fn unregister_external_texture(&mut self, id: ExternalTextureId) -> bool
注销外部零拷贝纹理。
Sourcepub fn retired_pool_count(&self) -> usize
pub fn retired_pool_count(&self) -> usize
返回待延迟销毁的旧代数池数量(用于验证 Resize 后的延迟回收机制)。
Sourcepub fn resize(&mut self, width: u32, height: u32)
pub fn resize(&mut self, width: u32, height: u32)
调整导出表面物理尺寸:重建三缓冲并递增 generation_id,将旧槽位移入延迟回收队列防悬垂。
Sourcepub fn gc_retired_pools(&mut self)
pub fn gc_retired_pools(&mut self)
回收宿主已释放且 GPU 栅栏已完成的旧代数共享池。
Sourcepub fn render_draw_ops(
&mut self,
ops: &[DrawOp<'_>],
viewport: Region,
scale_factor: f32,
dirty_regions: &[Region],
) -> u64
pub fn render_draw_ops( &mut self, ops: &[DrawOp<'_>], viewport: Region, scale_factor: f32, dirty_regions: &[Region], ) -> u64
将当前帧 DrawOp 渲染并零拷贝发布到三缓冲邮箱的 Ready 槽位,返回该帧对应的 GPU 栅栏值。
Sourcepub fn step_and_render(
&mut self,
engine: &mut VeloxEngine,
dt_ms: u16,
) -> Option<u64>
pub fn step_and_render( &mut self, engine: &mut VeloxEngine, dt_ms: u16, ) -> Option<u64>
推进一帧 VeloxEngine 并在有脏区(或首帧)时渲染发布至共享三缓冲邮箱。
宿主合成线程无锁获取最新就绪的共享显存帧句柄(若无新帧则返回当前 read 槽位且 is_fresh = false)。
宿主完成采样后归还帧租约;若为旧代数租约则标记为可安全回收并触发延迟垃圾回收。
Sourcepub fn wait_fence_cpu(&self, fence_value: u64, timeout_ms: u32) -> bool
pub fn wait_fence_cpu(&self, fence_value: u64, timeout_ms: u32) -> bool
阻塞等待指定栅栏值在 GPU 上执行完毕(主要供同步测试或同步宿主使用)。
Auto Trait Implementations§
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FluentBuilder for T
impl<T> FluentBuilder for T
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
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
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
fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self
option 为 Some(value) 时执行闭包修饰自身,否则原样返回。