mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-20 22:41:07 +01:00
expose adapter info on device (#8807)
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
7 files changed
+43
-1
No files matched your search
@@ -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
|
||||
|
||||
|
||||
@@ -128,6 +128,10 @@ impl DeviceInterface for CustomDevice {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn adapter_info(&self) -> wgpu::AdapterInfo {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn create_shader_module(
|
||||
&self,
|
||||
desc: wgpu::ShaderModuleDescriptor<'_>,
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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,
|
||||
@@ -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<'_>,
|
||||
@@ -2560,6 +2581,7 @@ impl dispatch::DeviceInterface for WebDevice {
|
||||
self.inner.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for WebDevice {
|
||||
fn drop(&mut self) {
|
||||
// no-op
|
||||
|
||||
@@ -1007,6 +1007,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(
|
||||
|
||||
@@ -131,6 +131,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,
|
||||
|
||||
Reference in new issue
Block a user