wgpu_test/
report.rs
1use std::collections::HashMap;
2
3use serde::Deserialize;
4use wgpu::{
5 AdapterInfo, DownlevelCapabilities, Features, Limits, TextureFormat, TextureFormatFeatures,
6};
7
8#[derive(Deserialize)]
12pub(crate) struct GpuReport {
13 #[cfg_attr(target_arch = "wasm32", allow(unused))]
14 pub devices: Vec<AdapterReport>,
15}
16
17impl GpuReport {
18 #[cfg(not(target_arch = "wasm32"))]
19 pub(crate) fn noop_only() -> Self {
21 GpuReport {
22 devices: vec![AdapterReport {
23 info: wgpu::hal::noop::adapter_info(),
24 features: Features::all(),
25 limits: wgpu::hal::noop::CAPABILITIES.limits,
26 downlevel_caps: wgpu::hal::noop::CAPABILITIES.downlevel,
27 texture_format_features: HashMap::new(), }],
29 }
30 }
31
32 #[cfg_attr(target_arch = "wasm32", allow(unused))]
33 pub(crate) fn from_json(file: &str) -> serde_json::Result<Self> {
34 profiling::scope!("Parsing .gpuconfig");
35 serde_json::from_str(file)
36 }
37}
38
39#[derive(Deserialize, Clone)]
43pub struct AdapterReport {
44 pub info: AdapterInfo,
45 pub features: Features,
46 pub limits: Limits,
47 pub downlevel_caps: DownlevelCapabilities,
48 #[allow(unused)]
49 pub texture_format_features: HashMap<TextureFormat, TextureFormatFeatures>,
50}
51
52impl AdapterReport {
53 pub(crate) fn from_adapter(adapter: &wgpu::Adapter) -> Self {
54 let info = adapter.get_info();
55 let features = adapter.features();
56 let limits = adapter.limits();
57 let downlevel_caps = adapter.get_downlevel_capabilities();
58
59 Self {
60 info,
61 features,
62 limits,
63 downlevel_caps,
64 texture_format_features: HashMap::new(), }
66 }
67}