diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cb917054d..4d71f4badc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,6 +73,7 @@ SurfaceConfiguration { - Add `Buffer::size()` and `Buffer::usage()`; by @kpreid in [#2923](https://github.com/gfx-rs/wgpu/pull/2923) - Expose `alpha_mode` on SurfaceConfiguration, by @jinleili in [#2836](https://github.com/gfx-rs/wgpu/pull/2836) +- Introduce fields for driver name and info in `AdapterInfo`, by @i509VCB in [#3037](https://github.com/gfx-rs/wgpu/pull/3037) ### Bug Fixes diff --git a/wgpu-hal/src/dx11/adapter.rs b/wgpu-hal/src/dx11/adapter.rs index bfae7b2030..327f585a69 100644 --- a/wgpu-hal/src/dx11/adapter.rs +++ b/wgpu-hal/src/dx11/adapter.rs @@ -243,6 +243,8 @@ impl super::Adapter { 1 => wgt::DeviceType::IntegratedGpu, _ => unreachable!(), }, + driver: String::new(), + driver_info: String::new(), backend: wgt::Backend::Dx11, }; diff --git a/wgpu-hal/src/dx12/adapter.rs b/wgpu-hal/src/dx12/adapter.rs index c44cf664e2..b7d70e77fe 100644 --- a/wgpu-hal/src/dx12/adapter.rs +++ b/wgpu-hal/src/dx12/adapter.rs @@ -122,6 +122,8 @@ impl super::Adapter { } else { wgt::DeviceType::DiscreteGpu }, + driver: String::new(), + driver_info: String::new(), }; let mut options: d3d12::D3D12_FEATURE_DATA_D3D12_OPTIONS = unsafe { mem::zeroed() }; diff --git a/wgpu-hal/src/gles/adapter.rs b/wgpu-hal/src/gles/adapter.rs index d6cff0932e..92aaf1bb13 100644 --- a/wgpu-hal/src/gles/adapter.rs +++ b/wgpu-hal/src/gles/adapter.rs @@ -173,6 +173,8 @@ impl super::Adapter { vendor: vendor_id as usize, device: 0, device_type: inferred_device_type, + driver: String::new(), + driver_info: String::new(), backend: wgt::Backend::Gl, } } diff --git a/wgpu-hal/src/metal/mod.rs b/wgpu-hal/src/metal/mod.rs index d4ba2d14cf..82cb2a889b 100644 --- a/wgpu-hal/src/metal/mod.rs +++ b/wgpu-hal/src/metal/mod.rs @@ -116,6 +116,8 @@ impl crate::Instance for Instance { vendor: 0, device: 0, device_type: shared.private_caps.device_type(), + driver: String::new(), + driver_info: String::new(), backend: wgt::Backend::Metal, }, features: shared.private_caps.features(), diff --git a/wgpu-hal/src/vulkan/adapter.rs b/wgpu-hal/src/vulkan/adapter.rs index 1353cdaf32..86e0893b27 100644 --- a/wgpu-hal/src/vulkan/adapter.rs +++ b/wgpu-hal/src/vulkan/adapter.rs @@ -511,6 +511,7 @@ pub struct PhysicalDeviceCapabilities { supported_extensions: Vec, properties: vk::PhysicalDeviceProperties, descriptor_indexing: Option, + driver: Option, /// The effective driver api version supported by the physical device. /// /// The Vulkan specification states the following in the documentation for VkPhysicalDeviceProperties: @@ -572,6 +573,11 @@ impl PhysicalDeviceCapabilities { extensions.push(vk::KhrImageFormatListFn::name()); // Required for `KhrImagelessFramebufferFn` } + // This extension is core in Vulkan 1.2 + if self.supports_extension(vk::KhrDriverPropertiesFn::name()) { + extensions.push(vk::KhrDriverPropertiesFn::name()); + } + extensions.push(vk::ExtSamplerFilterMinmaxFn::name()); extensions.push(vk::KhrTimelineSemaphoreFn::name()); @@ -747,9 +753,12 @@ impl super::InstanceShared { capabilities.properties = if let Some(ref get_device_properties) = self.get_physical_device_properties { - // Get this now to avoid borrowing conflicts later + // Get these now to avoid borrowing conflicts later let supports_descriptor_indexing = capabilities.supports_extension(vk::ExtDescriptorIndexingFn::name()); + let supports_driver_properties = capabilities.properties.api_version + >= vk::API_VERSION_1_2 + || capabilities.supports_extension(vk::KhrDriverPropertiesFn::name()); let mut builder = vk::PhysicalDeviceProperties2::builder(); @@ -760,6 +769,13 @@ impl super::InstanceShared { builder = builder.push_next(next); } + if supports_driver_properties { + let next = capabilities + .driver + .insert(vk::PhysicalDeviceDriverPropertiesKHR::default()); + builder = builder.push_next(next); + } + let mut properties2 = builder.build(); unsafe { get_device_properties.get_physical_device_properties2(phd, &mut properties2); @@ -889,6 +905,24 @@ impl super::Instance { ash::vk::PhysicalDeviceType::CPU => wgt::DeviceType::Cpu, _ => wgt::DeviceType::Other, }, + driver: unsafe { + let driver_name = if let Some(driver) = phd_capabilities.driver { + CStr::from_ptr(driver.driver_name.as_ptr()).to_str().ok() + } else { + None + }; + + driver_name.unwrap_or("?").to_owned() + }, + driver_info: unsafe { + let driver_info = if let Some(driver) = phd_capabilities.driver { + CStr::from_ptr(driver.driver_info.as_ptr()).to_str().ok() + } else { + None + }; + + driver_info.unwrap_or("?").to_owned() + }, backend: wgt::Backend::Vulkan, }; diff --git a/wgpu-info/src/main.rs b/wgpu-info/src/main.rs index 9840511491..426e7798e5 100644 --- a/wgpu-info/src/main.rs +++ b/wgpu-info/src/main.rs @@ -139,6 +139,8 @@ mod inner { println!("\t VendorID: {:?}", info.vendor); println!("\t DeviceID: {:?}", info.device); println!("\t Type: {:?}", info.device_type); + println!("\t Driver: {:?}", info.driver); + println!("\tDriverInfo: {:?}", info.driver); println!("\t Compliant: {:?}", downlevel.is_webgpu_compliant()); println!("\tFeatures:"); for i in 0..(size_of::() * 8) { diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index ab00124f61..4bd69850aa 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -1148,6 +1148,10 @@ pub struct AdapterInfo { pub device: usize, /// Type of device pub device_type: DeviceType, + /// Driver name + pub driver: String, + /// Driver info + pub driver_info: String, /// Backend used for device pub backend: Backend, } diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index afb3c45915..c366529756 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -1199,6 +1199,8 @@ impl crate::Context for Context { vendor: 0, device: 0, device_type: wgt::DeviceType::Other, + driver: String::new(), + driver_info: String::new(), backend: wgt::Backend::BrowserWebGpu, } }