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,
111 static const struct gen_device_info gen_device_info_g4x
= {
115 .has_surface_tile_offset
= true,
118 .num_subslices
= { 1, },
119 .num_eu_per_subslice
= 10,
120 .num_thread_per_eu
= 5,
121 .max_vs_threads
= 32,
123 .max_wm_threads
= 10 * 5,
127 .timestamp_frequency
= 12500000,
131 static const struct gen_device_info gen_device_info_ilk
= {
135 .has_surface_tile_offset
= true,
137 .num_subslices
= { 1, },
138 .num_eu_per_subslice
= 12,
139 .num_thread_per_eu
= 6,
140 .max_vs_threads
= 72,
141 .max_gs_threads
= 32,
142 .max_wm_threads
= 12 * 6,
146 .timestamp_frequency
= 12500000,
150 static const struct gen_device_info gen_device_info_snb_gt1
= {
153 .has_hiz_and_separate_stencil
= true,
156 .has_surface_tile_offset
= true,
157 .needs_unlit_centroid_workaround
= true,
159 .num_subslices
= { 1, },
160 .num_eu_per_subslice
= 6,
161 .num_thread_per_eu
= 6, /* Not confirmed */
162 .max_vs_threads
= 24,
163 .max_gs_threads
= 21, /* conservative; 24 if rendering disabled. */
164 .max_wm_threads
= 40,
168 [MESA_SHADER_VERTEX
] = 24,
171 [MESA_SHADER_VERTEX
] = 256,
172 [MESA_SHADER_GEOMETRY
] = 256,
175 .timestamp_frequency
= 12500000,
179 static const struct gen_device_info gen_device_info_snb_gt2
= {
182 .has_hiz_and_separate_stencil
= true,
185 .has_surface_tile_offset
= true,
186 .needs_unlit_centroid_workaround
= true,
188 .num_subslices
= { 1, },
189 .num_eu_per_subslice
= 12,
190 .num_thread_per_eu
= 6, /* Not confirmed */
191 .max_vs_threads
= 60,
192 .max_gs_threads
= 60,
193 .max_wm_threads
= 80,
197 [MESA_SHADER_VERTEX
] = 24,
200 [MESA_SHADER_VERTEX
] = 256,
201 [MESA_SHADER_GEOMETRY
] = 256,
204 .timestamp_frequency
= 12500000,
208 #define GEN7_FEATURES \
210 .has_hiz_and_separate_stencil = true, \
211 .must_use_separate_stencil = true, \
214 .has_64bit_types = true, \
215 .has_surface_tile_offset = true, \
216 .timestamp_frequency = 12500000
218 static const struct gen_device_info gen_device_info_ivb_gt1
= {
219 GEN7_FEATURES
, .is_ivybridge
= true, .gt
= 1,
221 .num_subslices
= { 1, },
222 .num_eu_per_subslice
= 6,
223 .num_thread_per_eu
= 6,
225 .max_vs_threads
= 36,
226 .max_tcs_threads
= 36,
227 .max_tes_threads
= 36,
228 .max_gs_threads
= 36,
229 .max_wm_threads
= 48,
230 .max_cs_threads
= 36,
234 [MESA_SHADER_VERTEX
] = 32,
235 [MESA_SHADER_TESS_EVAL
] = 10,
238 [MESA_SHADER_VERTEX
] = 512,
239 [MESA_SHADER_TESS_CTRL
] = 32,
240 [MESA_SHADER_TESS_EVAL
] = 288,
241 [MESA_SHADER_GEOMETRY
] = 192,
247 static const struct gen_device_info gen_device_info_ivb_gt2
= {
248 GEN7_FEATURES
, .is_ivybridge
= true, .gt
= 2,
250 .num_subslices
= { 1, },
251 .num_eu_per_subslice
= 12,
252 .num_thread_per_eu
= 8, /* Not sure why this isn't a multiple of
253 * @max_wm_threads ... */
255 .max_vs_threads
= 128,
256 .max_tcs_threads
= 128,
257 .max_tes_threads
= 128,
258 .max_gs_threads
= 128,
259 .max_wm_threads
= 172,
260 .max_cs_threads
= 64,
264 [MESA_SHADER_VERTEX
] = 32,
265 [MESA_SHADER_TESS_EVAL
] = 10,
268 [MESA_SHADER_VERTEX
] = 704,
269 [MESA_SHADER_TESS_CTRL
] = 64,
270 [MESA_SHADER_TESS_EVAL
] = 448,
271 [MESA_SHADER_GEOMETRY
] = 320,
277 static const struct gen_device_info gen_device_info_byt
= {
278 GEN7_FEATURES
, .is_baytrail
= true, .gt
= 1,
280 .num_subslices
= { 1, },
281 .num_eu_per_subslice
= 4,
282 .num_thread_per_eu
= 8,
285 .max_vs_threads
= 36,
286 .max_tcs_threads
= 36,
287 .max_tes_threads
= 36,
288 .max_gs_threads
= 36,
289 .max_wm_threads
= 48,
290 .max_cs_threads
= 32,
294 [MESA_SHADER_VERTEX
] = 32,
295 [MESA_SHADER_TESS_EVAL
] = 10,
298 [MESA_SHADER_VERTEX
] = 512,
299 [MESA_SHADER_TESS_CTRL
] = 32,
300 [MESA_SHADER_TESS_EVAL
] = 288,
301 [MESA_SHADER_GEOMETRY
] = 192,
307 #define HSW_FEATURES \
309 .is_haswell = true, \
310 .supports_simd16_3src = true, \
311 .has_resource_streamer = true
313 static const struct gen_device_info gen_device_info_hsw_gt1
= {
314 HSW_FEATURES
, .gt
= 1,
316 .num_subslices
= { 1, },
317 .num_eu_per_subslice
= 10,
318 .num_thread_per_eu
= 7,
320 .max_vs_threads
= 70,
321 .max_tcs_threads
= 70,
322 .max_tes_threads
= 70,
323 .max_gs_threads
= 70,
324 .max_wm_threads
= 102,
325 .max_cs_threads
= 70,
329 [MESA_SHADER_VERTEX
] = 32,
330 [MESA_SHADER_TESS_EVAL
] = 10,
333 [MESA_SHADER_VERTEX
] = 640,
334 [MESA_SHADER_TESS_CTRL
] = 64,
335 [MESA_SHADER_TESS_EVAL
] = 384,
336 [MESA_SHADER_GEOMETRY
] = 256,
342 static const struct gen_device_info gen_device_info_hsw_gt2
= {
343 HSW_FEATURES
, .gt
= 2,
345 .num_subslices
= { 2, },
346 .num_eu_per_subslice
= 10,
347 .num_thread_per_eu
= 7,
349 .max_vs_threads
= 280,
350 .max_tcs_threads
= 256,
351 .max_tes_threads
= 280,
352 .max_gs_threads
= 256,
353 .max_wm_threads
= 204,
354 .max_cs_threads
= 70,
358 [MESA_SHADER_VERTEX
] = 64,
359 [MESA_SHADER_TESS_EVAL
] = 10,
362 [MESA_SHADER_VERTEX
] = 1664,
363 [MESA_SHADER_TESS_CTRL
] = 128,
364 [MESA_SHADER_TESS_EVAL
] = 960,
365 [MESA_SHADER_GEOMETRY
] = 640,
371 static const struct gen_device_info gen_device_info_hsw_gt3
= {
372 HSW_FEATURES
, .gt
= 3,
374 .num_subslices
= { 2, },
375 .num_eu_per_subslice
= 10,
376 .num_thread_per_eu
= 7,
378 .max_vs_threads
= 280,
379 .max_tcs_threads
= 256,
380 .max_tes_threads
= 280,
381 .max_gs_threads
= 256,
382 .max_wm_threads
= 408,
383 .max_cs_threads
= 70,
387 [MESA_SHADER_VERTEX
] = 64,
388 [MESA_SHADER_TESS_EVAL
] = 10,
391 [MESA_SHADER_VERTEX
] = 1664,
392 [MESA_SHADER_TESS_CTRL
] = 128,
393 [MESA_SHADER_TESS_EVAL
] = 960,
394 [MESA_SHADER_GEOMETRY
] = 640,
400 /* It's unclear how well supported sampling from the hiz buffer is on GEN8,
401 * so keep things conservative for now and set has_sample_with_hiz = false.
403 #define GEN8_FEATURES \
405 .has_hiz_and_separate_stencil = true, \
406 .has_resource_streamer = true, \
407 .must_use_separate_stencil = true, \
409 .has_sample_with_hiz = false, \
411 .has_integer_dword_mul = true, \
412 .has_64bit_types = true, \
413 .supports_simd16_3src = true, \
414 .has_surface_tile_offset = true, \
415 .max_vs_threads = 504, \
416 .max_tcs_threads = 504, \
417 .max_tes_threads = 504, \
418 .max_gs_threads = 504, \
419 .max_wm_threads = 384, \
420 .timestamp_frequency = 12500000
422 static const struct gen_device_info gen_device_info_bdw_gt1
= {
423 GEN8_FEATURES
, .gt
= 1,
424 .is_broadwell
= true,
426 .num_subslices
= { 2, },
427 .num_eu_per_subslice
= 8,
428 .num_thread_per_eu
= 7,
430 .max_cs_threads
= 42,
434 [MESA_SHADER_VERTEX
] = 64,
435 [MESA_SHADER_TESS_EVAL
] = 34,
438 [MESA_SHADER_VERTEX
] = 2560,
439 [MESA_SHADER_TESS_CTRL
] = 504,
440 [MESA_SHADER_TESS_EVAL
] = 1536,
441 [MESA_SHADER_GEOMETRY
] = 960,
447 static const struct gen_device_info gen_device_info_bdw_gt2
= {
448 GEN8_FEATURES
, .gt
= 2,
449 .is_broadwell
= true,
451 .num_subslices
= { 3, },
452 .num_eu_per_subslice
= 8,
453 .num_thread_per_eu
= 7,
455 .max_cs_threads
= 56,
459 [MESA_SHADER_VERTEX
] = 64,
460 [MESA_SHADER_TESS_EVAL
] = 34,
463 [MESA_SHADER_VERTEX
] = 2560,
464 [MESA_SHADER_TESS_CTRL
] = 504,
465 [MESA_SHADER_TESS_EVAL
] = 1536,
466 [MESA_SHADER_GEOMETRY
] = 960,
472 static const struct gen_device_info gen_device_info_bdw_gt3
= {
473 GEN8_FEATURES
, .gt
= 3,
474 .is_broadwell
= true,
476 .num_subslices
= { 3, 3, },
477 .num_eu_per_subslice
= 8,
478 .num_thread_per_eu
= 7,
480 .max_cs_threads
= 56,
484 [MESA_SHADER_VERTEX
] = 64,
485 [MESA_SHADER_TESS_EVAL
] = 34,
488 [MESA_SHADER_VERTEX
] = 2560,
489 [MESA_SHADER_TESS_CTRL
] = 504,
490 [MESA_SHADER_TESS_EVAL
] = 1536,
491 [MESA_SHADER_GEOMETRY
] = 960,
497 static const struct gen_device_info gen_device_info_chv
= {
498 GEN8_FEATURES
, .is_cherryview
= 1, .gt
= 1,
500 .has_integer_dword_mul
= false,
502 .num_subslices
= { 2, },
503 .num_eu_per_subslice
= 8,
504 .num_thread_per_eu
= 7,
506 .max_vs_threads
= 80,
507 .max_tcs_threads
= 80,
508 .max_tes_threads
= 80,
509 .max_gs_threads
= 80,
510 .max_wm_threads
= 128,
511 .max_cs_threads
= 6 * 7,
515 [MESA_SHADER_VERTEX
] = 34,
516 [MESA_SHADER_TESS_EVAL
] = 34,
519 [MESA_SHADER_VERTEX
] = 640,
520 [MESA_SHADER_TESS_CTRL
] = 80,
521 [MESA_SHADER_TESS_EVAL
] = 384,
522 [MESA_SHADER_GEOMETRY
] = 256,
528 #define GEN9_HW_INFO \
530 .max_vs_threads = 336, \
531 .max_gs_threads = 336, \
532 .max_tcs_threads = 336, \
533 .max_tes_threads = 336, \
534 .max_cs_threads = 56, \
535 .timestamp_frequency = 12000000, \
539 [MESA_SHADER_VERTEX] = 64, \
540 [MESA_SHADER_TESS_EVAL] = 34, \
543 [MESA_SHADER_VERTEX] = 1856, \
544 [MESA_SHADER_TESS_CTRL] = 672, \
545 [MESA_SHADER_TESS_EVAL] = 1120, \
546 [MESA_SHADER_GEOMETRY] = 640, \
550 #define GEN9_LP_FEATURES \
553 .has_integer_dword_mul = false, \
556 .has_sample_with_hiz = true, \
558 .num_thread_per_eu = 6, \
559 .max_vs_threads = 112, \
560 .max_tcs_threads = 112, \
561 .max_tes_threads = 112, \
562 .max_gs_threads = 112, \
563 .max_cs_threads = 6 * 6, \
564 .timestamp_frequency = 19200000, \
568 [MESA_SHADER_VERTEX] = 34, \
569 [MESA_SHADER_TESS_EVAL] = 34, \
572 [MESA_SHADER_VERTEX] = 704, \
573 [MESA_SHADER_TESS_CTRL] = 256, \
574 [MESA_SHADER_TESS_EVAL] = 416, \
575 [MESA_SHADER_GEOMETRY] = 256, \
579 #define GEN9_LP_FEATURES_3X6 \
581 .num_subslices = { 3, }, \
582 .num_eu_per_subslice = 6
584 #define GEN9_LP_FEATURES_2X6 \
586 .num_subslices = { 2, }, \
587 .num_eu_per_subslice = 6, \
588 .max_vs_threads = 56, \
589 .max_tcs_threads = 56, \
590 .max_tes_threads = 56, \
591 .max_gs_threads = 56, \
592 .max_cs_threads = 6 * 6, \
596 [MESA_SHADER_VERTEX] = 34, \
597 [MESA_SHADER_TESS_EVAL] = 34, \
600 [MESA_SHADER_VERTEX] = 352, \
601 [MESA_SHADER_TESS_CTRL] = 128, \
602 [MESA_SHADER_TESS_EVAL] = 208, \
603 [MESA_SHADER_GEOMETRY] = 128, \
607 #define GEN9_FEATURES \
610 .has_sample_with_hiz = true, \
611 .num_thread_per_eu = 7
613 static const struct gen_device_info gen_device_info_skl_gt1
= {
614 GEN9_FEATURES
, .gt
= 1,
617 .num_subslices
= { 2, },
618 .num_eu_per_subslice
= 6,
624 static const struct gen_device_info gen_device_info_skl_gt2
= {
625 GEN9_FEATURES
, .gt
= 2,
628 .num_subslices
= { 3, },
629 .num_eu_per_subslice
= 8,
634 static const struct gen_device_info gen_device_info_skl_gt3
= {
635 GEN9_FEATURES
, .gt
= 3,
638 .num_subslices
= { 3, 3, },
639 .num_eu_per_subslice
= 8,
644 static const struct gen_device_info gen_device_info_skl_gt4
= {
645 GEN9_FEATURES
, .gt
= 4,
648 .num_subslices
= { 3, 3, 3, },
649 .num_eu_per_subslice
= 8,
651 /* From the "L3 Allocation and Programming" documentation:
653 * "URB is limited to 1008KB due to programming restrictions. This is not a
654 * restriction of the L3 implementation, but of the FF and other clients.
655 * Therefore, in a GT4 implementation it is possible for the programmed
656 * allocation of the L3 data array to provide 3*384KB=1152KB for URB, but
657 * only 1008KB of this will be used."
659 .urb
.size
= 1008 / 3,
663 static const struct gen_device_info gen_device_info_bxt
= {
664 GEN9_LP_FEATURES_3X6
,
670 static const struct gen_device_info gen_device_info_bxt_2x6
= {
671 GEN9_LP_FEATURES_2X6
,
677 * Note: for all KBL SKUs, the PRM says SKL for GS entries, not SKL+.
678 * There's no KBL entry. Using the default SKL (GEN9) GS entries value.
681 static const struct gen_device_info gen_device_info_kbl_gt1
= {
686 .max_cs_threads
= 7 * 6,
689 .num_subslices
= { 2, },
690 .num_eu_per_subslice
= 6,
695 static const struct gen_device_info gen_device_info_kbl_gt1_5
= {
700 .max_cs_threads
= 7 * 6,
702 .num_subslices
= { 3, },
703 .num_eu_per_subslice
= 6,
708 static const struct gen_device_info gen_device_info_kbl_gt2
= {
714 .num_subslices
= { 3, },
715 .num_eu_per_subslice
= 8,
720 static const struct gen_device_info gen_device_info_kbl_gt3
= {
726 .num_subslices
= { 3, 3, },
727 .num_eu_per_subslice
= 8,
732 static const struct gen_device_info gen_device_info_kbl_gt4
= {
738 * From the "L3 Allocation and Programming" documentation:
740 * "URB is limited to 1008KB due to programming restrictions. This
741 * is not a restriction of the L3 implementation, but of the FF and
742 * other clients. Therefore, in a GT4 implementation it is
743 * possible for the programmed allocation of the L3 data array to
744 * provide 3*384KB=1152KB for URB, but only 1008KB of this
747 .urb
.size
= 1008 / 3,
749 .num_subslices
= { 3, 3, 3, },
750 .num_eu_per_subslice
= 8,
755 static const struct gen_device_info gen_device_info_glk
= {
756 GEN9_LP_FEATURES_3X6
,
757 .is_geminilake
= true,
762 static const struct gen_device_info gen_device_info_glk_2x6
= {
763 GEN9_LP_FEATURES_2X6
,
764 .is_geminilake
= true,
769 static const struct gen_device_info gen_device_info_cfl_gt1
= {
771 .is_coffeelake
= true,
775 .num_subslices
= { 2, },
776 .num_eu_per_subslice
= 6,
780 static const struct gen_device_info gen_device_info_cfl_gt2
= {
782 .is_coffeelake
= true,
786 .num_subslices
= { 3, },
787 .num_eu_per_subslice
= 8,
792 static const struct gen_device_info gen_device_info_cfl_gt3
= {
794 .is_coffeelake
= true,
798 .num_subslices
= { 3, 3, },
799 .num_eu_per_subslice
= 8,
804 #define GEN10_HW_INFO \
806 .num_thread_per_eu = 7, \
807 .max_vs_threads = 728, \
808 .max_gs_threads = 432, \
809 .max_tcs_threads = 432, \
810 .max_tes_threads = 624, \
811 .max_cs_threads = 56, \
812 .timestamp_frequency = 19200000, \
816 [MESA_SHADER_VERTEX] = 64, \
817 [MESA_SHADER_TESS_EVAL] = 34, \
820 [MESA_SHADER_VERTEX] = 3936, \
821 [MESA_SHADER_TESS_CTRL] = 896, \
822 [MESA_SHADER_TESS_EVAL] = 2064, \
823 [MESA_SHADER_GEOMETRY] = 832, \
827 #define subslices(args...) { args, }
829 #define GEN10_FEATURES(_gt, _slices, _subslices, _l3) \
832 .has_sample_with_hiz = true, \
834 .num_slices = _slices, \
835 .num_subslices = _subslices, \
836 .num_eu_per_subslice = 8, \
839 static const struct gen_device_info gen_device_info_cnl_2x8
= {
841 GEN10_FEATURES(1, 1, subslices(2), 2),
842 .is_cannonlake
= true,
846 static const struct gen_device_info gen_device_info_cnl_3x8
= {
848 GEN10_FEATURES(1, 1, subslices(3), 3),
849 .is_cannonlake
= true,
853 static const struct gen_device_info gen_device_info_cnl_4x8
= {
855 GEN10_FEATURES(1, 2, subslices(2, 2), 6),
856 .is_cannonlake
= true,
860 static const struct gen_device_info gen_device_info_cnl_5x8
= {
862 GEN10_FEATURES(2, 2, subslices(3, 2), 6),
863 .is_cannonlake
= true,
867 #define GEN11_HW_INFO \
870 .max_vs_threads = 364, \
871 .max_gs_threads = 224, \
872 .max_tcs_threads = 224, \
873 .max_tes_threads = 364, \
874 .max_cs_threads = 56, \
878 [MESA_SHADER_VERTEX] = 64, \
879 [MESA_SHADER_TESS_EVAL] = 34, \
882 [MESA_SHADER_VERTEX] = 2384, \
883 [MESA_SHADER_TESS_CTRL] = 1032, \
884 [MESA_SHADER_TESS_EVAL] = 2384, \
885 [MESA_SHADER_GEOMETRY] = 1032, \
889 #define GEN11_FEATURES(_gt, _slices, _subslices, _l3) \
892 .has_64bit_types = false, \
893 .has_integer_dword_mul = false, \
894 .has_sample_with_hiz = false, \
895 .gt = _gt, .num_slices = _slices, .l3_banks = _l3, \
896 .num_subslices = _subslices, \
897 .num_eu_per_subslice = 8
899 static const struct gen_device_info gen_device_info_icl_8x8
= {
900 GEN11_FEATURES(2, 1, subslices(8), 8),
904 static const struct gen_device_info gen_device_info_icl_6x8
= {
905 GEN11_FEATURES(1, 1, subslices(6), 6),
909 static const struct gen_device_info gen_device_info_icl_4x8
= {
910 GEN11_FEATURES(1, 1, subslices(4), 6),
914 static const struct gen_device_info gen_device_info_icl_1x8
= {
915 GEN11_FEATURES(1, 1, subslices(1), 6),
920 gen_device_info_set_eu_mask(struct gen_device_info
*devinfo
,
925 unsigned subslice_offset
= slice
* devinfo
->eu_slice_stride
+
926 subslice
* devinfo
->eu_subslice_stride
;
928 for (unsigned b_eu
= 0; b_eu
< devinfo
->eu_subslice_stride
; b_eu
++) {
929 devinfo
->eu_masks
[subslice_offset
+ b_eu
] =
930 (((1U << devinfo
->num_eu_per_subslice
) - 1) >> (b_eu
* 8)) & 0xff;
934 /* Generate slice/subslice/eu masks from number of
935 * slices/subslices/eu_per_subslices in the per generation/gt gen_device_info
938 * These can be overridden with values reported by the kernel either from
939 * getparam SLICE_MASK/SUBSLICE_MASK values or from the kernel version 4.17+
940 * through the i915 query uapi.
943 fill_masks(struct gen_device_info
*devinfo
)
945 devinfo
->slice_masks
= (1U << devinfo
->num_slices
) - 1;
948 unsigned max_subslices
= 0;
949 for (int s
= 0; s
< devinfo
->num_slices
; s
++)
950 max_subslices
= MAX2(devinfo
->num_subslices
[s
], max_subslices
);
951 devinfo
->subslice_slice_stride
= DIV_ROUND_UP(max_subslices
, 8);
953 for (int s
= 0; s
< devinfo
->num_slices
; s
++) {
954 devinfo
->subslice_masks
[s
* devinfo
->subslice_slice_stride
] =
955 (1U << devinfo
->num_subslices
[s
]) - 1;
959 devinfo
->eu_subslice_stride
= DIV_ROUND_UP(devinfo
->num_eu_per_subslice
, 8);
960 devinfo
->eu_slice_stride
= max_subslices
* devinfo
->eu_subslice_stride
;
962 for (int s
= 0; s
< devinfo
->num_slices
; s
++) {
963 for (int ss
= 0; ss
< devinfo
->num_subslices
[s
]; ss
++) {
964 gen_device_info_set_eu_mask(devinfo
, s
, ss
,
965 (1U << devinfo
->num_eu_per_subslice
) - 1);
971 gen_device_info_update_from_masks(struct gen_device_info
*devinfo
,
973 uint32_t subslice_mask
,
977 struct drm_i915_query_topology_info base
;
981 assert((slice_mask
& 0xff) == slice_mask
);
983 memset(&topology
, 0, sizeof(topology
));
985 topology
.base
.max_slices
= util_last_bit(slice_mask
);
986 topology
.base
.max_subslices
= util_last_bit(subslice_mask
);
988 topology
.base
.subslice_offset
= DIV_ROUND_UP(topology
.base
.max_slices
, 8);
989 topology
.base
.subslice_stride
= DIV_ROUND_UP(topology
.base
.max_subslices
, 8);
991 uint32_t n_subslices
= __builtin_popcount(slice_mask
) *
992 __builtin_popcount(subslice_mask
);
993 uint32_t num_eu_per_subslice
= DIV_ROUND_UP(n_eus
, n_subslices
);
994 uint32_t eu_mask
= (1U << num_eu_per_subslice
) - 1;
996 topology
.base
.eu_offset
= topology
.base
.subslice_offset
+
997 DIV_ROUND_UP(topology
.base
.max_subslices
, 8);
998 topology
.base
.eu_stride
= DIV_ROUND_UP(num_eu_per_subslice
, 8);
1000 /* Set slice mask in topology */
1001 for (int b
= 0; b
< topology
.base
.subslice_offset
; b
++)
1002 topology
.base
.data
[b
] = (slice_mask
>> (b
* 8)) & 0xff;
1004 for (int s
= 0; s
< topology
.base
.max_slices
; s
++) {
1006 /* Set subslice mask in topology */
1007 for (int b
= 0; b
< topology
.base
.subslice_stride
; b
++) {
1008 int subslice_offset
= topology
.base
.subslice_offset
+
1009 s
* topology
.base
.subslice_stride
+ b
;
1011 topology
.base
.data
[subslice_offset
] = (subslice_mask
>> (b
* 8)) & 0xff;
1014 /* Set eu mask in topology */
1015 for (int ss
= 0; ss
< topology
.base
.max_subslices
; ss
++) {
1016 for (int b
= 0; b
< topology
.base
.eu_stride
; b
++) {
1017 int eu_offset
= topology
.base
.eu_offset
+
1018 (s
* topology
.base
.max_subslices
+ ss
) * topology
.base
.eu_stride
+ b
;
1020 topology
.base
.data
[eu_offset
] = (eu_mask
>> (b
* 8)) & 0xff;
1025 gen_device_info_update_from_topology(devinfo
, &topology
.base
);
1029 reset_masks(struct gen_device_info
*devinfo
)
1031 devinfo
->subslice_slice_stride
= 0;
1032 devinfo
->eu_subslice_stride
= 0;
1033 devinfo
->eu_slice_stride
= 0;
1035 devinfo
->num_slices
= 0;
1036 devinfo
->num_eu_per_subslice
= 0;
1037 memset(devinfo
->num_subslices
, 0, sizeof(devinfo
->num_subslices
));
1039 memset(&devinfo
->slice_masks
, 0, sizeof(devinfo
->slice_masks
));
1040 memset(devinfo
->subslice_masks
, 0, sizeof(devinfo
->subslice_masks
));
1041 memset(devinfo
->eu_masks
, 0, sizeof(devinfo
->eu_masks
));
1045 gen_device_info_update_from_topology(struct gen_device_info
*devinfo
,
1046 const struct drm_i915_query_topology_info
*topology
)
1048 reset_masks(devinfo
);
1050 devinfo
->subslice_slice_stride
= topology
->subslice_stride
;
1052 devinfo
->eu_subslice_stride
= DIV_ROUND_UP(topology
->max_eus_per_subslice
, 8);
1053 devinfo
->eu_slice_stride
= topology
->max_subslices
* devinfo
->eu_subslice_stride
;
1055 assert(sizeof(devinfo
->slice_masks
) >= DIV_ROUND_UP(topology
->max_slices
, 8));
1056 memcpy(&devinfo
->slice_masks
, topology
->data
, DIV_ROUND_UP(topology
->max_slices
, 8));
1057 devinfo
->num_slices
= __builtin_popcount(devinfo
->slice_masks
);
1059 uint32_t subslice_mask_len
=
1060 topology
->max_slices
* topology
->subslice_stride
;
1061 assert(sizeof(devinfo
->subslice_masks
) >= subslice_mask_len
);
1062 memcpy(devinfo
->subslice_masks
, &topology
->data
[topology
->subslice_offset
],
1065 uint32_t n_subslices
= 0;
1066 for (int s
= 0; s
< topology
->max_slices
; s
++) {
1067 if ((devinfo
->slice_masks
& (1UL << s
)) == 0)
1070 for (int b
= 0; b
< devinfo
->subslice_slice_stride
; b
++) {
1071 devinfo
->num_subslices
[s
] +=
1072 __builtin_popcount(devinfo
->subslice_masks
[b
]);
1074 n_subslices
+= devinfo
->num_subslices
[s
];
1076 assert(n_subslices
> 0);
1078 uint32_t eu_mask_len
=
1079 topology
->eu_stride
* topology
->max_subslices
* topology
->max_slices
;
1080 assert(sizeof(devinfo
->eu_masks
) >= eu_mask_len
);
1081 memcpy(devinfo
->eu_masks
, &topology
->data
[topology
->eu_offset
], eu_mask_len
);
1084 for (int b
= 0; b
< eu_mask_len
; b
++)
1085 n_eus
+= __builtin_popcount(devinfo
->eu_masks
[b
]);
1087 devinfo
->num_eu_per_subslice
= DIV_ROUND_UP(n_eus
, n_subslices
);
1091 gen_get_device_info(int devid
, struct gen_device_info
*devinfo
)
1095 #define CHIPSET(id, family, name) \
1096 case id: *devinfo = gen_device_info_##family; break;
1097 #include "pci_ids/i965_pci_ids.h"
1099 fprintf(stderr
, "i965_dri.so does not support the 0x%x PCI ID.\n", devid
);
1103 fill_masks(devinfo
);
1105 /* From the Skylake PRM, 3DSTATE_PS::Scratch Space Base Pointer:
1107 * "Scratch Space per slice is computed based on 4 sub-slices. SW must
1108 * allocate scratch space enough so that each slice has 4 slices allowed."
1110 * The equivalent internal documentation says that this programming note
1111 * applies to all Gen9+ platforms.
1113 * The hardware typically calculates the scratch space pointer by taking
1114 * the base address, and adding per-thread-scratch-space * thread ID.
1115 * Extra padding can be necessary depending how the thread IDs are
1116 * calculated for a particular shader stage.
1119 switch(devinfo
->gen
) {
1122 devinfo
->max_wm_threads
= 64 /* threads-per-PSD */
1123 * devinfo
->num_slices
1124 * 4; /* effective subslices per slice */
1127 devinfo
->max_wm_threads
= 128 /* threads-per-PSD */
1128 * devinfo
->num_slices
1129 * 8; /* subslices per slice */
1135 assert(devinfo
->num_slices
<= ARRAY_SIZE(devinfo
->num_subslices
));
1141 gen_get_device_name(int devid
)
1145 #define CHIPSET(id, family, name) case id: return name;
1146 #include "pci_ids/i965_pci_ids.h"