mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-18 01:15:39 +00:00
Report GPU arch on Metal devices with no vendorID
This change attempts to better classify devices with a Metal backend that aren't currently reporting vendor/device ID. In practice this mostly means Apple-produced GPUs, like the M1 series. Bug: dawn:1443 Change-Id: I9e8467a50c9f8eeccc00863f6dee32c0f91380dd Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92123 Kokoro: Kokoro <noreply+kokoro@google.com> Auto-Submit: Brandon Jones <bajones@chromium.org> Commit-Queue: Brandon Jones <bajones@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
b2ce202734
commit
d45b920aed
@@ -192,7 +192,7 @@ dawn_generator("dawn_gpu_info_gen") {
|
||||
script = "${dawn_root}/generator/dawn_gpu_info_generator.py"
|
||||
args = [
|
||||
"--gpu-info-json",
|
||||
rebase_path("${dawn_root}/gpu_info.json", root_build_dir),
|
||||
rebase_path("${dawn_root}/src/dawn/gpu_info.json", root_build_dir),
|
||||
]
|
||||
outputs = [
|
||||
"src/dawn/common/GPUInfo_autogen.h",
|
||||
|
||||
@@ -24,7 +24,7 @@ DawnGenerator(
|
||||
SCRIPT "${Dawn_SOURCE_DIR}/generator/dawn_gpu_info_generator.py"
|
||||
PRINT_NAME "Dawn GPU info utilities"
|
||||
ARGS "--gpu-info-json"
|
||||
"${Dawn_SOURCE_DIR}/gpu_info.json"
|
||||
"${Dawn_SOURCE_DIR}/src/dawn/gpu_info.json"
|
||||
RESULT_VARIABLE "DAWN_GPU_INFO_AUTOGEN_SOURCES"
|
||||
)
|
||||
|
||||
|
||||
137
src/dawn/gpu_info.json
Normal file
137
src/dawn/gpu_info.json
Normal file
@@ -0,0 +1,137 @@
|
||||
{
|
||||
"_comment": [
|
||||
"Copyright 2022 The Dawn Authors",
|
||||
"",
|
||||
"Licensed under the Apache License, Version 2.0 (the \"License\");",
|
||||
"you may not use this file except in compliance with the License.",
|
||||
"You may obtain a copy of the License at",
|
||||
"",
|
||||
" http://www.apache.org/licenses/LICENSE-2.0",
|
||||
"",
|
||||
"Unless required by applicable law or agreed to in writing, software",
|
||||
"distributed under the License is distributed on an \"AS IS\" BASIS,",
|
||||
"WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.",
|
||||
"See the License for the specific language governing permissions and",
|
||||
"limitations under the License."
|
||||
],
|
||||
|
||||
"vendors": {
|
||||
|
||||
"AMD": {
|
||||
"id": "0x1002",
|
||||
|
||||
"deviceMask": "0xFFF0",
|
||||
"architecture": {
|
||||
"GCN 1": ["0x6600", "0x6610", "0x6660", "0x6790", "0x6800", "0x6810", "0x6820", "0x6830"],
|
||||
"GCN 2": ["0x1300", "0x1310", "0x6640", "0x6650", "0x67A0", "0x67B0", "0x9830", "0x9850"],
|
||||
"GCN 3": ["0x6900", "0x6920", "0x6930", "0x7300", "0x9870", "0x98E0"],
|
||||
"GCN 4": ["0x67C0", "0x67D0", "0x67E0", "0x67F0", "0x6980", "0x6990"],
|
||||
"GCN 5": ["0x15D0", "0x1630", "0x1640", "0x66A0", "0x6860", "0x6870", "0x6940", "0x69A0"],
|
||||
"RDNA 1": ["0x7310", "0x7340", "0x7360"],
|
||||
"RDNA 2": ["0x73A0", "0x73B0", "0x73D0", "0x73E0", "0x73F0", "0x7420", "0x7430"]
|
||||
}
|
||||
},
|
||||
|
||||
"Apple": {
|
||||
"id": "0x106b",
|
||||
|
||||
"_comment": [
|
||||
"Apple GPUs do not report a DeviceID via the Metal API, and as such the typical device",
|
||||
"pattern matching does not work for them. The recommended approach is to find the highest",
|
||||
"supported 'common' family supported and report it as the architecture.",
|
||||
"Examples: 'common-1', 'common-3'",
|
||||
"https://developer.apple.com/documentation/metal/gpu_devices_and_work_submission/detecting_gpu_features_and_metal_software_versions"
|
||||
]
|
||||
},
|
||||
|
||||
"ARM": {
|
||||
"id": "0x13B5",
|
||||
|
||||
"deviceMask": "0xF0000000",
|
||||
"architecture": {
|
||||
"_comment": [
|
||||
"The Midgard GPUs have device IDs like 0x07______ and 0x08______, but it's easiest to",
|
||||
"mask those values out and simply check for the highest octet being zero, since that",
|
||||
"distinguishes it from the other architectures."
|
||||
],
|
||||
|
||||
"Midgard": ["0x00000000"],
|
||||
"Bifrost": ["0x60000000", "0x70000000"],
|
||||
"Valhall": ["0x90000000", "0xA0000000"]
|
||||
}
|
||||
},
|
||||
|
||||
"Google": {
|
||||
"id": "0x1AE0",
|
||||
|
||||
"architecture": {
|
||||
"Swiftshader": ["0xC0DE"]
|
||||
}
|
||||
},
|
||||
|
||||
"Img Tec": {
|
||||
"id": "0x1010"
|
||||
},
|
||||
|
||||
"Intel": {
|
||||
"id": "0x8086",
|
||||
|
||||
"deviceMask": "0xFF00",
|
||||
"architecture": {
|
||||
"Gen 7": ["0x0100", "0x0400", "0x0A00", "0x0D00", "0x0F00"],
|
||||
"Gen 8": ["0x1600", "0x2200"],
|
||||
"Gen 9": ["0x1900", "0x3100", "0x3E00", "0x5A00", "0x5900", "0x9B00"],
|
||||
"Gen 11": ["0x8A00"],
|
||||
"Xe": ["0x4600", "0x4C00", "0x4900", "0x9A00"]
|
||||
}
|
||||
},
|
||||
|
||||
"Mesa": {
|
||||
"id": "0x10005"
|
||||
},
|
||||
|
||||
"Microsoft": {
|
||||
"id": "0x1414",
|
||||
|
||||
"architecture": {
|
||||
"WARP": ["0x8c"]
|
||||
}
|
||||
},
|
||||
|
||||
"Nvidia": {
|
||||
"id": "0x10DE",
|
||||
|
||||
"deviceMask": "0xFF00",
|
||||
"architecture": {
|
||||
"Fermi": ["0x0D00"],
|
||||
"Kepler": ["0x0F00", "0x1000", "0x1100", "0x1200"],
|
||||
"Maxwell": ["0x1300", "0x1400", "0x1600", "0x1700"],
|
||||
"Pascal": ["0x1500", "0x1B00", "0x1C00", "0x1D00"],
|
||||
"Turing": ["0x1E00", "0x1F00", "0x2100"],
|
||||
"Ampere": ["0x2200", "0x2400", "0x2500"]
|
||||
}
|
||||
},
|
||||
|
||||
"Qualcomm": {
|
||||
"id": "0x5143",
|
||||
|
||||
"deviceMask": "0xFF000000",
|
||||
"architecture": {
|
||||
"Adreno 4xx": ["0x04000000"],
|
||||
"Adreno 5xx": ["0x05000000"],
|
||||
"Adreno 6xx": ["0x06000000"],
|
||||
"Adreno 7xx": ["0x07000000"]
|
||||
}
|
||||
},
|
||||
|
||||
"Samsung": {
|
||||
"id": "0x144d",
|
||||
|
||||
"architecture": {
|
||||
"RDNA 2": ["0x73A0"]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,6 +33,8 @@ AdapterBase::AdapterBase(InstanceBase* instance, wgpu::BackendType backend)
|
||||
|
||||
MaybeError AdapterBase::Initialize() {
|
||||
DAWN_TRY_CONTEXT(InitializeImpl(), "initializing adapter (backend=%s)", mBackend);
|
||||
InitializeVendorArchitectureImpl();
|
||||
|
||||
DAWN_TRY_CONTEXT(
|
||||
InitializeSupportedFeaturesImpl(),
|
||||
"gathering supported features for \"%s\" - \"%s\" (vendorId=%#06x deviceId=%#06x "
|
||||
@@ -44,9 +46,6 @@ MaybeError AdapterBase::Initialize() {
|
||||
"backend=%s type=%s)",
|
||||
mName, mDriverDescription, mVendorId, mDeviceId, mBackend, mAdapterType);
|
||||
|
||||
mVendorName = gpu_info::GetVendorName(mVendorId);
|
||||
mArchitectureName = gpu_info::GetArchitectureName(mVendorId, mDeviceId);
|
||||
|
||||
// Enforce internal Dawn constants.
|
||||
mLimits.v1.maxVertexBufferArrayStride =
|
||||
std::min(mLimits.v1.maxVertexBufferArrayStride, kMaxVertexBufferArrayStride);
|
||||
@@ -138,6 +137,11 @@ void AdapterBase::APIRequestDevice(const DeviceDescriptor* descriptor,
|
||||
callback(status, ToAPI(device.Detach()), nullptr, userdata);
|
||||
}
|
||||
|
||||
void AdapterBase::InitializeVendorArchitectureImpl() {
|
||||
mVendorName = gpu_info::GetVendorName(mVendorId);
|
||||
mArchitectureName = gpu_info::GetArchitectureName(mVendorId, mDeviceId);
|
||||
}
|
||||
|
||||
uint32_t AdapterBase::GetVendorId() const {
|
||||
return mVendorId;
|
||||
}
|
||||
|
||||
@@ -86,6 +86,8 @@ class AdapterBase : public RefCounted {
|
||||
// Check base WebGPU limits and populate supported limits.
|
||||
virtual MaybeError InitializeSupportedLimitsImpl(CombinedLimits* limits) = 0;
|
||||
|
||||
virtual void InitializeVendorArchitectureImpl();
|
||||
|
||||
ResultOrError<Ref<DeviceBase>> CreateDeviceInternal(const DeviceDescriptor* descriptor);
|
||||
|
||||
virtual MaybeError ResetInternalDeviceForTestingImpl();
|
||||
|
||||
@@ -47,11 +47,10 @@ struct Vendor {
|
||||
};
|
||||
|
||||
#if DAWN_PLATFORM_IS(MACOS)
|
||||
const Vendor kVendors[] = {{"AMD", gpu_info::kVendorID_AMD},
|
||||
{"Radeon", gpu_info::kVendorID_AMD},
|
||||
{"Intel", gpu_info::kVendorID_Intel},
|
||||
{"Geforce", gpu_info::kVendorID_Nvidia},
|
||||
{"Quadro", gpu_info::kVendorID_Nvidia}};
|
||||
const Vendor kVendors[] = {
|
||||
{"AMD", gpu_info::kVendorID_AMD}, {"Apple", gpu_info::kVendorID_Apple},
|
||||
{"Radeon", gpu_info::kVendorID_AMD}, {"Intel", gpu_info::kVendorID_Intel},
|
||||
{"Geforce", gpu_info::kVendorID_Nvidia}, {"Quadro", gpu_info::kVendorID_Nvidia}};
|
||||
|
||||
// Find vendor ID from MTLDevice name.
|
||||
MaybeError GetVendorIdFromVendors(id<MTLDevice> device, PCIIDs* ids) {
|
||||
@@ -147,10 +146,16 @@ MaybeError GetDevicePCIInfo(id<MTLDevice> device, PCIIDs* ids) {
|
||||
// [device registryID] is introduced on macOS 10.13+, otherwise workaround to get vendor
|
||||
// id by vendor name on old macOS
|
||||
if (@available(macos 10.13, *)) {
|
||||
return GetDeviceIORegistryPCIInfo(device, ids);
|
||||
} else {
|
||||
return GetVendorIdFromVendors(device, ids);
|
||||
auto result = GetDeviceIORegistryPCIInfo(device, ids);
|
||||
if (result.IsError()) {
|
||||
dawn::WarningLog() << "GetDeviceIORegistryPCIInfo failed: "
|
||||
<< result.AcquireError()->GetFormattedMessage();
|
||||
} else if (ids->vendorId != 0) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return GetVendorIdFromVendors(device, ids);
|
||||
}
|
||||
|
||||
bool IsMetalSupported() {
|
||||
@@ -391,6 +396,33 @@ class Adapter : public AdapterBase {
|
||||
return {};
|
||||
}
|
||||
|
||||
void InitializeVendorArchitectureImpl() override {
|
||||
if (@available(macOS 10.15, iOS 13.0, *)) {
|
||||
// According to Apple's documentation:
|
||||
// https://developer.apple.com/documentation/metal/gpu_devices_and_work_submission/detecting_gpu_features_and_metal_software_versions
|
||||
// - "Use the Common family to create apps that target a range of GPUs on multiple
|
||||
// platforms.""
|
||||
// - "A GPU can be a member of more than one family; in most cases, a GPU supports one
|
||||
// of the Common families and then one or more families specific to the build target."
|
||||
// So we'll use the highest supported common family as the reported "architecture" on
|
||||
// devices where a deviceID isn't available.
|
||||
if (mDeviceId == 0) {
|
||||
if ([*mDevice supportsFamily:MTLGPUFamilyCommon3]) {
|
||||
mArchitectureName = "common-3";
|
||||
} else if ([*mDevice supportsFamily:MTLGPUFamilyCommon2]) {
|
||||
mArchitectureName = "common-2";
|
||||
} else if ([*mDevice supportsFamily:MTLGPUFamilyCommon1]) {
|
||||
mArchitectureName = "common-1";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mVendorName = gpu_info::GetVendorName(mVendorId);
|
||||
if (mDeviceId != 0) {
|
||||
mArchitectureName = gpu_info::GetArchitectureName(mVendorId, mDeviceId);
|
||||
}
|
||||
};
|
||||
|
||||
enum class MTLGPUFamily {
|
||||
Apple1,
|
||||
Apple2,
|
||||
|
||||
@@ -649,6 +649,11 @@ void DawnTestEnvironment::PrintTestConfigurationAndAdapterInfo(
|
||||
<< ", backend: " << ParamName(properties.backendType) << "\n"
|
||||
<< " vendorId: 0x" << vendorId.str() << ", deviceId: 0x" << deviceId.str()
|
||||
<< (properties.selected ? " [Selected]" : "") << "\n";
|
||||
|
||||
if (strlen(properties.vendorName) || strlen(properties.architecture)) {
|
||||
log << " vendorName: " << properties.vendorName
|
||||
<< ", architecture: " << properties.architecture << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user