Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/intel/dev/intel_dev_info.c
7086 views
1
/*
2
* Copyright © 2020 Intel Corporation
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the "Software"),
6
* to deal in the Software without restriction, including without limitation
7
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
* and/or sell copies of the Software, and to permit persons to whom the
9
* Software is furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice (including the next
12
* paragraph) shall be included in all copies or substantial portions of the
13
* Software.
14
*
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21
* IN THE SOFTWARE.
22
*/
23
24
#include <stdio.h>
25
#include <stdlib.h>
26
#include <stdarg.h>
27
#include <inttypes.h>
28
29
#include <sys/types.h>
30
#include <sys/stat.h>
31
#include <fcntl.h>
32
#include <unistd.h>
33
34
#include <xf86drm.h>
35
36
#include "intel_device_info.h"
37
38
static int
39
error(char *fmt, ...)
40
{
41
va_list ap;
42
va_start(ap, fmt);
43
vfprintf(stderr, fmt, ap);
44
va_end(ap);
45
46
return EXIT_FAILURE;
47
}
48
49
int
50
main(int argc, char *argv[])
51
{
52
drmDevicePtr devices[8];
53
int max_devices;
54
55
max_devices = drmGetDevices2(0, devices, ARRAY_SIZE(devices));
56
if (max_devices < 1)
57
return error("Not device found");
58
59
for (int i = 0; i < max_devices; i++) {
60
struct intel_device_info devinfo;
61
const char *path = devices[i]->nodes[DRM_NODE_RENDER];
62
int fd = open(path, O_RDWR | O_CLOEXEC);
63
64
if (fd < 0)
65
continue;
66
67
bool success = intel_get_device_info_from_fd(fd, &devinfo);
68
close(fd);
69
70
if (!success)
71
continue;
72
73
fprintf(stdout, "%s:\n", path);
74
75
fprintf(stdout, " name: %s\n", intel_get_device_name(devinfo.chipset_id));
76
fprintf(stdout, " gen: %u\n", devinfo.ver);
77
fprintf(stdout, " PCI id: 0x%x\n", devinfo.chipset_id);
78
fprintf(stdout, " revision: %u\n", devinfo.revision);
79
80
const char *subslice_name = devinfo.ver >= 12 ? "dualsubslice" : "subslice";
81
uint32_t n_s = 0, n_ss = 0, n_eus = 0;
82
for (unsigned s = 0; s < devinfo.num_slices; s++) {
83
n_s += (devinfo.slice_masks & (1u << s)) ? 1 : 0;
84
for (unsigned ss = 0; ss < devinfo.num_subslices[s]; ss++) {
85
fprintf(stdout, " slice%u.%s%u: ", s, subslice_name, ss);
86
if (intel_device_info_subslice_available(&devinfo, s, ss)) {
87
n_ss++;
88
for (unsigned eu = 0; eu < devinfo.num_eu_per_subslice; eu++) {
89
n_eus += intel_device_info_eu_available(&devinfo, s, ss, eu) ? 1 : 0;
90
fprintf(stdout, "%s", intel_device_info_eu_available(&devinfo, s, ss, eu) ? "1" : "0");
91
}
92
} else {
93
fprintf(stderr, "fused");
94
}
95
fprintf(stdout, "\n");
96
}
97
}
98
fprintf(stdout, " slices: %u\n", n_s);
99
fprintf(stdout, " %s: %u\n", subslice_name, n_ss);
100
fprintf(stdout, " EU per %s: %u\n", subslice_name, devinfo.num_eu_per_subslice);
101
fprintf(stdout, " EUs: %u\n", n_eus);
102
fprintf(stdout, " EU threads: %u\n", n_eus * devinfo.num_thread_per_eu);
103
104
fprintf(stdout, " LLC: %u\n", devinfo.has_llc);
105
fprintf(stdout, " threads per EU: %u\n", devinfo.num_thread_per_eu);
106
fprintf(stdout, " L3 banks: %u\n", devinfo.l3_banks);
107
fprintf(stdout, " max VS threads: %u\n", devinfo.max_vs_threads);
108
fprintf(stdout, " max TCS threads: %u\n", devinfo.max_tcs_threads);
109
fprintf(stdout, " max TES threads: %u\n", devinfo.max_tes_threads);
110
fprintf(stdout, " max GS threads: %u\n", devinfo.max_gs_threads);
111
fprintf(stdout, " max WM threads: %u\n", devinfo.max_wm_threads);
112
fprintf(stdout, " max CS threads: %u\n", devinfo.max_cs_threads);
113
fprintf(stdout, " timestamp frequency: %" PRIu64 "\n", devinfo.timestamp_frequency);
114
}
115
116
return EXIT_SUCCESS;
117
}
118
119