Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions deno_webgpu/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ impl GPU {
noop: wgpu_types::NoopBackendOptions::default(),
},
},
None,
)));
state.borrow::<Instance>()
};
Expand Down
2 changes: 1 addition & 1 deletion player/src/bin/play.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fn main() {
.unwrap();

let instance_desc = wgt::InstanceDescriptor::from_env_or_default();
let instance = wgc::instance::Instance::new("player", &instance_desc);
let instance = wgc::instance::Instance::new("player", &instance_desc, None);

#[cfg(feature = "winit")]
let surface = unsafe {
Expand Down
2 changes: 1 addition & 1 deletion player/tests/player/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl Corpus {
println!("\t\tTest '{test_path:?}'");

let instance_desc = wgt::InstanceDescriptor::from_env_or_default();
let instance = wgc::instance::Instance::new("test", &instance_desc);
let instance = wgc::instance::Instance::new("test", &instance_desc, None);
let adapter = match instance.request_adapter(
&wgt::RequestAdapterOptions {
power_preference: wgt::PowerPreference::None,
Expand Down
8 changes: 6 additions & 2 deletions wgpu-core/src/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ pub struct Global {
}

impl Global {
pub fn new(name: &str, instance_desc: &wgt::InstanceDescriptor) -> Self {
pub fn new(
name: &str,
instance_desc: &wgt::InstanceDescriptor,
telemetry: Option<hal::Telemetry>,
) -> Self {
profiling::scope!("Global::new");
Self {
instance: Instance::new(name, instance_desc),
instance: Instance::new(name, instance_desc, telemetry),
surfaces: Registry::new(),
hub: Hub::new(),
}
Expand Down
24 changes: 17 additions & 7 deletions wgpu-core/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ pub struct Instance {
}

impl Instance {
pub fn new(name: &str, instance_desc: &wgt::InstanceDescriptor) -> Self {
pub fn new(
name: &str,
instance_desc: &wgt::InstanceDescriptor,
telemetry: Option<hal::Telemetry>,
) -> Self {
let mut this = Self {
name: name.to_owned(),
instance_per_backend: Vec::new(),
Expand All @@ -102,21 +106,26 @@ impl Instance {
};

#[cfg(vulkan)]
this.try_add_hal(hal::api::Vulkan, instance_desc);
this.try_add_hal(hal::api::Vulkan, instance_desc, telemetry);
#[cfg(metal)]
this.try_add_hal(hal::api::Metal, instance_desc);
this.try_add_hal(hal::api::Metal, instance_desc, telemetry);
#[cfg(dx12)]
this.try_add_hal(hal::api::Dx12, instance_desc);
this.try_add_hal(hal::api::Dx12, instance_desc, telemetry);
#[cfg(gles)]
this.try_add_hal(hal::api::Gles, instance_desc);
this.try_add_hal(hal::api::Gles, instance_desc, telemetry);
#[cfg(feature = "noop")]
this.try_add_hal(hal::api::Noop, instance_desc);
this.try_add_hal(hal::api::Noop, instance_desc, telemetry);

this
}

/// Helper for `Instance::new()`; attempts to add a single `wgpu-hal` backend to this instance.
fn try_add_hal<A: hal::Api>(&mut self, _: A, instance_desc: &wgt::InstanceDescriptor) {
fn try_add_hal<A: hal::Api>(
&mut self,
_: A,
instance_desc: &wgt::InstanceDescriptor,
telemetry: Option<hal::Telemetry>,
) {
// Whether or not the backend was requested, and whether or not it succeeds,
// note that we *could* try it.
self.supported_backends |= A::VARIANT.into();
Expand All @@ -131,6 +140,7 @@ impl Instance {
flags: self.flags,
memory_budget_thresholds: instance_desc.memory_budget_thresholds,
backend_options: instance_desc.backend_options.clone(),
telemetry,
};

use hal::Instance as _;
Expand Down
1 change: 1 addition & 0 deletions wgpu-hal/examples/halmark/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ impl<A: hal::Api> Example<A> {
memory_budget_thresholds: wgpu_types::MemoryBudgetThresholds::default(),
// Can't rely on having DXC available, so use FXC instead
backend_options: wgpu_types::BackendOptions::default(),
telemetry: None,
};
let instance = unsafe { A::Instance::init(&instance_desc)? };
let surface = {
Expand Down
1 change: 1 addition & 0 deletions wgpu-hal/examples/ray-traced-triangle/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ impl<A: hal::Api> Example<A> {
},
..Default::default()
},
telemetry: None,
};
let instance = unsafe { A::Instance::init(&instance_desc)? };
let surface = {
Expand Down
Loading