5dbd06075722f8cc644e82762e83411c31ec674b
[mesa.git] / src / intel / dev / gen_device_info.c
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 #include <assert.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <unistd.h>
29 #include "gen_device_info.h"
30 #include "compiler/shader_enums.h"
31 #include "util/bitscan.h"
32 #include "util/macros.h"
33
34 #include <i915_drm.h>
35
36 /**
37 * Get the PCI ID for the device name.
38 *
39 * Returns -1 if the device is not known.
40 */
41 int
42 gen_device_name_to_pci_device_id(const char *name)
43 {
44 static const struct {
45 const char *name;
46 int pci_id;
47 } name_map[] = {
48 { "brw", 0x2a02 },
49 { "g4x", 0x2a42 },
50 { "ilk", 0x0042 },
51 { "snb", 0x0126 },
52 { "ivb", 0x016a },
53 { "hsw", 0x0d2e },
54 { "byt", 0x0f33 },
55 { "bdw", 0x162e },
56 { "chv", 0x22B3 },
57 { "skl", 0x1912 },
58 { "bxt", 0x5A85 },
59 { "kbl", 0x5912 },
60 { "aml", 0x591C },
61 { "glk", 0x3185 },
62 { "cfl", 0x3E9B },
63 { "whl", 0x3EA1 },
64 { "cnl", 0x5a52 },
65 { "icl", 0x8a52 },
66 };
67
68 for (unsigned i = 0; i < ARRAY_SIZE(name_map); i++) {
69 if (!strcmp(name_map[i].name, name))
70 return name_map[i].pci_id;
71 }
72
73 return -1;
74 }
75
76 /**
77 * Get the overridden PCI ID for the device. This is set with the
78 * INTEL_DEVID_OVERRIDE environment variable.
79 *
80 * Returns -1 if the override is not set.
81 */
82 int
83 gen_get_pci_device_id_override(void)
84 {
85 if (geteuid() == getuid()) {
86 const char *devid_override = getenv("INTEL_DEVID_OVERRIDE");
87 if (devid_override) {
88 const int id = gen_device_name_to_pci_device_id(devid_override);
89 return id >= 0 ? id : strtol(devid_override, NULL, 0);
90 }
91 }
92
93 return -1;
94 }
95
96 static const struct gen_device_info gen_device_info_i965 = {
97 .gen = 4,
98 .has_negative_rhw_bug = true,
99 .num_slices = 1,
100 .num_subslices = { 1, },
101 .num_eu_per_subslice = 8,
102 .num_thread_per_eu = 4,
103 .max_vs_threads = 16,
104 .max_gs_threads = 2,
105 .max_wm_threads = 8 * 4,
106 .urb = {
107 .size = 256,
108 },
109 .timestamp_frequency = 12500000,
110 .simulator_id = -1,
111 };
112
113 static const struct gen_device_info gen_device_info_g4x = {
114 .gen = 4,
115 .has_pln = true,
116 .has_compr4 = true,
117 .has_surface_tile_offset = true,
118 .is_g4x = true,
119 .num_slices = 1,
120 .num_subslices = { 1, },
121 .num_eu_per_subslice = 10,
122 .num_thread_per_eu = 5,
123 .max_vs_threads = 32,
124 .max_gs_threads = 2,
125 .max_wm_threads = 10 * 5,
126 .urb = {
127 .size = 384,
128 },
129 .timestamp_frequency = 12500000,
130 .simulator_id = -1,
131 };
132
133 static const struct gen_device_info gen_device_info_ilk = {
134 .gen = 5,
135 .has_pln = true,
136 .has_compr4 = true,
137 .has_surface_tile_offset = true,
138 .num_slices = 1,
139 .num_subslices = { 1, },
140 .num_eu_per_subslice = 12,
141 .num_thread_per_eu = 6,
142 .max_vs_threads = 72,
143 .max_gs_threads = 32,
144 .max_wm_threads = 12 * 6,
145 .urb = {
146 .size = 1024,
147 },
148 .timestamp_frequency = 12500000,
149 .simulator_id = -1,
150 };
151
152 static const struct gen_device_info gen_device_info_snb_gt1 = {
153 .gen = 6,
154 .gt = 1,
155 .has_hiz_and_separate_stencil = true,
156 .has_llc = true,
157 .has_pln = true,
158 .has_surface_tile_offset = true,
159 .needs_unlit_centroid_workaround = true,
160 .num_slices = 1,
161 .num_subslices = { 1, },
162 .num_eu_per_subslice = 6,
163 .num_thread_per_eu = 6, /* Not confirmed */
164 .max_vs_threads = 24,
165 .max_gs_threads = 21, /* conservative; 24 if rendering disabled. */
166 .max_wm_threads = 40,
167 .urb = {
168 .size = 32,
169 .min_entries = {
170 [MESA_SHADER_VERTEX] = 24,
171 },
172 .max_entries = {
173 [MESA_SHADER_VERTEX] = 256,
174 [MESA_SHADER_GEOMETRY] = 256,
175 },
176 },
177 .timestamp_frequency = 12500000,
178 .simulator_id = -1,
179 };
180
181 static const struct gen_device_info gen_device_info_snb_gt2 = {
182 .gen = 6,
183 .gt = 2,
184 .has_hiz_and_separate_stencil = true,
185 .has_llc = true,
186 .has_pln = true,
187 .has_surface_tile_offset = true,
188 .needs_unlit_centroid_workaround = true,
189 .num_slices = 1,
190 .num_subslices = { 1, },
191 .num_eu_per_subslice = 12,
192 .num_thread_per_eu = 6, /* Not confirmed */
193 .max_vs_threads = 60,
194 .max_gs_threads = 60,
195 .max_wm_threads = 80,
196 .urb = {
197 .size = 64,
198 .min_entries = {
199 [MESA_SHADER_VERTEX] = 24,
200 },
201 .max_entries = {
202 [MESA_SHADER_VERTEX] = 256,
203 [MESA_SHADER_GEOMETRY] = 256,
204 },
205 },
206 .timestamp_frequency = 12500000,
207 .simulator_id = -1,
208 };
209
210 #define GEN7_FEATURES \
211 .gen = 7, \
212 .has_hiz_and_separate_stencil = true, \
213 .must_use_separate_stencil = true, \
214 .has_llc = true, \
215 .has_pln = true, \
216 .has_64bit_types = true, \
217 .has_surface_tile_offset = true, \
218 .timestamp_frequency = 12500000
219
220 static const struct gen_device_info gen_device_info_ivb_gt1 = {
221 GEN7_FEATURES, .is_ivybridge = true, .gt = 1,
222 .num_slices = 1,
223 .num_subslices = { 1, },
224 .num_eu_per_subslice = 6,
225 .num_thread_per_eu = 6,
226 .l3_banks = 2,
227 .max_vs_threads = 36,
228 .max_tcs_threads = 36,
229 .max_tes_threads = 36,
230 .max_gs_threads = 36,
231 .max_wm_threads = 48,
232 .max_cs_threads = 36,
233 .urb = {
234 .size = 128,
235 .min_entries = {
236 [MESA_SHADER_VERTEX] = 32,
237 [MESA_SHADER_TESS_EVAL] = 10,
238 },
239 .max_entries = {
240 [MESA_SHADER_VERTEX] = 512,
241 [MESA_SHADER_TESS_CTRL] = 32,
242 [MESA_SHADER_TESS_EVAL] = 288,
243 [MESA_SHADER_GEOMETRY] = 192,
244 },
245 },
246 .simulator_id = 7,
247 };
248
249 static const struct gen_device_info gen_device_info_ivb_gt2 = {
250 GEN7_FEATURES, .is_ivybridge = true, .gt = 2,
251 .num_slices = 1,
252 .num_subslices = { 1, },
253 .num_eu_per_subslice = 12,
254 .num_thread_per_eu = 8, /* Not sure why this isn't a multiple of
255 * @max_wm_threads ... */
256 .l3_banks = 4,
257 .max_vs_threads = 128,
258 .max_tcs_threads = 128,
259 .max_tes_threads = 128,
260 .max_gs_threads = 128,
261 .max_wm_threads = 172,
262 .max_cs_threads = 64,
263 .urb = {
264 .size = 256,
265 .min_entries = {
266 [MESA_SHADER_VERTEX] = 32,
267 [MESA_SHADER_TESS_EVAL] = 10,
268 },
269 .max_entries = {
270 [MESA_SHADER_VERTEX] = 704,
271 [MESA_SHADER_TESS_CTRL] = 64,
272 [MESA_SHADER_TESS_EVAL] = 448,
273 [MESA_SHADER_GEOMETRY] = 320,
274 },
275 },
276 .simulator_id = 7,
277 };
278
279 static const struct gen_device_info gen_device_info_byt = {
280 GEN7_FEATURES, .is_baytrail = true, .gt = 1,
281 .num_slices = 1,
282 .num_subslices = { 1, },
283 .num_eu_per_subslice = 4,
284 .num_thread_per_eu = 8,
285 .l3_banks = 1,
286 .has_llc = false,
287 .max_vs_threads = 36,
288 .max_tcs_threads = 36,
289 .max_tes_threads = 36,
290 .max_gs_threads = 36,
291 .max_wm_threads = 48,
292 .max_cs_threads = 32,
293 .urb = {
294 .size = 128,
295 .min_entries = {
296 [MESA_SHADER_VERTEX] = 32,
297 [MESA_SHADER_TESS_EVAL] = 10,
298 },
299 .max_entries = {
300 [MESA_SHADER_VERTEX] = 512,
301 [MESA_SHADER_TESS_CTRL] = 32,
302 [MESA_SHADER_TESS_EVAL] = 288,
303 [MESA_SHADER_GEOMETRY] = 192,
304 },
305 },
306 .simulator_id = 10,
307 };
308
309 #define HSW_FEATURES \
310 GEN7_FEATURES, \
311 .is_haswell = true, \
312 .supports_simd16_3src = true, \
313 .has_resource_streamer = true
314
315 static const struct gen_device_info gen_device_info_hsw_gt1 = {
316 HSW_FEATURES, .gt = 1,
317 .num_slices = 1,
318 .num_subslices = { 1, },
319 .num_eu_per_subslice = 10,
320 .num_thread_per_eu = 7,
321 .l3_banks = 2,
322 .max_vs_threads = 70,
323 .max_tcs_threads = 70,
324 .max_tes_threads = 70,
325 .max_gs_threads = 70,
326 .max_wm_threads = 102,
327 .max_cs_threads = 70,
328 .urb = {
329 .size = 128,
330 .min_entries = {
331 [MESA_SHADER_VERTEX] = 32,
332 [MESA_SHADER_TESS_EVAL] = 10,
333 },
334 .max_entries = {
335 [MESA_SHADER_VERTEX] = 640,
336 [MESA_SHADER_TESS_CTRL] = 64,
337 [MESA_SHADER_TESS_EVAL] = 384,
338 [MESA_SHADER_GEOMETRY] = 256,
339 },
340 },
341 .simulator_id = 9,
342 };
343
344 static const struct gen_device_info gen_device_info_hsw_gt2 = {
345 HSW_FEATURES, .gt = 2,
346 .num_slices = 1,
347 .num_subslices = { 2, },
348 .num_eu_per_subslice = 10,
349 .num_thread_per_eu = 7,
350 .l3_banks = 4,
351 .max_vs_threads = 280,
352 .max_tcs_threads = 256,
353 .max_tes_threads = 280,
354 .max_gs_threads = 256,
355 .max_wm_threads = 204,
356 .max_cs_threads = 70,
357 .urb = {
358 .size = 256,
359 .min_entries = {
360 [MESA_SHADER_VERTEX] = 64,
361 [MESA_SHADER_TESS_EVAL] = 10,
362 },
363 .max_entries = {
364 [MESA_SHADER_VERTEX] = 1664,
365 [MESA_SHADER_TESS_CTRL] = 128,
366 [MESA_SHADER_TESS_EVAL] = 960,
367 [MESA_SHADER_GEOMETRY] = 640,
368 },
369 },
370 .simulator_id = 9,
371 };
372
373 static const struct gen_device_info gen_device_info_hsw_gt3 = {
374 HSW_FEATURES, .gt = 3,
375 .num_slices = 2,
376 .num_subslices = { 2, },
377 .num_eu_per_subslice = 10,
378 .num_thread_per_eu = 7,
379 .l3_banks = 8,
380 .max_vs_threads = 280,
381 .max_tcs_threads = 256,
382 .max_tes_threads = 280,
383 .max_gs_threads = 256,
384 .max_wm_threads = 408,
385 .max_cs_threads = 70,
386 .urb = {
387 .size = 512,
388 .min_entries = {
389 [MESA_SHADER_VERTEX] = 64,
390 [MESA_SHADER_TESS_EVAL] = 10,
391 },
392 .max_entries = {
393 [MESA_SHADER_VERTEX] = 1664,
394 [MESA_SHADER_TESS_CTRL] = 128,
395 [MESA_SHADER_TESS_EVAL] = 960,
396 [MESA_SHADER_GEOMETRY] = 640,
397 },
398 },
399 .simulator_id = 9,
400 };
401
402 /* It's unclear how well supported sampling from the hiz buffer is on GEN8,
403 * so keep things conservative for now and set has_sample_with_hiz = false.
404 */
405 #define GEN8_FEATURES \
406 .gen = 8, \
407 .has_hiz_and_separate_stencil = true, \
408 .has_resource_streamer = true, \
409 .must_use_separate_stencil = true, \
410 .has_llc = true, \
411 .has_sample_with_hiz = false, \
412 .has_pln = true, \
413 .has_integer_dword_mul = true, \
414 .has_64bit_types = true, \
415 .supports_simd16_3src = true, \
416 .has_surface_tile_offset = true, \
417 .max_vs_threads = 504, \
418 .max_tcs_threads = 504, \
419 .max_tes_threads = 504, \
420 .max_gs_threads = 504, \
421 .max_wm_threads = 384, \
422 .timestamp_frequency = 12500000
423
424 static const struct gen_device_info gen_device_info_bdw_gt1 = {
425 GEN8_FEATURES, .gt = 1,
426 .is_broadwell = true,
427 .num_slices = 1,
428 .num_subslices = { 2, },
429 .num_eu_per_subslice = 8,
430 .num_thread_per_eu = 7,
431 .l3_banks = 2,
432 .max_cs_threads = 42,
433 .urb = {
434 .size = 192,
435 .min_entries = {
436 [MESA_SHADER_VERTEX] = 64,
437 [MESA_SHADER_TESS_EVAL] = 34,
438 },
439 .max_entries = {
440 [MESA_SHADER_VERTEX] = 2560,
441 [MESA_SHADER_TESS_CTRL] = 504,
442 [MESA_SHADER_TESS_EVAL] = 1536,
443 [MESA_SHADER_GEOMETRY] = 960,
444 },
445 },
446 .simulator_id = 11,
447 };
448
449 static const struct gen_device_info gen_device_info_bdw_gt2 = {
450 GEN8_FEATURES, .gt = 2,
451 .is_broadwell = true,
452 .num_slices = 1,
453 .num_subslices = { 3, },
454 .num_eu_per_subslice = 8,
455 .num_thread_per_eu = 7,
456 .l3_banks = 4,
457 .max_cs_threads = 56,
458 .urb = {
459 .size = 384,
460 .min_entries = {
461 [MESA_SHADER_VERTEX] = 64,
462 [MESA_SHADER_TESS_EVAL] = 34,
463 },
464 .max_entries = {
465 [MESA_SHADER_VERTEX] = 2560,
466 [MESA_SHADER_TESS_CTRL] = 504,
467 [MESA_SHADER_TESS_EVAL] = 1536,
468 [MESA_SHADER_GEOMETRY] = 960,
469 },
470 },
471 .simulator_id = 11,
472 };
473
474 static const struct gen_device_info gen_device_info_bdw_gt3 = {
475 GEN8_FEATURES, .gt = 3,
476 .is_broadwell = true,
477 .num_slices = 2,
478 .num_subslices = { 3, 3, },
479 .num_eu_per_subslice = 8,
480 .num_thread_per_eu = 7,
481 .l3_banks = 8,
482 .max_cs_threads = 56,
483 .urb = {
484 .size = 384,
485 .min_entries = {
486 [MESA_SHADER_VERTEX] = 64,
487 [MESA_SHADER_TESS_EVAL] = 34,
488 },
489 .max_entries = {
490 [MESA_SHADER_VERTEX] = 2560,
491 [MESA_SHADER_TESS_CTRL] = 504,
492 [MESA_SHADER_TESS_EVAL] = 1536,
493 [MESA_SHADER_GEOMETRY] = 960,
494 },
495 },
496 .simulator_id = 11,
497 };
498
499 static const struct gen_device_info gen_device_info_chv = {
500 GEN8_FEATURES, .is_cherryview = 1, .gt = 1,
501 .has_llc = false,
502 .has_integer_dword_mul = false,
503 .num_slices = 1,
504 .num_subslices = { 2, },
505 .num_eu_per_subslice = 8,
506 .num_thread_per_eu = 7,
507 .l3_banks = 2,
508 .max_vs_threads = 80,
509 .max_tcs_threads = 80,
510 .max_tes_threads = 80,
511 .max_gs_threads = 80,
512 .max_wm_threads = 128,
513 .max_cs_threads = 6 * 7,
514 .urb = {
515 .size = 192,
516 .min_entries = {
517 [MESA_SHADER_VERTEX] = 34,
518 [MESA_SHADER_TESS_EVAL] = 34,
519 },
520 .max_entries = {
521 [MESA_SHADER_VERTEX] = 640,
522 [MESA_SHADER_TESS_CTRL] = 80,
523 [MESA_SHADER_TESS_EVAL] = 384,
524 [MESA_SHADER_GEOMETRY] = 256,
525 },
526 },
527 .simulator_id = 13,
528 };
529
530 #define GEN9_HW_INFO \
531 .gen = 9, \
532 .max_vs_threads = 336, \
533 .max_gs_threads = 336, \
534 .max_tcs_threads = 336, \
535 .max_tes_threads = 336, \
536 .max_cs_threads = 56, \
537 .timestamp_frequency = 12000000, \
538 .urb = { \
539 .size = 384, \
540 .min_entries = { \
541 [MESA_SHADER_VERTEX] = 64, \
542 [MESA_SHADER_TESS_EVAL] = 34, \
543 }, \
544 .max_entries = { \
545 [MESA_SHADER_VERTEX] = 1856, \
546 [MESA_SHADER_TESS_CTRL] = 672, \
547 [MESA_SHADER_TESS_EVAL] = 1120, \
548 [MESA_SHADER_GEOMETRY] = 640, \
549 }, \
550 }
551
552 #define GEN9_LP_FEATURES \
553 GEN8_FEATURES, \
554 GEN9_HW_INFO, \
555 .has_integer_dword_mul = false, \
556 .gt = 1, \
557 .has_llc = false, \
558 .has_sample_with_hiz = true, \
559 .num_slices = 1, \
560 .num_thread_per_eu = 6, \
561 .max_vs_threads = 112, \
562 .max_tcs_threads = 112, \
563 .max_tes_threads = 112, \
564 .max_gs_threads = 112, \
565 .max_cs_threads = 6 * 6, \
566 .timestamp_frequency = 19200000, \
567 .urb = { \
568 .size = 192, \
569 .min_entries = { \
570 [MESA_SHADER_VERTEX] = 34, \
571 [MESA_SHADER_TESS_EVAL] = 34, \
572 }, \
573 .max_entries = { \
574 [MESA_SHADER_VERTEX] = 704, \
575 [MESA_SHADER_TESS_CTRL] = 256, \
576 [MESA_SHADER_TESS_EVAL] = 416, \
577 [MESA_SHADER_GEOMETRY] = 256, \
578 }, \
579 }
580
581 #define GEN9_LP_FEATURES_3X6 \
582 GEN9_LP_FEATURES, \
583 .num_subslices = { 3, }, \
584 .num_eu_per_subslice = 6
585
586 #define GEN9_LP_FEATURES_2X6 \
587 GEN9_LP_FEATURES, \
588 .num_subslices = { 2, }, \
589 .num_eu_per_subslice = 6, \
590 .max_vs_threads = 56, \
591 .max_tcs_threads = 56, \
592 .max_tes_threads = 56, \
593 .max_gs_threads = 56, \
594 .max_cs_threads = 6 * 6, \
595 .urb = { \
596 .size = 128, \
597 .min_entries = { \
598 [MESA_SHADER_VERTEX] = 34, \
599 [MESA_SHADER_TESS_EVAL] = 34, \
600 }, \
601 .max_entries = { \
602 [MESA_SHADER_VERTEX] = 352, \
603 [MESA_SHADER_TESS_CTRL] = 128, \
604 [MESA_SHADER_TESS_EVAL] = 208, \
605 [MESA_SHADER_GEOMETRY] = 128, \
606 }, \
607 }
608
609 #define GEN9_FEATURES \
610 GEN8_FEATURES, \
611 GEN9_HW_INFO, \
612 .has_sample_with_hiz = true, \
613 .num_thread_per_eu = 7
614
615 static const struct gen_device_info gen_device_info_skl_gt1 = {
616 GEN9_FEATURES, .gt = 1,
617 .is_skylake = true,
618 .num_slices = 1,
619 .num_subslices = { 2, },
620 .num_eu_per_subslice = 6,
621 .l3_banks = 2,
622 .urb.size = 192,
623 .simulator_id = 12,
624 };
625
626 static const struct gen_device_info gen_device_info_skl_gt2 = {
627 GEN9_FEATURES, .gt = 2,
628 .is_skylake = true,
629 .num_slices = 1,
630 .num_subslices = { 3, },
631 .num_eu_per_subslice = 8,
632 .l3_banks = 4,
633 .simulator_id = 12,
634 };
635
636 static const struct gen_device_info gen_device_info_skl_gt3 = {
637 GEN9_FEATURES, .gt = 3,
638 .is_skylake = true,
639 .num_slices = 2,
640 .num_subslices = { 3, 3, },
641 .num_eu_per_subslice = 8,
642 .l3_banks = 8,
643 .simulator_id = 12,
644 };
645
646 static const struct gen_device_info gen_device_info_skl_gt4 = {
647 GEN9_FEATURES, .gt = 4,
648 .is_skylake = true,
649 .num_slices = 3,
650 .num_subslices = { 3, 3, 3, },
651 .num_eu_per_subslice = 8,
652 .l3_banks = 12,
653 /* From the "L3 Allocation and Programming" documentation:
654 *
655 * "URB is limited to 1008KB due to programming restrictions. This is not a
656 * restriction of the L3 implementation, but of the FF and other clients.
657 * Therefore, in a GT4 implementation it is possible for the programmed
658 * allocation of the L3 data array to provide 3*384KB=1152KB for URB, but
659 * only 1008KB of this will be used."
660 */
661 .urb.size = 1008 / 3,
662 .simulator_id = 12,
663 };
664
665 static const struct gen_device_info gen_device_info_bxt = {
666 GEN9_LP_FEATURES_3X6,
667 .is_broxton = true,
668 .l3_banks = 2,
669 .simulator_id = 14,
670 };
671
672 static const struct gen_device_info gen_device_info_bxt_2x6 = {
673 GEN9_LP_FEATURES_2X6,
674 .is_broxton = true,
675 .l3_banks = 1,
676 .simulator_id = 14,
677 };
678 /*
679 * Note: for all KBL SKUs, the PRM says SKL for GS entries, not SKL+.
680 * There's no KBL entry. Using the default SKL (GEN9) GS entries value.
681 */
682
683 static const struct gen_device_info gen_device_info_kbl_gt1 = {
684 GEN9_FEATURES,
685 .is_kabylake = true,
686 .gt = 1,
687
688 .max_cs_threads = 7 * 6,
689 .urb.size = 192,
690 .num_slices = 1,
691 .num_subslices = { 2, },
692 .num_eu_per_subslice = 6,
693 .l3_banks = 2,
694 .simulator_id = 16,
695 };
696
697 static const struct gen_device_info gen_device_info_kbl_gt1_5 = {
698 GEN9_FEATURES,
699 .is_kabylake = true,
700 .gt = 1,
701
702 .max_cs_threads = 7 * 6,
703 .num_slices = 1,
704 .num_subslices = { 3, },
705 .num_eu_per_subslice = 6,
706 .l3_banks = 4,
707 .simulator_id = 16,
708 };
709
710 static const struct gen_device_info gen_device_info_kbl_gt2 = {
711 GEN9_FEATURES,
712 .is_kabylake = true,
713 .gt = 2,
714
715 .num_slices = 1,
716 .num_subslices = { 3, },
717 .num_eu_per_subslice = 8,
718 .l3_banks = 4,
719 .simulator_id = 16,
720 };
721
722 static const struct gen_device_info gen_device_info_kbl_gt3 = {
723 GEN9_FEATURES,
724 .is_kabylake = true,
725 .gt = 3,
726
727 .num_slices = 2,
728 .num_subslices = { 3, 3, },
729 .num_eu_per_subslice = 8,
730 .l3_banks = 8,
731 .simulator_id = 16,
732 };
733
734 static const struct gen_device_info gen_device_info_kbl_gt4 = {
735 GEN9_FEATURES,
736 .is_kabylake = true,
737 .gt = 4,
738
739 /*
740 * From the "L3 Allocation and Programming" documentation:
741 *
742 * "URB is limited to 1008KB due to programming restrictions. This
743 * is not a restriction of the L3 implementation, but of the FF and
744 * other clients. Therefore, in a GT4 implementation it is
745 * possible for the programmed allocation of the L3 data array to
746 * provide 3*384KB=1152KB for URB, but only 1008KB of this
747 * will be used."
748 */
749 .urb.size = 1008 / 3,
750 .num_slices = 3,
751 .num_subslices = { 3, 3, 3, },
752 .num_eu_per_subslice = 8,
753 .l3_banks = 12,
754 .simulator_id = 16,
755 };
756
757 static const struct gen_device_info gen_device_info_glk = {
758 GEN9_LP_FEATURES_3X6,
759 .is_geminilake = true,
760 .l3_banks = 2,
761 .simulator_id = 17,
762 };
763
764 static const struct gen_device_info gen_device_info_glk_2x6 = {
765 GEN9_LP_FEATURES_2X6,
766 .is_geminilake = true,
767 .l3_banks = 2,
768 .simulator_id = 17,
769 };
770
771 static const struct gen_device_info gen_device_info_cfl_gt1 = {
772 GEN9_FEATURES,
773 .is_coffeelake = true,
774 .gt = 1,
775
776 .num_slices = 1,
777 .num_subslices = { 2, },
778 .num_eu_per_subslice = 6,
779 .l3_banks = 2,
780 .simulator_id = 24,
781 };
782 static const struct gen_device_info gen_device_info_cfl_gt2 = {
783 GEN9_FEATURES,
784 .is_coffeelake = true,
785 .gt = 2,
786
787 .num_slices = 1,
788 .num_subslices = { 3, },
789 .num_eu_per_subslice = 8,
790 .l3_banks = 4,
791 .simulator_id = 24,
792 };
793
794 static const struct gen_device_info gen_device_info_cfl_gt3 = {
795 GEN9_FEATURES,
796 .is_coffeelake = true,
797 .gt = 3,
798
799 .num_slices = 2,
800 .num_subslices = { 3, 3, },
801 .num_eu_per_subslice = 8,
802 .l3_banks = 8,
803 .simulator_id = 24,
804 };
805
806 #define GEN10_HW_INFO \
807 .gen = 10, \
808 .num_thread_per_eu = 7, \
809 .max_vs_threads = 728, \
810 .max_gs_threads = 432, \
811 .max_tcs_threads = 432, \
812 .max_tes_threads = 624, \
813 .max_cs_threads = 56, \
814 .timestamp_frequency = 19200000, \
815 .urb = { \
816 .size = 256, \
817 .min_entries = { \
818 [MESA_SHADER_VERTEX] = 64, \
819 [MESA_SHADER_TESS_EVAL] = 34, \
820 }, \
821 .max_entries = { \
822 [MESA_SHADER_VERTEX] = 3936, \
823 [MESA_SHADER_TESS_CTRL] = 896, \
824 [MESA_SHADER_TESS_EVAL] = 2064, \
825 [MESA_SHADER_GEOMETRY] = 832, \
826 }, \
827 }
828
829 #define subslices(args...) { args, }
830
831 #define GEN10_FEATURES(_gt, _slices, _subslices, _l3) \
832 GEN8_FEATURES, \
833 GEN10_HW_INFO, \
834 .has_sample_with_hiz = true, \
835 .gt = _gt, \
836 .num_slices = _slices, \
837 .num_subslices = _subslices, \
838 .num_eu_per_subslice = 8, \
839 .l3_banks = _l3
840
841 static const struct gen_device_info gen_device_info_cnl_2x8 = {
842 /* GT0.5 */
843 GEN10_FEATURES(1, 1, subslices(2), 2),
844 .is_cannonlake = true,
845 .simulator_id = 15,
846 };
847
848 static const struct gen_device_info gen_device_info_cnl_3x8 = {
849 /* GT1 */
850 GEN10_FEATURES(1, 1, subslices(3), 3),
851 .is_cannonlake = true,
852 .simulator_id = 15,
853 };
854
855 static const struct gen_device_info gen_device_info_cnl_4x8 = {
856 /* GT 1.5 */
857 GEN10_FEATURES(1, 2, subslices(2, 2), 6),
858 .is_cannonlake = true,
859 .simulator_id = 15,
860 };
861
862 static const struct gen_device_info gen_device_info_cnl_5x8 = {
863 /* GT2 */
864 GEN10_FEATURES(2, 2, subslices(3, 2), 6),
865 .is_cannonlake = true,
866 .simulator_id = 15,
867 };
868
869 #define GEN11_HW_INFO \
870 .gen = 11, \
871 .has_pln = false, \
872 .max_vs_threads = 364, \
873 .max_gs_threads = 224, \
874 .max_tcs_threads = 224, \
875 .max_tes_threads = 364, \
876 .max_cs_threads = 56
877
878 #define GEN11_FEATURES(_gt, _slices, _subslices, _l3) \
879 GEN8_FEATURES, \
880 GEN11_HW_INFO, \
881 .has_64bit_types = false, \
882 .has_integer_dword_mul = false, \
883 .has_sample_with_hiz = false, \
884 .gt = _gt, .num_slices = _slices, .l3_banks = _l3, \
885 .num_subslices = _subslices, \
886 .num_eu_per_subslice = 8
887
888 #define GEN11_URB_MIN_MAX_ENTRIES \
889 .min_entries = { \
890 [MESA_SHADER_VERTEX] = 64, \
891 [MESA_SHADER_TESS_EVAL] = 34, \
892 }, \
893 .max_entries = { \
894 [MESA_SHADER_VERTEX] = 2384, \
895 [MESA_SHADER_TESS_CTRL] = 1032, \
896 [MESA_SHADER_TESS_EVAL] = 2384, \
897 [MESA_SHADER_GEOMETRY] = 1032, \
898 }
899
900 static const struct gen_device_info gen_device_info_icl_8x8 = {
901 GEN11_FEATURES(2, 1, subslices(8), 8),
902 .urb = {
903 .size = 1024,
904 GEN11_URB_MIN_MAX_ENTRIES,
905 },
906 .simulator_id = 19,
907 };
908
909 static const struct gen_device_info gen_device_info_icl_6x8 = {
910 GEN11_FEATURES(1, 1, subslices(6), 6),
911 .urb = {
912 .size = 768,
913 GEN11_URB_MIN_MAX_ENTRIES,
914 },
915 .simulator_id = 19,
916 };
917
918 static const struct gen_device_info gen_device_info_icl_4x8 = {
919 GEN11_FEATURES(1, 1, subslices(4), 6),
920 .urb = {
921 .size = 768,
922 GEN11_URB_MIN_MAX_ENTRIES,
923 },
924 .simulator_id = 19,
925 };
926
927 static const struct gen_device_info gen_device_info_icl_1x8 = {
928 GEN11_FEATURES(1, 1, subslices(1), 6),
929 .urb = {
930 .size = 768,
931 GEN11_URB_MIN_MAX_ENTRIES,
932 },
933 .simulator_id = 19,
934 };
935
936 static void
937 gen_device_info_set_eu_mask(struct gen_device_info *devinfo,
938 unsigned slice,
939 unsigned subslice,
940 unsigned eu_mask)
941 {
942 unsigned subslice_offset = slice * devinfo->eu_slice_stride +
943 subslice * devinfo->eu_subslice_stride;
944
945 for (unsigned b_eu = 0; b_eu < devinfo->eu_subslice_stride; b_eu++) {
946 devinfo->eu_masks[subslice_offset + b_eu] =
947 (((1U << devinfo->num_eu_per_subslice) - 1) >> (b_eu * 8)) & 0xff;
948 }
949 }
950
951 /* Generate slice/subslice/eu masks from number of
952 * slices/subslices/eu_per_subslices in the per generation/gt gen_device_info
953 * structure.
954 *
955 * These can be overridden with values reported by the kernel either from
956 * getparam SLICE_MASK/SUBSLICE_MASK values or from the kernel version 4.17+
957 * through the i915 query uapi.
958 */
959 static void
960 fill_masks(struct gen_device_info *devinfo)
961 {
962 devinfo->slice_masks = (1U << devinfo->num_slices) - 1;
963
964 /* Subslice masks */
965 unsigned max_subslices = 0;
966 for (int s = 0; s < devinfo->num_slices; s++)
967 max_subslices = MAX2(devinfo->num_subslices[s], max_subslices);
968 devinfo->subslice_slice_stride = DIV_ROUND_UP(max_subslices, 8);
969
970 for (int s = 0; s < devinfo->num_slices; s++) {
971 devinfo->subslice_masks[s * devinfo->subslice_slice_stride] =
972 (1U << devinfo->num_subslices[s]) - 1;
973 }
974
975 /* EU masks */
976 devinfo->eu_subslice_stride = DIV_ROUND_UP(devinfo->num_eu_per_subslice, 8);
977 devinfo->eu_slice_stride = max_subslices * devinfo->eu_subslice_stride;
978
979 for (int s = 0; s < devinfo->num_slices; s++) {
980 for (int ss = 0; ss < devinfo->num_subslices[s]; ss++) {
981 gen_device_info_set_eu_mask(devinfo, s, ss,
982 (1U << devinfo->num_eu_per_subslice) - 1);
983 }
984 }
985 }
986
987 void
988 gen_device_info_update_from_masks(struct gen_device_info *devinfo,
989 uint32_t slice_mask,
990 uint32_t subslice_mask,
991 uint32_t n_eus)
992 {
993 struct {
994 struct drm_i915_query_topology_info base;
995 uint8_t data[100];
996 } topology;
997
998 assert((slice_mask & 0xff) == slice_mask);
999
1000 memset(&topology, 0, sizeof(topology));
1001
1002 topology.base.max_slices = util_last_bit(slice_mask);
1003 topology.base.max_subslices = util_last_bit(subslice_mask);
1004
1005 topology.base.subslice_offset = DIV_ROUND_UP(topology.base.max_slices, 8);
1006 topology.base.subslice_stride = DIV_ROUND_UP(topology.base.max_subslices, 8);
1007
1008 uint32_t n_subslices = __builtin_popcount(slice_mask) *
1009 __builtin_popcount(subslice_mask);
1010 uint32_t num_eu_per_subslice = DIV_ROUND_UP(n_eus, n_subslices);
1011 uint32_t eu_mask = (1U << num_eu_per_subslice) - 1;
1012
1013 topology.base.eu_offset = topology.base.subslice_offset +
1014 DIV_ROUND_UP(topology.base.max_subslices, 8);
1015 topology.base.eu_stride = DIV_ROUND_UP(num_eu_per_subslice, 8);
1016
1017 /* Set slice mask in topology */
1018 for (int b = 0; b < topology.base.subslice_offset; b++)
1019 topology.base.data[b] = (slice_mask >> (b * 8)) & 0xff;
1020
1021 for (int s = 0; s < topology.base.max_slices; s++) {
1022
1023 /* Set subslice mask in topology */
1024 for (int b = 0; b < topology.base.subslice_stride; b++) {
1025 int subslice_offset = topology.base.subslice_offset +
1026 s * topology.base.subslice_stride + b;
1027
1028 topology.base.data[subslice_offset] = (subslice_mask >> (b * 8)) & 0xff;
1029 }
1030
1031 /* Set eu mask in topology */
1032 for (int ss = 0; ss < topology.base.max_subslices; ss++) {
1033 for (int b = 0; b < topology.base.eu_stride; b++) {
1034 int eu_offset = topology.base.eu_offset +
1035 (s * topology.base.max_subslices + ss) * topology.base.eu_stride + b;
1036
1037 topology.base.data[eu_offset] = (eu_mask >> (b * 8)) & 0xff;
1038 }
1039 }
1040 }
1041
1042 gen_device_info_update_from_topology(devinfo, &topology.base);
1043 }
1044
1045 static void
1046 reset_masks(struct gen_device_info *devinfo)
1047 {
1048 devinfo->subslice_slice_stride = 0;
1049 devinfo->eu_subslice_stride = 0;
1050 devinfo->eu_slice_stride = 0;
1051
1052 devinfo->num_slices = 0;
1053 devinfo->num_eu_per_subslice = 0;
1054 memset(devinfo->num_subslices, 0, sizeof(devinfo->num_subslices));
1055
1056 memset(&devinfo->slice_masks, 0, sizeof(devinfo->slice_masks));
1057 memset(devinfo->subslice_masks, 0, sizeof(devinfo->subslice_masks));
1058 memset(devinfo->eu_masks, 0, sizeof(devinfo->eu_masks));
1059 }
1060
1061 void
1062 gen_device_info_update_from_topology(struct gen_device_info *devinfo,
1063 const struct drm_i915_query_topology_info *topology)
1064 {
1065 reset_masks(devinfo);
1066
1067 devinfo->subslice_slice_stride = topology->subslice_stride;
1068
1069 devinfo->eu_subslice_stride = DIV_ROUND_UP(topology->max_eus_per_subslice, 8);
1070 devinfo->eu_slice_stride = topology->max_subslices * devinfo->eu_subslice_stride;
1071
1072 assert(sizeof(devinfo->slice_masks) >= DIV_ROUND_UP(topology->max_slices, 8));
1073 memcpy(&devinfo->slice_masks, topology->data, DIV_ROUND_UP(topology->max_slices, 8));
1074 devinfo->num_slices = __builtin_popcount(devinfo->slice_masks);
1075
1076 uint32_t subslice_mask_len =
1077 topology->max_slices * topology->subslice_stride;
1078 assert(sizeof(devinfo->subslice_masks) >= subslice_mask_len);
1079 memcpy(devinfo->subslice_masks, &topology->data[topology->subslice_offset],
1080 subslice_mask_len);
1081
1082 uint32_t n_subslices = 0;
1083 for (int s = 0; s < topology->max_slices; s++) {
1084 if ((devinfo->slice_masks & (1UL << s)) == 0)
1085 continue;
1086
1087 for (int b = 0; b < devinfo->subslice_slice_stride; b++) {
1088 devinfo->num_subslices[s] +=
1089 __builtin_popcount(devinfo->subslice_masks[b]);
1090 }
1091 n_subslices += devinfo->num_subslices[s];
1092 }
1093 assert(n_subslices > 0);
1094
1095 uint32_t eu_mask_len =
1096 topology->eu_stride * topology->max_subslices * topology->max_slices;
1097 assert(sizeof(devinfo->eu_masks) >= eu_mask_len);
1098 memcpy(devinfo->eu_masks, &topology->data[topology->eu_offset], eu_mask_len);
1099
1100 uint32_t n_eus = 0;
1101 for (int b = 0; b < eu_mask_len; b++)
1102 n_eus += __builtin_popcount(devinfo->eu_masks[b]);
1103
1104 devinfo->num_eu_per_subslice = DIV_ROUND_UP(n_eus, n_subslices);
1105 }
1106
1107 bool
1108 gen_get_device_info(int devid, struct gen_device_info *devinfo)
1109 {
1110 switch (devid) {
1111 #undef CHIPSET
1112 #define CHIPSET(id, family, name) \
1113 case id: *devinfo = gen_device_info_##family; break;
1114 #include "pci_ids/i965_pci_ids.h"
1115 default:
1116 fprintf(stderr, "i965_dri.so does not support the 0x%x PCI ID.\n", devid);
1117 return false;
1118 }
1119
1120 fill_masks(devinfo);
1121
1122 /* From the Skylake PRM, 3DSTATE_PS::Scratch Space Base Pointer:
1123 *
1124 * "Scratch Space per slice is computed based on 4 sub-slices. SW must
1125 * allocate scratch space enough so that each slice has 4 slices allowed."
1126 *
1127 * The equivalent internal documentation says that this programming note
1128 * applies to all Gen9+ platforms.
1129 *
1130 * The hardware typically calculates the scratch space pointer by taking
1131 * the base address, and adding per-thread-scratch-space * thread ID.
1132 * Extra padding can be necessary depending how the thread IDs are
1133 * calculated for a particular shader stage.
1134 */
1135
1136 switch(devinfo->gen) {
1137 case 9:
1138 case 10:
1139 devinfo->max_wm_threads = 64 /* threads-per-PSD */
1140 * devinfo->num_slices
1141 * 4; /* effective subslices per slice */
1142 break;
1143 case 11:
1144 devinfo->max_wm_threads = 128 /* threads-per-PSD */
1145 * devinfo->num_slices
1146 * 8; /* subslices per slice */
1147 break;
1148 default:
1149 break;
1150 }
1151
1152 assert(devinfo->num_slices <= ARRAY_SIZE(devinfo->num_subslices));
1153
1154 return true;
1155 }
1156
1157 const char *
1158 gen_get_device_name(int devid)
1159 {
1160 switch (devid) {
1161 #undef CHIPSET
1162 #define CHIPSET(id, family, name) case id: return name;
1163 #include "pci_ids/i965_pci_ids.h"
1164 default:
1165 return NULL;
1166 }
1167 }