2 * Copyright © 2013 Intel Corporation
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:
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
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
29 #include "gen_device_info.h"
30 #include "compiler/shader_enums.h"
31 #include "util/bitscan.h"
32 #include "util/macros.h"
37 * Get the PCI ID for the device name.
39 * Returns -1 if the device is not known.
42 gen_device_name_to_pci_device_id(const char *name
)
66 for (unsigned i
= 0; i
< ARRAY_SIZE(name_map
); i
++) {
67 if (!strcmp(name_map
[i
].name
, name
))
68 return name_map
[i
].pci_id
;
75 * Get the overridden PCI ID for the device. This is set with the
76 * INTEL_DEVID_OVERRIDE environment variable.
78 * Returns -1 if the override is not set.
81 gen_get_pci_device_id_override(void)
83 if (geteuid() == getuid()) {
84 const char *devid_override
= getenv("INTEL_DEVID_OVERRIDE");
86 const int id
= gen_device_name_to_pci_device_id(devid_override
);
87 return id
>= 0 ? id
: strtol(devid_override
, NULL
, 0);
94 static const struct gen_device_info gen_device_info_i965
= {
96 .has_negative_rhw_bug
= true,
98 .num_subslices
= { 1, },
99 .num_eu_per_subslice
= 8,
100 .num_thread_per_eu
= 4,
101 .max_vs_threads
= 16,
103 .max_wm_threads
= 8 * 4,
107 .timestamp_frequency
= 12500000,
110 static const struct gen_device_info gen_device_info_g4x
= {
114 .has_surface_tile_offset
= true,
117 .num_subslices
= { 1, },
118 .num_eu_per_subslice
= 10,
119 .num_thread_per_eu
= 5,
120 .max_vs_threads
= 32,
122 .max_wm_threads
= 10 * 5,
126 .timestamp_frequency
= 12500000,
129 static const struct gen_device_info gen_device_info_ilk
= {
133 .has_surface_tile_offset
= true,
135 .num_subslices
= { 1, },
136 .num_eu_per_subslice
= 12,
137 .num_thread_per_eu
= 6,
138 .max_vs_threads
= 72,
139 .max_gs_threads
= 32,
140 .max_wm_threads
= 12 * 6,
144 .timestamp_frequency
= 12500000,
147 static const struct gen_device_info gen_device_info_snb_gt1
= {
150 .has_hiz_and_separate_stencil
= true,
153 .has_surface_tile_offset
= true,
154 .needs_unlit_centroid_workaround
= true,
156 .num_subslices
= { 1, },
157 .num_eu_per_subslice
= 6,
158 .num_thread_per_eu
= 6, /* Not confirmed */
159 .max_vs_threads
= 24,
160 .max_gs_threads
= 21, /* conservative; 24 if rendering disabled. */
161 .max_wm_threads
= 40,
165 [MESA_SHADER_VERTEX
] = 24,
168 [MESA_SHADER_VERTEX
] = 256,
169 [MESA_SHADER_GEOMETRY
] = 256,
172 .timestamp_frequency
= 12500000,
175 static const struct gen_device_info gen_device_info_snb_gt2
= {
178 .has_hiz_and_separate_stencil
= true,
181 .has_surface_tile_offset
= true,
182 .needs_unlit_centroid_workaround
= true,
184 .num_subslices
= { 1, },
185 .num_eu_per_subslice
= 12,
186 .num_thread_per_eu
= 6, /* Not confirmed */
187 .max_vs_threads
= 60,
188 .max_gs_threads
= 60,
189 .max_wm_threads
= 80,
193 [MESA_SHADER_VERTEX
] = 24,
196 [MESA_SHADER_VERTEX
] = 256,
197 [MESA_SHADER_GEOMETRY
] = 256,
200 .timestamp_frequency
= 12500000,
203 #define GEN7_FEATURES \
205 .has_hiz_and_separate_stencil = true, \
206 .must_use_separate_stencil = true, \
209 .has_64bit_types = true, \
210 .has_surface_tile_offset = true, \
211 .timestamp_frequency = 12500000
213 static const struct gen_device_info gen_device_info_ivb_gt1
= {
214 GEN7_FEATURES
, .is_ivybridge
= true, .gt
= 1,
216 .num_subslices
= { 1, },
217 .num_eu_per_subslice
= 6,
218 .num_thread_per_eu
= 6,
220 .max_vs_threads
= 36,
221 .max_tcs_threads
= 36,
222 .max_tes_threads
= 36,
223 .max_gs_threads
= 36,
224 .max_wm_threads
= 48,
225 .max_cs_threads
= 36,
229 [MESA_SHADER_VERTEX
] = 32,
230 [MESA_SHADER_TESS_EVAL
] = 10,
233 [MESA_SHADER_VERTEX
] = 512,
234 [MESA_SHADER_TESS_CTRL
] = 32,
235 [MESA_SHADER_TESS_EVAL
] = 288,
236 [MESA_SHADER_GEOMETRY
] = 192,
241 static const struct gen_device_info gen_device_info_ivb_gt2
= {
242 GEN7_FEATURES
, .is_ivybridge
= true, .gt
= 2,
244 .num_subslices
= { 1, },
245 .num_eu_per_subslice
= 12,
246 .num_thread_per_eu
= 8, /* Not sure why this isn't a multiple of
247 * @max_wm_threads ... */
249 .max_vs_threads
= 128,
250 .max_tcs_threads
= 128,
251 .max_tes_threads
= 128,
252 .max_gs_threads
= 128,
253 .max_wm_threads
= 172,
254 .max_cs_threads
= 64,
258 [MESA_SHADER_VERTEX
] = 32,
259 [MESA_SHADER_TESS_EVAL
] = 10,
262 [MESA_SHADER_VERTEX
] = 704,
263 [MESA_SHADER_TESS_CTRL
] = 64,
264 [MESA_SHADER_TESS_EVAL
] = 448,
265 [MESA_SHADER_GEOMETRY
] = 320,
270 static const struct gen_device_info gen_device_info_byt
= {
271 GEN7_FEATURES
, .is_baytrail
= true, .gt
= 1,
273 .num_subslices
= { 1, },
274 .num_eu_per_subslice
= 4,
275 .num_thread_per_eu
= 8,
278 .max_vs_threads
= 36,
279 .max_tcs_threads
= 36,
280 .max_tes_threads
= 36,
281 .max_gs_threads
= 36,
282 .max_wm_threads
= 48,
283 .max_cs_threads
= 32,
287 [MESA_SHADER_VERTEX
] = 32,
288 [MESA_SHADER_TESS_EVAL
] = 10,
291 [MESA_SHADER_VERTEX
] = 512,
292 [MESA_SHADER_TESS_CTRL
] = 32,
293 [MESA_SHADER_TESS_EVAL
] = 288,
294 [MESA_SHADER_GEOMETRY
] = 192,
299 #define HSW_FEATURES \
301 .is_haswell = true, \
302 .supports_simd16_3src = true, \
303 .has_resource_streamer = true
305 static const struct gen_device_info gen_device_info_hsw_gt1
= {
306 HSW_FEATURES
, .gt
= 1,
308 .num_subslices
= { 1, },
309 .num_eu_per_subslice
= 10,
310 .num_thread_per_eu
= 7,
312 .max_vs_threads
= 70,
313 .max_tcs_threads
= 70,
314 .max_tes_threads
= 70,
315 .max_gs_threads
= 70,
316 .max_wm_threads
= 102,
317 .max_cs_threads
= 70,
321 [MESA_SHADER_VERTEX
] = 32,
322 [MESA_SHADER_TESS_EVAL
] = 10,
325 [MESA_SHADER_VERTEX
] = 640,
326 [MESA_SHADER_TESS_CTRL
] = 64,
327 [MESA_SHADER_TESS_EVAL
] = 384,
328 [MESA_SHADER_GEOMETRY
] = 256,
333 static const struct gen_device_info gen_device_info_hsw_gt2
= {
334 HSW_FEATURES
, .gt
= 2,
336 .num_subslices
= { 2, },
337 .num_eu_per_subslice
= 10,
338 .num_thread_per_eu
= 7,
340 .max_vs_threads
= 280,
341 .max_tcs_threads
= 256,
342 .max_tes_threads
= 280,
343 .max_gs_threads
= 256,
344 .max_wm_threads
= 204,
345 .max_cs_threads
= 70,
349 [MESA_SHADER_VERTEX
] = 64,
350 [MESA_SHADER_TESS_EVAL
] = 10,
353 [MESA_SHADER_VERTEX
] = 1664,
354 [MESA_SHADER_TESS_CTRL
] = 128,
355 [MESA_SHADER_TESS_EVAL
] = 960,
356 [MESA_SHADER_GEOMETRY
] = 640,
361 static const struct gen_device_info gen_device_info_hsw_gt3
= {
362 HSW_FEATURES
, .gt
= 3,
364 .num_subslices
= { 2, },
365 .num_eu_per_subslice
= 10,
366 .num_thread_per_eu
= 7,
368 .max_vs_threads
= 280,
369 .max_tcs_threads
= 256,
370 .max_tes_threads
= 280,
371 .max_gs_threads
= 256,
372 .max_wm_threads
= 408,
373 .max_cs_threads
= 70,
377 [MESA_SHADER_VERTEX
] = 64,
378 [MESA_SHADER_TESS_EVAL
] = 10,
381 [MESA_SHADER_VERTEX
] = 1664,
382 [MESA_SHADER_TESS_CTRL
] = 128,
383 [MESA_SHADER_TESS_EVAL
] = 960,
384 [MESA_SHADER_GEOMETRY
] = 640,
389 /* It's unclear how well supported sampling from the hiz buffer is on GEN8,
390 * so keep things conservative for now and set has_sample_with_hiz = false.
392 #define GEN8_FEATURES \
394 .has_hiz_and_separate_stencil = true, \
395 .has_resource_streamer = true, \
396 .must_use_separate_stencil = true, \
398 .has_sample_with_hiz = false, \
400 .has_integer_dword_mul = true, \
401 .has_64bit_types = true, \
402 .supports_simd16_3src = true, \
403 .has_surface_tile_offset = true, \
404 .max_vs_threads = 504, \
405 .max_tcs_threads = 504, \
406 .max_tes_threads = 504, \
407 .max_gs_threads = 504, \
408 .max_wm_threads = 384, \
409 .timestamp_frequency = 12500000
411 static const struct gen_device_info gen_device_info_bdw_gt1
= {
412 GEN8_FEATURES
, .gt
= 1,
413 .is_broadwell
= true,
415 .num_subslices
= { 2, },
416 .num_eu_per_subslice
= 8,
417 .num_thread_per_eu
= 7,
419 .max_cs_threads
= 42,
423 [MESA_SHADER_VERTEX
] = 64,
424 [MESA_SHADER_TESS_EVAL
] = 34,
427 [MESA_SHADER_VERTEX
] = 2560,
428 [MESA_SHADER_TESS_CTRL
] = 504,
429 [MESA_SHADER_TESS_EVAL
] = 1536,
430 [MESA_SHADER_GEOMETRY
] = 960,
435 static const struct gen_device_info gen_device_info_bdw_gt2
= {
436 GEN8_FEATURES
, .gt
= 2,
437 .is_broadwell
= true,
439 .num_subslices
= { 3, },
440 .num_eu_per_subslice
= 8,
441 .num_thread_per_eu
= 7,
443 .max_cs_threads
= 56,
447 [MESA_SHADER_VERTEX
] = 64,
448 [MESA_SHADER_TESS_EVAL
] = 34,
451 [MESA_SHADER_VERTEX
] = 2560,
452 [MESA_SHADER_TESS_CTRL
] = 504,
453 [MESA_SHADER_TESS_EVAL
] = 1536,
454 [MESA_SHADER_GEOMETRY
] = 960,
459 static const struct gen_device_info gen_device_info_bdw_gt3
= {
460 GEN8_FEATURES
, .gt
= 3,
461 .is_broadwell
= true,
463 .num_subslices
= { 3, 3, },
464 .num_eu_per_subslice
= 8,
465 .num_thread_per_eu
= 7,
467 .max_cs_threads
= 56,
471 [MESA_SHADER_VERTEX
] = 64,
472 [MESA_SHADER_TESS_EVAL
] = 34,
475 [MESA_SHADER_VERTEX
] = 2560,
476 [MESA_SHADER_TESS_CTRL
] = 504,
477 [MESA_SHADER_TESS_EVAL
] = 1536,
478 [MESA_SHADER_GEOMETRY
] = 960,
483 static const struct gen_device_info gen_device_info_chv
= {
484 GEN8_FEATURES
, .is_cherryview
= 1, .gt
= 1,
486 .has_integer_dword_mul
= false,
488 .num_subslices
= { 2, },
489 .num_eu_per_subslice
= 8,
490 .num_thread_per_eu
= 7,
492 .max_vs_threads
= 80,
493 .max_tcs_threads
= 80,
494 .max_tes_threads
= 80,
495 .max_gs_threads
= 80,
496 .max_wm_threads
= 128,
497 .max_cs_threads
= 6 * 7,
501 [MESA_SHADER_VERTEX
] = 34,
502 [MESA_SHADER_TESS_EVAL
] = 34,
505 [MESA_SHADER_VERTEX
] = 640,
506 [MESA_SHADER_TESS_CTRL
] = 80,
507 [MESA_SHADER_TESS_EVAL
] = 384,
508 [MESA_SHADER_GEOMETRY
] = 256,
513 #define GEN9_HW_INFO \
515 .max_vs_threads = 336, \
516 .max_gs_threads = 336, \
517 .max_tcs_threads = 336, \
518 .max_tes_threads = 336, \
519 .max_cs_threads = 56, \
520 .timestamp_frequency = 12000000, \
524 [MESA_SHADER_VERTEX] = 64, \
525 [MESA_SHADER_TESS_EVAL] = 34, \
528 [MESA_SHADER_VERTEX] = 1856, \
529 [MESA_SHADER_TESS_CTRL] = 672, \
530 [MESA_SHADER_TESS_EVAL] = 1120, \
531 [MESA_SHADER_GEOMETRY] = 640, \
535 #define GEN9_LP_FEATURES \
538 .has_integer_dword_mul = false, \
541 .has_sample_with_hiz = true, \
543 .num_thread_per_eu = 6, \
544 .max_vs_threads = 112, \
545 .max_tcs_threads = 112, \
546 .max_tes_threads = 112, \
547 .max_gs_threads = 112, \
548 .max_cs_threads = 6 * 6, \
549 .timestamp_frequency = 19200000, \
553 [MESA_SHADER_VERTEX] = 34, \
554 [MESA_SHADER_TESS_EVAL] = 34, \
557 [MESA_SHADER_VERTEX] = 704, \
558 [MESA_SHADER_TESS_CTRL] = 256, \
559 [MESA_SHADER_TESS_EVAL] = 416, \
560 [MESA_SHADER_GEOMETRY] = 256, \
564 #define GEN9_LP_FEATURES_3X6 \
566 .num_subslices = { 3, }, \
567 .num_eu_per_subslice = 6
569 #define GEN9_LP_FEATURES_2X6 \
571 .num_subslices = { 2, }, \
572 .num_eu_per_subslice = 6, \
573 .max_vs_threads = 56, \
574 .max_tcs_threads = 56, \
575 .max_tes_threads = 56, \
576 .max_gs_threads = 56, \
577 .max_cs_threads = 6 * 6, \
581 [MESA_SHADER_VERTEX] = 34, \
582 [MESA_SHADER_TESS_EVAL] = 34, \
585 [MESA_SHADER_VERTEX] = 352, \
586 [MESA_SHADER_TESS_CTRL] = 128, \
587 [MESA_SHADER_TESS_EVAL] = 208, \
588 [MESA_SHADER_GEOMETRY] = 128, \
592 #define GEN9_FEATURES \
595 .has_sample_with_hiz = true, \
596 .num_thread_per_eu = 7
598 static const struct gen_device_info gen_device_info_skl_gt1
= {
599 GEN9_FEATURES
, .gt
= 1,
602 .num_subslices
= { 2, },
603 .num_eu_per_subslice
= 6,
608 static const struct gen_device_info gen_device_info_skl_gt2
= {
609 GEN9_FEATURES
, .gt
= 2,
612 .num_subslices
= { 3, },
613 .num_eu_per_subslice
= 8,
617 static const struct gen_device_info gen_device_info_skl_gt3
= {
618 GEN9_FEATURES
, .gt
= 3,
621 .num_subslices
= { 3, 3, },
622 .num_eu_per_subslice
= 8,
626 static const struct gen_device_info gen_device_info_skl_gt4
= {
627 GEN9_FEATURES
, .gt
= 4,
630 .num_subslices
= { 3, 3, 3, },
631 .num_eu_per_subslice
= 8,
633 /* From the "L3 Allocation and Programming" documentation:
635 * "URB is limited to 1008KB due to programming restrictions. This is not a
636 * restriction of the L3 implementation, but of the FF and other clients.
637 * Therefore, in a GT4 implementation it is possible for the programmed
638 * allocation of the L3 data array to provide 3*384KB=1152KB for URB, but
639 * only 1008KB of this will be used."
641 .urb
.size
= 1008 / 3,
644 static const struct gen_device_info gen_device_info_bxt
= {
645 GEN9_LP_FEATURES_3X6
,
650 static const struct gen_device_info gen_device_info_bxt_2x6
= {
651 GEN9_LP_FEATURES_2X6
,
656 * Note: for all KBL SKUs, the PRM says SKL for GS entries, not SKL+.
657 * There's no KBL entry. Using the default SKL (GEN9) GS entries value.
660 static const struct gen_device_info gen_device_info_kbl_gt1
= {
665 .max_cs_threads
= 7 * 6,
668 .num_subslices
= { 2, },
669 .num_eu_per_subslice
= 6,
673 static const struct gen_device_info gen_device_info_kbl_gt1_5
= {
678 .max_cs_threads
= 7 * 6,
680 .num_subslices
= { 3, },
681 .num_eu_per_subslice
= 6,
685 static const struct gen_device_info gen_device_info_kbl_gt2
= {
691 .num_subslices
= { 3, },
692 .num_eu_per_subslice
= 8,
696 static const struct gen_device_info gen_device_info_kbl_gt3
= {
702 .num_subslices
= { 3, 3, },
703 .num_eu_per_subslice
= 8,
707 static const struct gen_device_info gen_device_info_kbl_gt4
= {
713 * From the "L3 Allocation and Programming" documentation:
715 * "URB is limited to 1008KB due to programming restrictions. This
716 * is not a restriction of the L3 implementation, but of the FF and
717 * other clients. Therefore, in a GT4 implementation it is
718 * possible for the programmed allocation of the L3 data array to
719 * provide 3*384KB=1152KB for URB, but only 1008KB of this
722 .urb
.size
= 1008 / 3,
724 .num_subslices
= { 3, 3, 3, },
725 .num_eu_per_subslice
= 8,
729 static const struct gen_device_info gen_device_info_glk
= {
730 GEN9_LP_FEATURES_3X6
,
731 .is_geminilake
= true,
735 /*TODO: Initialize l3_banks when we know the number. */
736 static const struct gen_device_info gen_device_info_glk_2x6
= {
737 GEN9_LP_FEATURES_2X6
,
738 .is_geminilake
= true,
741 static const struct gen_device_info gen_device_info_cfl_gt1
= {
743 .is_coffeelake
= true,
747 .num_subslices
= { 2, },
748 .num_eu_per_subslice
= 6,
751 static const struct gen_device_info gen_device_info_cfl_gt2
= {
753 .is_coffeelake
= true,
757 .num_subslices
= { 3, },
758 .num_eu_per_subslice
= 8,
762 static const struct gen_device_info gen_device_info_cfl_gt3
= {
764 .is_coffeelake
= true,
768 .num_subslices
= { 3, 3, },
769 .num_eu_per_subslice
= 8,
773 #define GEN10_HW_INFO \
775 .num_thread_per_eu = 7, \
776 .max_vs_threads = 728, \
777 .max_gs_threads = 432, \
778 .max_tcs_threads = 432, \
779 .max_tes_threads = 624, \
780 .max_cs_threads = 56, \
781 .timestamp_frequency = 19200000, \
785 [MESA_SHADER_VERTEX] = 64, \
786 [MESA_SHADER_TESS_EVAL] = 34, \
789 [MESA_SHADER_VERTEX] = 3936, \
790 [MESA_SHADER_TESS_CTRL] = 896, \
791 [MESA_SHADER_TESS_EVAL] = 2064, \
792 [MESA_SHADER_GEOMETRY] = 832, \
796 #define subslices(args...) { args, }
798 #define GEN10_FEATURES(_gt, _slices, _subslices, _l3) \
801 .has_sample_with_hiz = true, \
803 .num_slices = _slices, \
804 .num_subslices = _subslices, \
805 .num_eu_per_subslice = 8, \
808 static const struct gen_device_info gen_device_info_cnl_2x8
= {
810 GEN10_FEATURES(1, 1, subslices(2), 2),
811 .is_cannonlake
= true,
814 static const struct gen_device_info gen_device_info_cnl_3x8
= {
816 GEN10_FEATURES(1, 1, subslices(3), 3),
817 .is_cannonlake
= true,
820 static const struct gen_device_info gen_device_info_cnl_4x8
= {
822 GEN10_FEATURES(1, 2, subslices(2, 2), 6),
823 .is_cannonlake
= true,
826 static const struct gen_device_info gen_device_info_cnl_5x8
= {
828 GEN10_FEATURES(2, 2, subslices(3, 2), 6),
829 .is_cannonlake
= true,
832 #define GEN11_HW_INFO \
835 .max_vs_threads = 364, \
836 .max_gs_threads = 224, \
837 .max_tcs_threads = 224, \
838 .max_tes_threads = 364, \
839 .max_cs_threads = 56, \
843 [MESA_SHADER_VERTEX] = 64, \
844 [MESA_SHADER_TESS_EVAL] = 34, \
847 [MESA_SHADER_VERTEX] = 2384, \
848 [MESA_SHADER_TESS_CTRL] = 1032, \
849 [MESA_SHADER_TESS_EVAL] = 2384, \
850 [MESA_SHADER_GEOMETRY] = 1032, \
854 #define GEN11_FEATURES(_gt, _slices, _subslices, _l3) \
857 .has_64bit_types = false, \
858 .has_integer_dword_mul = false, \
859 .has_sample_with_hiz = false, \
860 .gt = _gt, .num_slices = _slices, .l3_banks = _l3, \
861 .num_subslices = _subslices, \
862 .num_eu_per_subslice = 8
864 static const struct gen_device_info gen_device_info_icl_8x8
= {
865 GEN11_FEATURES(2, 1, subslices(8), 8),
868 static const struct gen_device_info gen_device_info_icl_6x8
= {
869 GEN11_FEATURES(1, 1, subslices(6), 6),
872 static const struct gen_device_info gen_device_info_icl_4x8
= {
873 GEN11_FEATURES(1, 1, subslices(4), 6),
876 static const struct gen_device_info gen_device_info_icl_1x8
= {
877 GEN11_FEATURES(1, 1, subslices(1), 6),
881 gen_device_info_set_eu_mask(struct gen_device_info
*devinfo
,
886 unsigned subslice_offset
= slice
* devinfo
->eu_slice_stride
+
887 subslice
* devinfo
->eu_subslice_stride
;
889 for (unsigned b_eu
= 0; b_eu
< devinfo
->eu_subslice_stride
; b_eu
++) {
890 devinfo
->eu_masks
[subslice_offset
+ b_eu
] =
891 (((1U << devinfo
->num_eu_per_subslice
) - 1) >> (b_eu
* 8)) & 0xff;
895 /* Generate slice/subslice/eu masks from number of
896 * slices/subslices/eu_per_subslices in the per generation/gt gen_device_info
899 * These can be overridden with values reported by the kernel either from
900 * getparam SLICE_MASK/SUBSLICE_MASK values or from the kernel version 4.17+
901 * through the i915 query uapi.
904 fill_masks(struct gen_device_info
*devinfo
)
906 devinfo
->slice_masks
= (1U << devinfo
->num_slices
) - 1;
909 unsigned max_subslices
= 0;
910 for (int s
= 0; s
< devinfo
->num_slices
; s
++)
911 max_subslices
= MAX2(devinfo
->num_subslices
[s
], max_subslices
);
912 devinfo
->subslice_slice_stride
= DIV_ROUND_UP(max_subslices
, 8);
914 for (int s
= 0; s
< devinfo
->num_slices
; s
++) {
915 devinfo
->subslice_masks
[s
* devinfo
->subslice_slice_stride
] =
916 (1U << devinfo
->num_subslices
[s
]) - 1;
920 devinfo
->eu_subslice_stride
= DIV_ROUND_UP(devinfo
->num_eu_per_subslice
, 8);
921 devinfo
->eu_slice_stride
= max_subslices
* devinfo
->eu_subslice_stride
;
923 for (int s
= 0; s
< devinfo
->num_slices
; s
++) {
924 for (int ss
= 0; ss
< devinfo
->num_subslices
[s
]; ss
++) {
925 gen_device_info_set_eu_mask(devinfo
, s
, ss
,
926 (1U << devinfo
->num_eu_per_subslice
) - 1);
932 gen_device_info_update_from_masks(struct gen_device_info
*devinfo
,
934 uint32_t subslice_mask
,
938 struct drm_i915_query_topology_info base
;
942 assert((slice_mask
& 0xff) == slice_mask
);
944 memset(&topology
, 0, sizeof(topology
));
946 topology
.base
.max_slices
= util_last_bit(slice_mask
);
947 topology
.base
.max_subslices
= util_last_bit(subslice_mask
);
949 topology
.base
.subslice_offset
= DIV_ROUND_UP(topology
.base
.max_slices
, 8);
950 topology
.base
.subslice_stride
= DIV_ROUND_UP(topology
.base
.max_subslices
, 8);
952 uint32_t n_subslices
= __builtin_popcount(slice_mask
) *
953 __builtin_popcount(subslice_mask
);
954 uint32_t num_eu_per_subslice
= DIV_ROUND_UP(n_eus
, n_subslices
);
955 uint32_t eu_mask
= (1U << num_eu_per_subslice
) - 1;
957 topology
.base
.eu_offset
= topology
.base
.subslice_offset
+
958 DIV_ROUND_UP(topology
.base
.max_subslices
, 8);
959 topology
.base
.eu_stride
= DIV_ROUND_UP(num_eu_per_subslice
, 8);
961 /* Set slice mask in topology */
962 for (int b
= 0; b
< topology
.base
.subslice_offset
; b
++)
963 topology
.base
.data
[b
] = (slice_mask
>> (b
* 8)) & 0xff;
965 for (int s
= 0; s
< topology
.base
.max_slices
; s
++) {
967 /* Set subslice mask in topology */
968 for (int b
= 0; b
< topology
.base
.subslice_stride
; b
++) {
969 int subslice_offset
= topology
.base
.subslice_offset
+
970 s
* topology
.base
.subslice_stride
+ b
;
972 topology
.base
.data
[subslice_offset
] = (subslice_mask
>> (b
* 8)) & 0xff;
975 /* Set eu mask in topology */
976 for (int ss
= 0; ss
< topology
.base
.max_subslices
; ss
++) {
977 for (int b
= 0; b
< topology
.base
.eu_stride
; b
++) {
978 int eu_offset
= topology
.base
.eu_offset
+
979 (s
* topology
.base
.max_subslices
+ ss
) * topology
.base
.eu_stride
+ b
;
981 topology
.base
.data
[eu_offset
] = (eu_mask
>> (b
* 8)) & 0xff;
986 gen_device_info_update_from_topology(devinfo
, &topology
.base
);
990 reset_masks(struct gen_device_info
*devinfo
)
992 devinfo
->subslice_slice_stride
= 0;
993 devinfo
->eu_subslice_stride
= 0;
994 devinfo
->eu_slice_stride
= 0;
996 devinfo
->num_slices
= 0;
997 devinfo
->num_eu_per_subslice
= 0;
998 memset(devinfo
->num_subslices
, 0, sizeof(devinfo
->num_subslices
));
1000 memset(&devinfo
->slice_masks
, 0, sizeof(devinfo
->slice_masks
));
1001 memset(devinfo
->subslice_masks
, 0, sizeof(devinfo
->subslice_masks
));
1002 memset(devinfo
->eu_masks
, 0, sizeof(devinfo
->eu_masks
));
1006 gen_device_info_update_from_topology(struct gen_device_info
*devinfo
,
1007 const struct drm_i915_query_topology_info
*topology
)
1009 reset_masks(devinfo
);
1011 devinfo
->subslice_slice_stride
= topology
->subslice_stride
;
1013 devinfo
->eu_subslice_stride
= DIV_ROUND_UP(topology
->max_eus_per_subslice
, 8);
1014 devinfo
->eu_slice_stride
= topology
->max_subslices
* devinfo
->eu_subslice_stride
;
1016 assert(sizeof(devinfo
->slice_masks
) >= DIV_ROUND_UP(topology
->max_slices
, 8));
1017 memcpy(&devinfo
->slice_masks
, topology
->data
, DIV_ROUND_UP(topology
->max_slices
, 8));
1018 devinfo
->num_slices
= __builtin_popcount(devinfo
->slice_masks
);
1020 uint32_t subslice_mask_len
=
1021 topology
->max_slices
* topology
->subslice_stride
;
1022 assert(sizeof(devinfo
->subslice_masks
) >= subslice_mask_len
);
1023 memcpy(devinfo
->subslice_masks
, &topology
->data
[topology
->subslice_offset
],
1026 uint32_t n_subslices
= 0;
1027 for (int s
= 0; s
< topology
->max_slices
; s
++) {
1028 if ((devinfo
->slice_masks
& (1UL << s
)) == 0)
1031 for (int b
= 0; b
< devinfo
->subslice_slice_stride
; b
++) {
1032 devinfo
->num_subslices
[s
] +=
1033 __builtin_popcount(devinfo
->subslice_masks
[b
]);
1035 n_subslices
+= devinfo
->num_subslices
[s
];
1038 uint32_t eu_mask_len
=
1039 topology
->eu_stride
* topology
->max_subslices
* topology
->max_slices
;
1040 assert(sizeof(devinfo
->eu_masks
) >= eu_mask_len
);
1041 memcpy(devinfo
->eu_masks
, &topology
->data
[topology
->eu_offset
], eu_mask_len
);
1044 for (int b
= 0; b
< eu_mask_len
; b
++)
1045 n_eus
+= __builtin_popcount(devinfo
->eu_masks
[b
]);
1047 devinfo
->num_eu_per_subslice
= DIV_ROUND_UP(n_eus
, n_subslices
);
1051 gen_get_device_info(int devid
, struct gen_device_info
*devinfo
)
1055 #define CHIPSET(id, family, name) \
1056 case id: *devinfo = gen_device_info_##family; break;
1057 #include "pci_ids/i965_pci_ids.h"
1059 fprintf(stderr
, "i965_dri.so does not support the 0x%x PCI ID.\n", devid
);
1063 fill_masks(devinfo
);
1065 /* From the Skylake PRM, 3DSTATE_PS::Scratch Space Base Pointer:
1067 * "Scratch Space per slice is computed based on 4 sub-slices. SW must
1068 * allocate scratch space enough so that each slice has 4 slices allowed."
1070 * The equivalent internal documentation says that this programming note
1071 * applies to all Gen9+ platforms.
1073 * The hardware typically calculates the scratch space pointer by taking
1074 * the base address, and adding per-thread-scratch-space * thread ID.
1075 * Extra padding can be necessary depending how the thread IDs are
1076 * calculated for a particular shader stage.
1079 switch(devinfo
->gen
) {
1082 devinfo
->max_wm_threads
= 64 /* threads-per-PSD */
1083 * devinfo
->num_slices
1084 * 4; /* effective subslices per slice */
1087 devinfo
->max_wm_threads
= 128 /* threads-per-PSD */
1088 * devinfo
->num_slices
1089 * 8; /* subslices per slice */
1095 assert(devinfo
->num_slices
<= ARRAY_SIZE(devinfo
->num_subslices
));
1101 gen_get_device_name(int devid
)
1105 #define CHIPSET(id, family, name) case id: return name;
1106 #include "pci_ids/i965_pci_ids.h"