@@ -36,32 +36,23 @@ static CROSS_DEVICE_BIND_GROUP_USAGE: GpuTestConfiguration = GpuTestConfiguratio
36
36
#[ gpu_test]
37
37
static DEVICE_LIFETIME_CHECK : GpuTestConfiguration = GpuTestConfiguration :: new ( )
38
38
. parameters ( TestParameters :: default ( ) )
39
- . run_sync ( |_| {
40
- use pollster:: FutureExt as _;
41
-
42
- let instance = wgpu:: Instance :: new ( wgpu:: InstanceDescriptor {
43
- backends : wgpu:: util:: backend_bits_from_env ( ) . unwrap_or ( wgpu:: Backends :: all ( ) ) ,
44
- dx12_shader_compiler : wgpu:: util:: dx12_shader_compiler_from_env ( ) . unwrap_or_default ( ) ,
45
- gles_minor_version : wgpu:: util:: gles_minor_version_from_env ( ) . unwrap_or_default ( ) ,
46
- flags : wgpu:: InstanceFlags :: advanced_debugging ( ) . with_env ( ) ,
47
- } ) ;
48
-
49
- let adapter = wgpu:: util:: initialize_adapter_from_env_or_default ( & instance, None )
50
- . block_on ( )
51
- . expect ( "failed to create adapter" ) ;
52
-
53
- let ( device, queue) = adapter
54
- . request_device ( & wgpu:: DeviceDescriptor :: default ( ) , None )
55
- . block_on ( )
56
- . expect ( "failed to create device" ) ;
39
+ . run_sync ( |ctx| {
40
+ ctx. instance . poll_all ( false ) ;
57
41
58
- instance. poll_all ( false ) ;
42
+ let pre_report = ctx . instance . generate_report ( ) . unwrap ( ) ;
59
43
60
- let pre_report = instance. generate_report ( ) . unwrap ( ) ;
44
+ let TestingContext {
45
+ instance,
46
+ device,
47
+ queue,
48
+ ..
49
+ } = ctx;
61
50
62
51
drop ( queue) ;
63
52
drop ( device) ;
53
+
64
54
let post_report = instance. generate_report ( ) . unwrap ( ) ;
55
+
65
56
assert_ne ! (
66
57
pre_report, post_report,
67
58
"Queue and Device has not been dropped as expected"
@@ -72,29 +63,16 @@ static DEVICE_LIFETIME_CHECK: GpuTestConfiguration = GpuTestConfiguration::new()
72
63
#[ gpu_test]
73
64
static MULTIPLE_DEVICES : GpuTestConfiguration = GpuTestConfiguration :: new ( )
74
65
. parameters ( TestParameters :: default ( ) )
75
- . run_sync ( |_ | {
66
+ . run_sync ( |ctx | {
76
67
use pollster:: FutureExt as _;
77
-
78
- fn create_device_and_queue ( ) -> ( wgpu:: Device , wgpu:: Queue ) {
79
- let instance = wgpu:: Instance :: new ( wgpu:: InstanceDescriptor {
80
- backends : wgpu:: util:: backend_bits_from_env ( ) . unwrap_or ( wgpu:: Backends :: all ( ) ) ,
81
- dx12_shader_compiler : wgpu:: util:: dx12_shader_compiler_from_env ( )
82
- . unwrap_or_default ( ) ,
83
- gles_minor_version : wgpu:: util:: gles_minor_version_from_env ( ) . unwrap_or_default ( ) ,
84
- flags : wgpu:: InstanceFlags :: advanced_debugging ( ) . with_env ( ) ,
85
- } ) ;
86
-
87
- let adapter = wgpu:: util:: initialize_adapter_from_env_or_default ( & instance, None )
88
- . block_on ( )
89
- . expect ( "failed to create adapter" ) ;
90
-
91
- adapter
92
- . request_device ( & wgpu:: DeviceDescriptor :: default ( ) , None )
93
- . block_on ( )
94
- . expect ( "failed to create device" )
95
- }
96
-
97
- let _ = vec ! [ create_device_and_queue( ) , create_device_and_queue( ) ] ;
68
+ ctx. adapter
69
+ . request_device ( & wgpu:: DeviceDescriptor :: default ( ) , None )
70
+ . block_on ( )
71
+ . expect ( "failed to create device" ) ;
72
+ ctx. adapter
73
+ . request_device ( & wgpu:: DeviceDescriptor :: default ( ) , None )
74
+ . block_on ( )
75
+ . expect ( "failed to create device" ) ;
98
76
} ) ;
99
77
100
78
#[ cfg( not( all( target_arch = "wasm32" , not( target_os = "emscripten" ) ) ) ) ]
0 commit comments