forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpu_info_collector_mac.mm
69 lines (52 loc) · 1.93 KB
/
gpu_info_collector_mac.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "gpu/config/gpu_info_collector.h"
#include "base/mac/scoped_nsobject.h"
#include "base/metrics/histogram_macros.h"
#include "base/trace_event/trace_event.h"
#include "gpu/command_buffer/common/gpu_memory_buffer_support.h"
#include "third_party/angle/src/gpu_info_util/SystemInfo.h"
#import <Metal/Metal.h>
namespace gpu {
namespace {
// The enums is used for an UMA histogram so we should never reorder entries or
// remove unused values.
enum class MetalReadWriteTextureSupportTier {
kUnknown = 0,
kTier0_NoSupport = 1,
kTier1_R32Formats = 2,
kTier2_AdditionalFormats = 3,
kMaxValue = kTier2_AdditionalFormats,
};
void RecordReadWriteMetalTexturesSupportedHistogram() {
// Metal tiers go 0, 1, 2, but we reserve 0 for when macOS is less then 10.13
// and we can't query.
NSUInteger best_tier = 0;
if (@available(macOS 10.13, *)) {
base::scoped_nsobject<NSArray<id<MTLDevice>>> devices(MTLCopyAllDevices());
for (id<MTLDevice> device in devices.get()) {
best_tier = std::max(best_tier, [device readWriteTextureSupport] + 1);
}
}
UMA_HISTOGRAM_ENUMERATION(
"Gpu.Metal.ReadWriteTextureSupport",
static_cast<MetalReadWriteTextureSupportTier>(best_tier));
}
}
bool CollectContextGraphicsInfo(GPUInfo* gpu_info) {
DCHECK(gpu_info);
TRACE_EVENT0("gpu", "gpu_info_collector::CollectGraphicsInfo");
gpu_info->macos_specific_texture_target =
gpu::GetPlatformSpecificTextureTarget();
RecordReadWriteMetalTexturesSupportedHistogram();
return CollectGraphicsInfoGL(gpu_info);
}
bool CollectBasicGraphicsInfo(GPUInfo* gpu_info) {
DCHECK(gpu_info);
angle::SystemInfo system_info;
bool success = angle::GetSystemInfo(&system_info);
FillGPUInfoFromSystemInfo(gpu_info, &system_info);
return success;
}
} // namespace gpu