Path: blob/21.2-virgl/src/intel/dev/intel_device_info.h
7086 views
/*1* Copyright © 2013 Intel Corporation2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*22*/2324#ifndef INTEL_DEVICE_INFO_H25#define INTEL_DEVICE_INFO_H2627#include <stdbool.h>28#include <stdint.h>2930#include "util/macros.h"3132#ifdef __cplusplus33extern "C" {34#endif3536struct drm_i915_query_topology_info;3738#define INTEL_DEVICE_MAX_SLICES (6) /* Maximum on gfx10 */39#define INTEL_DEVICE_MAX_SUBSLICES (8) /* Maximum on gfx11 */40#define INTEL_DEVICE_MAX_EUS_PER_SUBSLICE (16) /* Maximum on gfx12 */41#define INTEL_DEVICE_MAX_PIXEL_PIPES (3) /* Maximum on gfx12 */4243/**44* Intel hardware information and quirks45*/46struct intel_device_info47{48/* Driver internal numbers used to differentiate platforms. */49int ver;50int verx10;51int revision;52int gt;5354bool is_g4x;55bool is_ivybridge;56bool is_baytrail;57bool is_haswell;58bool is_broadwell;59bool is_cherryview;60bool is_skylake;61bool is_broxton;62bool is_kabylake;63bool is_geminilake;64bool is_coffeelake;65bool is_elkhartlake;66bool is_tigerlake;67bool is_rocketlake;68bool is_dg1;69bool is_alderlake;7071bool has_hiz_and_separate_stencil;72bool must_use_separate_stencil;73bool has_sample_with_hiz;74bool has_llc;7576bool has_pln;77bool has_64bit_float;78bool has_64bit_int;79bool has_integer_dword_mul;80bool has_compr4;81bool has_surface_tile_offset;82bool supports_simd16_3src;83bool disable_ccs_repack;84bool has_aux_map;85bool has_tiling_uapi;86bool has_ray_tracing;87bool has_local_mem;88bool has_lsc;8990/**91* \name Intel hardware quirks92* @{93*/94bool has_negative_rhw_bug;9596/**97* Some versions of Gen hardware don't do centroid interpolation correctly98* on unlit pixels, causing incorrect values for derivatives near triangle99* edges. Enabling this flag causes the fragment shader to use100* non-centroid interpolation for unlit pixels, at the expense of two extra101* fragment shader instructions.102*/103bool needs_unlit_centroid_workaround;104/** @} */105106/**107* \name GPU hardware limits108*109* In general, you can find shader thread maximums by looking at the "Maximum110* Number of Threads" field in the Intel PRM description of the 3DSTATE_VS,111* 3DSTATE_GS, 3DSTATE_HS, 3DSTATE_DS, and 3DSTATE_PS commands. URB entry112* limits come from the "Number of URB Entries" field in the113* 3DSTATE_URB_VS command and friends.114*115* These fields are used to calculate the scratch space to allocate. The116* amount of scratch space can be larger without being harmful on modern117* GPUs, however, prior to Haswell, programming the maximum number of threads118* to greater than the hardware maximum would cause GPU performance to tank.119*120* @{121*/122/**123* Total number of slices present on the device whether or not they've been124* fused off.125*126* XXX: CS thread counts are limited by the inability to do cross subslice127* communication. It is the effectively the number of logical threads which128* can be executed in a subslice. Fuse configurations may cause this number129* to change, so we program @max_cs_threads as the lower maximum.130*/131unsigned num_slices;132133/**134* Number of subslices for each slice (used to be uniform until CNL).135*/136unsigned num_subslices[INTEL_DEVICE_MAX_SUBSLICES];137138/**139* Number of subslices on each pixel pipe (ICL).140*/141unsigned ppipe_subslices[INTEL_DEVICE_MAX_PIXEL_PIPES];142143/**144* Upper bound of number of EU per subslice (some SKUs might have just 1 EU145* fused across all subslices, like 47 EUs, in which case this number won't146* be acurate for one subslice).147*/148unsigned num_eu_per_subslice;149150/**151* Number of threads per eu, varies between 4 and 8 between generations.152*/153unsigned num_thread_per_eu;154155/**156* A bit mask of the slices available.157*/158uint8_t slice_masks;159160/**161* An array of bit mask of the subslices available, use subslice_slice_stride162* to access this array.163*/164uint8_t subslice_masks[INTEL_DEVICE_MAX_SLICES *165DIV_ROUND_UP(INTEL_DEVICE_MAX_SUBSLICES, 8)];166167/**168* An array of bit mask of EUs available, use eu_slice_stride &169* eu_subslice_stride to access this array.170*/171uint8_t eu_masks[INTEL_DEVICE_MAX_SLICES *172INTEL_DEVICE_MAX_SUBSLICES *173DIV_ROUND_UP(INTEL_DEVICE_MAX_EUS_PER_SUBSLICE, 8)];174175/**176* Stride to access subslice_masks[].177*/178uint16_t subslice_slice_stride;179180/**181* Strides to access eu_masks[].182*/183uint16_t eu_slice_stride;184uint16_t eu_subslice_stride;185186unsigned l3_banks;187unsigned max_vs_threads; /**< Maximum Vertex Shader threads */188unsigned max_tcs_threads; /**< Maximum Hull Shader threads */189unsigned max_tes_threads; /**< Maximum Domain Shader threads */190unsigned max_gs_threads; /**< Maximum Geometry Shader threads. */191/**192* Theoretical maximum number of Pixel Shader threads.193*194* PSD means Pixel Shader Dispatcher. On modern Intel GPUs, hardware will195* automatically scale pixel shader thread count, based on a single value196* programmed into 3DSTATE_PS.197*198* To calculate the maximum number of threads for Gfx8 beyond (which have199* multiple Pixel Shader Dispatchers):200*201* - Look up 3DSTATE_PS and find "Maximum Number of Threads Per PSD"202* - Usually there's only one PSD per subslice, so use the number of203* subslices for number of PSDs.204* - For max_wm_threads, the total should be PSD threads * #PSDs.205*/206unsigned max_wm_threads;207208/**209* Maximum Compute Shader threads.210*211* Thread count * number of EUs per subslice212*/213unsigned max_cs_threads;214215struct {216/**217* Fixed size of the URB.218*219* On Gfx6 and DG1, this is measured in KB. Gfx4-5 instead measure220* this in 512b blocks, as that's more convenient there.221*222* On most Gfx7+ platforms, the URB is a section of the L3 cache,223* and can be resized based on the L3 programming. For those platforms,224* simply leave this field blank (zero) - it isn't used.225*/226unsigned size;227228/**229* The minimum number of URB entries. See the 3DSTATE_URB_<XS> docs.230*/231unsigned min_entries[4];232233/**234* The maximum number of URB entries. See the 3DSTATE_URB_<XS> docs.235*/236unsigned max_entries[4];237} urb;238239/**240* Size of the command streamer prefetch. This is important to know for241* self modifying batches.242*/243unsigned cs_prefetch_size;244245/**246* For the longest time the timestamp frequency for Gen's timestamp counter247* could be assumed to be 12.5MHz, where the least significant bit neatly248* corresponded to 80 nanoseconds.249*250* Since Gfx9 the numbers aren't so round, with a a frequency of 12MHz for251* SKL (or scale factor of 83.33333333) and a frequency of 19200000Hz for252* BXT.253*254* For simplicty to fit with the current code scaling by a single constant255* to map from raw timestamps to nanoseconds we now do the conversion in256* floating point instead of integer arithmetic.257*258* In general it's probably worth noting that the documented constants we259* have for the per-platform timestamp frequencies aren't perfect and260* shouldn't be trusted for scaling and comparing timestamps with a large261* delta.262*263* E.g. with crude testing on my system using the 'correct' scale factor I'm264* seeing a drift of ~2 milliseconds per second.265*/266uint64_t timestamp_frequency;267268uint64_t aperture_bytes;269270/**271* ID to put into the .aub files.272*/273int simulator_id;274275/**276* holds the pci device id277*/278uint32_t chipset_id;279280/**281* no_hw is true when the chipset_id pci device id has been overridden282*/283bool no_hw;284/** @} */285};286287#ifdef GFX_VER288289#define intel_device_info_is_9lp(devinfo) \290(GFX_VER == 9 && ((devinfo)->is_broxton || (devinfo)->is_geminilake))291292#else293294#define intel_device_info_is_9lp(devinfo) \295((devinfo)->is_broxton || (devinfo)->is_geminilake)296297#endif298299static inline bool300intel_device_info_subslice_available(const struct intel_device_info *devinfo,301int slice, int subslice)302{303return (devinfo->subslice_masks[slice * devinfo->subslice_slice_stride +304subslice / 8] & (1U << (subslice % 8))) != 0;305}306307static inline bool308intel_device_info_eu_available(const struct intel_device_info *devinfo,309int slice, int subslice, int eu)310{311unsigned subslice_offset = slice * devinfo->eu_slice_stride +312subslice * devinfo->eu_subslice_stride;313314return (devinfo->eu_masks[subslice_offset + eu / 8] & (1U << eu % 8)) != 0;315}316317static inline uint32_t318intel_device_info_subslice_total(const struct intel_device_info *devinfo)319{320uint32_t total = 0;321322for (uint32_t i = 0; i < devinfo->num_slices; i++)323total += __builtin_popcount(devinfo->subslice_masks[i]);324325return total;326}327328static inline uint32_t329intel_device_info_eu_total(const struct intel_device_info *devinfo)330{331uint32_t total = 0;332333for (uint32_t i = 0; i < ARRAY_SIZE(devinfo->eu_masks); i++)334total += __builtin_popcount(devinfo->eu_masks[i]);335336return total;337}338339static inline unsigned340intel_device_info_num_dual_subslices(UNUSED341const struct intel_device_info *devinfo)342{343unreachable("TODO");344}345346int intel_device_name_to_pci_device_id(const char *name);347const char *intel_get_device_name(int devid);348349static inline uint64_t350intel_device_info_timebase_scale(const struct intel_device_info *devinfo,351uint64_t gpu_timestamp)352{353return (1000000000ull * gpu_timestamp) / devinfo->timestamp_frequency;354}355356bool intel_get_device_info_from_fd(int fh, struct intel_device_info *devinfo);357bool intel_get_device_info_from_pci_id(int pci_id,358struct intel_device_info *devinfo);359int intel_get_aperture_size(int fd, uint64_t *size);360361#ifdef __cplusplus362}363#endif364365#endif /* INTEL_DEVICE_INFO_H */366367368