Skip to content

Commit

Permalink
Vendor id clarification (#3036)
Browse files Browse the repository at this point in the history
* set GL vendor for id Mesa and Apple

* match on "apple m" to mark M2 cpu as integrated in gles

* document AdapterInfo::vendor if the vendor has no PCI id
  • Loading branch information
i509VCB authored Sep 20, 2022
1 parent 03b989c commit f877a8a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -98,6 +99,10 @@ 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)
- Report Apple M2 gpu as integrated. By @i509VCB [#3036](https://github.com/gfx-rs/wgpu/pull/3036)

### Changes

#### General
Expand Down
10 changes: 10 additions & 0 deletions wgpu-hal/src/auxil/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
6 changes: 5 additions & 1 deletion wgpu-hal/src/gles/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"];

Expand Down Expand Up @@ -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
};
Expand Down
3 changes: 3 additions & 0 deletions wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f877a8a

Please sign in to comment.