1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! **The one door to a GPU in this test binary** (bl-f824).
//!
//! Every [`TestRenderer`] opens a wgpu instance, and on this platform that is
//! a Vulkan instance through the system loader (`libvulkan.so.1`) onto the
//! software rasterizer. The loader is not safe to drive from two threads at
//! once: caught under a debugger, one test's `vkEnumeratePhysicalDevices` was
//! inside `dlclose` — the loader unloading a driver library it had scanned —
//! while another test's `vkSetDebugUtilsObjectNameEXT` was calling through
//! that library, and the whole test binary died of SIGSEGV with no test named.
//! The suite runs its tests on parallel threads, and three of them each held
//! a renderer, so it happened now and then and passed on the re-run.
//!
//! So a renderer is held only under [`GPU`], for its whole life — created,
//! used and dropped while the lock stands — which serializes the loader and
//! nothing else: the harnesses themselves still build and run in parallel.
use ;
use Harness;
use TestRenderer;
/// The lock every renderer in this binary is held under.
static GPU: = new;
/// **A renderer, and the lock it is held under.** The renderer is declared
/// first, so it drops first: the device is torn down while the lock stands.
pub
/// **Take the GPU**: wait for whoever holds it, then open a renderer. A test
/// that panicked holding it poisoned nothing worth refusing over — the lock
/// guards the loader's calls, not a value.
pub