blob: 2b30d96662e0c5dae5ed3bacc7893d5eae647ae5 [file] [log] [blame]
Brandon Jonesd1cba102020-01-07 17:49:15 +00001// 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 Shaoce3d4a52021-05-19 08:43:33 +000018#include <array>
Brandon Jonesd1cba102020-01-07 17:49:15 +000019#include <cstdint>
20
21using PCIVendorID = uint32_t;
Corentin Wallezd56b69f2020-04-09 08:16:30 +000022using PCIDeviceID = uint32_t;
Brandon Jonesd1cba102020-01-07 17:49:15 +000023
24namespace 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 Wallezd56b69f2020-04-09 08:16:30 +000032 static constexpr PCIVendorID kVendorID_Google = 0x1AE0;
Bryan Bernhart8c255ac2020-07-10 22:58:48 +000033 static constexpr PCIVendorID kVendorID_Microsoft = 0x1414;
Corentin Wallezd56b69f2020-04-09 08:16:30 +000034
35 static constexpr PCIDeviceID kDeviceID_Swiftshader = 0xC0DE;
Bryan Bernhart8c255ac2020-07-10 22:58:48 +000036 static constexpr PCIDeviceID kDeviceID_WARP = 0x8c;
Brandon Jonesd1cba102020-01-07 17:49:15 +000037
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 Wallezd56b69f2020-04-09 08:16:30 +000044 bool IsSwiftshader(PCIVendorID vendorId, PCIDeviceID deviceId);
Bryan Bernhart8c255ac2020-07-10 22:58:48 +000045 bool IsWARP(PCIVendorID vendorId, PCIDeviceID deviceId);
Brandon Jonesd1cba102020-01-07 17:49:15 +000046
Jiawei Shaoce3d4a52021-05-19 08:43:33 +000047 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 Guc45c7a42021-07-07 08:58:01 +000051 // - Return -1 if build number of version1 is smaller
52 // - Return 1 if build number of version1 is bigger
Jiawei Shaoce3d4a52021-05-19 08:43:33 +000053 // - 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 Shaof905e572021-03-11 19:34:50 +000058 // Intel architectures
59 bool IsSkylake(PCIDeviceID deviceId);
60 bool IsKabylake(PCIDeviceID deviceId);
61 bool IsCoffeelake(PCIDeviceID deviceId);
62
Brandon Jonesd1cba102020-01-07 17:49:15 +000063} // namespace gpu_info
Corentin Wallezd56b69f2020-04-09 08:16:30 +000064#endif // COMMON_GPUINFO_H