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:
teoxoy 2024-07-03 17:15:55 +02:00 committed by Teodor Tanasoaia
parent f3e8e594ed
commit d1da4456a6
3 changed files with 36 additions and 48 deletions

View File

@ -178,8 +178,6 @@ impl Test<'_> {
);
}
}
wgc::gfx_select!(device_id => global.clear_backend(()));
}
}
@ -202,19 +200,23 @@ impl Corpus {
let dir = path.parent().unwrap();
let corpus: Corpus = ron::de::from_reader(File::open(&path).unwrap()).unwrap();
for &backend in BACKENDS {
if !corpus.backends.contains(backend.into()) {
continue;
}
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: corpus.backends,
backends: backend.into(),
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,
@ -233,9 +235,7 @@ impl Corpus {
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 test = Test::load(dir.join(test_path), adapter.backend());
if !supported_features.contains(test.features) {
println!(

View File

@ -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();

View File

@ -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,11 +254,9 @@ impl<A: HalApi> Hub<A> {
self.queues.write().map.clear();
devices.map.clear();
if with_adapters {
drop(devices);
self.adapters.write().map.clear();
}
}
pub fn generate_report(&self) -> HubReport {
HubReport {