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 18 #include <array> 19 #include <cstdint> 20 21 using PCIVendorID = uint32_t; 22 using PCIDeviceID = uint32_t; 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; 32 static constexpr PCIVendorID kVendorID_Google = 0x1AE0; 33 static constexpr PCIVendorID kVendorID_Microsoft = 0x1414; 34 35 static constexpr PCIDeviceID kDeviceID_Swiftshader = 0xC0DE; 36 static constexpr PCIDeviceID kDeviceID_WARP = 0x8c; 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); 44 bool IsSwiftshader(PCIVendorID vendorId, PCIDeviceID deviceId); 45 bool IsWARP(PCIVendorID vendorId, PCIDeviceID deviceId); 46 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. 51 // - Return -1 if build number of version1 is smaller 52 // - Return 1 if build number of version1 is bigger 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 58 // Intel architectures 59 bool IsSkylake(PCIDeviceID deviceId); 60 bool IsKabylake(PCIDeviceID deviceId); 61 bool IsCoffeelake(PCIDeviceID deviceId); 62 63 } // namespace gpu_info 64 #endif // COMMON_GPUINFO_H 65