Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change AdapterInfo::{device,vendor} fields to u32 #3760

Merged
merged 2 commits into from
May 9, 2023
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
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