gpu_info/gpu-info.rs
1//! Print the device a test run draws with, as JSON.
2//!
3//! Run by `cargo xtask print-gpu`, which cannot link wgpu itself: the task
4//! runner builds no graphics code, so the description is produced here and
5//! printed by the task that wraps it. `UNLIT3D_DEVICE_TIER` picks the tier, the
6//! same variable a test run reads.
7
8// Printing it is the whole job, and only a native build has a device to
9// print.
10#![cfg_attr(
11 not(target_arch = "wasm32"),
12 expect(
13 clippy::print_stdout,
14 reason = "printing the description is this binary's job"
15 )
16)]
17
18fn main() {
19 #[cfg(not(target_arch = "wasm32"))]
20 {
21 let ctx = unlit_wgpu_test_util::block_on(unlit_wgpu_test_util::Ctx::headless());
22 // Nothing reads this but a human and the task that wraps it, so a
23 // failure to serialize would be a bug in wgpu's own serde rather than
24 // anything a caller could act on.
25 let text = serde_json::to_string_pretty(&unlit_wgpu_test_util::GpuInfo::read(&ctx))
26 .expect("the device description is serializable");
27 println!("{text}");
28 }
29}