Brandon Jones | d1cba10 | 2020-01-07 17:49:15 +0000 | [diff] [blame] | 1 | // Copyright 2019 The Dawn Authors |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #ifndef COMMON_GPUINFO_H |
| 16 | #define COMMON_GPUINFO_H |
| 17 | |
Jiawei Shao | ce3d4a5 | 2021-05-19 08:43:33 +0000 | [diff] [blame] | 18 | #include <array> |
Brandon Jones | d1cba10 | 2020-01-07 17:49:15 +0000 | [diff] [blame] | 19 | #include <cstdint> |
| 20 | |
| 21 | using PCIVendorID = uint32_t; |
Corentin Wallez | d56b69f | 2020-04-09 08:16:30 +0000 | [diff] [blame] | 22 | using PCIDeviceID = uint32_t; |
Brandon Jones | d1cba10 | 2020-01-07 17:49:15 +0000 | [diff] [blame] | 23 | |
| 24 | namespace gpu_info { |
| 25 | |
| 26 | static constexpr PCIVendorID kVendorID_AMD = 0x1002; |
| 27 | static constexpr PCIVendorID kVendorID_ARM = 0x13B5; |
| 28 | static constexpr PCIVendorID kVendorID_ImgTec = 0x1010; |
| 29 | static constexpr PCIVendorID kVendorID_Intel = 0x8086; |
| 30 | static constexpr PCIVendorID kVendorID_Nvidia = 0x10DE; |
| 31 | static constexpr PCIVendorID kVendorID_Qualcomm = 0x5143; |
Corentin Wallez | d56b69f | 2020-04-09 08:16:30 +0000 | [diff] [blame] | 32 | static constexpr PCIVendorID kVendorID_Google = 0x1AE0; |
Bryan Bernhart | 8c255ac | 2020-07-10 22:58:48 +0000 | [diff] [blame] | 33 | static constexpr PCIVendorID kVendorID_Microsoft = 0x1414; |
Corentin Wallez | d56b69f | 2020-04-09 08:16:30 +0000 | [diff] [blame] | 34 | |
| 35 | static constexpr PCIDeviceID kDeviceID_Swiftshader = 0xC0DE; |
Bryan Bernhart | 8c255ac | 2020-07-10 22:58:48 +0000 | [diff] [blame] | 36 | static constexpr PCIDeviceID kDeviceID_WARP = 0x8c; |
Brandon Jones | d1cba10 | 2020-01-07 17:49:15 +0000 | [diff] [blame] | 37 | |
| 38 | bool IsAMD(PCIVendorID vendorId); |
| 39 | bool IsARM(PCIVendorID vendorId); |
| 40 | bool IsImgTec(PCIVendorID vendorId); |
| 41 | bool IsIntel(PCIVendorID vendorId); |
| 42 | bool IsNvidia(PCIVendorID vendorId); |
| 43 | bool IsQualcomm(PCIVendorID vendorId); |
Corentin Wallez | d56b69f | 2020-04-09 08:16:30 +0000 | [diff] [blame] | 44 | bool IsSwiftshader(PCIVendorID vendorId, PCIDeviceID deviceId); |
Bryan Bernhart | 8c255ac | 2020-07-10 22:58:48 +0000 | [diff] [blame] | 45 | bool IsWARP(PCIVendorID vendorId, PCIDeviceID deviceId); |
Brandon Jones | d1cba10 | 2020-01-07 17:49:15 +0000 | [diff] [blame] | 46 | |
Jiawei Shao | ce3d4a5 | 2021-05-19 08:43:33 +0000 | [diff] [blame] | 47 | using D3DDriverVersion = std::array<uint16_t, 4>; |
| 48 | |
| 49 | // Do comparison between two driver versions. Currently we only support the comparison between |
| 50 | // Intel D3D driver versions. |
Yang Gu | c45c7a4 | 2021-07-07 08:58:01 +0000 | [diff] [blame] | 51 | // - Return -1 if build number of version1 is smaller |
| 52 | // - Return 1 if build number of version1 is bigger |
Jiawei Shao | ce3d4a5 | 2021-05-19 08:43:33 +0000 | [diff] [blame] | 53 | // - Return 0 if version1 and version2 represent same driver version |
| 54 | int CompareD3DDriverVersion(PCIVendorID vendorId, |
| 55 | const D3DDriverVersion& version1, |
| 56 | const D3DDriverVersion& version2); |
| 57 | |
Jiawei Shao | f905e57 | 2021-03-11 19:34:50 +0000 | [diff] [blame] | 58 | // Intel architectures |
| 59 | bool IsSkylake(PCIDeviceID deviceId); |
| 60 | bool IsKabylake(PCIDeviceID deviceId); |
| 61 | bool IsCoffeelake(PCIDeviceID deviceId); |
| 62 | |
Brandon Jones | d1cba10 | 2020-01-07 17:49:15 +0000 | [diff] [blame] | 63 | } // namespace gpu_info |
Corentin Wallez | d56b69f | 2020-04-09 08:16:30 +0000 | [diff] [blame] | 64 | #endif // COMMON_GPUINFO_H |