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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Bottom level categories:
### New Features

- Added support for cooperative load/store operations in shaders. Currently only WGSL on the input and SPIR-V, METAL, and WGSL on the output are supported. By @kvark in [#8251](https://github.com/gfx-rs/wgpu/issues/8251).
- Added support for obtaining `AdapterInfo` from `Device`. By @sagudev in [#8807](https://github.com/gfx-rs/wgpu/pull/8807).

### Bug Fixes

Expand Down
4 changes: 4 additions & 0 deletions examples/standalone/custom_backend/src/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ impl DeviceInterface for CustomDevice {
unimplemented!()
}

fn adapter_info(&self) -> wgpu::AdapterInfo {
unimplemented!()
}

fn create_shader_module(
&self,
desc: wgpu::ShaderModuleDescriptor<'_>,
Expand Down
5 changes: 5 additions & 0 deletions wgpu-core/src/device/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ impl Global {
device.limits.clone()
}

pub fn device_adapter_info(&self, device_id: DeviceId) -> wgt::AdapterInfo {
let device = self.hub.devices.get(device_id);
device.adapter.get_info()
}

pub fn device_downlevel_properties(&self, device_id: DeviceId) -> wgt::DownlevelCapabilities {
let device = self.hub.devices.get(device_id);
device.downlevel.clone()
Expand Down
5 changes: 5 additions & 0 deletions wgpu/src/api/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ impl Device {
self.inner.limits()
}

/// Get info about the adapter that this device was created from.
pub fn adapter_info(&self) -> AdapterInfo {
self.inner.adapter_info()
}

/// Creates a shader module.
///
/// <div class="warning">
Expand Down
24 changes: 23 additions & 1 deletion wgpu/src/backend/webgpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,23 @@ fn map_wgt_limits(limits: webgpu_sys::GpuSupportedLimits) -> wgt::Limits {
}
}

fn map_adapter_info(adapter_info: &webgpu_sys::GpuAdapterInfo) -> wgt::AdapterInfo {
// TODO(https://github.com/gfx-rs/wgpu/issues/8819): populate more fields if/when possible
wgt::AdapterInfo {
name: adapter_info.description().to_string(),
vendor: 0,
device: 0,
device_type: wgt::DeviceType::Other,
device_pci_bus_id: String::new(),
driver: String::new(),
driver_info: String::new(),
backend: wgt::Backend::BrowserWebGpu,
subgroup_min_size: wgt::MINIMUM_SUBGROUP_MIN_SIZE,
subgroup_max_size: wgt::MAXIMUM_SUBGROUP_MAX_SIZE,
transient_saves_memory: false,
}
}

fn map_js_sys_limits(limits: &wgt::Limits) -> js_sys::Object {
let object = js_sys::Object::new();

Expand Down Expand Up @@ -1716,7 +1733,7 @@ impl dispatch::AdapterInterface for WebAdapter {
}

fn get_info(&self) -> crate::AdapterInfo {
// TODO: web-sys has no way of getting information on adapters
// TODO(https://github.com/gfx-rs/wgpu/issues/8818): web-sys has no way of getting information on adapters
wgt::AdapterInfo {
name: String::new(),
vendor: 0,
Expand Down Expand Up @@ -1762,6 +1779,10 @@ impl dispatch::DeviceInterface for WebDevice {
map_wgt_limits(self.inner.limits())
}

fn adapter_info(&self) -> crate::AdapterInfo {
map_adapter_info(&self.inner.adapter_info())
}

fn create_shader_module(
&self,
desc: crate::ShaderModuleDescriptor<'_>,
Expand Down Expand Up @@ -2560,6 +2581,7 @@ impl dispatch::DeviceInterface for WebDevice {
self.inner.destroy();
}
}

impl Drop for WebDevice {
fn drop(&mut self) {
// no-op
Expand Down
4 changes: 4 additions & 0 deletions wgpu/src/backend/wgpu_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,10 @@ impl dispatch::DeviceInterface for CoreDevice {
self.context.0.device_limits(self.id)
}

fn adapter_info(&self) -> crate::AdapterInfo {
self.context.0.device_adapter_info(self.id)
}

// If we have no way to create a shader module, we can't return one, and so most of the function is unreachable.
#[cfg_attr(
not(any(
Expand Down
1 change: 1 addition & 0 deletions wgpu/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ pub trait AdapterInterface: CommonTraits {
pub trait DeviceInterface: CommonTraits {
fn features(&self) -> crate::Features;
fn limits(&self) -> crate::Limits;
fn adapter_info(&self) -> crate::AdapterInfo;

fn create_shader_module(
&self,
Expand Down