Skip to content

Commit 5c76751

Browse files
authored
[d3d12] add support for optional adapter telemetry (#8576)
1 parent 61f08ed commit 5c76751

File tree

13 files changed

+222
-98
lines changed

13 files changed

+222
-98
lines changed

deno_webgpu/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ impl GPU {
180180
noop: wgpu_types::NoopBackendOptions::default(),
181181
},
182182
},
183+
None,
183184
)));
184185
state.borrow::<Instance>()
185186
};

player/src/bin/play.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fn main() {
7070
.unwrap();
7171

7272
let instance_desc = wgt::InstanceDescriptor::from_env_or_default();
73-
let instance = wgc::instance::Instance::new("player", &instance_desc);
73+
let instance = wgc::instance::Instance::new("player", &instance_desc, None);
7474

7575
#[cfg(feature = "winit")]
7676
let surface = unsafe {

player/tests/player/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl Corpus {
182182
println!("\t\tTest '{test_path:?}'");
183183

184184
let instance_desc = wgt::InstanceDescriptor::from_env_or_default();
185-
let instance = wgc::instance::Instance::new("test", &instance_desc);
185+
let instance = wgc::instance::Instance::new("test", &instance_desc, None);
186186
let adapter = match instance.request_adapter(
187187
&wgt::RequestAdapterOptions {
188188
power_preference: wgt::PowerPreference::None,

wgpu-core/src/global.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,14 @@ pub struct Global {
3131
}
3232

3333
impl Global {
34-
pub fn new(name: &str, instance_desc: &wgt::InstanceDescriptor) -> Self {
34+
pub fn new(
35+
name: &str,
36+
instance_desc: &wgt::InstanceDescriptor,
37+
telemetry: Option<hal::Telemetry>,
38+
) -> Self {
3539
profiling::scope!("Global::new");
3640
Self {
37-
instance: Instance::new(name, instance_desc),
41+
instance: Instance::new(name, instance_desc, telemetry),
3842
surfaces: Registry::new(),
3943
hub: Hub::new(),
4044
}

wgpu-core/src/instance.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ pub struct Instance {
9292
}
9393

9494
impl Instance {
95-
pub fn new(name: &str, instance_desc: &wgt::InstanceDescriptor) -> Self {
95+
pub fn new(
96+
name: &str,
97+
instance_desc: &wgt::InstanceDescriptor,
98+
telemetry: Option<hal::Telemetry>,
99+
) -> Self {
96100
let mut this = Self {
97101
name: name.to_owned(),
98102
instance_per_backend: Vec::new(),
@@ -102,21 +106,26 @@ impl Instance {
102106
};
103107

104108
#[cfg(vulkan)]
105-
this.try_add_hal(hal::api::Vulkan, instance_desc);
109+
this.try_add_hal(hal::api::Vulkan, instance_desc, telemetry);
106110
#[cfg(metal)]
107-
this.try_add_hal(hal::api::Metal, instance_desc);
111+
this.try_add_hal(hal::api::Metal, instance_desc, telemetry);
108112
#[cfg(dx12)]
109-
this.try_add_hal(hal::api::Dx12, instance_desc);
113+
this.try_add_hal(hal::api::Dx12, instance_desc, telemetry);
110114
#[cfg(gles)]
111-
this.try_add_hal(hal::api::Gles, instance_desc);
115+
this.try_add_hal(hal::api::Gles, instance_desc, telemetry);
112116
#[cfg(feature = "noop")]
113-
this.try_add_hal(hal::api::Noop, instance_desc);
117+
this.try_add_hal(hal::api::Noop, instance_desc, telemetry);
114118

115119
this
116120
}
117121

118122
/// Helper for `Instance::new()`; attempts to add a single `wgpu-hal` backend to this instance.
119-
fn try_add_hal<A: hal::Api>(&mut self, _: A, instance_desc: &wgt::InstanceDescriptor) {
123+
fn try_add_hal<A: hal::Api>(
124+
&mut self,
125+
_: A,
126+
instance_desc: &wgt::InstanceDescriptor,
127+
telemetry: Option<hal::Telemetry>,
128+
) {
120129
// Whether or not the backend was requested, and whether or not it succeeds,
121130
// note that we *could* try it.
122131
self.supported_backends |= A::VARIANT.into();
@@ -131,6 +140,7 @@ impl Instance {
131140
flags: self.flags,
132141
memory_budget_thresholds: instance_desc.memory_budget_thresholds,
133142
backend_options: instance_desc.backend_options.clone(),
143+
telemetry,
134144
};
135145

136146
use hal::Instance as _;

wgpu-hal/examples/halmark/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ impl<A: hal::Api> Example<A> {
9999
memory_budget_thresholds: wgpu_types::MemoryBudgetThresholds::default(),
100100
// Can't rely on having DXC available, so use FXC instead
101101
backend_options: wgpu_types::BackendOptions::default(),
102+
telemetry: None,
102103
};
103104
let instance = unsafe { A::Instance::init(&instance_desc)? };
104105
let surface = {

wgpu-hal/examples/ray-traced-triangle/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ impl<A: hal::Api> Example<A> {
246246
},
247247
..Default::default()
248248
},
249+
telemetry: None,
249250
};
250251
let instance = unsafe { A::Instance::init(&instance_desc)? };
251252
let surface = {

0 commit comments

Comments
 (0)