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/macros.h"
34 * Get the PCI ID for the device name.
36 * Returns -1 if the device is not known.
39 gen_device_name_to_pci_device_id(const char *name
)
62 for (unsigned i
= 0; i
< ARRAY_SIZE(name_map
); i
++) {
63 if (!strcmp(name_map
[i
].name
, name
))
64 return name_map
[i
].pci_id
;
71 * Get the overridden PCI ID for the device. This is set with the
72 * INTEL_DEVID_OVERRIDE environment variable.
74 * Returns -1 if the override is not set.
77 gen_get_pci_device_id_override(void)
79 if (geteuid() == getuid()) {
80 const char *devid_override
= getenv("INTEL_DEVID_OVERRIDE");
82 const int id
= gen_device_name_to_pci_device_id(devid_override
);
83 return id
>= 0 ? id
: strtol(devid_override
, NULL
, 0);
90 static const struct gen_device_info gen_device_info_i965
= {
92 .has_negative_rhw_bug
= true,
94 .num_subslices
= { 1, },
95 .num_thread_per_eu
= 4,
98 .max_wm_threads
= 8 * 4,
102 .timestamp_frequency
= 12500000,
105 static const struct gen_device_info gen_device_info_g4x
= {
109 .has_surface_tile_offset
= true,
112 .num_subslices
= { 1, },
113 .num_thread_per_eu
= 5,
114 .max_vs_threads
= 32,
116 .max_wm_threads
= 10 * 5,
120 .timestamp_frequency
= 12500000,
123 static const struct gen_device_info gen_device_info_ilk
= {
127 .has_surface_tile_offset
= true,
129 .num_subslices
= { 1, },
130 .num_thread_per_eu
= 6,
131 .max_vs_threads
= 72,
132 .max_gs_threads
= 32,
133 .max_wm_threads
= 12 * 6,
137 .timestamp_frequency
= 12500000,
140 static const struct gen_device_info gen_device_info_snb_gt1
= {
143 .has_hiz_and_separate_stencil
= true,
146 .has_surface_tile_offset
= true,
147 .needs_unlit_centroid_workaround
= true,
149 .num_subslices
= { 1, },
150 .num_thread_per_eu
= 6, /* Not confirmed */
151 .max_vs_threads
= 24,
152 .max_gs_threads
= 21, /* conservative; 24 if rendering disabled. */
153 .max_wm_threads
= 40,
157 [MESA_SHADER_VERTEX
] = 24,
160 [MESA_SHADER_VERTEX
] = 256,
161 [MESA_SHADER_GEOMETRY
] = 256,
164 .timestamp_frequency
= 12500000,
167 static const struct gen_device_info gen_device_info_snb_gt2
= {
170 .has_hiz_and_separate_stencil
= true,
173 .has_surface_tile_offset
= true,
174 .needs_unlit_centroid_workaround
= true,
176 .num_subslices
= { 1, },
177 .num_thread_per_eu
= 6, /* Not confirmed */
178 .max_vs_threads
= 60,
179 .max_gs_threads
= 60,
180 .max_wm_threads
= 80,
184 [MESA_SHADER_VERTEX
] = 24,
187 [MESA_SHADER_VERTEX
] = 256,
188 [MESA_SHADER_GEOMETRY
] = 256,
191 .timestamp_frequency
= 12500000,
194 #define GEN7_FEATURES \
196 .has_hiz_and_separate_stencil = true, \
197 .must_use_separate_stencil = true, \
200 .has_64bit_types = true, \
201 .has_surface_tile_offset = true, \
202 .timestamp_frequency = 12500000
204 static const struct gen_device_info gen_device_info_ivb_gt1
= {
205 GEN7_FEATURES
, .is_ivybridge
= true, .gt
= 1,
207 .num_subslices
= { 1, },
208 .num_thread_per_eu
= 6,
210 .max_vs_threads
= 36,
211 .max_tcs_threads
= 36,
212 .max_tes_threads
= 36,
213 .max_gs_threads
= 36,
214 .max_wm_threads
= 48,
215 .max_cs_threads
= 36,
219 [MESA_SHADER_VERTEX
] = 32,
220 [MESA_SHADER_TESS_EVAL
] = 10,
223 [MESA_SHADER_VERTEX
] = 512,
224 [MESA_SHADER_TESS_CTRL
] = 32,
225 [MESA_SHADER_TESS_EVAL
] = 288,
226 [MESA_SHADER_GEOMETRY
] = 192,
231 static const struct gen_device_info gen_device_info_ivb_gt2
= {
232 GEN7_FEATURES
, .is_ivybridge
= true, .gt
= 2,
234 .num_subslices
= { 1, },
235 .num_thread_per_eu
= 8, /* Not sure why this isn't a multiple of
236 * @max_wm_threads ... */
238 .max_vs_threads
= 128,
239 .max_tcs_threads
= 128,
240 .max_tes_threads
= 128,
241 .max_gs_threads
= 128,
242 .max_wm_threads
= 172,
243 .max_cs_threads
= 64,
247 [MESA_SHADER_VERTEX
] = 32,
248 [MESA_SHADER_TESS_EVAL
] = 10,
251 [MESA_SHADER_VERTEX
] = 704,
252 [MESA_SHADER_TESS_CTRL
] = 64,
253 [MESA_SHADER_TESS_EVAL
] = 448,
254 [MESA_SHADER_GEOMETRY
] = 320,
259 static const struct gen_device_info gen_device_info_byt
= {
260 GEN7_FEATURES
, .is_baytrail
= true, .gt
= 1,
262 .num_subslices
= { 1, },
263 .num_thread_per_eu
= 8,
266 .max_vs_threads
= 36,
267 .max_tcs_threads
= 36,
268 .max_tes_threads
= 36,
269 .max_gs_threads
= 36,
270 .max_wm_threads
= 48,
271 .max_cs_threads
= 32,
275 [MESA_SHADER_VERTEX
] = 32,
276 [MESA_SHADER_TESS_EVAL
] = 10,
279 [MESA_SHADER_VERTEX
] = 512,
280 [MESA_SHADER_TESS_CTRL
] = 32,
281 [MESA_SHADER_TESS_EVAL
] = 288,
282 [MESA_SHADER_GEOMETRY
] = 192,
287 #define HSW_FEATURES \
289 .is_haswell = true, \
290 .supports_simd16_3src = true, \
291 .has_resource_streamer = true
293 static const struct gen_device_info gen_device_info_hsw_gt1
= {
294 HSW_FEATURES
, .gt
= 1,
296 .num_subslices
= { 1, },
297 .num_thread_per_eu
= 7,
299 .max_vs_threads
= 70,
300 .max_tcs_threads
= 70,
301 .max_tes_threads
= 70,
302 .max_gs_threads
= 70,
303 .max_wm_threads
= 102,
304 .max_cs_threads
= 70,
308 [MESA_SHADER_VERTEX
] = 32,
309 [MESA_SHADER_TESS_EVAL
] = 10,
312 [MESA_SHADER_VERTEX
] = 640,
313 [MESA_SHADER_TESS_CTRL
] = 64,
314 [MESA_SHADER_TESS_EVAL
] = 384,
315 [MESA_SHADER_GEOMETRY
] = 256,
320 static const struct gen_device_info gen_device_info_hsw_gt2
= {
321 HSW_FEATURES
, .gt
= 2,
323 .num_subslices
= { 2, },
324 .num_thread_per_eu
= 7,
326 .max_vs_threads
= 280,
327 .max_tcs_threads
= 256,
328 .max_tes_threads
= 280,
329 .max_gs_threads
= 256,
330 .max_wm_threads
= 204,
331 .max_cs_threads
= 70,
335 [MESA_SHADER_VERTEX
] = 64,
336 [MESA_SHADER_TESS_EVAL
] = 10,
339 [MESA_SHADER_VERTEX
] = 1664,
340 [MESA_SHADER_TESS_CTRL
] = 128,
341 [MESA_SHADER_TESS_EVAL
] = 960,
342 [MESA_SHADER_GEOMETRY
] = 640,
347 static const struct gen_device_info gen_device_info_hsw_gt3
= {
348 HSW_FEATURES
, .gt
= 3,
350 .num_subslices
= { 2, },
351 .num_thread_per_eu
= 7,
353 .max_vs_threads
= 280,
354 .max_tcs_threads
= 256,
355 .max_tes_threads
= 280,
356 .max_gs_threads
= 256,
357 .max_wm_threads
= 408,
358 .max_cs_threads
= 70,
362 [MESA_SHADER_VERTEX
] = 64,
363 [MESA_SHADER_TESS_EVAL
] = 10,
366 [MESA_SHADER_VERTEX
] = 1664,
367 [MESA_SHADER_TESS_CTRL
] = 128,
368 [MESA_SHADER_TESS_EVAL
] = 960,
369 [MESA_SHADER_GEOMETRY
] = 640,
374 /* It's unclear how well supported sampling from the hiz buffer is on GEN8,
375 * so keep things conservative for now and set has_sample_with_hiz = false.
377 #define GEN8_FEATURES \
379 .has_hiz_and_separate_stencil = true, \
380 .has_resource_streamer = true, \
381 .must_use_separate_stencil = true, \
383 .has_sample_with_hiz = false, \
385 .has_integer_dword_mul = true, \
386 .has_64bit_types = true, \
387 .supports_simd16_3src = true, \
388 .has_surface_tile_offset = true, \
389 .max_vs_threads = 504, \
390 .max_tcs_threads = 504, \
391 .max_tes_threads = 504, \
392 .max_gs_threads = 504, \
393 .max_wm_threads = 384, \
394 .timestamp_frequency = 12500000
396 static const struct gen_device_info gen_device_info_bdw_gt1
= {
397 GEN8_FEATURES
, .gt
= 1,
398 .is_broadwell
= true,
400 .num_subslices
= { 2, },
401 .num_thread_per_eu
= 7,
403 .max_cs_threads
= 42,
407 [MESA_SHADER_VERTEX
] = 64,
408 [MESA_SHADER_TESS_EVAL
] = 34,
411 [MESA_SHADER_VERTEX
] = 2560,
412 [MESA_SHADER_TESS_CTRL
] = 504,
413 [MESA_SHADER_TESS_EVAL
] = 1536,
414 [MESA_SHADER_GEOMETRY
] = 960,
419 static const struct gen_device_info gen_device_info_bdw_gt2
= {
420 GEN8_FEATURES
, .gt
= 2,
421 .is_broadwell
= true,
423 .num_subslices
= { 3, },
424 .num_thread_per_eu
= 7,
426 .max_cs_threads
= 56,
430 [MESA_SHADER_VERTEX
] = 64,
431 [MESA_SHADER_TESS_EVAL
] = 34,
434 [MESA_SHADER_VERTEX
] = 2560,
435 [MESA_SHADER_TESS_CTRL
] = 504,
436 [MESA_SHADER_TESS_EVAL
] = 1536,
437 [MESA_SHADER_GEOMETRY
] = 960,
442 static const struct gen_device_info gen_device_info_bdw_gt3
= {
443 GEN8_FEATURES
, .gt
= 3,
444 .is_broadwell
= true,
446 .num_subslices
= { 3, 3, },
447 .num_thread_per_eu
= 7,
449 .max_cs_threads
= 56,
453 [MESA_SHADER_VERTEX
] = 64,
454 [MESA_SHADER_TESS_EVAL
] = 34,
457 [MESA_SHADER_VERTEX
] = 2560,
458 [MESA_SHADER_TESS_CTRL
] = 504,
459 [MESA_SHADER_TESS_EVAL
] = 1536,
460 [MESA_SHADER_GEOMETRY
] = 960,
465 static const struct gen_device_info gen_device_info_chv
= {
466 GEN8_FEATURES
, .is_cherryview
= 1, .gt
= 1,
468 .has_integer_dword_mul
= false,
470 .num_subslices
= { 2, },
471 .num_thread_per_eu
= 7,
473 .max_vs_threads
= 80,
474 .max_tcs_threads
= 80,
475 .max_tes_threads
= 80,
476 .max_gs_threads
= 80,
477 .max_wm_threads
= 128,
478 .max_cs_threads
= 6 * 7,
482 [MESA_SHADER_VERTEX
] = 34,
483 [MESA_SHADER_TESS_EVAL
] = 34,
486 [MESA_SHADER_VERTEX
] = 640,
487 [MESA_SHADER_TESS_CTRL
] = 80,
488 [MESA_SHADER_TESS_EVAL
] = 384,
489 [MESA_SHADER_GEOMETRY
] = 256,
494 #define GEN9_HW_INFO \
496 .max_vs_threads = 336, \
497 .max_gs_threads = 336, \
498 .max_tcs_threads = 336, \
499 .max_tes_threads = 336, \
500 .max_cs_threads = 56, \
501 .timestamp_frequency = 12000000, \
505 [MESA_SHADER_VERTEX] = 64, \
506 [MESA_SHADER_TESS_EVAL] = 34, \
509 [MESA_SHADER_VERTEX] = 1856, \
510 [MESA_SHADER_TESS_CTRL] = 672, \
511 [MESA_SHADER_TESS_EVAL] = 1120, \
512 [MESA_SHADER_GEOMETRY] = 640, \
516 #define GEN9_LP_FEATURES \
519 .has_integer_dword_mul = false, \
522 .has_sample_with_hiz = true, \
524 .num_thread_per_eu = 6, \
525 .max_vs_threads = 112, \
526 .max_tcs_threads = 112, \
527 .max_tes_threads = 112, \
528 .max_gs_threads = 112, \
529 .max_cs_threads = 6 * 6, \
530 .timestamp_frequency = 19200000, \
534 [MESA_SHADER_VERTEX] = 34, \
535 [MESA_SHADER_TESS_EVAL] = 34, \
538 [MESA_SHADER_VERTEX] = 704, \
539 [MESA_SHADER_TESS_CTRL] = 256, \
540 [MESA_SHADER_TESS_EVAL] = 416, \
541 [MESA_SHADER_GEOMETRY] = 256, \
545 #define GEN9_LP_FEATURES_3X6 \
547 .num_subslices = { 3, }
549 #define GEN9_LP_FEATURES_2X6 \
551 .num_subslices = { 2, }, \
552 .max_vs_threads = 56, \
553 .max_tcs_threads = 56, \
554 .max_tes_threads = 56, \
555 .max_gs_threads = 56, \
556 .max_cs_threads = 6 * 6, \
560 [MESA_SHADER_VERTEX] = 34, \
561 [MESA_SHADER_TESS_EVAL] = 34, \
564 [MESA_SHADER_VERTEX] = 352, \
565 [MESA_SHADER_TESS_CTRL] = 128, \
566 [MESA_SHADER_TESS_EVAL] = 208, \
567 [MESA_SHADER_GEOMETRY] = 128, \
571 #define GEN9_FEATURES \
574 .has_sample_with_hiz = true, \
575 .num_thread_per_eu = 7
577 static const struct gen_device_info gen_device_info_skl_gt1
= {
578 GEN9_FEATURES
, .gt
= 1,
581 .num_subslices
= { 2, },
586 static const struct gen_device_info gen_device_info_skl_gt2
= {
587 GEN9_FEATURES
, .gt
= 2,
590 .num_subslices
= { 3, },
594 static const struct gen_device_info gen_device_info_skl_gt3
= {
595 GEN9_FEATURES
, .gt
= 3,
598 .num_subslices
= { 3, 3, },
602 static const struct gen_device_info gen_device_info_skl_gt4
= {
603 GEN9_FEATURES
, .gt
= 4,
606 .num_subslices
= { 3, 3, 3, },
608 /* From the "L3 Allocation and Programming" documentation:
610 * "URB is limited to 1008KB due to programming restrictions. This is not a
611 * restriction of the L3 implementation, but of the FF and other clients.
612 * Therefore, in a GT4 implementation it is possible for the programmed
613 * allocation of the L3 data array to provide 3*384KB=1152KB for URB, but
614 * only 1008KB of this will be used."
616 .urb
.size
= 1008 / 3,
619 static const struct gen_device_info gen_device_info_bxt
= {
620 GEN9_LP_FEATURES_3X6
,
625 static const struct gen_device_info gen_device_info_bxt_2x6
= {
626 GEN9_LP_FEATURES_2X6
,
631 * Note: for all KBL SKUs, the PRM says SKL for GS entries, not SKL+.
632 * There's no KBL entry. Using the default SKL (GEN9) GS entries value.
635 static const struct gen_device_info gen_device_info_kbl_gt1
= {
640 .max_cs_threads
= 7 * 6,
643 .num_subslices
= { 2, },
647 static const struct gen_device_info gen_device_info_kbl_gt1_5
= {
652 .max_cs_threads
= 7 * 6,
654 .num_subslices
= { 3, },
658 static const struct gen_device_info gen_device_info_kbl_gt2
= {
664 .num_subslices
= { 3, },
668 static const struct gen_device_info gen_device_info_kbl_gt3
= {
674 .num_subslices
= { 3, 3, },
678 static const struct gen_device_info gen_device_info_kbl_gt4
= {
684 * From the "L3 Allocation and Programming" documentation:
686 * "URB is limited to 1008KB due to programming restrictions. This
687 * is not a restriction of the L3 implementation, but of the FF and
688 * other clients. Therefore, in a GT4 implementation it is
689 * possible for the programmed allocation of the L3 data array to
690 * provide 3*384KB=1152KB for URB, but only 1008KB of this
693 .urb
.size
= 1008 / 3,
695 .num_subslices
= { 3, 3, 3, },
699 static const struct gen_device_info gen_device_info_glk
= {
700 GEN9_LP_FEATURES_3X6
,
701 .is_geminilake
= true,
705 /*TODO: Initialize l3_banks when we know the number. */
706 static const struct gen_device_info gen_device_info_glk_2x6
= {
707 GEN9_LP_FEATURES_2X6
,
708 .is_geminilake
= true,
711 static const struct gen_device_info gen_device_info_cfl_gt1
= {
713 .is_coffeelake
= true,
717 .num_subslices
= { 2, },
720 static const struct gen_device_info gen_device_info_cfl_gt2
= {
722 .is_coffeelake
= true,
726 .num_subslices
= { 3, },
730 static const struct gen_device_info gen_device_info_cfl_gt3
= {
732 .is_coffeelake
= true,
736 .num_subslices
= { 3, 3, },
740 #define GEN10_HW_INFO \
742 .num_thread_per_eu = 7, \
743 .max_vs_threads = 728, \
744 .max_gs_threads = 432, \
745 .max_tcs_threads = 432, \
746 .max_tes_threads = 624, \
747 .max_cs_threads = 56, \
748 .timestamp_frequency = 19200000, \
752 [MESA_SHADER_VERTEX] = 64, \
753 [MESA_SHADER_TESS_EVAL] = 34, \
756 [MESA_SHADER_VERTEX] = 3936, \
757 [MESA_SHADER_TESS_CTRL] = 896, \
758 [MESA_SHADER_TESS_EVAL] = 2064, \
759 [MESA_SHADER_GEOMETRY] = 832, \
763 #define subslices(args...) { args, }
765 #define GEN10_FEATURES(_gt, _slices, _subslices, _l3) \
768 .has_sample_with_hiz = true, \
770 .num_slices = _slices, \
771 .num_subslices = _subslices, \
774 static const struct gen_device_info gen_device_info_cnl_2x8
= {
776 GEN10_FEATURES(1, 1, subslices(2), 2),
777 .is_cannonlake
= true,
780 static const struct gen_device_info gen_device_info_cnl_3x8
= {
782 GEN10_FEATURES(1, 1, subslices(3), 3),
783 .is_cannonlake
= true,
786 static const struct gen_device_info gen_device_info_cnl_4x8
= {
788 GEN10_FEATURES(1, 2, subslices(2, 2), 6),
789 .is_cannonlake
= true,
792 static const struct gen_device_info gen_device_info_cnl_5x8
= {
794 GEN10_FEATURES(2, 2, subslices(3, 2), 6),
795 .is_cannonlake
= true,
798 #define GEN11_HW_INFO \
801 .max_vs_threads = 364, \
802 .max_gs_threads = 224, \
803 .max_tcs_threads = 224, \
804 .max_tes_threads = 364, \
805 .max_cs_threads = 56, \
809 [MESA_SHADER_VERTEX] = 64, \
810 [MESA_SHADER_TESS_EVAL] = 34, \
813 [MESA_SHADER_VERTEX] = 2384, \
814 [MESA_SHADER_TESS_CTRL] = 1032, \
815 [MESA_SHADER_TESS_EVAL] = 2384, \
816 [MESA_SHADER_GEOMETRY] = 1032, \
820 #define GEN11_FEATURES(_gt, _slices, _subslices, _l3) \
823 .has_64bit_types = false, \
824 .has_integer_dword_mul = false, \
825 .gt = _gt, .num_slices = _slices, .l3_banks = _l3, \
826 .num_subslices = _subslices
828 static const struct gen_device_info gen_device_info_icl_8x8
= {
829 GEN11_FEATURES(2, 1, subslices(8), 8),
832 static const struct gen_device_info gen_device_info_icl_6x8
= {
833 GEN11_FEATURES(1, 1, subslices(6), 6),
836 static const struct gen_device_info gen_device_info_icl_4x8
= {
837 GEN11_FEATURES(1, 1, subslices(4), 6),
840 static const struct gen_device_info gen_device_info_icl_1x8
= {
841 GEN11_FEATURES(1, 1, subslices(1), 6),
845 gen_get_device_info(int devid
, struct gen_device_info
*devinfo
)
849 #define CHIPSET(id, family, name) \
850 case id: *devinfo = gen_device_info_##family; break;
851 #include "pci_ids/i965_pci_ids.h"
853 fprintf(stderr
, "i965_dri.so does not support the 0x%x PCI ID.\n", devid
);
857 /* From the Skylake PRM, 3DSTATE_PS::Scratch Space Base Pointer:
859 * "Scratch Space per slice is computed based on 4 sub-slices. SW must
860 * allocate scratch space enough so that each slice has 4 slices allowed."
862 * The equivalent internal documentation says that this programming note
863 * applies to all Gen9+ platforms.
865 * The hardware typically calculates the scratch space pointer by taking
866 * the base address, and adding per-thread-scratch-space * thread ID.
867 * Extra padding can be necessary depending how the thread IDs are
868 * calculated for a particular shader stage.
871 switch(devinfo
->gen
) {
874 devinfo
->max_wm_threads
= 64 /* threads-per-PSD */
875 * devinfo
->num_slices
876 * 4; /* effective subslices per slice */
879 devinfo
->max_wm_threads
= 128 /* threads-per-PSD */
880 * devinfo
->num_slices
881 * 8; /* subslices per slice */
887 assert(devinfo
->num_slices
<= ARRAY_SIZE(devinfo
->num_subslices
));
893 gen_get_device_name(int devid
)
897 #define CHIPSET(id, family, name) case id: return name;
898 #include "pci_ids/i965_pci_ids.h"