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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
use crate::platform::COLOR_TEXTURE_FORMAT;
use std::borrow::Cow;
pub use wgpu::Backends;
pub use wgpu::Features;
pub use wgpu::Limits;
pub use wgpu::PowerPreference;
pub use wgpu::TextureFormat;
#[derive(Clone)]
pub struct WgpuSettings {
pub device_label: Option<Cow<'static, str>>,
pub backends: Option<Backends>,
pub power_preference: PowerPreference,
pub features: Features,
pub disabled_features: Option<Features>,
pub limits: Limits,
pub constrained_limits: Option<Limits>,
pub record_trace: bool,
}
impl Default for WgpuSettings {
fn default() -> Self {
let backends = Some(wgpu::util::backend_bits_from_env().unwrap_or(wgpu::Backends::all()));
let limits = if cfg!(feature = "web-webgl") {
Limits {
max_texture_dimension_2d: 4096,
..Limits::downlevel_webgl2_defaults()
}
} else if cfg!(target_os = "android") {
Limits {
max_storage_textures_per_shader_stage: 4,
max_compute_workgroups_per_dimension: 0,
max_compute_workgroup_size_z: 0,
max_compute_workgroup_size_y: 0,
max_compute_workgroup_size_x: 0,
max_compute_workgroup_storage_size: 0,
max_compute_invocations_per_workgroup: 0,
..Limits::downlevel_defaults()
}
} else {
Limits {
..Limits::default()
}
};
Self {
device_label: Default::default(),
backends,
power_preference: PowerPreference::HighPerformance,
features: Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES,
disabled_features: None,
limits,
constrained_limits: None,
record_trace: false,
}
}
}
#[derive(Clone)]
pub enum SurfaceType {
Headless,
Headed,
}
#[derive(Copy, Clone)]
pub struct Msaa {
pub samples: u32,
}
impl Msaa {
pub fn is_active(&self) -> bool {
self.samples > 1
}
}
impl Default for Msaa {
fn default() -> Self {
Self { samples: 4 }
}
}
#[derive(Clone)]
pub struct RendererSettings {
pub msaa: Msaa,
pub texture_format: TextureFormat,
}
impl Default for RendererSettings {
fn default() -> Self {
Self {
msaa: Msaa::default(),
texture_format: COLOR_TEXTURE_FORMAT,
}
}
}