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 pub texture_format_features: HashMap<TextureFormat, TextureFormatFeatures>,
49}
50
51impl AdapterReport {
52 pub(crate) fn from_adapter(adapter: &wgpu::Adapter) -> Self {
53 let info = adapter.get_info();
54 let features = adapter.features();
55 let limits = adapter.limits();
56 let downlevel_caps = adapter.get_downlevel_capabilities();
57
58 Self {
59 info,
60 features,
61 limits,
62 downlevel_caps,
63 texture_format_features: HashMap::new(), }
65 }
66}