mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-10-30 05:51:42 +00:00
remove Global.clear_backend()
The method was only used by the player's tests which was refactored to create a new `Global` instead. Removing it cleans up the internals of `Hub.clear()`, we should avoid having test only items.
This commit is contained in:
parent
f3e8e594ed
commit
d1da4456a6
@ -178,8 +178,6 @@ impl Test<'_> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
wgc::gfx_select!(device_id => global.clear_backend(()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,40 +200,42 @@ impl Corpus {
|
||||
let dir = path.parent().unwrap();
|
||||
let corpus: Corpus = ron::de::from_reader(File::open(&path).unwrap()).unwrap();
|
||||
|
||||
let global = wgc::global::Global::new(
|
||||
"test",
|
||||
wgt::InstanceDescriptor {
|
||||
backends: corpus.backends,
|
||||
flags: wgt::InstanceFlags::debugging(),
|
||||
dx12_shader_compiler: wgt::Dx12Compiler::Fxc,
|
||||
gles_minor_version: wgt::Gles3MinorVersion::default(),
|
||||
},
|
||||
);
|
||||
for &backend in BACKENDS {
|
||||
if !corpus.backends.contains(backend.into()) {
|
||||
continue;
|
||||
}
|
||||
let adapter = match global.request_adapter(
|
||||
&wgc::instance::RequestAdapterOptions {
|
||||
power_preference: wgt::PowerPreference::None,
|
||||
force_fallback_adapter: false,
|
||||
compatible_surface: None,
|
||||
},
|
||||
wgc::instance::AdapterInputs::IdSet(&[wgc::id::Id::zip(0, 0, backend)]),
|
||||
) {
|
||||
Ok(adapter) => adapter,
|
||||
Err(_) => continue,
|
||||
};
|
||||
|
||||
println!("\tBackend {:?}", backend);
|
||||
let supported_features =
|
||||
wgc::gfx_select!(adapter => global.adapter_features(adapter)).unwrap();
|
||||
let downlevel_caps =
|
||||
wgc::gfx_select!(adapter => global.adapter_downlevel_capabilities(adapter))
|
||||
.unwrap();
|
||||
let mut test_num = 0;
|
||||
for test_path in &corpus.tests {
|
||||
println!("\t\tTest '{:?}'", test_path);
|
||||
|
||||
let global = wgc::global::Global::new(
|
||||
"test",
|
||||
wgt::InstanceDescriptor {
|
||||
backends: backend.into(),
|
||||
flags: wgt::InstanceFlags::debugging(),
|
||||
dx12_shader_compiler: wgt::Dx12Compiler::Fxc,
|
||||
gles_minor_version: wgt::Gles3MinorVersion::default(),
|
||||
},
|
||||
);
|
||||
let adapter = match global.request_adapter(
|
||||
&wgc::instance::RequestAdapterOptions {
|
||||
power_preference: wgt::PowerPreference::None,
|
||||
force_fallback_adapter: false,
|
||||
compatible_surface: None,
|
||||
},
|
||||
wgc::instance::AdapterInputs::IdSet(&[wgc::id::Id::zip(0, 0, backend)]),
|
||||
) {
|
||||
Ok(adapter) => adapter,
|
||||
Err(_) => continue,
|
||||
};
|
||||
|
||||
println!("\tBackend {:?}", backend);
|
||||
let supported_features =
|
||||
wgc::gfx_select!(adapter => global.adapter_features(adapter)).unwrap();
|
||||
let downlevel_caps =
|
||||
wgc::gfx_select!(adapter => global.adapter_downlevel_capabilities(adapter))
|
||||
.unwrap();
|
||||
|
||||
let test = Test::load(dir.join(test_path), adapter.backend());
|
||||
if !supported_features.contains(test.features) {
|
||||
println!(
|
||||
|
@ -87,13 +87,6 @@ impl Global {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clear_backend<A: HalApi>(&self, _dummy: ()) {
|
||||
let hub = A::hub(self);
|
||||
let surfaces_locked = self.surfaces.read();
|
||||
// this is used for tests, which keep the adapter
|
||||
hub.clear(&surfaces_locked, false);
|
||||
}
|
||||
|
||||
pub fn generate_report(&self) -> GlobalReport {
|
||||
GlobalReport {
|
||||
surfaces: self.surfaces.generate_report(),
|
||||
@ -134,19 +127,19 @@ impl Drop for Global {
|
||||
// destroy hubs before the instance gets dropped
|
||||
#[cfg(vulkan)]
|
||||
{
|
||||
self.hubs.vulkan.clear(&surfaces_locked, true);
|
||||
self.hubs.vulkan.clear(&surfaces_locked);
|
||||
}
|
||||
#[cfg(metal)]
|
||||
{
|
||||
self.hubs.metal.clear(&surfaces_locked, true);
|
||||
self.hubs.metal.clear(&surfaces_locked);
|
||||
}
|
||||
#[cfg(dx12)]
|
||||
{
|
||||
self.hubs.dx12.clear(&surfaces_locked, true);
|
||||
self.hubs.dx12.clear(&surfaces_locked);
|
||||
}
|
||||
#[cfg(gles)]
|
||||
{
|
||||
self.hubs.gl.clear(&surfaces_locked, true);
|
||||
self.hubs.gl.clear(&surfaces_locked);
|
||||
}
|
||||
|
||||
surfaces_locked.map.clear();
|
||||
|
@ -214,10 +214,7 @@ impl<A: HalApi> Hub<A> {
|
||||
}
|
||||
}
|
||||
|
||||
//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.
|
||||
pub(crate) fn clear(&self, surface_guard: &Storage<Surface>, with_adapters: bool) {
|
||||
pub(crate) fn clear(&self, surface_guard: &Storage<Surface>) {
|
||||
use hal::Surface;
|
||||
|
||||
let mut devices = self.devices.write();
|
||||
@ -257,10 +254,8 @@ impl<A: HalApi> Hub<A> {
|
||||
self.queues.write().map.clear();
|
||||
devices.map.clear();
|
||||
|
||||
if with_adapters {
|
||||
drop(devices);
|
||||
self.adapters.write().map.clear();
|
||||
}
|
||||
drop(devices);
|
||||
self.adapters.write().map.clear();
|
||||
}
|
||||
|
||||
pub fn generate_report(&self) -> HubReport {
|
||||
|
Loading…
Reference in New Issue
Block a user