Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/intel/dev/intel_device_info.h
7086 views
1
/*
2
* Copyright © 2013 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
25
#ifndef INTEL_DEVICE_INFO_H
26
#define INTEL_DEVICE_INFO_H
27
28
#include <stdbool.h>
29
#include <stdint.h>
30
31
#include "util/macros.h"
32
33
#ifdef __cplusplus
34
extern "C" {
35
#endif
36
37
struct drm_i915_query_topology_info;
38
39
#define INTEL_DEVICE_MAX_SLICES (6) /* Maximum on gfx10 */
40
#define INTEL_DEVICE_MAX_SUBSLICES (8) /* Maximum on gfx11 */
41
#define INTEL_DEVICE_MAX_EUS_PER_SUBSLICE (16) /* Maximum on gfx12 */
42
#define INTEL_DEVICE_MAX_PIXEL_PIPES (3) /* Maximum on gfx12 */
43
44
/**
45
* Intel hardware information and quirks
46
*/
47
struct intel_device_info
48
{
49
/* Driver internal numbers used to differentiate platforms. */
50
int ver;
51
int verx10;
52
int revision;
53
int gt;
54
55
bool is_g4x;
56
bool is_ivybridge;
57
bool is_baytrail;
58
bool is_haswell;
59
bool is_broadwell;
60
bool is_cherryview;
61
bool is_skylake;
62
bool is_broxton;
63
bool is_kabylake;
64
bool is_geminilake;
65
bool is_coffeelake;
66
bool is_elkhartlake;
67
bool is_tigerlake;
68
bool is_rocketlake;
69
bool is_dg1;
70
bool is_alderlake;
71
72
bool has_hiz_and_separate_stencil;
73
bool must_use_separate_stencil;
74
bool has_sample_with_hiz;
75
bool has_llc;
76
77
bool has_pln;
78
bool has_64bit_float;
79
bool has_64bit_int;
80
bool has_integer_dword_mul;
81
bool has_compr4;
82
bool has_surface_tile_offset;
83
bool supports_simd16_3src;
84
bool disable_ccs_repack;
85
bool has_aux_map;
86
bool has_tiling_uapi;
87
bool has_ray_tracing;
88
bool has_local_mem;
89
bool has_lsc;
90
91
/**
92
* \name Intel hardware quirks
93
* @{
94
*/
95
bool has_negative_rhw_bug;
96
97
/**
98
* Some versions of Gen hardware don't do centroid interpolation correctly
99
* on unlit pixels, causing incorrect values for derivatives near triangle
100
* edges. Enabling this flag causes the fragment shader to use
101
* non-centroid interpolation for unlit pixels, at the expense of two extra
102
* fragment shader instructions.
103
*/
104
bool needs_unlit_centroid_workaround;
105
/** @} */
106
107
/**
108
* \name GPU hardware limits
109
*
110
* In general, you can find shader thread maximums by looking at the "Maximum
111
* Number of Threads" field in the Intel PRM description of the 3DSTATE_VS,
112
* 3DSTATE_GS, 3DSTATE_HS, 3DSTATE_DS, and 3DSTATE_PS commands. URB entry
113
* limits come from the "Number of URB Entries" field in the
114
* 3DSTATE_URB_VS command and friends.
115
*
116
* These fields are used to calculate the scratch space to allocate. The
117
* amount of scratch space can be larger without being harmful on modern
118
* GPUs, however, prior to Haswell, programming the maximum number of threads
119
* to greater than the hardware maximum would cause GPU performance to tank.
120
*
121
* @{
122
*/
123
/**
124
* Total number of slices present on the device whether or not they've been
125
* fused off.
126
*
127
* XXX: CS thread counts are limited by the inability to do cross subslice
128
* communication. It is the effectively the number of logical threads which
129
* can be executed in a subslice. Fuse configurations may cause this number
130
* to change, so we program @max_cs_threads as the lower maximum.
131
*/
132
unsigned num_slices;
133
134
/**
135
* Number of subslices for each slice (used to be uniform until CNL).
136
*/
137
unsigned num_subslices[INTEL_DEVICE_MAX_SUBSLICES];
138
139
/**
140
* Number of subslices on each pixel pipe (ICL).
141
*/
142
unsigned ppipe_subslices[INTEL_DEVICE_MAX_PIXEL_PIPES];
143
144
/**
145
* Upper bound of number of EU per subslice (some SKUs might have just 1 EU
146
* fused across all subslices, like 47 EUs, in which case this number won't
147
* be acurate for one subslice).
148
*/
149
unsigned num_eu_per_subslice;
150
151
/**
152
* Number of threads per eu, varies between 4 and 8 between generations.
153
*/
154
unsigned num_thread_per_eu;
155
156
/**
157
* A bit mask of the slices available.
158
*/
159
uint8_t slice_masks;
160
161
/**
162
* An array of bit mask of the subslices available, use subslice_slice_stride
163
* to access this array.
164
*/
165
uint8_t subslice_masks[INTEL_DEVICE_MAX_SLICES *
166
DIV_ROUND_UP(INTEL_DEVICE_MAX_SUBSLICES, 8)];
167
168
/**
169
* An array of bit mask of EUs available, use eu_slice_stride &
170
* eu_subslice_stride to access this array.
171
*/
172
uint8_t eu_masks[INTEL_DEVICE_MAX_SLICES *
173
INTEL_DEVICE_MAX_SUBSLICES *
174
DIV_ROUND_UP(INTEL_DEVICE_MAX_EUS_PER_SUBSLICE, 8)];
175
176
/**
177
* Stride to access subslice_masks[].
178
*/
179
uint16_t subslice_slice_stride;
180
181
/**
182
* Strides to access eu_masks[].
183
*/
184
uint16_t eu_slice_stride;
185
uint16_t eu_subslice_stride;
186
187
unsigned l3_banks;
188
unsigned max_vs_threads; /**< Maximum Vertex Shader threads */
189
unsigned max_tcs_threads; /**< Maximum Hull Shader threads */
190
unsigned max_tes_threads; /**< Maximum Domain Shader threads */
191
unsigned max_gs_threads; /**< Maximum Geometry Shader threads. */
192
/**
193
* Theoretical maximum number of Pixel Shader threads.
194
*
195
* PSD means Pixel Shader Dispatcher. On modern Intel GPUs, hardware will
196
* automatically scale pixel shader thread count, based on a single value
197
* programmed into 3DSTATE_PS.
198
*
199
* To calculate the maximum number of threads for Gfx8 beyond (which have
200
* multiple Pixel Shader Dispatchers):
201
*
202
* - Look up 3DSTATE_PS and find "Maximum Number of Threads Per PSD"
203
* - Usually there's only one PSD per subslice, so use the number of
204
* subslices for number of PSDs.
205
* - For max_wm_threads, the total should be PSD threads * #PSDs.
206
*/
207
unsigned max_wm_threads;
208
209
/**
210
* Maximum Compute Shader threads.
211
*
212
* Thread count * number of EUs per subslice
213
*/
214
unsigned max_cs_threads;
215
216
struct {
217
/**
218
* Fixed size of the URB.
219
*
220
* On Gfx6 and DG1, this is measured in KB. Gfx4-5 instead measure
221
* this in 512b blocks, as that's more convenient there.
222
*
223
* On most Gfx7+ platforms, the URB is a section of the L3 cache,
224
* and can be resized based on the L3 programming. For those platforms,
225
* simply leave this field blank (zero) - it isn't used.
226
*/
227
unsigned size;
228
229
/**
230
* The minimum number of URB entries. See the 3DSTATE_URB_<XS> docs.
231
*/
232
unsigned min_entries[4];
233
234
/**
235
* The maximum number of URB entries. See the 3DSTATE_URB_<XS> docs.
236
*/
237
unsigned max_entries[4];
238
} urb;
239
240
/**
241
* Size of the command streamer prefetch. This is important to know for
242
* self modifying batches.
243
*/
244
unsigned cs_prefetch_size;
245
246
/**
247
* For the longest time the timestamp frequency for Gen's timestamp counter
248
* could be assumed to be 12.5MHz, where the least significant bit neatly
249
* corresponded to 80 nanoseconds.
250
*
251
* Since Gfx9 the numbers aren't so round, with a a frequency of 12MHz for
252
* SKL (or scale factor of 83.33333333) and a frequency of 19200000Hz for
253
* BXT.
254
*
255
* For simplicty to fit with the current code scaling by a single constant
256
* to map from raw timestamps to nanoseconds we now do the conversion in
257
* floating point instead of integer arithmetic.
258
*
259
* In general it's probably worth noting that the documented constants we
260
* have for the per-platform timestamp frequencies aren't perfect and
261
* shouldn't be trusted for scaling and comparing timestamps with a large
262
* delta.
263
*
264
* E.g. with crude testing on my system using the 'correct' scale factor I'm
265
* seeing a drift of ~2 milliseconds per second.
266
*/
267
uint64_t timestamp_frequency;
268
269
uint64_t aperture_bytes;
270
271
/**
272
* ID to put into the .aub files.
273
*/
274
int simulator_id;
275
276
/**
277
* holds the pci device id
278
*/
279
uint32_t chipset_id;
280
281
/**
282
* no_hw is true when the chipset_id pci device id has been overridden
283
*/
284
bool no_hw;
285
/** @} */
286
};
287
288
#ifdef GFX_VER
289
290
#define intel_device_info_is_9lp(devinfo) \
291
(GFX_VER == 9 && ((devinfo)->is_broxton || (devinfo)->is_geminilake))
292
293
#else
294
295
#define intel_device_info_is_9lp(devinfo) \
296
((devinfo)->is_broxton || (devinfo)->is_geminilake)
297
298
#endif
299
300
static inline bool
301
intel_device_info_subslice_available(const struct intel_device_info *devinfo,
302
int slice, int subslice)
303
{
304
return (devinfo->subslice_masks[slice * devinfo->subslice_slice_stride +
305
subslice / 8] & (1U << (subslice % 8))) != 0;
306
}
307
308
static inline bool
309
intel_device_info_eu_available(const struct intel_device_info *devinfo,
310
int slice, int subslice, int eu)
311
{
312
unsigned subslice_offset = slice * devinfo->eu_slice_stride +
313
subslice * devinfo->eu_subslice_stride;
314
315
return (devinfo->eu_masks[subslice_offset + eu / 8] & (1U << eu % 8)) != 0;
316
}
317
318
static inline uint32_t
319
intel_device_info_subslice_total(const struct intel_device_info *devinfo)
320
{
321
uint32_t total = 0;
322
323
for (uint32_t i = 0; i < devinfo->num_slices; i++)
324
total += __builtin_popcount(devinfo->subslice_masks[i]);
325
326
return total;
327
}
328
329
static inline uint32_t
330
intel_device_info_eu_total(const struct intel_device_info *devinfo)
331
{
332
uint32_t total = 0;
333
334
for (uint32_t i = 0; i < ARRAY_SIZE(devinfo->eu_masks); i++)
335
total += __builtin_popcount(devinfo->eu_masks[i]);
336
337
return total;
338
}
339
340
static inline unsigned
341
intel_device_info_num_dual_subslices(UNUSED
342
const struct intel_device_info *devinfo)
343
{
344
unreachable("TODO");
345
}
346
347
int intel_device_name_to_pci_device_id(const char *name);
348
const char *intel_get_device_name(int devid);
349
350
static inline uint64_t
351
intel_device_info_timebase_scale(const struct intel_device_info *devinfo,
352
uint64_t gpu_timestamp)
353
{
354
return (1000000000ull * gpu_timestamp) / devinfo->timestamp_frequency;
355
}
356
357
bool intel_get_device_info_from_fd(int fh, struct intel_device_info *devinfo);
358
bool intel_get_device_info_from_pci_id(int pci_id,
359
struct intel_device_info *devinfo);
360
int intel_get_aperture_size(int fd, uint64_t *size);
361
362
#ifdef __cplusplus
363
}
364
#endif
365
366
#endif /* INTEL_DEVICE_INFO_H */
367
368