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
)
74 for (unsigned i
= 0; i
< ARRAY_SIZE(name_map
); i
++) {
75 if (!strcmp(name_map
[i
].name
, name
))
76 return name_map
[i
].pci_id
;
79 fprintf(stderr
, "Unknown platform '%s'. Supported names: %s",
80 name
, name_map
[0].name
);
81 for (unsigned i
= 1; i
< ARRAY_SIZE(name_map
); i
++)
82 fprintf(stderr
, ", %s", name_map
[i
].name
);
83 fprintf(stderr
, "\n");
89 * Get the overridden PCI ID for the device. This is set with the
90 * INTEL_DEVID_OVERRIDE environment variable.
92 * Returns -1 if the override is not set.
95 get_pci_device_id_override(void)
97 if (geteuid() == getuid()) {
98 const char *devid_override
= getenv("INTEL_DEVID_OVERRIDE");
100 const int id
= gen_device_name_to_pci_device_id(devid_override
);
101 return id
>= 0 ? id
: strtol(devid_override
, NULL
, 0);
108 static const struct gen_device_info gen_device_info_i965
= {
110 .has_negative_rhw_bug
= true,
112 .num_subslices
= { 1, },
113 .num_eu_per_subslice
= 8,
114 .num_thread_per_eu
= 4,
115 .max_vs_threads
= 16,
117 .max_wm_threads
= 8 * 4,
121 .timestamp_frequency
= 12500000,
125 static const struct gen_device_info gen_device_info_g4x
= {
129 .has_surface_tile_offset
= true,
132 .num_subslices
= { 1, },
133 .num_eu_per_subslice
= 10,
134 .num_thread_per_eu
= 5,
135 .max_vs_threads
= 32,
137 .max_wm_threads
= 10 * 5,
141 .timestamp_frequency
= 12500000,
145 static const struct gen_device_info gen_device_info_ilk
= {
149 .has_surface_tile_offset
= true,
151 .num_subslices
= { 1, },
152 .num_eu_per_subslice
= 12,
153 .num_thread_per_eu
= 6,
154 .max_vs_threads
= 72,
155 .max_gs_threads
= 32,
156 .max_wm_threads
= 12 * 6,
160 .timestamp_frequency
= 12500000,
164 static const struct gen_device_info gen_device_info_snb_gt1
= {
167 .has_hiz_and_separate_stencil
= true,
170 .has_surface_tile_offset
= true,
171 .needs_unlit_centroid_workaround
= true,
173 .num_subslices
= { 1, },
174 .num_eu_per_subslice
= 6,
175 .num_thread_per_eu
= 6, /* Not confirmed */
176 .max_vs_threads
= 24,
177 .max_gs_threads
= 21, /* conservative; 24 if rendering disabled. */
178 .max_wm_threads
= 40,
182 [MESA_SHADER_VERTEX
] = 24,
185 [MESA_SHADER_VERTEX
] = 256,
186 [MESA_SHADER_GEOMETRY
] = 256,
189 .timestamp_frequency
= 12500000,
193 static const struct gen_device_info gen_device_info_snb_gt2
= {
196 .has_hiz_and_separate_stencil
= true,
199 .has_surface_tile_offset
= true,
200 .needs_unlit_centroid_workaround
= true,
202 .num_subslices
= { 1, },
203 .num_eu_per_subslice
= 12,
204 .num_thread_per_eu
= 6, /* Not confirmed */
205 .max_vs_threads
= 60,
206 .max_gs_threads
= 60,
207 .max_wm_threads
= 80,
211 [MESA_SHADER_VERTEX
] = 24,
214 [MESA_SHADER_VERTEX
] = 256,
215 [MESA_SHADER_GEOMETRY
] = 256,
218 .timestamp_frequency
= 12500000,
222 #define GEN7_FEATURES \
224 .has_hiz_and_separate_stencil = true, \
225 .must_use_separate_stencil = true, \
228 .has_64bit_float = true, \
229 .has_surface_tile_offset = true, \
230 .timestamp_frequency = 12500000
232 static const struct gen_device_info gen_device_info_ivb_gt1
= {
233 GEN7_FEATURES
, .is_ivybridge
= true, .gt
= 1,
235 .num_subslices
= { 1, },
236 .num_eu_per_subslice
= 6,
237 .num_thread_per_eu
= 6,
239 .max_vs_threads
= 36,
240 .max_tcs_threads
= 36,
241 .max_tes_threads
= 36,
242 .max_gs_threads
= 36,
243 .max_wm_threads
= 48,
244 .max_cs_threads
= 36,
248 [MESA_SHADER_VERTEX
] = 32,
249 [MESA_SHADER_TESS_EVAL
] = 10,
252 [MESA_SHADER_VERTEX
] = 512,
253 [MESA_SHADER_TESS_CTRL
] = 32,
254 [MESA_SHADER_TESS_EVAL
] = 288,
255 [MESA_SHADER_GEOMETRY
] = 192,
261 static const struct gen_device_info gen_device_info_ivb_gt2
= {
262 GEN7_FEATURES
, .is_ivybridge
= true, .gt
= 2,
264 .num_subslices
= { 1, },
265 .num_eu_per_subslice
= 12,
266 .num_thread_per_eu
= 8, /* Not sure why this isn't a multiple of
267 * @max_wm_threads ... */
269 .max_vs_threads
= 128,
270 .max_tcs_threads
= 128,
271 .max_tes_threads
= 128,
272 .max_gs_threads
= 128,
273 .max_wm_threads
= 172,
274 .max_cs_threads
= 64,
278 [MESA_SHADER_VERTEX
] = 32,
279 [MESA_SHADER_TESS_EVAL
] = 10,
282 [MESA_SHADER_VERTEX
] = 704,
283 [MESA_SHADER_TESS_CTRL
] = 64,
284 [MESA_SHADER_TESS_EVAL
] = 448,
285 [MESA_SHADER_GEOMETRY
] = 320,
291 static const struct gen_device_info gen_device_info_byt
= {
292 GEN7_FEATURES
, .is_baytrail
= true, .gt
= 1,
294 .num_subslices
= { 1, },
295 .num_eu_per_subslice
= 4,
296 .num_thread_per_eu
= 8,
299 .max_vs_threads
= 36,
300 .max_tcs_threads
= 36,
301 .max_tes_threads
= 36,
302 .max_gs_threads
= 36,
303 .max_wm_threads
= 48,
304 .max_cs_threads
= 32,
308 [MESA_SHADER_VERTEX
] = 32,
309 [MESA_SHADER_TESS_EVAL
] = 10,
312 [MESA_SHADER_VERTEX
] = 512,
313 [MESA_SHADER_TESS_CTRL
] = 32,
314 [MESA_SHADER_TESS_EVAL
] = 288,
315 [MESA_SHADER_GEOMETRY
] = 192,
321 #define HSW_FEATURES \
323 .is_haswell = true, \
324 .supports_simd16_3src = true, \
325 .has_resource_streamer = true
327 static const struct gen_device_info gen_device_info_hsw_gt1
= {
328 HSW_FEATURES
, .gt
= 1,
330 .num_subslices
= { 1, },
331 .num_eu_per_subslice
= 10,
332 .num_thread_per_eu
= 7,
334 .max_vs_threads
= 70,
335 .max_tcs_threads
= 70,
336 .max_tes_threads
= 70,
337 .max_gs_threads
= 70,
338 .max_wm_threads
= 102,
339 .max_cs_threads
= 70,
343 [MESA_SHADER_VERTEX
] = 32,
344 [MESA_SHADER_TESS_EVAL
] = 10,
347 [MESA_SHADER_VERTEX
] = 640,
348 [MESA_SHADER_TESS_CTRL
] = 64,
349 [MESA_SHADER_TESS_EVAL
] = 384,
350 [MESA_SHADER_GEOMETRY
] = 256,
356 static const struct gen_device_info gen_device_info_hsw_gt2
= {
357 HSW_FEATURES
, .gt
= 2,
359 .num_subslices
= { 2, },
360 .num_eu_per_subslice
= 10,
361 .num_thread_per_eu
= 7,
363 .max_vs_threads
= 280,
364 .max_tcs_threads
= 256,
365 .max_tes_threads
= 280,
366 .max_gs_threads
= 256,
367 .max_wm_threads
= 204,
368 .max_cs_threads
= 70,
372 [MESA_SHADER_VERTEX
] = 64,
373 [MESA_SHADER_TESS_EVAL
] = 10,
376 [MESA_SHADER_VERTEX
] = 1664,
377 [MESA_SHADER_TESS_CTRL
] = 128,
378 [MESA_SHADER_TESS_EVAL
] = 960,
379 [MESA_SHADER_GEOMETRY
] = 640,
385 static const struct gen_device_info gen_device_info_hsw_gt3
= {
386 HSW_FEATURES
, .gt
= 3,
388 .num_subslices
= { 2, },
389 .num_eu_per_subslice
= 10,
390 .num_thread_per_eu
= 7,
392 .max_vs_threads
= 280,
393 .max_tcs_threads
= 256,
394 .max_tes_threads
= 280,
395 .max_gs_threads
= 256,
396 .max_wm_threads
= 408,
397 .max_cs_threads
= 70,
401 [MESA_SHADER_VERTEX
] = 64,
402 [MESA_SHADER_TESS_EVAL
] = 10,
405 [MESA_SHADER_VERTEX
] = 1664,
406 [MESA_SHADER_TESS_CTRL
] = 128,
407 [MESA_SHADER_TESS_EVAL
] = 960,
408 [MESA_SHADER_GEOMETRY
] = 640,
414 /* It's unclear how well supported sampling from the hiz buffer is on GEN8,
415 * so keep things conservative for now and set has_sample_with_hiz = false.
417 #define GEN8_FEATURES \
419 .has_hiz_and_separate_stencil = true, \
420 .has_resource_streamer = true, \
421 .must_use_separate_stencil = true, \
423 .has_sample_with_hiz = false, \
425 .has_integer_dword_mul = true, \
426 .has_64bit_float = true, \
427 .has_64bit_int = true, \
428 .supports_simd16_3src = true, \
429 .has_surface_tile_offset = true, \
430 .num_thread_per_eu = 7, \
431 .max_vs_threads = 504, \
432 .max_tcs_threads = 504, \
433 .max_tes_threads = 504, \
434 .max_gs_threads = 504, \
435 .max_wm_threads = 384, \
436 .timestamp_frequency = 12500000
438 static const struct gen_device_info gen_device_info_bdw_gt1
= {
439 GEN8_FEATURES
, .gt
= 1,
440 .is_broadwell
= true,
442 .num_subslices
= { 2, },
443 .num_eu_per_subslice
= 6,
445 .max_cs_threads
= 42,
449 [MESA_SHADER_VERTEX
] = 64,
450 [MESA_SHADER_TESS_EVAL
] = 34,
453 [MESA_SHADER_VERTEX
] = 2560,
454 [MESA_SHADER_TESS_CTRL
] = 504,
455 [MESA_SHADER_TESS_EVAL
] = 1536,
456 /* Reduced from 960, seems to be similar to the bug on Gen9 GT1. */
457 [MESA_SHADER_GEOMETRY
] = 690,
463 static const struct gen_device_info gen_device_info_bdw_gt2
= {
464 GEN8_FEATURES
, .gt
= 2,
465 .is_broadwell
= true,
467 .num_subslices
= { 3, },
468 .num_eu_per_subslice
= 8,
470 .max_cs_threads
= 56,
474 [MESA_SHADER_VERTEX
] = 64,
475 [MESA_SHADER_TESS_EVAL
] = 34,
478 [MESA_SHADER_VERTEX
] = 2560,
479 [MESA_SHADER_TESS_CTRL
] = 504,
480 [MESA_SHADER_TESS_EVAL
] = 1536,
481 [MESA_SHADER_GEOMETRY
] = 960,
487 static const struct gen_device_info gen_device_info_bdw_gt3
= {
488 GEN8_FEATURES
, .gt
= 3,
489 .is_broadwell
= true,
491 .num_subslices
= { 3, 3, },
492 .num_eu_per_subslice
= 8,
494 .max_cs_threads
= 56,
498 [MESA_SHADER_VERTEX
] = 64,
499 [MESA_SHADER_TESS_EVAL
] = 34,
502 [MESA_SHADER_VERTEX
] = 2560,
503 [MESA_SHADER_TESS_CTRL
] = 504,
504 [MESA_SHADER_TESS_EVAL
] = 1536,
505 [MESA_SHADER_GEOMETRY
] = 960,
511 static const struct gen_device_info gen_device_info_chv
= {
512 GEN8_FEATURES
, .is_cherryview
= 1, .gt
= 1,
514 .has_integer_dword_mul
= false,
516 .num_subslices
= { 2, },
517 .num_eu_per_subslice
= 8,
519 .max_vs_threads
= 80,
520 .max_tcs_threads
= 80,
521 .max_tes_threads
= 80,
522 .max_gs_threads
= 80,
523 .max_wm_threads
= 128,
524 .max_cs_threads
= 6 * 7,
528 [MESA_SHADER_VERTEX
] = 34,
529 [MESA_SHADER_TESS_EVAL
] = 34,
532 [MESA_SHADER_VERTEX
] = 640,
533 [MESA_SHADER_TESS_CTRL
] = 80,
534 [MESA_SHADER_TESS_EVAL
] = 384,
535 [MESA_SHADER_GEOMETRY
] = 256,
541 #define GEN9_HW_INFO \
543 .max_vs_threads = 336, \
544 .max_gs_threads = 336, \
545 .max_tcs_threads = 336, \
546 .max_tes_threads = 336, \
547 .max_cs_threads = 56, \
548 .timestamp_frequency = 12000000, \
552 [MESA_SHADER_VERTEX] = 64, \
553 [MESA_SHADER_TESS_EVAL] = 34, \
556 [MESA_SHADER_VERTEX] = 1856, \
557 [MESA_SHADER_TESS_CTRL] = 672, \
558 [MESA_SHADER_TESS_EVAL] = 1120, \
559 [MESA_SHADER_GEOMETRY] = 640, \
563 #define GEN9_LP_FEATURES \
566 .has_integer_dword_mul = false, \
569 .has_sample_with_hiz = true, \
571 .num_thread_per_eu = 6, \
572 .max_vs_threads = 112, \
573 .max_tcs_threads = 112, \
574 .max_tes_threads = 112, \
575 .max_gs_threads = 112, \
576 .max_cs_threads = 6 * 6, \
577 .timestamp_frequency = 19200000, \
581 [MESA_SHADER_VERTEX] = 34, \
582 [MESA_SHADER_TESS_EVAL] = 34, \
585 [MESA_SHADER_VERTEX] = 704, \
586 [MESA_SHADER_TESS_CTRL] = 256, \
587 [MESA_SHADER_TESS_EVAL] = 416, \
588 [MESA_SHADER_GEOMETRY] = 256, \
592 #define GEN9_LP_FEATURES_3X6 \
594 .num_subslices = { 3, }, \
595 .num_eu_per_subslice = 6
597 #define GEN9_LP_FEATURES_2X6 \
599 .num_subslices = { 2, }, \
600 .num_eu_per_subslice = 6, \
601 .max_vs_threads = 56, \
602 .max_tcs_threads = 56, \
603 .max_tes_threads = 56, \
604 .max_gs_threads = 56, \
605 .max_cs_threads = 6 * 6, \
609 [MESA_SHADER_VERTEX] = 34, \
610 [MESA_SHADER_TESS_EVAL] = 34, \
613 [MESA_SHADER_VERTEX] = 352, \
614 [MESA_SHADER_TESS_CTRL] = 128, \
615 [MESA_SHADER_TESS_EVAL] = 208, \
616 [MESA_SHADER_GEOMETRY] = 128, \
620 #define GEN9_FEATURES \
623 .has_sample_with_hiz = true
625 static const struct gen_device_info gen_device_info_skl_gt1
= {
626 GEN9_FEATURES
, .gt
= 1,
629 .num_subslices
= { 2, },
630 .num_eu_per_subslice
= 6,
633 /* GT1 seems to have a bug in the top of the pipe (VF/VS?) fixed functions
634 * leading to some vertices to go missing if we use too much URB.
636 .urb
.max_entries
[MESA_SHADER_VERTEX
] = 928,
640 static const struct gen_device_info gen_device_info_skl_gt2
= {
641 GEN9_FEATURES
, .gt
= 2,
644 .num_subslices
= { 3, },
645 .num_eu_per_subslice
= 8,
650 static const struct gen_device_info gen_device_info_skl_gt3
= {
651 GEN9_FEATURES
, .gt
= 3,
654 .num_subslices
= { 3, 3, },
655 .num_eu_per_subslice
= 8,
660 static const struct gen_device_info gen_device_info_skl_gt4
= {
661 GEN9_FEATURES
, .gt
= 4,
664 .num_subslices
= { 3, 3, 3, },
665 .num_eu_per_subslice
= 8,
667 /* From the "L3 Allocation and Programming" documentation:
669 * "URB is limited to 1008KB due to programming restrictions. This is not a
670 * restriction of the L3 implementation, but of the FF and other clients.
671 * Therefore, in a GT4 implementation it is possible for the programmed
672 * allocation of the L3 data array to provide 3*384KB=1152KB for URB, but
673 * only 1008KB of this will be used."
675 .urb
.size
= 1008 / 3,
679 static const struct gen_device_info gen_device_info_bxt
= {
680 GEN9_LP_FEATURES_3X6
,
686 static const struct gen_device_info gen_device_info_bxt_2x6
= {
687 GEN9_LP_FEATURES_2X6
,
693 * Note: for all KBL SKUs, the PRM says SKL for GS entries, not SKL+.
694 * There's no KBL entry. Using the default SKL (GEN9) GS entries value.
697 static const struct gen_device_info gen_device_info_kbl_gt1
= {
702 .max_cs_threads
= 7 * 6,
705 .num_subslices
= { 2, },
706 .num_eu_per_subslice
= 6,
708 /* GT1 seems to have a bug in the top of the pipe (VF/VS?) fixed functions
709 * leading to some vertices to go missing if we use too much URB.
711 .urb
.max_entries
[MESA_SHADER_VERTEX
] = 928,
715 static const struct gen_device_info gen_device_info_kbl_gt1_5
= {
720 .max_cs_threads
= 7 * 6,
722 .num_subslices
= { 3, },
723 .num_eu_per_subslice
= 6,
728 static const struct gen_device_info gen_device_info_kbl_gt2
= {
734 .num_subslices
= { 3, },
735 .num_eu_per_subslice
= 8,
740 static const struct gen_device_info gen_device_info_kbl_gt3
= {
746 .num_subslices
= { 3, 3, },
747 .num_eu_per_subslice
= 8,
752 static const struct gen_device_info gen_device_info_kbl_gt4
= {
758 * From the "L3 Allocation and Programming" documentation:
760 * "URB is limited to 1008KB due to programming restrictions. This
761 * is not a restriction of the L3 implementation, but of the FF and
762 * other clients. Therefore, in a GT4 implementation it is
763 * possible for the programmed allocation of the L3 data array to
764 * provide 3*384KB=1152KB for URB, but only 1008KB of this
767 .urb
.size
= 1008 / 3,
769 .num_subslices
= { 3, 3, 3, },
770 .num_eu_per_subslice
= 8,
775 static const struct gen_device_info gen_device_info_glk
= {
776 GEN9_LP_FEATURES_3X6
,
777 .is_geminilake
= true,
782 static const struct gen_device_info gen_device_info_glk_2x6
= {
783 GEN9_LP_FEATURES_2X6
,
784 .is_geminilake
= true,
789 static const struct gen_device_info gen_device_info_cfl_gt1
= {
791 .is_coffeelake
= true,
795 .num_subslices
= { 2, },
796 .num_eu_per_subslice
= 6,
799 /* GT1 seems to have a bug in the top of the pipe (VF/VS?) fixed functions
800 * leading to some vertices to go missing if we use too much URB.
802 .urb
.max_entries
[MESA_SHADER_VERTEX
] = 928,
805 static const struct gen_device_info gen_device_info_cfl_gt2
= {
807 .is_coffeelake
= true,
811 .num_subslices
= { 3, },
812 .num_eu_per_subslice
= 8,
817 static const struct gen_device_info gen_device_info_cfl_gt3
= {
819 .is_coffeelake
= true,
823 .num_subslices
= { 3, 3, },
824 .num_eu_per_subslice
= 8,
829 #define GEN10_HW_INFO \
831 .num_thread_per_eu = 7, \
832 .max_vs_threads = 728, \
833 .max_gs_threads = 432, \
834 .max_tcs_threads = 432, \
835 .max_tes_threads = 624, \
836 .max_cs_threads = 56, \
837 .timestamp_frequency = 19200000, \
841 [MESA_SHADER_VERTEX] = 64, \
842 [MESA_SHADER_TESS_EVAL] = 34, \
845 [MESA_SHADER_VERTEX] = 3936, \
846 [MESA_SHADER_TESS_CTRL] = 896, \
847 [MESA_SHADER_TESS_EVAL] = 2064, \
848 [MESA_SHADER_GEOMETRY] = 832, \
852 #define subslices(args...) { args, }
854 #define GEN10_FEATURES(_gt, _slices, _subslices, _l3) \
857 .has_sample_with_hiz = true, \
859 .num_slices = _slices, \
860 .num_subslices = _subslices, \
861 .num_eu_per_subslice = 8, \
864 static const struct gen_device_info gen_device_info_cnl_gt0_5
= {
866 GEN10_FEATURES(1, 1, subslices(2), 2),
867 .is_cannonlake
= true,
871 static const struct gen_device_info gen_device_info_cnl_gt1
= {
873 GEN10_FEATURES(1, 1, subslices(3), 3),
874 .is_cannonlake
= true,
878 static const struct gen_device_info gen_device_info_cnl_gt1_5
= {
880 GEN10_FEATURES(1, 2, subslices(2, 2), 6),
881 .is_cannonlake
= true,
885 static const struct gen_device_info gen_device_info_cnl_gt2
= {
887 GEN10_FEATURES(2, 2, subslices(3, 2), 6),
888 .is_cannonlake
= true,
892 #define GEN11_HW_INFO \
895 .max_vs_threads = 364, \
896 .max_gs_threads = 224, \
897 .max_tcs_threads = 224, \
898 .max_tes_threads = 364, \
901 #define GEN11_FEATURES(_gt, _slices, _subslices, _l3) \
904 .has_64bit_float = false, \
905 .has_64bit_int = false, \
906 .has_integer_dword_mul = false, \
907 .has_sample_with_hiz = false, \
908 .gt = _gt, .num_slices = _slices, .l3_banks = _l3, \
909 .num_subslices = _subslices, \
910 .num_eu_per_subslice = 8
912 #define GEN11_URB_MIN_MAX_ENTRIES \
914 [MESA_SHADER_VERTEX] = 64, \
915 [MESA_SHADER_TESS_EVAL] = 34, \
918 [MESA_SHADER_VERTEX] = 2384, \
919 [MESA_SHADER_TESS_CTRL] = 1032, \
920 [MESA_SHADER_TESS_EVAL] = 2384, \
921 [MESA_SHADER_GEOMETRY] = 1032, \
924 static const struct gen_device_info gen_device_info_icl_gt2
= {
925 GEN11_FEATURES(2, 1, subslices(8), 8),
928 GEN11_URB_MIN_MAX_ENTRIES
,
933 static const struct gen_device_info gen_device_info_icl_gt1_5
= {
934 GEN11_FEATURES(1, 1, subslices(6), 6),
937 GEN11_URB_MIN_MAX_ENTRIES
,
942 static const struct gen_device_info gen_device_info_icl_gt1
= {
943 GEN11_FEATURES(1, 1, subslices(4), 6),
946 GEN11_URB_MIN_MAX_ENTRIES
,
951 static const struct gen_device_info gen_device_info_icl_gt0_5
= {
952 GEN11_FEATURES(1, 1, subslices(1), 6),
955 GEN11_URB_MIN_MAX_ENTRIES
,
960 static const struct gen_device_info gen_device_info_ehl_7
= {
961 GEN11_FEATURES(1, 1, subslices(4), 4),
962 .is_elkhartlake
= true,
966 [MESA_SHADER_VERTEX
] = 64,
967 [MESA_SHADER_TESS_EVAL
] = 34,
970 [MESA_SHADER_VERTEX
] = 2384,
971 [MESA_SHADER_TESS_CTRL
] = 1032,
972 [MESA_SHADER_TESS_EVAL
] = 2384,
973 [MESA_SHADER_GEOMETRY
] = 1032,
976 .disable_ccs_repack
= true,
980 static const struct gen_device_info gen_device_info_ehl_6
= {
981 GEN11_FEATURES(1, 1, subslices(4), 4),
982 .is_elkhartlake
= true,
986 [MESA_SHADER_VERTEX
] = 64,
987 [MESA_SHADER_TESS_EVAL
] = 34,
990 [MESA_SHADER_VERTEX
] = 2384,
991 [MESA_SHADER_TESS_CTRL
] = 1032,
992 [MESA_SHADER_TESS_EVAL
] = 2384,
993 [MESA_SHADER_GEOMETRY
] = 1032,
996 .disable_ccs_repack
= true,
997 .num_eu_per_subslice
= 6,
1001 static const struct gen_device_info gen_device_info_ehl_5
= {
1002 GEN11_FEATURES(1, 1, subslices(4), 4),
1003 .is_elkhartlake
= true,
1007 [MESA_SHADER_VERTEX
] = 64,
1008 [MESA_SHADER_TESS_EVAL
] = 34,
1011 [MESA_SHADER_VERTEX
] = 2384,
1012 [MESA_SHADER_TESS_CTRL
] = 1032,
1013 [MESA_SHADER_TESS_EVAL
] = 2384,
1014 [MESA_SHADER_GEOMETRY
] = 1032,
1017 .disable_ccs_repack
= true,
1018 .num_eu_per_subslice
= 4,
1022 static const struct gen_device_info gen_device_info_ehl_4
= {
1023 GEN11_FEATURES(1, 1, subslices(2), 4),
1024 .is_elkhartlake
= true,
1028 [MESA_SHADER_VERTEX
] = 64,
1029 [MESA_SHADER_TESS_EVAL
] = 34,
1032 [MESA_SHADER_VERTEX
] = 2384,
1033 [MESA_SHADER_TESS_CTRL
] = 1032,
1034 [MESA_SHADER_TESS_EVAL
] = 2384,
1035 [MESA_SHADER_GEOMETRY
] = 1032,
1038 .disable_ccs_repack
= true,
1039 .num_eu_per_subslice
=4,
1043 #define GEN12_URB_MIN_MAX_ENTRIES \
1045 [MESA_SHADER_VERTEX] = 64, \
1046 [MESA_SHADER_TESS_EVAL] = 34, \
1049 [MESA_SHADER_VERTEX] = 3576, \
1050 [MESA_SHADER_TESS_CTRL] = 1548, \
1051 [MESA_SHADER_TESS_EVAL] = 3576, \
1052 [MESA_SHADER_GEOMETRY] = 1548, \
1055 #define GEN12_HW_INFO \
1058 .has_sample_with_hiz = false, \
1059 .has_aux_map = true, \
1060 .max_vs_threads = 546, \
1061 .max_gs_threads = 336, \
1062 .max_tcs_threads = 336, \
1063 .max_tes_threads = 546, \
1064 .max_cs_threads = 112, /* threads per DSS */ \
1066 GEN12_URB_MIN_MAX_ENTRIES, \
1069 #define GEN12_FEATURES(_gt, _slices, _dual_subslices, _l3) \
1072 .has_64bit_float = false, \
1073 .has_64bit_int = false, \
1074 .has_integer_dword_mul = false, \
1075 .gt = _gt, .num_slices = _slices, .l3_banks = _l3, \
1076 .simulator_id = 22, \
1077 .urb.size = (_gt) == 1 ? 512 : 1024, \
1078 .num_subslices = _dual_subslices, \
1079 .num_eu_per_subslice = 16
1081 #define dual_subslices(args...) { args, }
1083 static const struct gen_device_info gen_device_info_tgl_gt1
= {
1084 GEN12_FEATURES(1, 1, dual_subslices(2), 8),
1087 static const struct gen_device_info gen_device_info_tgl_gt2
= {
1088 GEN12_FEATURES(2, 1, dual_subslices(6), 8),
1092 gen_device_info_set_eu_mask(struct gen_device_info
*devinfo
,
1097 unsigned subslice_offset
= slice
* devinfo
->eu_slice_stride
+
1098 subslice
* devinfo
->eu_subslice_stride
;
1100 for (unsigned b_eu
= 0; b_eu
< devinfo
->eu_subslice_stride
; b_eu
++) {
1101 devinfo
->eu_masks
[subslice_offset
+ b_eu
] =
1102 (((1U << devinfo
->num_eu_per_subslice
) - 1) >> (b_eu
* 8)) & 0xff;
1106 /* Generate slice/subslice/eu masks from number of
1107 * slices/subslices/eu_per_subslices in the per generation/gt gen_device_info
1110 * These can be overridden with values reported by the kernel either from
1111 * getparam SLICE_MASK/SUBSLICE_MASK values or from the kernel version 4.17+
1112 * through the i915 query uapi.
1115 fill_masks(struct gen_device_info
*devinfo
)
1117 devinfo
->slice_masks
= (1U << devinfo
->num_slices
) - 1;
1119 /* Subslice masks */
1120 unsigned max_subslices
= 0;
1121 for (int s
= 0; s
< devinfo
->num_slices
; s
++)
1122 max_subslices
= MAX2(devinfo
->num_subslices
[s
], max_subslices
);
1123 devinfo
->subslice_slice_stride
= DIV_ROUND_UP(max_subslices
, 8);
1125 for (int s
= 0; s
< devinfo
->num_slices
; s
++) {
1126 devinfo
->subslice_masks
[s
* devinfo
->subslice_slice_stride
] =
1127 (1U << devinfo
->num_subslices
[s
]) - 1;
1131 devinfo
->eu_subslice_stride
= DIV_ROUND_UP(devinfo
->num_eu_per_subslice
, 8);
1132 devinfo
->eu_slice_stride
= max_subslices
* devinfo
->eu_subslice_stride
;
1134 for (int s
= 0; s
< devinfo
->num_slices
; s
++) {
1135 for (int ss
= 0; ss
< devinfo
->num_subslices
[s
]; ss
++) {
1136 gen_device_info_set_eu_mask(devinfo
, s
, ss
,
1137 (1U << devinfo
->num_eu_per_subslice
) - 1);
1143 reset_masks(struct gen_device_info
*devinfo
)
1145 devinfo
->subslice_slice_stride
= 0;
1146 devinfo
->eu_subslice_stride
= 0;
1147 devinfo
->eu_slice_stride
= 0;
1149 devinfo
->num_slices
= 0;
1150 devinfo
->num_eu_per_subslice
= 0;
1151 memset(devinfo
->num_subslices
, 0, sizeof(devinfo
->num_subslices
));
1153 memset(&devinfo
->slice_masks
, 0, sizeof(devinfo
->slice_masks
));
1154 memset(devinfo
->subslice_masks
, 0, sizeof(devinfo
->subslice_masks
));
1155 memset(devinfo
->eu_masks
, 0, sizeof(devinfo
->eu_masks
));
1156 memset(devinfo
->ppipe_subslices
, 0, sizeof(devinfo
->ppipe_subslices
));
1160 update_from_topology(struct gen_device_info
*devinfo
,
1161 const struct drm_i915_query_topology_info
*topology
)
1163 reset_masks(devinfo
);
1165 devinfo
->subslice_slice_stride
= topology
->subslice_stride
;
1167 devinfo
->eu_subslice_stride
= DIV_ROUND_UP(topology
->max_eus_per_subslice
, 8);
1168 devinfo
->eu_slice_stride
= topology
->max_subslices
* devinfo
->eu_subslice_stride
;
1170 assert(sizeof(devinfo
->slice_masks
) >= DIV_ROUND_UP(topology
->max_slices
, 8));
1171 memcpy(&devinfo
->slice_masks
, topology
->data
, DIV_ROUND_UP(topology
->max_slices
, 8));
1172 devinfo
->num_slices
= __builtin_popcount(devinfo
->slice_masks
);
1174 uint32_t subslice_mask_len
=
1175 topology
->max_slices
* topology
->subslice_stride
;
1176 assert(sizeof(devinfo
->subslice_masks
) >= subslice_mask_len
);
1177 memcpy(devinfo
->subslice_masks
, &topology
->data
[topology
->subslice_offset
],
1180 uint32_t n_subslices
= 0;
1181 for (int s
= 0; s
< topology
->max_slices
; s
++) {
1182 if ((devinfo
->slice_masks
& (1 << s
)) == 0)
1185 for (int b
= 0; b
< devinfo
->subslice_slice_stride
; b
++) {
1186 devinfo
->num_subslices
[s
] +=
1187 __builtin_popcount(devinfo
->subslice_masks
[s
* devinfo
->subslice_slice_stride
+ b
]);
1189 n_subslices
+= devinfo
->num_subslices
[s
];
1191 assert(n_subslices
> 0);
1193 if (devinfo
->gen
== 11) {
1194 /* On ICL we only have one slice */
1195 assert(devinfo
->slice_masks
== 1);
1197 /* Count the number of subslices on each pixel pipe. Assume that
1198 * subslices 0-3 are on pixel pipe 0, and 4-7 are on pixel pipe 1.
1200 unsigned subslices
= devinfo
->subslice_masks
[0];
1202 while (subslices
> 0) {
1204 devinfo
->ppipe_subslices
[ss
>= 4 ? 1 : 0] += 1;
1210 if (devinfo
->gen
== 12 && devinfo
->num_slices
== 1) {
1211 if (n_subslices
>= 6) {
1212 assert(n_subslices
== 6);
1213 devinfo
->l3_banks
= 8;
1214 } else if (n_subslices
> 2) {
1215 devinfo
->l3_banks
= 6;
1217 devinfo
->l3_banks
= 4;
1221 uint32_t eu_mask_len
=
1222 topology
->eu_stride
* topology
->max_subslices
* topology
->max_slices
;
1223 assert(sizeof(devinfo
->eu_masks
) >= eu_mask_len
);
1224 memcpy(devinfo
->eu_masks
, &topology
->data
[topology
->eu_offset
], eu_mask_len
);
1227 for (int b
= 0; b
< eu_mask_len
; b
++)
1228 n_eus
+= __builtin_popcount(devinfo
->eu_masks
[b
]);
1230 devinfo
->num_eu_per_subslice
= DIV_ROUND_UP(n_eus
, n_subslices
);
1234 update_from_masks(struct gen_device_info
*devinfo
, uint32_t slice_mask
,
1235 uint32_t subslice_mask
, uint32_t n_eus
)
1237 struct drm_i915_query_topology_info
*topology
;
1239 assert((slice_mask
& 0xff) == slice_mask
);
1241 size_t data_length
= 100;
1243 topology
= calloc(1, sizeof(*topology
) + data_length
);
1247 topology
->max_slices
= util_last_bit(slice_mask
);
1248 topology
->max_subslices
= util_last_bit(subslice_mask
);
1250 topology
->subslice_offset
= DIV_ROUND_UP(topology
->max_slices
, 8);
1251 topology
->subslice_stride
= DIV_ROUND_UP(topology
->max_subslices
, 8);
1253 uint32_t n_subslices
= __builtin_popcount(slice_mask
) *
1254 __builtin_popcount(subslice_mask
);
1255 uint32_t num_eu_per_subslice
= DIV_ROUND_UP(n_eus
, n_subslices
);
1256 uint32_t eu_mask
= (1U << num_eu_per_subslice
) - 1;
1258 topology
->eu_offset
= topology
->subslice_offset
+
1259 DIV_ROUND_UP(topology
->max_subslices
, 8);
1260 topology
->eu_stride
= DIV_ROUND_UP(num_eu_per_subslice
, 8);
1262 /* Set slice mask in topology */
1263 for (int b
= 0; b
< topology
->subslice_offset
; b
++)
1264 topology
->data
[b
] = (slice_mask
>> (b
* 8)) & 0xff;
1266 for (int s
= 0; s
< topology
->max_slices
; s
++) {
1268 /* Set subslice mask in topology */
1269 for (int b
= 0; b
< topology
->subslice_stride
; b
++) {
1270 int subslice_offset
= topology
->subslice_offset
+
1271 s
* topology
->subslice_stride
+ b
;
1273 topology
->data
[subslice_offset
] = (subslice_mask
>> (b
* 8)) & 0xff;
1276 /* Set eu mask in topology */
1277 for (int ss
= 0; ss
< topology
->max_subslices
; ss
++) {
1278 for (int b
= 0; b
< topology
->eu_stride
; b
++) {
1279 int eu_offset
= topology
->eu_offset
+
1280 (s
* topology
->max_subslices
+ ss
) * topology
->eu_stride
+ b
;
1282 topology
->data
[eu_offset
] = (eu_mask
>> (b
* 8)) & 0xff;
1287 update_from_topology(devinfo
, topology
);
1294 getparam(int fd
, uint32_t param
, int *value
)
1298 struct drm_i915_getparam gp
= {
1303 int ret
= gen_ioctl(fd
, DRM_IOCTL_I915_GETPARAM
, &gp
);
1312 gen_get_device_info_from_pci_id(int pci_id
,
1313 struct gen_device_info
*devinfo
)
1317 #define CHIPSET(id, family, fam_str, name) \
1318 case id: *devinfo = gen_device_info_##family; break;
1319 #include "pci_ids/i965_pci_ids.h"
1320 #include "pci_ids/iris_pci_ids.h"
1322 fprintf(stderr
, "Driver does not support the 0x%x PCI ID.\n", pci_id
);
1326 fill_masks(devinfo
);
1328 /* From the Skylake PRM, 3DSTATE_PS::Scratch Space Base Pointer:
1330 * "Scratch Space per slice is computed based on 4 sub-slices. SW must
1331 * allocate scratch space enough so that each slice has 4 slices allowed."
1333 * The equivalent internal documentation says that this programming note
1334 * applies to all Gen9+ platforms.
1336 * The hardware typically calculates the scratch space pointer by taking
1337 * the base address, and adding per-thread-scratch-space * thread ID.
1338 * Extra padding can be necessary depending how the thread IDs are
1339 * calculated for a particular shader stage.
1342 switch(devinfo
->gen
) {
1345 devinfo
->max_wm_threads
= 64 /* threads-per-PSD */
1346 * devinfo
->num_slices
1347 * 4; /* effective subslices per slice */
1351 devinfo
->max_wm_threads
= 128 /* threads-per-PSD */
1352 * devinfo
->num_slices
1353 * 8; /* subslices per slice */
1356 assert(devinfo
->gen
< 9);
1360 assert(devinfo
->num_slices
<= ARRAY_SIZE(devinfo
->num_subslices
));
1362 devinfo
->chipset_id
= pci_id
;
1367 gen_get_device_name(int devid
)
1371 #define CHIPSET(id, family, fam_str, name) case id: return name " (" fam_str ")"; break;
1372 #include "pci_ids/i965_pci_ids.h"
1373 #include "pci_ids/iris_pci_ids.h"
1380 * for gen8/gen9, SLICE_MASK/SUBSLICE_MASK can be used to compute the topology
1384 getparam_topology(struct gen_device_info
*devinfo
, int fd
)
1387 if (!getparam(fd
, I915_PARAM_SLICE_MASK
, &slice_mask
))
1391 if (!getparam(fd
, I915_PARAM_EU_TOTAL
, &n_eus
))
1394 int subslice_mask
= 0;
1395 if (!getparam(fd
, I915_PARAM_SUBSLICE_MASK
, &subslice_mask
))
1398 return update_from_masks(devinfo
, slice_mask
, subslice_mask
, n_eus
);
1402 * preferred API for updating the topology in devinfo (kernel 4.17+)
1405 query_topology(struct gen_device_info
*devinfo
, int fd
)
1407 struct drm_i915_query_item item
= {
1408 .query_id
= DRM_I915_QUERY_TOPOLOGY_INFO
,
1410 struct drm_i915_query query
= {
1412 .items_ptr
= (uintptr_t) &item
,
1415 if (gen_ioctl(fd
, DRM_IOCTL_I915_QUERY
, &query
))
1418 if (item
.length
< 0)
1421 struct drm_i915_query_topology_info
*topo_info
=
1422 (struct drm_i915_query_topology_info
*) calloc(1, item
.length
);
1423 item
.data_ptr
= (uintptr_t) topo_info
;
1425 if (gen_ioctl(fd
, DRM_IOCTL_I915_QUERY
, &query
) ||
1429 update_from_topology(devinfo
, topo_info
);
1438 gen_get_device_info_from_fd(int fd
, struct gen_device_info
*devinfo
)
1440 int devid
= get_pci_device_id_override();
1442 if (!gen_get_device_info_from_pci_id(devid
, devinfo
))
1444 devinfo
->no_hw
= true;
1446 /* query the device id */
1447 if (!getparam(fd
, I915_PARAM_CHIPSET_ID
, &devid
))
1449 if (!gen_get_device_info_from_pci_id(devid
, devinfo
))
1451 devinfo
->no_hw
= false;
1454 /* remaining initializion queries the kernel for device info */
1458 int timestamp_frequency
;
1459 if (getparam(fd
, I915_PARAM_CS_TIMESTAMP_FREQUENCY
,
1460 ×tamp_frequency
))
1461 devinfo
->timestamp_frequency
= timestamp_frequency
;
1462 else if (devinfo
->gen
>= 10)
1463 /* gen10 and later requires the timestamp_frequency to be updated */
1466 if (!getparam(fd
, I915_PARAM_REVISION
, &devinfo
->revision
))
1467 devinfo
->revision
= 0;
1469 if (!query_topology(devinfo
, fd
)) {
1470 if (devinfo
->gen
>= 10) {
1471 /* topology uAPI required for CNL+ (kernel 4.17+) */
1475 /* else use the kernel 4.13+ api for gen8+. For older kernels, topology
1476 * will be wrong, affecting GPU metrics. In this case, fail silently.
1478 getparam_topology(devinfo
, fd
);