From be8ef0c9c0bf0b8e2e331afe10f962b30143668a Mon Sep 17 00:00:00 2001 From: i509VCB Date: Mon, 19 Sep 2022 19:43:59 -0500 Subject: [PATCH 1/3] set GL vendor for id Mesa and Apple --- CHANGELOG.md | 3 +++ wgpu-hal/src/auxil/mod.rs | 10 ++++++++++ wgpu-hal/src/gles/adapter.rs | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd1493c315..41862085ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -98,6 +98,9 @@ SurfaceConfiguration { and `VUID-StandaloneSpirv-Flat-04744`. By @jimblandy in [#3008](https://github.com/gfx-rs/wgpu/pull/3008) +#### Gles +- Report vendor id for Mesa and Apple GPUs. By @i509VCB [#3036](https://github.com/gfx-rs/wgpu/pull/3036). + ### Changes #### General diff --git a/wgpu-hal/src/auxil/mod.rs b/wgpu-hal/src/auxil/mod.rs index b6aa57c076..d8675ac0d0 100644 --- a/wgpu-hal/src/auxil/mod.rs +++ b/wgpu-hal/src/auxil/mod.rs @@ -8,6 +8,9 @@ pub mod db { pub mod amd { pub const VENDOR: u32 = 0x1002; } + pub mod apple { + pub const VENDOR: u32 = 0x106B; + } pub mod arm { pub const VENDOR: u32 = 0x13B5; } @@ -22,6 +25,13 @@ pub mod db { pub const DEVICE_KABY_LAKE_MASK: u32 = 0x5900; pub const DEVICE_SKY_LAKE_MASK: u32 = 0x1900; } + pub mod mesa { + // Mesa does not actually have a PCI vendor id. + // + // To match Vulkan, we use the VkVendorId for Mesa in the gles backend so that lavapipe (Vulkan) and + // llvmpipe (OpenGL) have the same vendor id. + pub const VENDOR: u32 = 0x10005; + } pub mod nvidia { pub const VENDOR: u32 = 0x10DE; } diff --git a/wgpu-hal/src/gles/adapter.rs b/wgpu-hal/src/gles/adapter.rs index 66709a424f..68a68af17b 100644 --- a/wgpu-hal/src/gles/adapter.rs +++ b/wgpu-hal/src/gles/adapter.rs @@ -160,6 +160,10 @@ impl super::Adapter { db::intel::VENDOR } else if vendor.contains("broadcom") { db::broadcom::VENDOR + } else if vendor.contains("mesa") { + db::mesa::VENDOR + } else if vendor.contains("apple") { + db::apple::VENDOR } else { 0 }; From 2d01d9355f296319e2397e33f21def649a0f45a0 Mon Sep 17 00:00:00 2001 From: i509VCB Date: Mon, 19 Sep 2022 19:45:07 -0500 Subject: [PATCH 2/3] match on "apple m" to mark M2 cpu as integrated in gles --- CHANGELOG.md | 3 ++- wgpu-hal/src/gles/adapter.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41862085ba..914f3225b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -99,7 +99,8 @@ SurfaceConfiguration { [#3008](https://github.com/gfx-rs/wgpu/pull/3008) #### Gles -- Report vendor id for Mesa and Apple GPUs. By @i509VCB [#3036](https://github.com/gfx-rs/wgpu/pull/3036). +- Report vendor id for Mesa and Apple GPUs. By @i509VCB [#3036](https://github.com/gfx-rs/wgpu/pull/3036) +- Report Apple M2 gpu as integrated. By @i509VCB [#3036](https://github.com/gfx-rs/wgpu/pull/3036) ### Changes diff --git a/wgpu-hal/src/gles/adapter.rs b/wgpu-hal/src/gles/adapter.rs index 68a68af17b..992f565c98 100644 --- a/wgpu-hal/src/gles/adapter.rs +++ b/wgpu-hal/src/gles/adapter.rs @@ -122,7 +122,7 @@ impl super::Adapter { "mali", "intel", "v3d", - "apple m1", + "apple m", // all apple m are integrated ]; let strings_that_imply_cpu = ["mesa offscreen", "swiftshader", "llvmpipe"]; From d90b7ae9ea3bfd4aebd7a0ec0c3d87edc0fdb975 Mon Sep 17 00:00:00 2001 From: i509VCB Date: Mon, 19 Sep 2022 19:49:32 -0500 Subject: [PATCH 3/3] document AdapterInfo::vendor if the vendor has no PCI id --- CHANGELOG.md | 1 + wgpu-types/src/lib.rs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 914f3225b2..058c343902 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -85,6 +85,7 @@ SurfaceConfiguration { - Added missing validation for `BufferUsages` mismatches when `Features::MAPPABLE_PRIMARY_BUFFERS` is not enabled. By @imberflur in [#3023](https://github.com/gfx-rs/wgpu/pull/3023) - Fixed `CommandEncoder` not being `Send` and `Sync` on web by @i509VCB in [#3025](https://github.com/gfx-rs/wgpu/pull/3025) +- Document meaning of `vendor` in `AdapterInfo` if the vendor has no PCI id. #### Metal - Add the missing `msg_send![view, retain]` call within `from_view` by @jinleili in [#2976](https://github.com/gfx-rs/wgpu/pull/2976) diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 1b698bd9d4..5a3b916b42 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -1140,6 +1140,9 @@ pub struct AdapterInfo { /// Adapter name pub name: String, /// Vendor PCI id of the adapter + /// + /// 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, /// PCI id of the adapter pub device: usize,