mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 00:03:29 +00:00
[tests] don't create a new instance/adapter for DEVICE_LIFETIME_CHECK
& MULTIPLE_DEVICES
tests
The test harness creates the instance and adapter that a test should use. Tests should not create these with default configurations or configs from the environment.
This commit is contained in:
parent
595ae7cb47
commit
07becfe5b5
@ -36,32 +36,23 @@ static CROSS_DEVICE_BIND_GROUP_USAGE: GpuTestConfiguration = GpuTestConfiguratio
|
||||
#[gpu_test]
|
||||
static DEVICE_LIFETIME_CHECK: GpuTestConfiguration = GpuTestConfiguration::new()
|
||||
.parameters(TestParameters::default())
|
||||
.run_sync(|_| {
|
||||
use pollster::FutureExt as _;
|
||||
.run_sync(|ctx| {
|
||||
ctx.instance.poll_all(false);
|
||||
|
||||
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
|
||||
backends: wgpu::util::backend_bits_from_env().unwrap_or(wgpu::Backends::all()),
|
||||
dx12_shader_compiler: wgpu::util::dx12_shader_compiler_from_env().unwrap_or_default(),
|
||||
gles_minor_version: wgpu::util::gles_minor_version_from_env().unwrap_or_default(),
|
||||
flags: wgpu::InstanceFlags::advanced_debugging().with_env(),
|
||||
});
|
||||
let pre_report = ctx.instance.generate_report().unwrap();
|
||||
|
||||
let adapter = wgpu::util::initialize_adapter_from_env_or_default(&instance, None)
|
||||
.block_on()
|
||||
.expect("failed to create adapter");
|
||||
|
||||
let (device, queue) = adapter
|
||||
.request_device(&wgpu::DeviceDescriptor::default(), None)
|
||||
.block_on()
|
||||
.expect("failed to create device");
|
||||
|
||||
instance.poll_all(false);
|
||||
|
||||
let pre_report = instance.generate_report().unwrap();
|
||||
let TestingContext {
|
||||
instance,
|
||||
device,
|
||||
queue,
|
||||
..
|
||||
} = ctx;
|
||||
|
||||
drop(queue);
|
||||
drop(device);
|
||||
|
||||
let post_report = instance.generate_report().unwrap();
|
||||
|
||||
assert_ne!(
|
||||
pre_report, post_report,
|
||||
"Queue and Device has not been dropped as expected"
|
||||
@ -72,29 +63,16 @@ static DEVICE_LIFETIME_CHECK: GpuTestConfiguration = GpuTestConfiguration::new()
|
||||
#[gpu_test]
|
||||
static MULTIPLE_DEVICES: GpuTestConfiguration = GpuTestConfiguration::new()
|
||||
.parameters(TestParameters::default())
|
||||
.run_sync(|_| {
|
||||
.run_sync(|ctx| {
|
||||
use pollster::FutureExt as _;
|
||||
|
||||
fn create_device_and_queue() -> (wgpu::Device, wgpu::Queue) {
|
||||
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
|
||||
backends: wgpu::util::backend_bits_from_env().unwrap_or(wgpu::Backends::all()),
|
||||
dx12_shader_compiler: wgpu::util::dx12_shader_compiler_from_env()
|
||||
.unwrap_or_default(),
|
||||
gles_minor_version: wgpu::util::gles_minor_version_from_env().unwrap_or_default(),
|
||||
flags: wgpu::InstanceFlags::advanced_debugging().with_env(),
|
||||
});
|
||||
|
||||
let adapter = wgpu::util::initialize_adapter_from_env_or_default(&instance, None)
|
||||
.block_on()
|
||||
.expect("failed to create adapter");
|
||||
|
||||
adapter
|
||||
.request_device(&wgpu::DeviceDescriptor::default(), None)
|
||||
.block_on()
|
||||
.expect("failed to create device")
|
||||
}
|
||||
|
||||
let _ = vec![create_device_and_queue(), create_device_and_queue()];
|
||||
ctx.adapter
|
||||
.request_device(&wgpu::DeviceDescriptor::default(), None)
|
||||
.block_on()
|
||||
.expect("failed to create device");
|
||||
ctx.adapter
|
||||
.request_device(&wgpu::DeviceDescriptor::default(), None)
|
||||
.block_on()
|
||||
.expect("failed to create device");
|
||||
});
|
||||
|
||||
#[cfg(not(all(target_arch = "wasm32", not(target_os = "emscripten"))))]
|
||||
|
Loading…
Reference in New Issue
Block a user