pub struct PreparedWgpuContext { /* private fields */ }Expand description
后台线程无头预初始化的 wgpu 设备与预编译 2D SDF 渲染管线上下文(可跨线程 Send 移交主线程)。
用于实现「秒开首屏 + 异步后台 GPU 无缝热升舱」:
后台线程并发执行最耗时的图形驱动加载、request_adapter、request_device 与着色器管线编译,
就绪后主线程仅需 ~10ms 绑定窗口 Surface 即可零闪烁接管至硬件加速渲染。
Implementations§
Source§impl PreparedWgpuContext
impl PreparedWgpuContext
Sourcepub fn init_headless() -> Option<Self>
pub fn init_headless() -> Option<Self>
在无窗口句柄的独立后台线程中完成 wgpu 驱动加载、设备创建与着色器管线预编译。
直接复用外部引擎(如海图/3D/视频渲染器)已创建的 wgpu::Device 与 wgpu::Queue 构建共享上下文。
外部引擎与 Velox 共享同一物理 GPU 与命令队列后,可将外部 wgpu::TextureView 通过
WgpuRenderer::register_external_texture 零拷贝嵌入 Velox UI,无需任何跨 API 句柄转换或 CPU 回读。
Sourcepub fn from_host_adapter_id(
adapter_luid: Option<[u8; 8]>,
device_uuid: Option<[u8; 16]>,
) -> Option<Self>
pub fn from_host_adapter_id( adapter_luid: Option<[u8; 8]>, device_uuid: Option<[u8; 16]>, ) -> Option<Self>
按宿主物理显卡标识(Windows DX12 LUID 或 Linux/Android Vulkan deviceUUID)对齐并创建上下文。
- 启用
gpu-interopfeature 时,通过底层wgpu-hal精确匹配与宿主 Qt/GTK4/WPF/WinUI 相同的物理 GPU 并激活跨进程/跨 API 外部显存与信号量扩展; - 未启用
gpu-interop或参数均为None时自动退化为默认硬件无头初始化。
Sourcepub fn adapter_name(&self) -> &str
pub fn adapter_name(&self) -> &str
返回适配器名称。
Sourcepub const fn backend_name(&self) -> &'static str
pub const fn backend_name(&self) -> &'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 take_or_create_renderer(&mut self, format: TextureFormat) -> WgpuRenderer
pub fn take_or_create_renderer(&mut self, format: TextureFormat) -> WgpuRenderer
取出预编译的 WgpuRenderer(若格式一致)或按指定像素格式即时构建。
Trait Implementations§
impl Send for PreparedWgpuContext
Auto Trait Implementations§
impl !RefUnwindSafe for PreparedWgpuContext
impl !UnwindSafe for PreparedWgpuContext
impl Forget for PreparedWgpuContext
impl Freeze for PreparedWgpuContext
impl Move for PreparedWgpuContext
impl Sync for PreparedWgpuContext
impl Unpin for PreparedWgpuContext
impl UnsafeUnpin for PreparedWgpuContext
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
Mutably borrows from an owned value. Read more
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) 时执行闭包修饰自身,否则原样返回。