wgpu-core: Move Global to new global module.

This commit is contained in:
Jim Blandy
2023-05-22 13:54:20 -07:00
parent 9c8666a5c9
commit f00e6b70ea
23 changed files with 223 additions and 199 deletions

View File

@@ -94,7 +94,8 @@ fn check_unstable(state: &OpState, api_name: &str) {
}
}
pub type Instance = std::sync::Arc<wgpu_core::hub::Global<wgpu_core::hub::IdentityManagerFactory>>;
pub type Instance =
std::sync::Arc<wgpu_core::global::Global<wgpu_core::hub::IdentityManagerFactory>>;
struct WebGpuAdapter(Instance, wgpu_core::id::AdapterId);
impl Resource for WebGpuAdapter {
@@ -321,7 +322,7 @@ pub async fn op_webgpu_request_adapter(
let instance = if let Some(instance) = state.try_borrow::<Instance>() {
instance
} else {
state.put(std::sync::Arc::new(wgpu_core::hub::Global::new(
state.put(std::sync::Arc::new(wgpu_core::global::Global::new(
"webgpu",
wgpu_core::hub::IdentityManagerFactory,
wgpu_types::InstanceDescriptor {

View File

@@ -43,7 +43,7 @@ fn main() {
.build(&event_loop)
.unwrap();
let global = wgc::hub::Global::new(
let global = wgc::global::Global::new(
"player",
IdentityPassThroughFactory,
wgt::InstanceDescriptor::default(),

View File

@@ -51,7 +51,7 @@ pub trait GlobalPlay {
);
}
impl GlobalPlay for wgc::hub::Global<IdentityPassThroughFactory> {
impl GlobalPlay for wgc::global::Global<IdentityPassThroughFactory> {
fn encode_commands<A: wgc::hub::HalApi>(
&self,
encoder: wgc::id::CommandEncoderId,

View File

@@ -78,7 +78,7 @@ impl Test<'_> {
fn run(
self,
dir: &Path,
global: &wgc::hub::Global<IdentityPassThroughFactory>,
global: &wgc::global::Global<IdentityPassThroughFactory>,
adapter: wgc::id::AdapterId,
test_num: u32,
) {
@@ -178,7 +178,7 @@ impl Corpus {
let dir = path.parent().unwrap();
let corpus: Corpus = ron::de::from_reader(File::open(&path).unwrap()).unwrap();
let global = wgc::hub::Global::new(
let global = wgc::global::Global::new(
"test",
IdentityPassThroughFactory,
wgt::InstanceDescriptor {

View File

@@ -71,8 +71,8 @@ called. It goes through the commands and issues them into the native command
buffer. Thanks to isolation, it doesn't track any bind group invalidations or
index format changes.
[Gdcrbe]: crate::hub::Global::device_create_render_bundle_encoder
[Grbef]: crate::hub::Global::render_bundle_encoder_finish
[Gdcrbe]: crate::global::Global::device_create_render_bundle_encoder
[Grbef]: crate::global::Global::render_bundle_encoder_finish
[wrpeb]: crate::command::render_ffi::wgpu_render_pass_execute_bundles
!*/

View File

@@ -5,7 +5,8 @@ use crate::device::trace::Command as TraceCommand;
use crate::{
command::CommandBuffer,
get_lowest_common_denom,
hub::{self, Global, GlobalIdentityHandlerFactory, HalApi, Token},
global::Global,
hub::{self, GlobalIdentityHandlerFactory, HalApi, Token},
id::{BufferId, CommandEncoderId, DeviceId, TextureId, Valid},
init_tracker::{MemoryInitKind, TextureInitRange},
resource::{Texture, TextureClearMode},

View File

@@ -11,7 +11,8 @@ use crate::{
},
device::{MissingDownlevelFlags, MissingFeatures},
error::{ErrorFormatter, PrettyError},
hub::{Global, GlobalIdentityHandlerFactory, HalApi, Storage, Token},
global::Global,
hub::{GlobalIdentityHandlerFactory, HalApi, Storage, Token},
id,
init_tracker::MemoryInitKind,
pipeline,

View File

@@ -21,7 +21,8 @@ use crate::error::{ErrorFormatter, PrettyError};
use crate::init_tracker::BufferInitTrackerAction;
use crate::track::{Tracker, UsageScope};
use crate::{
hub::{Global, GlobalIdentityHandlerFactory, HalApi, Storage, Token},
global::Global,
hub::{GlobalIdentityHandlerFactory, HalApi, Storage, Token},
id,
resource::{Buffer, Texture},
Label, Stored,

View File

@@ -4,7 +4,8 @@ use hal::CommandEncoder as _;
use crate::device::trace::Command as TraceCommand;
use crate::{
command::{CommandBuffer, CommandEncoderError},
hub::{Global, GlobalIdentityHandlerFactory, HalApi, Storage, Token},
global::Global,
hub::{GlobalIdentityHandlerFactory, HalApi, Storage, Token},
id::{self, Id, TypedId},
init_tracker::MemoryInitKind,
resource::QuerySet,

View File

@@ -14,7 +14,8 @@ use crate::{
RenderPassCompatibilityCheckType, RenderPassCompatibilityError, RenderPassContext,
},
error::{ErrorFormatter, PrettyError},
hub::{Global, GlobalIdentityHandlerFactory, HalApi, Storage, Token},
global::Global,
hub::{GlobalIdentityHandlerFactory, HalApi, Storage, Token},
id,
init_tracker::{MemoryInitKind, TextureInitRange, TextureInitTrackerAction},
pipeline::{self, PipelineFlags},

View File

@@ -5,7 +5,8 @@ use crate::{
conv,
device::{Device, MissingDownlevelFlags},
error::{ErrorFormatter, PrettyError},
hub::{Global, GlobalIdentityHandlerFactory, HalApi, Storage, Token},
global::Global,
hub::{GlobalIdentityHandlerFactory, HalApi, Storage, Token},
id::{BufferId, CommandEncoderId, TextureId, Valid},
init_tracker::{
has_copy_partial_init_tracker_coverage, MemoryInitKind, TextureInitRange,

View File

@@ -1,7 +1,8 @@
use crate::{
binding_model, command, conv,
device::life::WaitIdleError,
hub::{Global, GlobalIdentityHandlerFactory, HalApi, Hub, Input, InvalidId, Storage, Token},
global::Global,
hub::{GlobalIdentityHandlerFactory, HalApi, Hub, Input, InvalidId, Storage, Token},
id,
init_tracker::{
BufferInitTracker, BufferInitTrackerAction, MemoryInitKind, TextureInitRange,

View File

@@ -8,7 +8,8 @@ use crate::{
conv,
device::{DeviceError, WaitIdleError},
get_lowest_common_denom,
hub::{Global, GlobalIdentityHandlerFactory, HalApi, Input, Token},
global::Global,
hub::{GlobalIdentityHandlerFactory, HalApi, Input, Token},
id,
init_tracker::{has_copy_partial_init_tracker_coverage, TextureInitRange},
resource::{BufferAccessError, BufferMapState, StagingBuffer, TextureInner},

View File

@@ -1,10 +1,7 @@
use core::fmt;
use std::error::Error;
use crate::{
gfx_select,
hub::{Global, IdentityManagerFactory},
};
use crate::{gfx_select, global::Global, hub::IdentityManagerFactory};
pub struct ErrorFormatter<'a> {
writer: &'a mut dyn fmt::Write,

162
wgpu-core/src/global.rs Normal file
View File

@@ -0,0 +1,162 @@
use crate::{
hub::GlobalIdentityHandlerFactory,
hub::HalApi,
hub::Registry,
hub::{Element, StorageReport},
hub::{HubReport, Hubs},
id,
instance::{Instance, Surface},
};
#[derive(Debug)]
pub struct GlobalReport {
pub surfaces: StorageReport,
#[cfg(all(feature = "vulkan", not(target_arch = "wasm32")))]
pub vulkan: Option<HubReport>,
#[cfg(all(feature = "metal", any(target_os = "macos", target_os = "ios")))]
pub metal: Option<HubReport>,
#[cfg(all(feature = "dx12", windows))]
pub dx12: Option<HubReport>,
#[cfg(all(feature = "dx11", windows))]
pub dx11: Option<HubReport>,
#[cfg(feature = "gles")]
pub gl: Option<HubReport>,
}
pub struct Global<G: GlobalIdentityHandlerFactory> {
pub instance: Instance,
pub surfaces: Registry<Surface, id::SurfaceId, G>,
pub(crate) hubs: Hubs<G>,
}
impl<G: GlobalIdentityHandlerFactory> Global<G> {
pub fn new(name: &str, factory: G, instance_desc: wgt::InstanceDescriptor) -> Self {
profiling::scope!("Global::new");
Self {
instance: Instance::new(name, instance_desc),
surfaces: Registry::without_backend(&factory, "Surface"),
hubs: Hubs::new(&factory),
}
}
/// # Safety
///
/// Refer to the creation of wgpu-hal Instance for every backend.
pub unsafe fn from_hal_instance<A: HalApi>(
name: &str,
factory: G,
hal_instance: A::Instance,
) -> Self {
profiling::scope!("Global::new");
Self {
instance: A::create_instance_from_hal(name, hal_instance),
surfaces: Registry::without_backend(&factory, "Surface"),
hubs: Hubs::new(&factory),
}
}
/// # Safety
///
/// - The raw instance handle returned must not be manually destroyed.
pub unsafe fn instance_as_hal<A: HalApi>(&self) -> Option<&A::Instance> {
A::instance_as_hal(&self.instance)
}
/// # Safety
///
/// - The raw handles obtained from the Instance must not be manually destroyed
pub unsafe fn from_instance(factory: G, instance: Instance) -> Self {
profiling::scope!("Global::new");
Self {
instance,
surfaces: Registry::without_backend(&factory, "Surface"),
hubs: Hubs::new(&factory),
}
}
pub fn clear_backend<A: HalApi>(&self, _dummy: ()) {
let mut surface_guard = self.surfaces.data.write();
let hub = A::hub(self);
// this is used for tests, which keep the adapter
hub.clear(&mut surface_guard, false);
}
pub fn generate_report(&self) -> GlobalReport {
GlobalReport {
surfaces: self.surfaces.data.read().generate_report(),
#[cfg(all(feature = "vulkan", not(target_arch = "wasm32")))]
vulkan: if self.instance.vulkan.is_some() {
Some(self.hubs.vulkan.generate_report())
} else {
None
},
#[cfg(all(feature = "metal", any(target_os = "macos", target_os = "ios")))]
metal: if self.instance.metal.is_some() {
Some(self.hubs.metal.generate_report())
} else {
None
},
#[cfg(all(feature = "dx12", windows))]
dx12: if self.instance.dx12.is_some() {
Some(self.hubs.dx12.generate_report())
} else {
None
},
#[cfg(all(feature = "dx11", windows))]
dx11: if self.instance.dx11.is_some() {
Some(self.hubs.dx11.generate_report())
} else {
None
},
#[cfg(feature = "gles")]
gl: if self.instance.gl.is_some() {
Some(self.hubs.gl.generate_report())
} else {
None
},
}
}
}
impl<G: GlobalIdentityHandlerFactory> Drop for Global<G> {
fn drop(&mut self) {
profiling::scope!("Global::drop");
log::info!("Dropping Global");
let mut surface_guard = self.surfaces.data.write();
// destroy hubs before the instance gets dropped
#[cfg(all(feature = "vulkan", not(target_arch = "wasm32")))]
{
self.hubs.vulkan.clear(&mut surface_guard, true);
}
#[cfg(all(feature = "metal", any(target_os = "macos", target_os = "ios")))]
{
self.hubs.metal.clear(&mut surface_guard, true);
}
#[cfg(all(feature = "dx12", windows))]
{
self.hubs.dx12.clear(&mut surface_guard, true);
}
#[cfg(all(feature = "dx11", windows))]
{
self.hubs.dx11.clear(&mut surface_guard, true);
}
#[cfg(feature = "gles")]
{
self.hubs.gl.clear(&mut surface_guard, true);
}
// destroy surfaces
for element in surface_guard.map.drain(..) {
if let Element::Occupied(surface, _) = element {
self.instance.destroy_surface(surface);
}
}
}
}
#[cfg(test)]
fn _test_send_sync(global: &Global<crate::hub::IdentityManagerFactory>) {
fn test_internal<T: Send + Sync>(_: T) {}
test_internal(global)
}

View File

@@ -153,6 +153,7 @@ use crate::{
binding_model::{BindGroup, BindGroupLayout, PipelineLayout},
command::{CommandBuffer, RenderBundle},
device::Device,
global::Global,
id,
instance::{Adapter, HalSurface, Instance, Surface},
pipeline::{ComputePipeline, RenderPipeline, ShaderModule},
@@ -243,7 +244,7 @@ impl IdentityManager {
/// An entry in a `Storage::map` table.
#[derive(Debug)]
enum Element<T> {
pub(crate) enum Element<T> {
/// There are no live ids with this index.
Vacant,
@@ -282,7 +283,7 @@ pub(crate) struct InvalidId;
/// that keeps the index values dense and close to zero.
#[derive(Debug)]
pub struct Storage<T, I: id::TypedId> {
map: Vec<Element<T>>,
pub(crate) map: Vec<Element<T>>,
kind: &'static str,
_phantom: PhantomData<I>,
}
@@ -454,7 +455,7 @@ impl<T, I: id::TypedId> Storage<T, I> {
self.map.len()
}
fn generate_report(&self) -> StorageReport {
pub(crate) fn generate_report(&self) -> StorageReport {
let mut report = StorageReport {
element_size: mem::size_of::<T>(),
..Default::default()
@@ -755,7 +756,7 @@ pub trait Resource {
#[derive(Debug)]
pub struct Registry<T: Resource, I: id::TypedId, F: IdentityHandlerFactory<I>> {
identity: F::Filter,
data: RwLock<Storage<T, I>>,
pub(crate) data: RwLock<Storage<T, I>>,
backend: Backend,
}
@@ -772,7 +773,7 @@ impl<T: Resource, I: id::TypedId, F: IdentityHandlerFactory<I>> Registry<T, I, F
}
}
fn without_backend(factory: &F, kind: &'static str) -> Self {
pub(crate) fn without_backend(factory: &F, kind: &'static str) -> Self {
Self {
identity: factory.spawn(),
data: RwLock::new(Storage {
@@ -1068,7 +1069,11 @@ impl<A: HalApi, F: GlobalIdentityHandlerFactory> Hub<A, F> {
//TODO: instead of having a hacky `with_adapters` parameter,
// we should have `clear_device(device_id)` that specifically destroys
// everything related to a logical device.
fn clear(&self, surface_guard: &mut Storage<Surface, id::SurfaceId>, with_adapters: bool) {
pub(crate) fn clear(
&self,
surface_guard: &mut Storage<Surface, id::SurfaceId>,
with_adapters: bool,
) {
use crate::resource::TextureInner;
use hal::{Device as _, Surface as _};
@@ -1258,19 +1263,19 @@ impl<A: HalApi, F: GlobalIdentityHandlerFactory> Hub<A, F> {
pub struct Hubs<F: GlobalIdentityHandlerFactory> {
#[cfg(all(feature = "vulkan", not(target_arch = "wasm32")))]
vulkan: Hub<hal::api::Vulkan, F>,
pub(crate) vulkan: Hub<hal::api::Vulkan, F>,
#[cfg(all(feature = "metal", any(target_os = "macos", target_os = "ios")))]
metal: Hub<hal::api::Metal, F>,
pub(crate) metal: Hub<hal::api::Metal, F>,
#[cfg(all(feature = "dx12", windows))]
dx12: Hub<hal::api::Dx12, F>,
pub(crate) dx12: Hub<hal::api::Dx12, F>,
#[cfg(all(feature = "dx11", windows))]
dx11: Hub<hal::api::Dx11, F>,
pub(crate) dx11: Hub<hal::api::Dx11, F>,
#[cfg(feature = "gles")]
gl: Hub<hal::api::Gles, F>,
pub(crate) gl: Hub<hal::api::Gles, F>,
}
impl<F: GlobalIdentityHandlerFactory> Hubs<F> {
fn new(factory: &F) -> Self {
pub(crate) fn new(factory: &F) -> Self {
Self {
#[cfg(all(feature = "vulkan", not(target_arch = "wasm32")))]
vulkan: Hub::new(factory),
@@ -1286,153 +1291,6 @@ impl<F: GlobalIdentityHandlerFactory> Hubs<F> {
}
}
#[derive(Debug)]
pub struct GlobalReport {
pub surfaces: StorageReport,
#[cfg(all(feature = "vulkan", not(target_arch = "wasm32")))]
pub vulkan: Option<HubReport>,
#[cfg(all(feature = "metal", any(target_os = "macos", target_os = "ios")))]
pub metal: Option<HubReport>,
#[cfg(all(feature = "dx12", windows))]
pub dx12: Option<HubReport>,
#[cfg(all(feature = "dx11", windows))]
pub dx11: Option<HubReport>,
#[cfg(feature = "gles")]
pub gl: Option<HubReport>,
}
pub struct Global<G: GlobalIdentityHandlerFactory> {
pub instance: Instance,
pub surfaces: Registry<Surface, id::SurfaceId, G>,
hubs: Hubs<G>,
}
impl<G: GlobalIdentityHandlerFactory> Global<G> {
pub fn new(name: &str, factory: G, instance_desc: wgt::InstanceDescriptor) -> Self {
profiling::scope!("Global::new");
Self {
instance: Instance::new(name, instance_desc),
surfaces: Registry::without_backend(&factory, "Surface"),
hubs: Hubs::new(&factory),
}
}
/// # Safety
///
/// Refer to the creation of wgpu-hal Instance for every backend.
pub unsafe fn from_hal_instance<A: HalApi>(
name: &str,
factory: G,
hal_instance: A::Instance,
) -> Self {
profiling::scope!("Global::new");
Self {
instance: A::create_instance_from_hal(name, hal_instance),
surfaces: Registry::without_backend(&factory, "Surface"),
hubs: Hubs::new(&factory),
}
}
/// # Safety
///
/// - The raw instance handle returned must not be manually destroyed.
pub unsafe fn instance_as_hal<A: HalApi>(&self) -> Option<&A::Instance> {
A::instance_as_hal(&self.instance)
}
/// # Safety
///
/// - The raw handles obtained from the Instance must not be manually destroyed
pub unsafe fn from_instance(factory: G, instance: Instance) -> Self {
profiling::scope!("Global::new");
Self {
instance,
surfaces: Registry::without_backend(&factory, "Surface"),
hubs: Hubs::new(&factory),
}
}
pub fn clear_backend<A: HalApi>(&self, _dummy: ()) {
let mut surface_guard = self.surfaces.data.write();
let hub = A::hub(self);
// this is used for tests, which keep the adapter
hub.clear(&mut surface_guard, false);
}
pub fn generate_report(&self) -> GlobalReport {
GlobalReport {
surfaces: self.surfaces.data.read().generate_report(),
#[cfg(all(feature = "vulkan", not(target_arch = "wasm32")))]
vulkan: if self.instance.vulkan.is_some() {
Some(self.hubs.vulkan.generate_report())
} else {
None
},
#[cfg(all(feature = "metal", any(target_os = "macos", target_os = "ios")))]
metal: if self.instance.metal.is_some() {
Some(self.hubs.metal.generate_report())
} else {
None
},
#[cfg(all(feature = "dx12", windows))]
dx12: if self.instance.dx12.is_some() {
Some(self.hubs.dx12.generate_report())
} else {
None
},
#[cfg(all(feature = "dx11", windows))]
dx11: if self.instance.dx11.is_some() {
Some(self.hubs.dx11.generate_report())
} else {
None
},
#[cfg(feature = "gles")]
gl: if self.instance.gl.is_some() {
Some(self.hubs.gl.generate_report())
} else {
None
},
}
}
}
impl<G: GlobalIdentityHandlerFactory> Drop for Global<G> {
fn drop(&mut self) {
profiling::scope!("Global::drop");
log::info!("Dropping Global");
let mut surface_guard = self.surfaces.data.write();
// destroy hubs before the instance gets dropped
#[cfg(all(feature = "vulkan", not(target_arch = "wasm32")))]
{
self.hubs.vulkan.clear(&mut surface_guard, true);
}
#[cfg(all(feature = "metal", any(target_os = "macos", target_os = "ios")))]
{
self.hubs.metal.clear(&mut surface_guard, true);
}
#[cfg(all(feature = "dx12", windows))]
{
self.hubs.dx12.clear(&mut surface_guard, true);
}
#[cfg(all(feature = "dx11", windows))]
{
self.hubs.dx11.clear(&mut surface_guard, true);
}
#[cfg(feature = "gles")]
{
self.hubs.gl.clear(&mut surface_guard, true);
}
// destroy surfaces
for element in surface_guard.map.drain(..) {
if let Element::Occupied(surface, _) = element {
self.instance.destroy_surface(surface);
}
}
}
}
pub trait HalApi: hal::Api {
const VARIANT: Backend;
fn create_instance_from_hal(name: &str, hal_instance: Self::Instance) -> Instance;
@@ -1582,12 +1440,6 @@ impl HalApi for hal::api::Gles {
}
}
#[cfg(test)]
fn _test_send_sync(global: &Global<IdentityManagerFactory>) {
fn test_internal<T: Send + Sync>(_: T) {}
test_internal(global)
}
#[test]
fn test_epoch_end_of_life() {
use id::TypedId as _;

View File

@@ -42,7 +42,7 @@ type Dummy = hal::api::Empty;
/// `X<Empty>` type with the resource type `X<A>`, for some specific backend
/// `A`.
///
/// [`Global`]: crate::hub::Global
/// [`Global`]: crate::global::Global
/// [`Hub`]: crate::hub::Hub
/// [`Hub<A>`]: crate::hub::Hub
/// [`Storage`]: crate::hub::Storage

View File

@@ -1,6 +1,7 @@
use crate::{
device::{Device, DeviceDescriptor},
hub::{Global, GlobalIdentityHandlerFactory, HalApi, Input, Token},
global::Global,
hub::{GlobalIdentityHandlerFactory, HalApi, Input, Token},
id::{AdapterId, DeviceId, SurfaceId, Valid},
present::Presentation,
LabelHelpers, LifeGuard, Stored, DOWNLEVEL_WARNING_MESSAGE,

View File

@@ -42,6 +42,7 @@ pub mod command;
mod conv;
pub mod device;
pub mod error;
pub mod global;
pub mod hub;
pub mod id;
mod init_tracker;
@@ -355,7 +356,7 @@ define_backend_caller! { gfx_if_gles, gfx_if_gles_hidden, "gles" if feature = "g
/// identifiers to select backends dynamically, even though many `wgpu_core`
/// methods are compiled and optimized for a specific back end.
///
/// This macro is typically used to call methods on [`wgpu_core::hub::Global`],
/// This macro is typically used to call methods on [`wgpu_core::global::Global`],
/// many of which take a single `hal::Api` type parameter. For example, to
/// create a new buffer on the device indicated by `device_id`, one would say:
///
@@ -375,13 +376,13 @@ define_backend_caller! { gfx_if_gles, gfx_if_gles_hidden, "gles" if feature = "g
/// That `gfx_select!` call uses `device_id`'s backend to select the right
/// backend type `A` for a call to `Global::device_create_buffer<A>`.
///
/// However, there's nothing about this macro that is specific to `hub::Global`.
/// However, there's nothing about this macro that is specific to `global::Global`.
/// For example, Firefox's embedding of `wgpu_core` defines its own types with
/// methods that take `hal::Api` type parameters. Firefox uses `gfx_select!` to
/// dynamically dispatch to the right specialization based on the resource's id.
///
/// [`wgpu_types::Backend`]: wgt::Backend
/// [`wgpu_core::hub::Global`]: crate::hub::Global
/// [`wgpu_core::global::Global`]: crate::global::Global
/// [`Id`]: id::Id
#[macro_export]
macro_rules! gfx_select {

View File

@@ -16,7 +16,8 @@ use crate::device::trace::Action;
use crate::{
conv,
device::{DeviceError, MissingDownlevelFlags},
hub::{Global, GlobalIdentityHandlerFactory, HalApi, Input, Token},
global::Global,
hub::{GlobalIdentityHandlerFactory, HalApi, Input, Token},
id::{DeviceId, SurfaceId, TextureId, Valid},
init_tracker::TextureInitTracker,
resource, track, LifeGuard, Stored,

View File

@@ -1,6 +1,7 @@
use crate::{
device::{DeviceError, HostMap, MissingDownlevelFlags, MissingFeatures},
hub::{Global, GlobalIdentityHandlerFactory, HalApi, Resource, Token},
global::Global,
hub::{GlobalIdentityHandlerFactory, HalApi, Resource, Token},
id::{AdapterId, DeviceId, SurfaceId, TextureId, Valid},
init_tracker::{BufferInitTracker, TextureInitTracker},
track::TextureSelector,

View File

@@ -26,7 +26,7 @@ use wgc::id::TypedId;
const LABEL: &str = "label";
pub struct Context(wgc::hub::Global<wgc::hub::IdentityManagerFactory>);
pub struct Context(wgc::global::Global<wgc::hub::IdentityManagerFactory>);
impl Drop for Context {
fn drop(&mut self) {
@@ -43,7 +43,7 @@ impl fmt::Debug for Context {
impl Context {
pub unsafe fn from_hal_instance<A: wgc::hub::HalApi>(hal_instance: A::Instance) -> Self {
Self(unsafe {
wgc::hub::Global::from_hal_instance::<A>(
wgc::global::Global::from_hal_instance::<A>(
"wgpu",
wgc::hub::IdentityManagerFactory,
hal_instance,
@@ -60,11 +60,11 @@ impl Context {
pub unsafe fn from_core_instance(core_instance: wgc::instance::Instance) -> Self {
Self(unsafe {
wgc::hub::Global::from_instance(wgc::hub::IdentityManagerFactory, core_instance)
wgc::global::Global::from_instance(wgc::hub::IdentityManagerFactory, core_instance)
})
}
pub(crate) fn global(&self) -> &wgc::hub::Global<wgc::hub::IdentityManagerFactory> {
pub(crate) fn global(&self) -> &wgc::global::Global<wgc::hub::IdentityManagerFactory> {
&self.0
}
@@ -186,7 +186,7 @@ impl Context {
}
}
pub fn generate_report(&self) -> wgc::hub::GlobalReport {
pub fn generate_report(&self) -> wgc::global::GlobalReport {
self.0.generate_report()
}
@@ -536,7 +536,7 @@ impl crate::Context for Context {
type PopErrorScopeFuture = Ready<Option<crate::Error>>;
fn init(instance_desc: wgt::InstanceDescriptor) -> Self {
Self(wgc::hub::Global::new(
Self(wgc::global::Global::new(
"wgpu",
wgc::hub::IdentityManagerFactory,
instance_desc,

View File

@@ -1698,7 +1698,7 @@ impl Instance {
target_os = "emscripten",
feature = "webgl"
))]
pub fn generate_report(&self) -> wgc::hub::GlobalReport {
pub fn generate_report(&self) -> wgc::global::GlobalReport {
self.context
.as_any()
.downcast_ref::<crate::backend::Context>()