Skip to content

Commit

Permalink
Change AdapterInfo::{device,vendor} fields to u32 (#3760)
Browse files Browse the repository at this point in the history
* Change AdapterInfo device and vendor to u32s

* Add CHANGELOG
  • Loading branch information
ameknite authored May 9, 2023
1 parent 4558849 commit 4d8a7ed
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ Bottom level categories:

## Unreleased

### Changes

#### Misc Breaking Changes

- Change `AdapterInfo::{device,vendor}` to be `u32` instead of `usize`. By @ameknite in [#3760](https://github.com/gfx-rs/wgpu/pull/3760)

### Documentation

#### General
Expand Down
4 changes: 2 additions & 2 deletions wgpu-hal/src/dx12/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ impl super::Adapter {
let info = wgt::AdapterInfo {
backend: wgt::Backend::Dx12,
name: device_name,
vendor: desc.VendorId as usize,
device: desc.DeviceId as usize,
vendor: desc.VendorId,
device: desc.DeviceId,
device_type: if (desc.Flags & dxgi::DXGI_ADAPTER_FLAG_SOFTWARE) != 0 {
workarounds.avoid_cpu_descriptor_overwrites = true;
wgt::DeviceType::Cpu
Expand Down
2 changes: 1 addition & 1 deletion wgpu-hal/src/gles/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl super::Adapter {

wgt::AdapterInfo {
name: renderer_orig,
vendor: vendor_id as usize,
vendor: vendor_id,
device: 0,
device_type: inferred_device_type,
driver: String::new(),
Expand Down
4 changes: 2 additions & 2 deletions wgpu-hal/src/vulkan/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -961,8 +961,8 @@ impl super::Instance {
.unwrap_or("?")
.to_owned()
},
vendor: phd_capabilities.properties.vendor_id as usize,
device: phd_capabilities.properties.device_id as usize,
vendor: phd_capabilities.properties.vendor_id,
device: phd_capabilities.properties.device_id,
device_type: match phd_capabilities.properties.device_type {
ash::vk::PhysicalDeviceType::OTHER => wgt::DeviceType::Other,
ash::vk::PhysicalDeviceType::INTEGRATED_GPU => wgt::DeviceType::IntegratedGpu,
Expand Down
4 changes: 2 additions & 2 deletions wgpu-hal/src/vulkan/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,12 +691,12 @@ impl crate::Instance<super::Api> for super::Instance {
// Detect if it's an Intel + NVidia configuration with Optimus
let has_nvidia_dgpu = exposed_adapters.iter().any(|exposed| {
exposed.info.device_type == wgt::DeviceType::DiscreteGpu
&& exposed.info.vendor == db::nvidia::VENDOR as usize
&& exposed.info.vendor == db::nvidia::VENDOR
});
if cfg!(target_os = "linux") && has_nvidia_dgpu && self.shared.has_nv_optimus {
for exposed in exposed_adapters.iter_mut() {
if exposed.info.device_type == wgt::DeviceType::IntegratedGpu
&& exposed.info.vendor == db::intel::VENDOR as usize
&& exposed.info.vendor == db::intel::VENDOR
{
// See https://gitlab.freedesktop.org/mesa/mesa/-/issues/4688
log::warn!(
Expand Down
4 changes: 2 additions & 2 deletions wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1307,9 +1307,9 @@ pub struct AdapterInfo {
///
/// If the vendor has no PCI id, then this value will be the backend's vendor id equivalent. On Vulkan,
/// Mesa would have a vendor id equivalent to it's `VkVendorId` value.
pub vendor: usize,
pub vendor: u32,
/// PCI id of the adapter
pub device: usize,
pub device: u32,
/// Type of device
pub device_type: DeviceType,
/// Driver name
Expand Down
4 changes: 2 additions & 2 deletions wgpu/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn lowest_downlevel_properties() -> DownlevelCapabilities {

pub struct FailureCase {
backends: Option<wgpu::Backends>,
vendor: Option<usize>,
vendor: Option<u32>,
adapter: Option<String>,
skip: bool,
}
Expand Down Expand Up @@ -170,7 +170,7 @@ impl TestParameters {
pub fn specific_failure(
mut self,
backends: Option<Backends>,
vendor: Option<usize>,
vendor: Option<u32>,
device: Option<&'static str>,
skip: bool,
) -> Self {
Expand Down

0 comments on commit 4d8a7ed

Please sign in to comment.