1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 04:40:03 -04:00

Make wgpu Instance public (#8321)

This commit is contained in:
oleflb
2026-08-03 13:53:28 +02:00
committed by GitHub
parent ddec5f3e4c
commit 3d70aa1123

View File

@@ -115,6 +115,9 @@ pub struct RenderState {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
pub available_adapters: Vec<wgpu::Adapter>, pub available_adapters: Vec<wgpu::Adapter>,
/// Wgpu instance used for creating surfaces and adapters.
pub instance: wgpu::Instance,
/// Wgpu device used for rendering, created from the adapter. /// Wgpu device used for rendering, created from the adapter.
pub device: wgpu::Device, pub device: wgpu::Device,
@@ -218,7 +221,7 @@ impl RenderState {
instance.enumerate_adapters(backends).await instance.enumerate_adapters(backends).await
}; };
let (adapter, device, queue) = match config.wgpu_setup.clone() { let (instance, adapter, device, queue) = match config.wgpu_setup.clone() {
WgpuSetup::CreateNew(WgpuSetupCreateNew { WgpuSetup::CreateNew(WgpuSetupCreateNew {
instance_descriptor: _, instance_descriptor: _,
display_handle: _, display_handle: _,
@@ -253,14 +256,14 @@ impl RenderState {
.await? .await?
}; };
(adapter, device, queue) (instance.clone(), adapter, device, queue)
} }
WgpuSetup::Existing(WgpuSetupExisting { WgpuSetup::Existing(WgpuSetupExisting {
instance: _, instance,
adapter, adapter,
device, device,
queue, queue,
}) => (adapter, device, queue), }) => (instance, adapter, device, queue),
}; };
log_adapter_info(&adapter.get_info()); log_adapter_info(&adapter.get_info());
@@ -280,6 +283,7 @@ impl RenderState {
// It doesn't make sense to switch to Rc for that special usecase, so simply disable the lint. // It doesn't make sense to switch to Rc for that special usecase, so simply disable the lint.
#[allow(clippy::allow_attributes, clippy::arc_with_non_send_sync)] // For wasm #[allow(clippy::allow_attributes, clippy::arc_with_non_send_sync)] // For wasm
Ok(Self { Ok(Self {
instance,
adapter, adapter,
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
available_adapters, available_adapters,