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
30 #include "gen_device_info.h"
31 #include "compiler/shader_enums.h"
32 #include "intel/common/gen_gem.h"
33 #include "util/bitscan.h"
34 #include "util/macros.h"
36 #include "drm-uapi/i915_drm.h"
39 * Get the PCI ID for the device name.
41 * Returns -1 if the device is not known.
44 gen_device_name_to_pci_device_id(const char *name
)
72 for (unsigned i
= 0; i
< ARRAY_SIZE(name_map
); i
++) {
73 if (!strcmp(name_map
[i
].name
, name
))
74 return name_map
[i
].pci_id
;
81 * Get the overridden PCI ID for the device. This is set with the
82 * INTEL_DEVID_OVERRIDE environment variable.
84 * Returns -1 if the override is not set.
87 get_pci_device_id_override(void)
89 if (geteuid() == getuid()) {
90 const char *devid_override
= getenv("INTEL_DEVID_OVERRIDE");
92 const int id
= gen_device_name_to_pci_device_id(devid_override
);
93 return id
>= 0 ? id
: strtol(devid_override
, NULL
, 0);
100 static const struct gen_device_info gen_device_info_i965
= {
102 .has_negative_rhw_bug
= true,
104 .num_subslices
= { 1, },
105 .num_eu_per_subslice
= 8,
106 .num_thread_per_eu
= 4,
107 .max_vs_threads
= 16,
109 .max_wm_threads
= 8 * 4,
113 .timestamp_frequency
= 12500000,
117 static const struct gen_device_info gen_device_info_g4x
= {
121 .has_surface_tile_offset
= true,
124 .num_subslices
= { 1, },
125 .num_eu_per_subslice
= 10,
126 .num_thread_per_eu
= 5,
127 .max_vs_threads
= 32,
129 .max_wm_threads
= 10 * 5,
133 .timestamp_frequency
= 12500000,
137 static const struct gen_device_info gen_device_info_ilk
= {
141 .has_surface_tile_offset
= true,
143 .num_subslices
= { 1, },
144 .num_eu_per_subslice
= 12,
145 .num_thread_per_eu
= 6,
146 .max_vs_threads
= 72,
147 .max_gs_threads
= 32,
148 .max_wm_threads
= 12 * 6,
152 .timestamp_frequency
= 12500000,
156 static const struct gen_device_info gen_device_info_snb_gt1
= {
159 .has_hiz_and_separate_stencil
= true,
162 .has_surface_tile_offset
= true,
163 .needs_unlit_centroid_workaround
= true,
165 .num_subslices
= { 1, },
166 .num_eu_per_subslice
= 6,
167 .num_thread_per_eu
= 6, /* Not confirmed */
168 .max_vs_threads
= 24,
169 .max_gs_threads
= 21, /* conservative; 24 if rendering disabled. */
170 .max_wm_threads
= 40,
174 [MESA_SHADER_VERTEX
] = 24,
177 [MESA_SHADER_VERTEX
] = 256,
178 [MESA_SHADER_GEOMETRY
] = 256,
181 .timestamp_frequency
= 12500000,
185 static const struct gen_device_info gen_device_info_snb_gt2
= {
188 .has_hiz_and_separate_stencil
= true,
191 .has_surface_tile_offset
= true,
192 .needs_unlit_centroid_workaround
= true,
194 .num_subslices
= { 1, },
195 .num_eu_per_subslice
= 12,
196 .num_thread_per_eu
= 6, /* Not confirmed */
197 .max_vs_threads
= 60,
198 .max_gs_threads
= 60,
199 .max_wm_threads
= 80,
203 [MESA_SHADER_VERTEX
] = 24,
206 [MESA_SHADER_VERTEX
] = 256,
207 [MESA_SHADER_GEOMETRY
] = 256,
210 .timestamp_frequency
= 12500000,
214 #define GEN7_FEATURES \
216 .has_hiz_and_separate_stencil = true, \
217 .must_use_separate_stencil = true, \
220 .has_64bit_types = true, \
221 .has_surface_tile_offset = true, \
222 .timestamp_frequency = 12500000
224 static const struct gen_device_info gen_device_info_ivb_gt1
= {
225 GEN7_FEATURES
, .is_ivybridge
= true, .gt
= 1,
227 .num_subslices
= { 1, },
228 .num_eu_per_subslice
= 6,
229 .num_thread_per_eu
= 6,
231 .max_vs_threads
= 36,
232 .max_tcs_threads
= 36,
233 .max_tes_threads
= 36,
234 .max_gs_threads
= 36,
235 .max_wm_threads
= 48,
236 .max_cs_threads
= 36,
240 [MESA_SHADER_VERTEX
] = 32,
241 [MESA_SHADER_TESS_EVAL
] = 10,
244 [MESA_SHADER_VERTEX
] = 512,
245 [MESA_SHADER_TESS_CTRL
] = 32,
246 [MESA_SHADER_TESS_EVAL
] = 288,
247 [MESA_SHADER_GEOMETRY
] = 192,
253 static const struct gen_device_info gen_device_info_ivb_gt2
= {
254 GEN7_FEATURES
, .is_ivybridge
= true, .gt
= 2,
256 .num_subslices
= { 1, },
257 .num_eu_per_subslice
= 12,
258 .num_thread_per_eu
= 8, /* Not sure why this isn't a multiple of
259 * @max_wm_threads ... */
261 .max_vs_threads
= 128,
262 .max_tcs_threads
= 128,
263 .max_tes_threads
= 128,
264 .max_gs_threads
= 128,
265 .max_wm_threads
= 172,
266 .max_cs_threads
= 64,
270 [MESA_SHADER_VERTEX
] = 32,
271 [MESA_SHADER_TESS_EVAL
] = 10,
274 [MESA_SHADER_VERTEX
] = 704,
275 [MESA_SHADER_TESS_CTRL
] = 64,
276 [MESA_SHADER_TESS_EVAL
] = 448,
277 [MESA_SHADER_GEOMETRY
] = 320,
283 static const struct gen_device_info gen_device_info_byt
= {
284 GEN7_FEATURES
, .is_baytrail
= true, .gt
= 1,
286 .num_subslices
= { 1, },
287 .num_eu_per_subslice
= 4,
288 .num_thread_per_eu
= 8,
291 .max_vs_threads
= 36,
292 .max_tcs_threads
= 36,
293 .max_tes_threads
= 36,
294 .max_gs_threads
= 36,
295 .max_wm_threads
= 48,
296 .max_cs_threads
= 32,
300 [MESA_SHADER_VERTEX
] = 32,
301 [MESA_SHADER_TESS_EVAL
] = 10,
304 [MESA_SHADER_VERTEX
] = 512,
305 [MESA_SHADER_TESS_CTRL
] = 32,
306 [MESA_SHADER_TESS_EVAL
] = 288,
307 [MESA_SHADER_GEOMETRY
] = 192,
313 #define HSW_FEATURES \
315 .is_haswell = true, \
316 .supports_simd16_3src = true, \
317 .has_resource_streamer = true
319 static const struct gen_device_info gen_device_info_hsw_gt1
= {
320 HSW_FEATURES
, .gt
= 1,
322 .num_subslices
= { 1, },
323 .num_eu_per_subslice
= 10,
324 .num_thread_per_eu
= 7,
326 .max_vs_threads
= 70,
327 .max_tcs_threads
= 70,
328 .max_tes_threads
= 70,
329 .max_gs_threads
= 70,
330 .max_wm_threads
= 102,
331 .max_cs_threads
= 70,
335 [MESA_SHADER_VERTEX
] = 32,
336 [MESA_SHADER_TESS_EVAL
] = 10,
339 [MESA_SHADER_VERTEX
] = 640,
340 [MESA_SHADER_TESS_CTRL
] = 64,
341 [MESA_SHADER_TESS_EVAL
] = 384,
342 [MESA_SHADER_GEOMETRY
] = 256,
348 static const struct gen_device_info gen_device_info_hsw_gt2
= {
349 HSW_FEATURES
, .gt
= 2,
351 .num_subslices
= { 2, },
352 .num_eu_per_subslice
= 10,
353 .num_thread_per_eu
= 7,
355 .max_vs_threads
= 280,
356 .max_tcs_threads
= 256,
357 .max_tes_threads
= 280,
358 .max_gs_threads
= 256,
359 .max_wm_threads
= 204,
360 .max_cs_threads
= 70,
364 [MESA_SHADER_VERTEX
] = 64,
365 [MESA_SHADER_TESS_EVAL
] = 10,
368 [MESA_SHADER_VERTEX
] = 1664,
369 [MESA_SHADER_TESS_CTRL
] = 128,
370 [MESA_SHADER_TESS_EVAL
] = 960,
371 [MESA_SHADER_GEOMETRY
] = 640,
377 static const struct gen_device_info gen_device_info_hsw_gt3
= {
378 HSW_FEATURES
, .gt
= 3,
380 .num_subslices
= { 2, },
381 .num_eu_per_subslice
= 10,
382 .num_thread_per_eu
= 7,
384 .max_vs_threads
= 280,
385 .max_tcs_threads
= 256,
386 .max_tes_threads
= 280,
387 .max_gs_threads
= 256,
388 .max_wm_threads
= 408,
389 .max_cs_threads
= 70,
393 [MESA_SHADER_VERTEX
] = 64,
394 [MESA_SHADER_TESS_EVAL
] = 10,
397 [MESA_SHADER_VERTEX
] = 1664,
398 [MESA_SHADER_TESS_CTRL
] = 128,
399 [MESA_SHADER_TESS_EVAL
] = 960,
400 [MESA_SHADER_GEOMETRY
] = 640,
406 /* It's unclear how well supported sampling from the hiz buffer is on GEN8,
407 * so keep things conservative for now and set has_sample_with_hiz = false.
409 #define GEN8_FEATURES \
411 .has_hiz_and_separate_stencil = true, \
412 .has_resource_streamer = true, \
413 .must_use_separate_stencil = true, \
415 .has_sample_with_hiz = false, \
417 .has_integer_dword_mul = true, \
418 .has_64bit_types = true, \
419 .supports_simd16_3src = true, \
420 .has_surface_tile_offset = true, \
421 .num_thread_per_eu = 7, \
422 .max_vs_threads = 504, \
423 .max_tcs_threads = 504, \
424 .max_tes_threads = 504, \
425 .max_gs_threads = 504, \
426 .max_wm_threads = 384, \
427 .timestamp_frequency = 12500000
429 static const struct gen_device_info gen_device_info_bdw_gt1
= {
430 GEN8_FEATURES
, .gt
= 1,
431 .is_broadwell
= true,
433 .num_subslices
= { 2, },
434 .num_eu_per_subslice
= 8,
436 .max_cs_threads
= 42,
440 [MESA_SHADER_VERTEX
] = 64,
441 [MESA_SHADER_TESS_EVAL
] = 34,
444 [MESA_SHADER_VERTEX
] = 2560,
445 [MESA_SHADER_TESS_CTRL
] = 504,
446 [MESA_SHADER_TESS_EVAL
] = 1536,
447 [MESA_SHADER_GEOMETRY
] = 960,
453 static const struct gen_device_info gen_device_info_bdw_gt2
= {
454 GEN8_FEATURES
, .gt
= 2,
455 .is_broadwell
= true,
457 .num_subslices
= { 3, },
458 .num_eu_per_subslice
= 8,
460 .max_cs_threads
= 56,
464 [MESA_SHADER_VERTEX
] = 64,
465 [MESA_SHADER_TESS_EVAL
] = 34,
468 [MESA_SHADER_VERTEX
] = 2560,
469 [MESA_SHADER_TESS_CTRL
] = 504,
470 [MESA_SHADER_TESS_EVAL
] = 1536,
471 [MESA_SHADER_GEOMETRY
] = 960,
477 static const struct gen_device_info gen_device_info_bdw_gt3
= {
478 GEN8_FEATURES
, .gt
= 3,
479 .is_broadwell
= true,
481 .num_subslices
= { 3, 3, },
482 .num_eu_per_subslice
= 8,
484 .max_cs_threads
= 56,
488 [MESA_SHADER_VERTEX
] = 64,
489 [MESA_SHADER_TESS_EVAL
] = 34,
492 [MESA_SHADER_VERTEX
] = 2560,
493 [MESA_SHADER_TESS_CTRL
] = 504,
494 [MESA_SHADER_TESS_EVAL
] = 1536,
495 [MESA_SHADER_GEOMETRY
] = 960,
501 static const struct gen_device_info gen_device_info_chv
= {
502 GEN8_FEATURES
, .is_cherryview
= 1, .gt
= 1,
504 .has_integer_dword_mul
= false,
506 .num_subslices
= { 2, },
507 .num_eu_per_subslice
= 8,
509 .max_vs_threads
= 80,
510 .max_tcs_threads
= 80,
511 .max_tes_threads
= 80,
512 .max_gs_threads
= 80,
513 .max_wm_threads
= 128,
514 .max_cs_threads
= 6 * 7,
518 [MESA_SHADER_VERTEX
] = 34,
519 [MESA_SHADER_TESS_EVAL
] = 34,
522 [MESA_SHADER_VERTEX
] = 640,
523 [MESA_SHADER_TESS_CTRL
] = 80,
524 [MESA_SHADER_TESS_EVAL
] = 384,
525 [MESA_SHADER_GEOMETRY
] = 256,
531 #define GEN9_HW_INFO \
533 .max_vs_threads = 336, \
534 .max_gs_threads = 336, \
535 .max_tcs_threads = 336, \
536 .max_tes_threads = 336, \
537 .max_cs_threads = 56, \
538 .timestamp_frequency = 12000000, \
542 [MESA_SHADER_VERTEX] = 64, \
543 [MESA_SHADER_TESS_EVAL] = 34, \
546 [MESA_SHADER_VERTEX] = 1856, \
547 [MESA_SHADER_TESS_CTRL] = 672, \
548 [MESA_SHADER_TESS_EVAL] = 1120, \
549 [MESA_SHADER_GEOMETRY] = 640, \
553 #define GEN9_LP_FEATURES \
556 .has_integer_dword_mul = false, \
559 .has_sample_with_hiz = true, \
561 .num_thread_per_eu = 6, \
562 .max_vs_threads = 112, \
563 .max_tcs_threads = 112, \
564 .max_tes_threads = 112, \
565 .max_gs_threads = 112, \
566 .max_cs_threads = 6 * 6, \
567 .timestamp_frequency = 19200000, \
571 [MESA_SHADER_VERTEX] = 34, \
572 [MESA_SHADER_TESS_EVAL] = 34, \
575 [MESA_SHADER_VERTEX] = 704, \
576 [MESA_SHADER_TESS_CTRL] = 256, \
577 [MESA_SHADER_TESS_EVAL] = 416, \
578 [MESA_SHADER_GEOMETRY] = 256, \
582 #define GEN9_LP_FEATURES_3X6 \
584 .num_subslices = { 3, }, \
585 .num_eu_per_subslice = 6
587 #define GEN9_LP_FEATURES_2X6 \
589 .num_subslices = { 2, }, \
590 .num_eu_per_subslice = 6, \
591 .max_vs_threads = 56, \
592 .max_tcs_threads = 56, \
593 .max_tes_threads = 56, \
594 .max_gs_threads = 56, \
595 .max_cs_threads = 6 * 6, \
599 [MESA_SHADER_VERTEX] = 34, \
600 [MESA_SHADER_TESS_EVAL] = 34, \
603 [MESA_SHADER_VERTEX] = 352, \
604 [MESA_SHADER_TESS_CTRL] = 128, \
605 [MESA_SHADER_TESS_EVAL] = 208, \
606 [MESA_SHADER_GEOMETRY] = 128, \
610 #define GEN9_FEATURES \
613 .has_sample_with_hiz = true
615 static const struct gen_device_info gen_device_info_skl_gt1
= {
616 GEN9_FEATURES
, .gt
= 1,
619 .num_subslices
= { 2, },
620 .num_eu_per_subslice
= 6,
623 /* GT1 seems to have a bug in the top of the pipe (VF/VS?) fixed functions
624 * leading to some vertices to go missing if we use too much URB.
626 .urb
.max_entries
[MESA_SHADER_VERTEX
] = 928,
630 static const struct gen_device_info gen_device_info_skl_gt2
= {
631 GEN9_FEATURES
, .gt
= 2,
634 .num_subslices
= { 3, },
635 .num_eu_per_subslice
= 8,
640 static const struct gen_device_info gen_device_info_skl_gt3
= {
641 GEN9_FEATURES
, .gt
= 3,
644 .num_subslices
= { 3, 3, },
645 .num_eu_per_subslice
= 8,
650 static const struct gen_device_info gen_device_info_skl_gt4
= {
651 GEN9_FEATURES
, .gt
= 4,
654 .num_subslices
= { 3, 3, 3, },
655 .num_eu_per_subslice
= 8,
657 /* From the "L3 Allocation and Programming" documentation:
659 * "URB is limited to 1008KB due to programming restrictions. This is not a
660 * restriction of the L3 implementation, but of the FF and other clients.
661 * Therefore, in a GT4 implementation it is possible for the programmed
662 * allocation of the L3 data array to provide 3*384KB=1152KB for URB, but
663 * only 1008KB of this will be used."
665 .urb
.size
= 1008 / 3,
669 static const struct gen_device_info gen_device_info_bxt
= {
670 GEN9_LP_FEATURES_3X6
,
676 static const struct gen_device_info gen_device_info_bxt_2x6
= {
677 GEN9_LP_FEATURES_2X6
,
683 * Note: for all KBL SKUs, the PRM says SKL for GS entries, not SKL+.
684 * There's no KBL entry. Using the default SKL (GEN9) GS entries value.
687 static const struct gen_device_info gen_device_info_kbl_gt1
= {
692 .max_cs_threads
= 7 * 6,
695 .num_subslices
= { 2, },
696 .num_eu_per_subslice
= 6,
698 /* GT1 seems to have a bug in the top of the pipe (VF/VS?) fixed functions
699 * leading to some vertices to go missing if we use too much URB.
701 .urb
.max_entries
[MESA_SHADER_VERTEX
] = 928,
705 static const struct gen_device_info gen_device_info_kbl_gt1_5
= {
710 .max_cs_threads
= 7 * 6,
712 .num_subslices
= { 3, },
713 .num_eu_per_subslice
= 6,
718 static const struct gen_device_info gen_device_info_kbl_gt2
= {
724 .num_subslices
= { 3, },
725 .num_eu_per_subslice
= 8,
730 static const struct gen_device_info gen_device_info_kbl_gt3
= {
736 .num_subslices
= { 3, 3, },
737 .num_eu_per_subslice
= 8,
742 static const struct gen_device_info gen_device_info_kbl_gt4
= {
748 * From the "L3 Allocation and Programming" documentation:
750 * "URB is limited to 1008KB due to programming restrictions. This
751 * is not a restriction of the L3 implementation, but of the FF and
752 * other clients. Therefore, in a GT4 implementation it is
753 * possible for the programmed allocation of the L3 data array to
754 * provide 3*384KB=1152KB for URB, but only 1008KB of this
757 .urb
.size
= 1008 / 3,
759 .num_subslices
= { 3, 3, 3, },
760 .num_eu_per_subslice
= 8,
765 static const struct gen_device_info gen_device_info_glk
= {
766 GEN9_LP_FEATURES_3X6
,
767 .is_geminilake
= true,
772 static const struct gen_device_info gen_device_info_glk_2x6
= {
773 GEN9_LP_FEATURES_2X6
,
774 .is_geminilake
= true,
779 static const struct gen_device_info gen_device_info_cfl_gt1
= {
781 .is_coffeelake
= true,
785 .num_subslices
= { 2, },
786 .num_eu_per_subslice
= 6,
789 /* GT1 seems to have a bug in the top of the pipe (VF/VS?) fixed functions
790 * leading to some vertices to go missing if we use too much URB.
792 .urb
.max_entries
[MESA_SHADER_VERTEX
] = 928,
795 static const struct gen_device_info gen_device_info_cfl_gt2
= {
797 .is_coffeelake
= true,
801 .num_subslices
= { 3, },
802 .num_eu_per_subslice
= 8,
807 static const struct gen_device_info gen_device_info_cfl_gt3
= {
809 .is_coffeelake
= true,
813 .num_subslices
= { 3, 3, },
814 .num_eu_per_subslice
= 8,
819 #define GEN10_HW_INFO \
821 .num_thread_per_eu = 7, \
822 .max_vs_threads = 728, \
823 .max_gs_threads = 432, \
824 .max_tcs_threads = 432, \
825 .max_tes_threads = 624, \
826 .max_cs_threads = 56, \
827 .timestamp_frequency = 19200000, \
831 [MESA_SHADER_VERTEX] = 64, \
832 [MESA_SHADER_TESS_EVAL] = 34, \
835 [MESA_SHADER_VERTEX] = 3936, \
836 [MESA_SHADER_TESS_CTRL] = 896, \
837 [MESA_SHADER_TESS_EVAL] = 2064, \
838 [MESA_SHADER_GEOMETRY] = 832, \
842 #define subslices(args...) { args, }
844 #define GEN10_FEATURES(_gt, _slices, _subslices, _l3) \
847 .has_sample_with_hiz = true, \
849 .num_slices = _slices, \
850 .num_subslices = _subslices, \
851 .num_eu_per_subslice = 8, \
854 static const struct gen_device_info gen_device_info_cnl_2x8
= {
856 GEN10_FEATURES(1, 1, subslices(2), 2),
857 .is_cannonlake
= true,
861 static const struct gen_device_info gen_device_info_cnl_3x8
= {
863 GEN10_FEATURES(1, 1, subslices(3), 3),
864 .is_cannonlake
= true,
868 static const struct gen_device_info gen_device_info_cnl_4x8
= {
870 GEN10_FEATURES(1, 2, subslices(2, 2), 6),
871 .is_cannonlake
= true,
875 static const struct gen_device_info gen_device_info_cnl_5x8
= {
877 GEN10_FEATURES(2, 2, subslices(3, 2), 6),
878 .is_cannonlake
= true,
882 #define GEN11_HW_INFO \
885 .max_vs_threads = 364, \
886 .max_gs_threads = 224, \
887 .max_tcs_threads = 224, \
888 .max_tes_threads = 364, \
891 #define GEN11_FEATURES(_gt, _slices, _subslices, _l3) \
894 .has_64bit_types = false, \
895 .has_integer_dword_mul = false, \
896 .has_sample_with_hiz = false, \
897 .gt = _gt, .num_slices = _slices, .l3_banks = _l3, \
898 .num_subslices = _subslices, \
899 .num_eu_per_subslice = 8
901 #define GEN11_URB_MIN_MAX_ENTRIES \
903 [MESA_SHADER_VERTEX] = 64, \
904 [MESA_SHADER_TESS_EVAL] = 34, \
907 [MESA_SHADER_VERTEX] = 2384, \
908 [MESA_SHADER_TESS_CTRL] = 1032, \
909 [MESA_SHADER_TESS_EVAL] = 2384, \
910 [MESA_SHADER_GEOMETRY] = 1032, \
913 static const struct gen_device_info gen_device_info_icl_8x8
= {
914 GEN11_FEATURES(2, 1, subslices(8), 8),
917 GEN11_URB_MIN_MAX_ENTRIES
,
922 static const struct gen_device_info gen_device_info_icl_6x8
= {
923 GEN11_FEATURES(1, 1, subslices(6), 6),
926 GEN11_URB_MIN_MAX_ENTRIES
,
931 static const struct gen_device_info gen_device_info_icl_4x8
= {
932 GEN11_FEATURES(1, 1, subslices(4), 6),
935 GEN11_URB_MIN_MAX_ENTRIES
,
940 static const struct gen_device_info gen_device_info_icl_1x8
= {
941 GEN11_FEATURES(1, 1, subslices(1), 6),
944 GEN11_URB_MIN_MAX_ENTRIES
,
949 static const struct gen_device_info gen_device_info_ehl_4x8
= {
950 GEN11_FEATURES(1, 1, subslices(4), 4),
954 [MESA_SHADER_VERTEX
] = 64,
955 [MESA_SHADER_TESS_EVAL
] = 34,
958 [MESA_SHADER_VERTEX
] = 2384,
959 [MESA_SHADER_TESS_CTRL
] = 1032,
960 [MESA_SHADER_TESS_EVAL
] = 2384,
961 [MESA_SHADER_GEOMETRY
] = 1032,
964 .disable_ccs_repack
= true,
968 /* FIXME: Verfiy below entries when more information is available for this SKU.
970 static const struct gen_device_info gen_device_info_ehl_4x4
= {
971 GEN11_FEATURES(1, 1, subslices(4), 4),
975 [MESA_SHADER_VERTEX
] = 64,
976 [MESA_SHADER_TESS_EVAL
] = 34,
979 [MESA_SHADER_VERTEX
] = 2384,
980 [MESA_SHADER_TESS_CTRL
] = 1032,
981 [MESA_SHADER_TESS_EVAL
] = 2384,
982 [MESA_SHADER_GEOMETRY
] = 1032,
985 .disable_ccs_repack
= true,
986 .num_eu_per_subslice
= 4,
990 /* FIXME: Verfiy below entries when more information is available for this SKU.
992 static const struct gen_device_info gen_device_info_ehl_2x4
= {
993 GEN11_FEATURES(1, 1, subslices(2), 4),
997 [MESA_SHADER_VERTEX
] = 64,
998 [MESA_SHADER_TESS_EVAL
] = 34,
1001 [MESA_SHADER_VERTEX
] = 2384,
1002 [MESA_SHADER_TESS_CTRL
] = 1032,
1003 [MESA_SHADER_TESS_EVAL
] = 2384,
1004 [MESA_SHADER_GEOMETRY
] = 1032,
1007 .disable_ccs_repack
= true,
1008 .num_eu_per_subslice
=4,
1012 #define GEN12_URB_MIN_MAX_ENTRIES \
1014 [MESA_SHADER_VERTEX] = 64, \
1015 [MESA_SHADER_TESS_EVAL] = 34, \
1018 [MESA_SHADER_VERTEX] = 3576, \
1019 [MESA_SHADER_TESS_CTRL] = 1548, \
1020 [MESA_SHADER_TESS_EVAL] = 3576, \
1021 [MESA_SHADER_GEOMETRY] = 1548, \
1024 #define GEN12_HW_INFO \
1027 .has_sample_with_hiz = false, \
1028 .has_aux_map = true, \
1029 .max_vs_threads = 546, \
1030 .max_gs_threads = 336, \
1031 .max_tcs_threads = 336, \
1032 .max_tes_threads = 546, \
1033 .max_cs_threads = 112, /* threads per DSS */ \
1035 GEN12_URB_MIN_MAX_ENTRIES, \
1038 #define GEN12_FEATURES(_gt, _slices, _dual_subslices, _l3) \
1041 .has_64bit_types = false, \
1042 .has_integer_dword_mul = false, \
1043 .gt = _gt, .num_slices = _slices, .l3_banks = _l3, \
1044 .simulator_id = 22, \
1045 .urb.size = (_gt) == 1 ? 512 : 1024, \
1046 .num_subslices = _dual_subslices, \
1047 .num_eu_per_subslice = 16
1049 #define dual_subslices(args...) { args, }
1051 static const struct gen_device_info gen_device_info_tgl_1x2x16
= {
1052 GEN12_FEATURES(1, 1, dual_subslices(2), 8),
1055 static const struct gen_device_info gen_device_info_tgl_1x6x16
= {
1056 GEN12_FEATURES(2, 1, dual_subslices(6), 8),
1060 gen_device_info_set_eu_mask(struct gen_device_info
*devinfo
,
1065 unsigned subslice_offset
= slice
* devinfo
->eu_slice_stride
+
1066 subslice
* devinfo
->eu_subslice_stride
;
1068 for (unsigned b_eu
= 0; b_eu
< devinfo
->eu_subslice_stride
; b_eu
++) {
1069 devinfo
->eu_masks
[subslice_offset
+ b_eu
] =
1070 (((1U << devinfo
->num_eu_per_subslice
) - 1) >> (b_eu
* 8)) & 0xff;
1074 /* Generate slice/subslice/eu masks from number of
1075 * slices/subslices/eu_per_subslices in the per generation/gt gen_device_info
1078 * These can be overridden with values reported by the kernel either from
1079 * getparam SLICE_MASK/SUBSLICE_MASK values or from the kernel version 4.17+
1080 * through the i915 query uapi.
1083 fill_masks(struct gen_device_info
*devinfo
)
1085 devinfo
->slice_masks
= (1U << devinfo
->num_slices
) - 1;
1087 /* Subslice masks */
1088 unsigned max_subslices
= 0;
1089 for (int s
= 0; s
< devinfo
->num_slices
; s
++)
1090 max_subslices
= MAX2(devinfo
->num_subslices
[s
], max_subslices
);
1091 devinfo
->subslice_slice_stride
= DIV_ROUND_UP(max_subslices
, 8);
1093 for (int s
= 0; s
< devinfo
->num_slices
; s
++) {
1094 devinfo
->subslice_masks
[s
* devinfo
->subslice_slice_stride
] =
1095 (1U << devinfo
->num_subslices
[s
]) - 1;
1099 devinfo
->eu_subslice_stride
= DIV_ROUND_UP(devinfo
->num_eu_per_subslice
, 8);
1100 devinfo
->eu_slice_stride
= max_subslices
* devinfo
->eu_subslice_stride
;
1102 for (int s
= 0; s
< devinfo
->num_slices
; s
++) {
1103 for (int ss
= 0; ss
< devinfo
->num_subslices
[s
]; ss
++) {
1104 gen_device_info_set_eu_mask(devinfo
, s
, ss
,
1105 (1U << devinfo
->num_eu_per_subslice
) - 1);
1111 reset_masks(struct gen_device_info
*devinfo
)
1113 devinfo
->subslice_slice_stride
= 0;
1114 devinfo
->eu_subslice_stride
= 0;
1115 devinfo
->eu_slice_stride
= 0;
1117 devinfo
->num_slices
= 0;
1118 devinfo
->num_eu_per_subslice
= 0;
1119 memset(devinfo
->num_subslices
, 0, sizeof(devinfo
->num_subslices
));
1121 memset(&devinfo
->slice_masks
, 0, sizeof(devinfo
->slice_masks
));
1122 memset(devinfo
->subslice_masks
, 0, sizeof(devinfo
->subslice_masks
));
1123 memset(devinfo
->eu_masks
, 0, sizeof(devinfo
->eu_masks
));
1124 memset(devinfo
->ppipe_subslices
, 0, sizeof(devinfo
->ppipe_subslices
));
1128 update_from_topology(struct gen_device_info
*devinfo
,
1129 const struct drm_i915_query_topology_info
*topology
)
1131 reset_masks(devinfo
);
1133 devinfo
->subslice_slice_stride
= topology
->subslice_stride
;
1135 devinfo
->eu_subslice_stride
= DIV_ROUND_UP(topology
->max_eus_per_subslice
, 8);
1136 devinfo
->eu_slice_stride
= topology
->max_subslices
* devinfo
->eu_subslice_stride
;
1138 assert(sizeof(devinfo
->slice_masks
) >= DIV_ROUND_UP(topology
->max_slices
, 8));
1139 memcpy(&devinfo
->slice_masks
, topology
->data
, DIV_ROUND_UP(topology
->max_slices
, 8));
1140 devinfo
->num_slices
= __builtin_popcount(devinfo
->slice_masks
);
1142 uint32_t subslice_mask_len
=
1143 topology
->max_slices
* topology
->subslice_stride
;
1144 assert(sizeof(devinfo
->subslice_masks
) >= subslice_mask_len
);
1145 memcpy(devinfo
->subslice_masks
, &topology
->data
[topology
->subslice_offset
],
1148 uint32_t n_subslices
= 0;
1149 for (int s
= 0; s
< topology
->max_slices
; s
++) {
1150 if ((devinfo
->slice_masks
& (1 << s
)) == 0)
1153 for (int b
= 0; b
< devinfo
->subslice_slice_stride
; b
++) {
1154 devinfo
->num_subslices
[s
] +=
1155 __builtin_popcount(devinfo
->subslice_masks
[s
* devinfo
->subslice_slice_stride
+ b
]);
1157 n_subslices
+= devinfo
->num_subslices
[s
];
1159 assert(n_subslices
> 0);
1161 if (devinfo
->gen
== 11) {
1162 /* On ICL we only have one slice */
1163 assert(devinfo
->slice_masks
== 1);
1165 /* Count the number of subslices on each pixel pipe. Assume that
1166 * subslices 0-3 are on pixel pipe 0, and 4-7 are on pixel pipe 1.
1168 unsigned subslices
= devinfo
->subslice_masks
[0];
1170 while (subslices
> 0) {
1172 devinfo
->ppipe_subslices
[ss
>= 4 ? 1 : 0] += 1;
1178 uint32_t eu_mask_len
=
1179 topology
->eu_stride
* topology
->max_subslices
* topology
->max_slices
;
1180 assert(sizeof(devinfo
->eu_masks
) >= eu_mask_len
);
1181 memcpy(devinfo
->eu_masks
, &topology
->data
[topology
->eu_offset
], eu_mask_len
);
1184 for (int b
= 0; b
< eu_mask_len
; b
++)
1185 n_eus
+= __builtin_popcount(devinfo
->eu_masks
[b
]);
1187 devinfo
->num_eu_per_subslice
= DIV_ROUND_UP(n_eus
, n_subslices
);
1191 update_from_masks(struct gen_device_info
*devinfo
, uint32_t slice_mask
,
1192 uint32_t subslice_mask
, uint32_t n_eus
)
1194 struct drm_i915_query_topology_info
*topology
;
1196 assert((slice_mask
& 0xff) == slice_mask
);
1198 size_t data_length
= 100;
1200 topology
= calloc(1, sizeof(*topology
) + data_length
);
1204 topology
->max_slices
= util_last_bit(slice_mask
);
1205 topology
->max_subslices
= util_last_bit(subslice_mask
);
1207 topology
->subslice_offset
= DIV_ROUND_UP(topology
->max_slices
, 8);
1208 topology
->subslice_stride
= DIV_ROUND_UP(topology
->max_subslices
, 8);
1210 uint32_t n_subslices
= __builtin_popcount(slice_mask
) *
1211 __builtin_popcount(subslice_mask
);
1212 uint32_t num_eu_per_subslice
= DIV_ROUND_UP(n_eus
, n_subslices
);
1213 uint32_t eu_mask
= (1U << num_eu_per_subslice
) - 1;
1215 topology
->eu_offset
= topology
->subslice_offset
+
1216 DIV_ROUND_UP(topology
->max_subslices
, 8);
1217 topology
->eu_stride
= DIV_ROUND_UP(num_eu_per_subslice
, 8);
1219 /* Set slice mask in topology */
1220 for (int b
= 0; b
< topology
->subslice_offset
; b
++)
1221 topology
->data
[b
] = (slice_mask
>> (b
* 8)) & 0xff;
1223 for (int s
= 0; s
< topology
->max_slices
; s
++) {
1225 /* Set subslice mask in topology */
1226 for (int b
= 0; b
< topology
->subslice_stride
; b
++) {
1227 int subslice_offset
= topology
->subslice_offset
+
1228 s
* topology
->subslice_stride
+ b
;
1230 topology
->data
[subslice_offset
] = (subslice_mask
>> (b
* 8)) & 0xff;
1233 /* Set eu mask in topology */
1234 for (int ss
= 0; ss
< topology
->max_subslices
; ss
++) {
1235 for (int b
= 0; b
< topology
->eu_stride
; b
++) {
1236 int eu_offset
= topology
->eu_offset
+
1237 (s
* topology
->max_subslices
+ ss
) * topology
->eu_stride
+ b
;
1239 topology
->data
[eu_offset
] = (eu_mask
>> (b
* 8)) & 0xff;
1244 update_from_topology(devinfo
, topology
);
1251 getparam(int fd
, uint32_t param
, int *value
)
1255 struct drm_i915_getparam gp
= {
1260 int ret
= gen_ioctl(fd
, DRM_IOCTL_I915_GETPARAM
, &gp
);
1269 gen_get_device_info_from_pci_id(int pci_id
,
1270 struct gen_device_info
*devinfo
)
1274 #define CHIPSET(id, family, name) \
1275 case id: *devinfo = gen_device_info_##family; break;
1276 #include "pci_ids/i965_pci_ids.h"
1277 #include "pci_ids/iris_pci_ids.h"
1279 fprintf(stderr
, "Driver does not support the 0x%x PCI ID.\n", pci_id
);
1283 fill_masks(devinfo
);
1285 /* From the Skylake PRM, 3DSTATE_PS::Scratch Space Base Pointer:
1287 * "Scratch Space per slice is computed based on 4 sub-slices. SW must
1288 * allocate scratch space enough so that each slice has 4 slices allowed."
1290 * The equivalent internal documentation says that this programming note
1291 * applies to all Gen9+ platforms.
1293 * The hardware typically calculates the scratch space pointer by taking
1294 * the base address, and adding per-thread-scratch-space * thread ID.
1295 * Extra padding can be necessary depending how the thread IDs are
1296 * calculated for a particular shader stage.
1299 switch(devinfo
->gen
) {
1302 devinfo
->max_wm_threads
= 64 /* threads-per-PSD */
1303 * devinfo
->num_slices
1304 * 4; /* effective subslices per slice */
1308 devinfo
->max_wm_threads
= 128 /* threads-per-PSD */
1309 * devinfo
->num_slices
1310 * 8; /* subslices per slice */
1313 assert(devinfo
->gen
< 9);
1317 assert(devinfo
->num_slices
<= ARRAY_SIZE(devinfo
->num_subslices
));
1319 devinfo
->chipset_id
= pci_id
;
1324 gen_get_device_name(int devid
)
1328 #define CHIPSET(id, family, name) case id: return name;
1329 #include "pci_ids/i965_pci_ids.h"
1330 #include "pci_ids/iris_pci_ids.h"
1337 * for gen8/gen9, SLICE_MASK/SUBSLICE_MASK can be used to compute the topology
1341 getparam_topology(struct gen_device_info
*devinfo
, int fd
)
1344 if (!getparam(fd
, I915_PARAM_SLICE_MASK
, &slice_mask
))
1348 if (!getparam(fd
, I915_PARAM_EU_TOTAL
, &n_eus
))
1351 int subslice_mask
= 0;
1352 if (!getparam(fd
, I915_PARAM_SUBSLICE_MASK
, &subslice_mask
))
1355 return update_from_masks(devinfo
, slice_mask
, subslice_mask
, n_eus
);
1359 * preferred API for updating the topology in devinfo (kernel 4.17+)
1362 query_topology(struct gen_device_info
*devinfo
, int fd
)
1364 struct drm_i915_query_item item
= {
1365 .query_id
= DRM_I915_QUERY_TOPOLOGY_INFO
,
1367 struct drm_i915_query query
= {
1369 .items_ptr
= (uintptr_t) &item
,
1372 if (gen_ioctl(fd
, DRM_IOCTL_I915_QUERY
, &query
))
1375 if (item
.length
< 0)
1378 struct drm_i915_query_topology_info
*topo_info
=
1379 (struct drm_i915_query_topology_info
*) calloc(1, item
.length
);
1380 item
.data_ptr
= (uintptr_t) topo_info
;
1382 if (gen_ioctl(fd
, DRM_IOCTL_I915_QUERY
, &query
) ||
1386 update_from_topology(devinfo
, topo_info
);
1395 gen_get_device_info_from_fd(int fd
, struct gen_device_info
*devinfo
)
1397 int devid
= get_pci_device_id_override();
1399 if (!gen_get_device_info_from_pci_id(devid
, devinfo
))
1401 devinfo
->no_hw
= true;
1403 /* query the device id */
1404 if (!getparam(fd
, I915_PARAM_CHIPSET_ID
, &devid
))
1406 if (!gen_get_device_info_from_pci_id(devid
, devinfo
))
1408 devinfo
->no_hw
= false;
1411 /* remaining initializion queries the kernel for device info */
1415 int timestamp_frequency
;
1416 if (getparam(fd
, I915_PARAM_CS_TIMESTAMP_FREQUENCY
,
1417 ×tamp_frequency
))
1418 devinfo
->timestamp_frequency
= timestamp_frequency
;
1419 else if (devinfo
->gen
>= 10)
1420 /* gen10 and later requires the timestamp_frequency to be updated */
1423 if (!getparam(fd
, I915_PARAM_REVISION
, &devinfo
->revision
))
1426 if (!query_topology(devinfo
, fd
)) {
1427 if (devinfo
->gen
>= 10) {
1428 /* topology uAPI required for CNL+ (kernel 4.17+) */
1432 /* else use the kernel 4.13+ api for gen8+. For older kernels, topology
1433 * will be wrong, affecting GPU metrics. In this case, fail silently.
1435 getparam_topology(devinfo
, fd
);