1 /*========================== begin_copyright_notice ============================
2 
3 Copyright (C) 2017-2021 Intel Corporation
4 
5 SPDX-License-Identifier: MIT
6 
7 ============================= end_copyright_notice ===========================*/
8 
9 #pragma once
10 #include "inc/common/igfxfmid.h"
11 #include "Compiler/compiler_caps.h"
12 #include "Compiler/igc_workaround.h"
13 #include "common/Types.hpp"
14 #include "Probe/Assertion.h"
15 #include "common/igc_regkeys.hpp"
16 
17 
18 namespace IGC
19 {
20 
21 class CPlatform
22 {
23     PLATFORM m_platformInfo = {};
24     SCompilerHwCaps m_caps = {};
25     WA_TABLE m_WaTable = {};
26     SKU_FEATURE_TABLE m_SkuTable = {};
27     GT_SYSTEM_INFO m_GTSystemInfo = {};
28     OCLCaps m_OCLCaps = {};
29 
30 public:
CPlatform()31     CPlatform() {}
32 
CPlatform(const PLATFORM & platform)33     CPlatform(const PLATFORM& platform)
34     {
35         m_platformInfo = platform;
36     }
37 
38 public:
setOclCaps(OCLCaps & caps)39 void setOclCaps(OCLCaps& caps) { m_OCLCaps = caps; }
getMaxOCLParameteSize() const40 uint32_t getMaxOCLParameteSize() const {
41     uint32_t limitFromFlag = IGC_GET_FLAG_VALUE(OverrideOCLMaxParamSize);
42     return limitFromFlag ? limitFromFlag : m_OCLCaps.MaxParameterSize;
43 }
OverrideRevId(unsigned short newRevId)44 void OverrideRevId(unsigned short newRevId)
45 {
46     m_platformInfo.usRevId = newRevId;
47 }
48 
OverrideDeviceId(unsigned short newDeviceID)49 void OverrideDeviceId(unsigned short newDeviceID)
50 {
51     m_platformInfo.usDeviceID = newDeviceID;
52 }
53 
54 
OverrideProductFamily(unsigned int productID)55 void OverrideProductFamily(unsigned int productID)
56 {
57     PRODUCT_FAMILY eProd = static_cast<PRODUCT_FAMILY>(productID);
58     if(eProd > IGFX_UNKNOWN && eProd < IGFX_MAX_PRODUCT)
59         m_platformInfo.eProductFamily = (PRODUCT_FAMILY)productID;
60 }
61 
getWATable() const62     WA_TABLE const& getWATable() const { return m_WaTable; }
getSkuTable() const63 SKU_FEATURE_TABLE const& getSkuTable() const { return m_SkuTable; }
64 
hasPackedVertexAttr() const65 bool hasPackedVertexAttr() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN9_CORE; }
hasScaledMessage() const66 bool hasScaledMessage() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN9_CORE; }
has8ByteA64ByteScatteredMessage() const67 bool has8ByteA64ByteScatteredMessage() const { return m_platformInfo.eRenderCoreFamily == IGFX_GEN8_CORE; }
68 
hasPredicatedBarriers() const69 bool hasPredicatedBarriers() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN9_CORE; }
hasIEEEMinmaxBit() const70 bool hasIEEEMinmaxBit() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN9_CORE; }
hasL1ReadOnlyCache() const71 bool hasL1ReadOnlyCache() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN10_CORE; }
72 // Gen10+ HW supports adding vertex start to vertex ID
hasVertexOffsetEnable() const73 bool hasVertexOffsetEnable() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN10_CORE; }
74 
75 // Gen10+ HW supports sending base instance, base vertex and draw index with
76 // VF, this is programmed using 3DSTATE_VF_SGVS2 command.
hasSGVS2Command() const77 bool hasSGVS2Command() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN10_CORE; }
78 
79 // Sampler supports normalization of coordinates during sampling from
80 // rectangle textures.
supportsCoordinateNormalizationForRectangleTextures() const81 bool supportsCoordinateNormalizationForRectangleTextures() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN10_CORE; }
82 
83 /// On some platforms ld sources order is: u lod v r
hasOldLdOrder() const84 bool hasOldLdOrder() const { return m_platformInfo.eRenderCoreFamily <= IGFX_GEN8_CORE; }
supportSampleAndLd_lz() const85 bool supportSampleAndLd_lz() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN9_CORE; }
supportSamplerToRT() const86 bool supportSamplerToRT() const {
87         return (m_platformInfo.eProductFamily == IGFX_CHERRYVIEW) || (m_platformInfo.eRenderCoreFamily == IGFX_GEN9_CORE);
88     }
supportFP16() const89     bool supportFP16() const {
90         return (m_platformInfo.eRenderCoreFamily >= IGFX_GEN9_CORE) ||
91             ((m_platformInfo.eRenderCoreFamily == IGFX_GEN8_CORE) && (m_platformInfo.eProductFamily == IGFX_CHERRYVIEW));
92     }
supportFP16Rounding() const93 bool supportFP16Rounding() const { return false; }
supportSamplerFp16Input() const94 bool supportSamplerFp16Input() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN10_CORE; }
supportPooledEU() const95 bool supportPooledEU() const { return m_SkuTable.FtrPooledEuEnabled != 0; }
supportSplitSend() const96 bool supportSplitSend() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN9_CORE; }
supportSendInstShootdown() const97 bool supportSendInstShootdown() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN10_CORE; }
supportHSEightPatchDispatch() const98 bool supportHSEightPatchDispatch() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN9_CORE; }
supportSingleInstanceVertexShader() const99 bool supportSingleInstanceVertexShader() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN10_CORE; }
supportDSDualPatchDispatch() const100 bool supportDSDualPatchDispatch() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN9_CORE; }
needsHSBarrierIDWorkaround() const101 bool needsHSBarrierIDWorkaround() const { return m_platformInfo.eRenderCoreFamily <= IGFX_GEN10_CORE; }
supportBindless() const102 bool supportBindless() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN9_CORE; }
supportsBindlessSamplers() const103 bool supportsBindlessSamplers() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN10_CORE; }
104 
SupportSurfaceInfoMessage() const105 bool SupportSurfaceInfoMessage() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN9_CORE; }
SupportHDCUnormFormats() const106 bool SupportHDCUnormFormats() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN10_CORE; }
localMemFenceSupress() const107     bool localMemFenceSupress() const {
108         return m_platformInfo.eRenderCoreFamily <= IGFX_GEN9_CORE ||
109             IGC_IS_FLAG_ENABLED(DisbleLocalFences);
110     }
psSimd32SkipStallHeuristic() const111 bool psSimd32SkipStallHeuristic() const { return m_caps.KernelHwCaps.EUThreadsPerEU == 6; }
enablePSsimd32() const112 bool enablePSsimd32() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN9_CORE; }
113 
supportSimd32PerPixelPSWithNumSamples16() const114 bool supportSimd32PerPixelPSWithNumSamples16() const
115 {
116     return false;
117 }
118 
119 
supportDisableMidThreadPreemptionSwitch() const120 bool supportDisableMidThreadPreemptionSwitch() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN10_CORE; }
121 
needSWStencil() const122 bool needSWStencil() const
123 {
124         return (m_platformInfo.eRenderCoreFamily == IGFX_GEN9_CORE && IGC_IS_FLAG_ENABLED(EnableSoftwareStencil));
125 }
supportMSAARateInPayload() const126 bool supportMSAARateInPayload() const
127 {
128     return m_platformInfo.eRenderCoreFamily >= IGFX_GEN10_CORE;
129 }
130 
support16BitImmSrcForMad() const131 bool support16BitImmSrcForMad() const {
132     return (m_platformInfo.eRenderCoreFamily >= IGFX_GEN10_CORE);
133 }
GetProductFamily() const134 PRODUCT_FAMILY GetProductFamily() const { return m_platformInfo.eProductFamily; }
GetDeviceId() const135 unsigned short GetDeviceId() const { return m_platformInfo.usDeviceID; }
GetRevId() const136 unsigned short GetRevId() const { return m_platformInfo.usRevId; }
GetPlatformFamily() const137 GFXCORE_FAMILY GetPlatformFamily() const { return m_platformInfo.eRenderCoreFamily; }
getPlatformInfo() const138 const PLATFORM& getPlatformInfo() const { return m_platformInfo; }
SetCaps(const SCompilerHwCaps & caps)139 void SetCaps(const SCompilerHwCaps& caps) { m_caps = caps; }
SetWATable(const WA_TABLE & waTable)140 void SetWATable(const WA_TABLE& waTable) { m_WaTable = waTable; }
SetSkuTable(const SKU_FEATURE_TABLE & skuTable)141 void SetSkuTable(const SKU_FEATURE_TABLE& skuTable) { m_SkuTable = skuTable; }
SetGTSystemInfo(const SUscGTSystemInfo gtSystemInfo)142 void SetGTSystemInfo(const SUscGTSystemInfo gtSystemInfo) {
143     m_GTSystemInfo.EUCount = gtSystemInfo.EUCount;
144     m_GTSystemInfo.ThreadCount = gtSystemInfo.ThreadCount;
145     m_GTSystemInfo.SliceCount = gtSystemInfo.SliceCount;
146     m_GTSystemInfo.SubSliceCount = gtSystemInfo.SubSliceCount;
147     m_GTSystemInfo.SLMSizeInKb = gtSystemInfo.SLMSizeInKb;
148     m_GTSystemInfo.TotalPsThreadsWindowerRange = gtSystemInfo.TotalPsThreadsWindowerRange;
149     m_GTSystemInfo.TotalVsThreads = gtSystemInfo.TotalVsThreads;
150     m_GTSystemInfo.TotalVsThreads_Pocs = gtSystemInfo.TotalVsThreads_Pocs;
151     m_GTSystemInfo.TotalDsThreads = gtSystemInfo.TotalDsThreads;
152     m_GTSystemInfo.TotalGsThreads = gtSystemInfo.TotalGsThreads;
153     m_GTSystemInfo.TotalHsThreads = gtSystemInfo.TotalHsThreads;
154     m_GTSystemInfo.MaxEuPerSubSlice = gtSystemInfo.MaxEuPerSubSlice;
155     m_GTSystemInfo.EuCountPerPoolMax = gtSystemInfo.EuCountPerPoolMax;
156     m_GTSystemInfo.EuCountPerPoolMin = gtSystemInfo.EuCountPerPoolMin;
157     m_GTSystemInfo.MaxSlicesSupported = gtSystemInfo.MaxSlicesSupported;
158     m_GTSystemInfo.MaxSubSlicesSupported = gtSystemInfo.MaxSubSlicesSupported;
159     m_GTSystemInfo.IsDynamicallyPopulated = gtSystemInfo.IsDynamicallyPopulated;
160     m_GTSystemInfo.CsrSizeInMb = gtSystemInfo.CsrSizeInMb;
161 }
162 
SetGTSystemInfo(const GT_SYSTEM_INFO & gtSystemInfo)163     void SetGTSystemInfo(const GT_SYSTEM_INFO& gtSystemInfo) {
164     m_GTSystemInfo = gtSystemInfo;
165 }
166 
GetGTSystemInfo() const167 GT_SYSTEM_INFO GetGTSystemInfo() const { return m_GTSystemInfo; }
168 
getMaxPixelShaderThreads() const169     unsigned int getMaxPixelShaderThreads() const {
170         return m_platformInfo.eRenderCoreFamily >= IGFX_GEN9_CORE ?
171             m_caps.PixelShaderThreadsWindowerRange - 1 : m_caps.PixelShaderThreadsWindowerRange - 2;
172     }
supportGPGPUMidThreadPreemption() const173 bool supportGPGPUMidThreadPreemption() const {
174     return m_platformInfo.eRenderCoreFamily >= IGFX_GEN9_CORE &&
175         m_platformInfo.eRenderCoreFamily <= IGFX_GEN11LP_CORE;
176 }
supportFtrWddm2Svm() const177 bool supportFtrWddm2Svm() const { return m_SkuTable.FtrWddm2Svm != 0; }
supportStructuredAsRaw() const178 bool supportStructuredAsRaw() const {
179         return m_platformInfo.eRenderCoreFamily >= IGFX_GEN9_CORE;
180     }
supportSamplerCacheResinfo() const181 bool supportSamplerCacheResinfo() const { return m_platformInfo.eRenderCoreFamily == IGFX_GEN8_CORE; }
182 
getMaxVertexShaderThreads(const bool isPositionOnlyShader) const183 unsigned int getMaxVertexShaderThreads(const bool isPositionOnlyShader) const
184 {
185     const unsigned int maxVertexShaderThreads = isPositionOnlyShader ? m_caps.VertexShaderThreadsPosh : m_caps.VertexShaderThreads;
186     return maxVertexShaderThreads - 1;
187 }
getMaxGeometryShaderThreads() const188 unsigned int getMaxGeometryShaderThreads() const { return m_caps.GeometryShaderThreads - 1; }
getMaxHullShaderThreads() const189 unsigned int getMaxHullShaderThreads() const { return m_caps.HullShaderThreads - 1; }
getMaxDomainShaderThreads() const190 unsigned int getMaxDomainShaderThreads() const { return m_caps.DomainShaderThreads - 1; }
getMaxGPGPUShaderThreads() const191 unsigned int getMaxGPGPUShaderThreads() const { return m_caps.MediaShaderThreads - 1; }
getKernelPointerAlignSize() const192 unsigned int getKernelPointerAlignSize() const { return m_caps.KernelHwCaps.KernelPointerAlignSize; }
getSharedLocalMemoryBlockSize() const193 unsigned int getSharedLocalMemoryBlockSize() const { return m_caps.SharedLocalMemoryBlockSize; }
getMaxNumberThreadPerSubslice() const194 unsigned int getMaxNumberThreadPerSubslice() const
195 {
196     //total number of threads per subslice
197         if (m_caps.KernelHwCaps.SubSliceCount != 0)
198         return m_caps.KernelHwCaps.ThreadCount / m_caps.KernelHwCaps.SubSliceCount;
199     return 0;
200 }
getMaxNumberThreadPerWorkgroupPooledMax() const201 unsigned int getMaxNumberThreadPerWorkgroupPooledMax() const
202 {
203     return m_caps.KernelHwCaps.EUCountPerPoolMax * m_caps.KernelHwCaps.EUThreadsPerEU;
204 }
getFFTIDBitMask() const205 unsigned int getFFTIDBitMask() const {
206     return (m_platformInfo.eRenderCoreFamily >= IGFX_GEN10_CORE) ? 0x3FF : 0x1FF;
207 }
getBarrierCountBits(unsigned int count) const208 unsigned int getBarrierCountBits(unsigned int count) const
209 {
210     // Returns barrier count field + enable for barrier message
211     if (m_platformInfo.eRenderCoreFamily <= IGFX_GEN10_CORE)
212     {
213         // up to Gen9 barrier count is in bits 14:9, enable is bit 15
214         return (count << 9) | (1 << 15);
215     }
216     else
217     {
218         // for Gen10+ barrier count is in bits 14:8, enable is bit 15
219         return (count << 8) | (1 << 15);
220     }
221 }
222 
supportsDrawParametersSGVs() const223 bool supportsDrawParametersSGVs() const
224 {
225     // Gen10+, 3DSTATE_VF_SGVS_2
226     return m_platformInfo.eRenderCoreFamily >= IGFX_GEN10_CORE;
227 }
228 
hasPSDBottleneck() const229 bool hasPSDBottleneck() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN11_CORE; }
230 
supportsHardwareResourceStreamer() const231 bool supportsHardwareResourceStreamer() const
232 {
233     return m_platformInfo.eRenderCoreFamily < IGFX_GEN11_CORE;
234 }
AOComputeShadersSIMD32Mode() const235 bool AOComputeShadersSIMD32Mode() const
236 {
237     return (m_platformInfo.eRenderCoreFamily >= IGFX_GEN11_CORE);
238 }
getHullShaderThreadInstanceIdBitFieldPosition() const239 unsigned int getHullShaderThreadInstanceIdBitFieldPosition() const
240 {
241     // HS thread receives instance ID in R0.2 bits 22:16 for Gen10+ and bits 23:17 for older Gens
242     return (m_platformInfo.eRenderCoreFamily >= IGFX_GEN11_CORE) ? 16 : 17;
243 }
supportsBinaryAtomicCounterMessage() const244 bool supportsBinaryAtomicCounterMessage() const
245 {
246     return m_platformInfo.eRenderCoreFamily >= IGFX_GEN11_CORE;
247 }
supportSLMBlockMessage() const248 bool supportSLMBlockMessage() const
249 {
250     return (m_platformInfo.eRenderCoreFamily >= IGFX_GEN11_CORE);
251 }
252 
hasSLMFence() const253 bool hasSLMFence() const
254 {
255     return (m_platformInfo.eRenderCoreFamily >= IGFX_GEN11_CORE);
256 }
257 
supportRotateInstruction() const258 bool supportRotateInstruction() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN11_CORE; }
supportLRPInstruction() const259 bool supportLRPInstruction() const { return m_platformInfo.eRenderCoreFamily < IGFX_GEN11_CORE; }
support16bitMSAAPayload() const260 bool support16bitMSAAPayload() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN11_CORE; }
supportTwoStackTSG() const261 bool supportTwoStackTSG() const
262 {
263     //Will need check for specific skus where TwoStackTSG is enabled
264     //Not all skus have it enabled
265     return (m_platformInfo.eRenderCoreFamily >= IGFX_GEN11_CORE);
266 }
enableBlendToDiscardAndFill() const267 bool enableBlendToDiscardAndFill() const
268 {
269     return (m_platformInfo.eRenderCoreFamily < IGFX_GEN11_CORE);
270 }
HSUsesHWBarriers() const271 bool HSUsesHWBarriers() const
272 {
273     // HS HW barriers work correctly since ICL platform.
274     return (m_platformInfo.eRenderCoreFamily >= IGFX_GEN11_CORE);
275 }
276 
NeedResetA0forVxHA0() const277 bool NeedResetA0forVxHA0() const
278 {
279     return (m_platformInfo.eRenderCoreFamily >= IGFX_GEN11_CORE);
280 }
281 
GetLogBindlessSamplerSize() const282 unsigned int GetLogBindlessSamplerSize() const
283 {
284     // Samplers are 16 bytes
285     return 4;
286 }
287 
SupportCPS() const288 bool SupportCPS() const
289 {
290     return (m_platformInfo.eRenderCoreFamily >= IGFX_GEN10_CORE);
291 }
292 
supportsThreadCombining() const293 bool supportsThreadCombining() const
294 {
295     return (!(!m_WaTable.WaEnablePooledEuFor2x6 &&
296         m_platformInfo.eProductFamily == IGFX_BROXTON &&
297         m_GTSystemInfo.SubSliceCount == 2))
298         && (m_platformInfo.eRenderCoreFamily < IGFX_GEN12_CORE);
299 }
300 
enableMaxWorkGroupSizeCalculation() const301 bool enableMaxWorkGroupSizeCalculation() const
302 {
303     return (m_platformInfo.eRenderCoreFamily >= IGFX_GEN11_CORE) &&
304         IGC_IS_FLAG_ENABLED(EnableMaxWGSizeCalculation);
305 }
306 
has8DWA64ScatteredMessage() const307 bool has8DWA64ScatteredMessage() const { return m_platformInfo.eRenderCoreFamily < IGFX_GEN12_CORE; }
308 
flushL3ForTypedMemory() const309 bool flushL3ForTypedMemory() const
310 {
311     return m_platformInfo.eRenderCoreFamily <= IGFX_GEN11_CORE;
312 }
313 
supportsStencil(SIMDMode simdMode) const314 bool supportsStencil(SIMDMode simdMode) const
315 {
316     return getMinDispatchMode() == SIMDMode::SIMD16 ? true : simdMode == SIMDMode::SIMD8;
317 }
318 
hasFDIV() const319 bool hasFDIV() const {
320     if (IGC_IS_FLAG_ENABLED(DisableFDIV))
321         return false;
322     return (m_platformInfo.eRenderCoreFamily < IGFX_GEN12_CORE);
323 }
324 
doIntegerMad() const325 bool doIntegerMad() const
326 {
327     return m_platformInfo.eRenderCoreFamily >= IGFX_GEN11_CORE && m_platformInfo.eProductFamily != IGFX_DG1 &&
328         IGC_IS_FLAG_ENABLED(EnableIntegerMad);
329 }
330 
isDG1() const331 bool isDG1() const
332 {
333     return m_platformInfo.eProductFamily == IGFX_DG1;
334 }
335 
simplePushIsFasterThanGather() const336 bool simplePushIsFasterThanGather() const
337 {
338     return m_platformInfo.eRenderCoreFamily >= IGFX_GEN12_CORE;
339 }
340 
singleThreadBasedInstScheduling() const341 bool singleThreadBasedInstScheduling() const
342 {
343     return m_platformInfo.eRenderCoreFamily < IGFX_GEN12_CORE;
344 }
345 
346 //all the platforms which do not support 64 bit operations and
347 //needs int64 emulation support. Except also for BXT where
348 //64-bit inst has much lower throughput compared to SKL.
349 //Emulating it improves performance on some benchmarks and
350 //won't have impact on the overall performance.
need64BitEmulation() const351 bool need64BitEmulation() const {
352     return m_platformInfo.eProductFamily == IGFX_GEMINILAKE ||
353         m_platformInfo.eProductFamily == IGFX_BROXTON ||
354         hasNoInt64Inst();
355 }
356 
HDCCoalesceSLMAtomicINCWithNoReturn() const357 bool HDCCoalesceSLMAtomicINCWithNoReturn() const
358 {
359     return m_platformInfo.eRenderCoreFamily >= IGFX_GEN12_CORE;
360 }
361 
HDCCoalesceAtomicCounterAccess() const362 bool HDCCoalesceAtomicCounterAccess() const
363 {
364     return (m_platformInfo.eRenderCoreFamily < IGFX_GEN12_CORE) && IGC_IS_FLAG_DISABLED(ForceSWCoalescingOfAtomicCounter);
365 }
366 
supportsMCSNonCompressedFix() const367 bool supportsMCSNonCompressedFix() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN12_CORE; }
368 
hasHWDp4AddSupport() const369 bool hasHWDp4AddSupport() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN12_CORE; }
370 
useOnlyEightPatchDispatchHS() const371 bool useOnlyEightPatchDispatchHS() const
372 {
373     return (m_platformInfo.eRenderCoreFamily >= IGFX_GEN12_CORE);
374 }
375 
supportsPrimitiveReplication() const376 bool supportsPrimitiveReplication() const
377 {
378     return ((m_platformInfo.eRenderCoreFamily >= IGFX_GEN12_CORE) ||
379             (m_platformInfo.eRenderCoreFamily == IGFX_GEN11_CORE && m_platformInfo.eProductFamily == IGFX_ICELAKE));
380 }
381 
382 // If true then screen space coordinates for upper-left vertex of a triangle
383 // being rasterized are delivered together with source depth or W deltas.
hasStartCoordinatesDeliveredWithDeltas() const384 bool hasStartCoordinatesDeliveredWithDeltas() const
385 {
386     return m_platformInfo.eRenderCoreFamily >= IGFX_GEN12_CORE;
387 }
388 
disableStaticVertexCount() const389 bool disableStaticVertexCount() const
390 {
391     return m_WaTable.Wa_14012504847 != 0 || IGC_IS_FLAG_ENABLED(ForceStaticToDynamic);
392 }
393 
hasSamplerSupport() const394 bool hasSamplerSupport() const
395 {
396     return true;
397 }
398 
getMinPushConstantBufferAlignment() const399 uint32_t getMinPushConstantBufferAlignment() const
400 {
401     return 8; // DWORDs
402 }
403 
404 // Returns the default limit of pushed constant data in GRFs. This value limits
405 // the amount of constant buffer data promoted to registers.
getBlockPushConstantGRFThreshold() const406 uint32_t getBlockPushConstantGRFThreshold() const
407 {
408     constexpr uint32_t defaultThreshold = 31;
409     constexpr uint32_t gen9GT2Threshold = 15;
410 
411     const GTTYPE gt = m_platformInfo.eGTType;
412     switch (m_platformInfo.eProductFamily)
413     {
414     case IGFX_COFFEELAKE:
415     case IGFX_SKYLAKE:
416     case IGFX_KABYLAKE:
417         return (gt == GTTYPE_GT2) ? gen9GT2Threshold : defaultThreshold;
418     default:
419         return defaultThreshold;
420     }
421 }
422 
hasDualSubSlices() const423 bool hasDualSubSlices() const
424 {
425     bool hasDualSS = m_platformInfo.eRenderCoreFamily == IGFX_GEN12_CORE ||
426         m_platformInfo.eRenderCoreFamily == IGFX_GEN12LP_CORE;
427     return hasDualSS;
428 }
429 
getSlmSizePerSsOrDss() const430 unsigned getSlmSizePerSsOrDss() const
431 {
432     // GTSysInfo sets SLMSize only for gen12+
433     unsigned slmSizePerSsOrDss = 65536;
434     if (hasDualSubSlices())
435     {
436         if (GetGTSystemInfo().DualSubSliceCount)
437         {
438             slmSizePerSsOrDss = GetGTSystemInfo().SLMSizeInKb / GetGTSystemInfo().DualSubSliceCount * 1024;
439         }
440         else
441         {
442             slmSizePerSsOrDss = 131072;
443         }
444     }
445     return slmSizePerSsOrDss;
446 }
447 
canForcePrivateToGlobal() const448 bool canForcePrivateToGlobal() const
449 {
450     return m_platformInfo.eRenderCoreFamily >= IGFX_GEN9_CORE && IGC_IS_FLAG_ENABLED(ForcePrivateMemoryToGlobalOnGeneric);
451 }
452 
getHWTIDFromSR0() const453 bool getHWTIDFromSR0() const
454 {
455     return isXeHPSDVPlus();
456 }
457 
supportAdd3Instruction() const458 bool supportAdd3Instruction() const
459 {
460     return isXeHPSDVPlus();
461 }
462 
supportBfnInstruction() const463 bool supportBfnInstruction() const
464 {
465     return isXeHPSDVPlus();
466 }
467 
supportDpasInstruction() const468 bool supportDpasInstruction() const
469 {
470     return isXeHPSDVPlus();
471 }
472 
hasPackedRestrictedFloatVector() const473 bool hasPackedRestrictedFloatVector() const
474 {
475     return true;
476 }
477 
supportLoadThreadPayloadForCompute() const478 bool supportLoadThreadPayloadForCompute() const
479 {
480     return isXeHPSDVPlus();
481 }
482 
Enable32BitIntDivRemEmu() const483 bool Enable32BitIntDivRemEmu() const
484 {
485     return isXeHPSDVPlus();
486 }
487 
support16DWURBWrite() const488 bool support16DWURBWrite() const
489 {
490     return IGC_IS_FLAG_ENABLED(Enable16DWURBWrite) && isXeHPSDVPlus();
491 }
492 
hasScratchSurface() const493 bool hasScratchSurface() const
494 {
495     return isXeHPSDVPlus();
496 }
497 
hasAtomicPreDec() const498 bool hasAtomicPreDec() const
499 {
500     return !isXeHPSDVPlus();
501 }
502 
support26BitBSOFormat() const503 bool support26BitBSOFormat() const
504 {
505     return isXeHPSDVPlus();
506 }
507 
needsHeaderForAtomicCounter() const508 bool needsHeaderForAtomicCounter() const
509 {
510     return isXeHPSDVPlus();
511 }
512 
doScalar64bScan() const513 bool doScalar64bScan() const
514 {
515     return isXeHPSDVPlus();
516 }
517 
hasHWLocalThreadID() const518 bool hasHWLocalThreadID() const
519 {
520     return isXeHPSDVPlus();
521 }
522 
getOfflineCompilerMaxWorkGroupSize() const523 unsigned int getOfflineCompilerMaxWorkGroupSize() const
524 {
525     if (isXeHPSDVPlus())
526         return 1024;
527     return 448;
528 }
529 
hasFP16AtomicMinMax() const530 bool hasFP16AtomicMinMax() const
531 {
532     return isXeHPSDVPlus();
533 }
534 
hasFP32GlobalAtomicAdd() const535 bool hasFP32GlobalAtomicAdd() const
536 {
537     return isXeHPSDVPlus();
538 }
539 
has16OWSLMBlockRW() const540 bool has16OWSLMBlockRW() const
541 {
542     return IGC_IS_FLAG_ENABLED(Enable16OWSLMBlockRW) && isXeHPSDVPlus();
543 }
544 
supportInlineData() const545 bool supportInlineData() const
546 {
547     return isXeHPSDVPlus();
548 }
549 
supportsAutoGRFSelection() const550 bool supportsAutoGRFSelection() const
551 {
552     return m_platformInfo.eProductFamily == IGFX_XE_HP_SDV;
553 }
554 
adjustedSpillThreshold() const555 float adjustedSpillThreshold() const
556 {
557     return 12.0f;
558 }
559 
isXeHPSDVPlus() const560 bool isXeHPSDVPlus() const
561 {
562     return m_platformInfo.eProductFamily >= IGFX_XE_HP_SDV;
563 }
564 
supportInlineDataOCL() const565 bool supportInlineDataOCL() const
566 {
567     return isXeHPSDVPlus();
568 }
569 
has64BMediaBlockRW() const570 bool has64BMediaBlockRW() const
571 {
572     return IGC_IS_FLAG_ENABLED(Enable64BMediaBlockRW) && isXeHPSDVPlus();
573 }
574 
hasNoFullI64Support() const575 bool hasNoFullI64Support() const
576 {
577     return hasNoInt64Inst();
578 }
579 
hasNoInt64AddInst() const580 bool hasNoInt64AddInst() const
581 {
582     return hasNoFullI64Support();
583 }
584 
supportsSIMD16TypedRW() const585 bool supportsSIMD16TypedRW() const
586 {
587     return false;
588 }
589 
supportsStaticRegSharing() const590 bool supportsStaticRegSharing() const
591 {
592     return isXeHPSDVPlus();
593 }
emulateByteScraterMsgForSS() const594 bool emulateByteScraterMsgForSS() const
595 {
596     return isXeHPSDVPlus() && (m_platformInfo.usRevId == 0 || IGC_IS_FLAG_ENABLED(EnableUntypedSurfRWofSS));
597 }
598 
599 //all the platforms which DONOT support 64 bit int operations
hasNoInt64Inst() const600 bool hasNoInt64Inst() const {
601     return m_platformInfo.eProductFamily == IGFX_ICELAKE_LP ||
602         m_platformInfo.eProductFamily == IGFX_LAKEFIELD ||
603         m_platformInfo.eProductFamily == IGFX_ELKHARTLAKE ||
604         m_platformInfo.eProductFamily == IGFX_JASPERLAKE ||
605         m_platformInfo.eProductFamily == IGFX_TIGERLAKE_LP ||
606         m_platformInfo.eProductFamily == IGFX_ROCKETLAKE ||
607         m_platformInfo.eProductFamily == IGFX_ALDERLAKE_S ||
608         m_platformInfo.eProductFamily == IGFX_ALDERLAKE_P ||
609         m_platformInfo.eProductFamily == IGFX_DG1;
610 }
611 
612 //all the platforms which DONOT support 64 bit float operations
hasNoFP64Inst() const613 bool hasNoFP64Inst() const {
614     return m_platformInfo.eProductFamily == IGFX_ICELAKE_LP ||
615         m_platformInfo.eProductFamily == IGFX_LAKEFIELD ||
616         m_platformInfo.eProductFamily == IGFX_ELKHARTLAKE ||
617         m_platformInfo.eProductFamily == IGFX_JASPERLAKE ||
618         m_platformInfo.eProductFamily == IGFX_TIGERLAKE_LP ||
619         m_platformInfo.eProductFamily == IGFX_ROCKETLAKE ||
620         m_platformInfo.eProductFamily == IGFX_ALDERLAKE_S ||
621         m_platformInfo.eProductFamily == IGFX_ALDERLAKE_P ||
622         m_platformInfo.eProductFamily == IGFX_DG1;
623 }
624 
625 //all the platforms which have correctly rounded macros (INVM, RSQRTM, MADM)
hasCorrectlyRoundedMacros() const626 bool hasCorrectlyRoundedMacros() const {
627     return m_platformInfo.eProductFamily != IGFX_ICELAKE_LP &&
628         m_platformInfo.eProductFamily != IGFX_LAKEFIELD &&
629         m_platformInfo.eProductFamily != IGFX_JASPERLAKE &&
630         m_platformInfo.eProductFamily != IGFX_TIGERLAKE_LP &&
631         m_platformInfo.eProductFamily != IGFX_ROCKETLAKE &&
632         m_platformInfo.eProductFamily != IGFX_DG1 &&
633         m_platformInfo.eProductFamily != IGFX_ALDERLAKE_S &&
634         m_platformInfo.eProductFamily != IGFX_ALDERLAKE_P;
635 }
636 
hasFusedEU() const637 bool hasFusedEU() const { return m_platformInfo.eRenderCoreFamily >= IGFX_GEN12_CORE; }
supportMixMode() const638 bool supportMixMode() const {
639     return IGC_IS_FLAG_ENABLED(ForceMixMode) ||
640         (IGC_IS_FLAG_DISABLED(DisableMixMode) &&
641         (m_platformInfo.eProductFamily == IGFX_CHERRYVIEW ||
642             m_platformInfo.eRenderCoreFamily == IGFX_GEN9_CORE ||
643             m_platformInfo.eRenderCoreFamily == IGFX_GEN10_CORE));
644 }
DSPrimitiveIDPayloadPhaseCanBeSkipped() const645 bool DSPrimitiveIDPayloadPhaseCanBeSkipped() const { return false; }
useScratchSpaceForOCL() const646 bool useScratchSpaceForOCL() const
647 {
648     return IGC_IS_FLAG_ENABLED(EnableOCLScratchPrivateMemory);
649 }
650 
getGRFSize() const651 uint32_t getGRFSize() const
652 {
653     return 32;
654 }
655 
maxPerThreadScratchSpace() const656 uint32_t maxPerThreadScratchSpace() const
657 {
658     return 0x200000;
659 }
660 
supportByteALUOperation() const661 bool supportByteALUOperation() const
662 {
663     return true;
664 }
665 
NeedsHDCFenceBeforeEOTInPixelShader() const666 bool NeedsHDCFenceBeforeEOTInPixelShader() const
667 {
668     return m_WaTable.Wa_1807084924 != 0;
669 }
670 
canFuseTypedWrite() const671 bool canFuseTypedWrite() const
672 {
673     return false;
674 }
675 
getMaxNumberHWThreadForEachWG() const676 unsigned int getMaxNumberHWThreadForEachWG() const
677 {
678     if (m_platformInfo.eRenderCoreFamily < IGFX_GEN12_CORE)
679     {
680         //each WG is dispatched into one subslice for GEN11 and before
681         return getMaxNumberThreadPerSubslice();
682     }
683     else
684     {
685         return getMaxNumberThreadPerSubslice() * 2;
686     }
687 }
688 
689 // max block size for legacy OWord block messages
getMaxBlockMsgSize(bool isSLM) const690 uint32_t getMaxBlockMsgSize(bool isSLM) const
691 {
692     return 128;
693 }
694 
getMinDispatchMode() const695 SIMDMode getMinDispatchMode() const
696 {
697     return SIMDMode::SIMD8;
698 }
699 
getAccChNumUD() const700 unsigned getAccChNumUD() const
701 {
702     return 8;
703 }
704 
getBSOLocInExtDescriptor() const705 int getBSOLocInExtDescriptor() const
706 {
707     return 12;
708 }
709 
710 // ***** Below go accessor methods for testing WA data from WA_TABLE *****
711 
WaDoNotPushConstantsForAllPulledGSTopologies() const712 bool WaDoNotPushConstantsForAllPulledGSTopologies() const
713 {
714     return (m_platformInfo.eProductFamily == IGFX_BROADWELL) ||
715         m_WaTable.WaDoNotPushConstantsForAllPulledGSTopologies != 0;
716 }
717 
WaForceMinMaxGSThreadCount() const718 bool WaForceMinMaxGSThreadCount() const
719 {
720     return m_WaTable.WaForceMinMaxGSThreadCount != 0;
721 }
722 
WaOCLEnableFMaxFMinPlusZero() const723 bool WaOCLEnableFMaxFMinPlusZero() const
724 {
725     return m_WaTable.WaOCLEnableFMaxFMinPlusZero != 0;
726 }
727 
WaDisableSendsSrc0DstOverlap() const728 bool WaDisableSendsSrc0DstOverlap() const
729 {
730     return m_WaTable.WaDisableSendsSrc0DstOverlap != 0;
731 }
732 
WaDisableEuBypass() const733 bool WaDisableEuBypass() const
734 {
735         return (m_WaTable.WaDisableEuBypassOnSimd16Float32 != 0);
736 }
737 
WaDisableDSDualPatchMode() const738 bool WaDisableDSDualPatchMode() const
739 {
740     return m_WaTable.WaDisableDSDualPatchMode == 0;
741 }
742 
WaDispatchGRFHWIssueInGSAndHSUnit() const743 bool WaDispatchGRFHWIssueInGSAndHSUnit() const
744 {
745     return m_WaTable.WaDispatchGRFHWIssueInGSAndHSUnit != 0;
746 }
747 
WaSamplerResponseLengthMustBeGreaterThan1() const748 bool WaSamplerResponseLengthMustBeGreaterThan1() const
749 {
750     return m_WaTable.WaSamplerResponseLengthMustBeGreaterThan1 != 0;
751 }
752 
WaDisableDSPushConstantsInFusedDownModeWithOnlyTwoSubslices() const753 bool WaDisableDSPushConstantsInFusedDownModeWithOnlyTwoSubslices() const
754 {
755     return ((m_WaTable.WaDisableDSPushConstantsInFusedDownModeWithOnlyTwoSubslices) &&
756             (m_GTSystemInfo.IsDynamicallyPopulated && m_GTSystemInfo.SubSliceCount == 2));
757 }
758 
WaDisableVSPushConstantsInFusedDownModeWithOnlyTwoSubslices() const759 bool WaDisableVSPushConstantsInFusedDownModeWithOnlyTwoSubslices() const
760 {
761     return ((m_WaTable.WaDisableVSPushConstantsInFusedDownModeWithOnlyTwoSubslices) &&
762             (m_GTSystemInfo.IsDynamicallyPopulated && m_GTSystemInfo.SubSliceCount == 2));
763 }
764 
WaForceCB0ToBeZeroWhenSendingPC() const765 bool WaForceCB0ToBeZeroWhenSendingPC() const
766 {
767     return m_WaTable.WaForceCB0ToBeZeroWhenSendingPC != 0;
768 }
769 
WaConservativeRasterization() const770 bool WaConservativeRasterization() const
771 {
772     return (m_WaTable.WaConservativeRasterization != 0 &&
773         IGC_IS_FLAG_ENABLED(ApplyConservativeRastWAHeader));
774 }
775 
WaReturnZeroforRTReadOutsidePrimitive() const776 bool WaReturnZeroforRTReadOutsidePrimitive() const
777 {
778     return m_WaTable.WaReturnZeroforRTReadOutsidePrimitive != 0;
779 }
780 
WaFixInnerCoverageWithSampleMask() const781 bool WaFixInnerCoverageWithSampleMask() const
782 {
783     return m_WaTable.Wa_220856683 != 0;
784 }
785 
WaForceDSToWriteURB() const786 bool WaForceDSToWriteURB() const
787 {
788     return m_WaTable.Wa_1805992985 != 0;
789 }
790 
WaOverwriteFFID() const791 bool WaOverwriteFFID() const
792 {
793     return m_WaTable.Wa_1409460247 != 0;
794 }
795 
796 
WaDisableSendSrcDstOverlap() const797 bool WaDisableSendSrcDstOverlap() const
798 {
799     return (!IGC_IS_FLAG_ENABLED(DisableSendSrcDstOverlapWA)) &&
800         (m_SkuTable.FtrWddm2Svm != 0 || m_platformInfo.eRenderCoreFamily == IGFX_GEN10_CORE ||
801             m_platformInfo.eRenderCoreFamily == IGFX_GEN11_CORE);
802 
803 }
804 
WaInsertHDCFenceBeforeEOTWhenSparseAliasedResources() const805 bool WaInsertHDCFenceBeforeEOTWhenSparseAliasedResources() const
806 {
807     return m_WaTable.Wa_1807084924 != 0;
808 }
809 
WaDisableSampleLz() const810 bool WaDisableSampleLz() const
811 {
812     return (IGC_IS_FLAG_DISABLED(DisableWaSampleLZ) && m_WaTable.Wa_14013297064);
813 }
814 
WaEnableA64WA() const815 bool WaEnableA64WA() const
816 {
817     if (IGC_IS_FLAG_ENABLED(EnableA64WA) && m_WaTable.Wa_14010595310) {
818         return true;
819     }
820     return false;
821 }
822 
823 //Only enable this WA for TGLLP+ because, in pre TGLLP projects, smov was replaced with two instructions which caused performance penalty.
enableMultiGRFAccessWA() const824 bool enableMultiGRFAccessWA() const
825 {
826     return (m_platformInfo.eProductFamily >= IGFX_TIGERLAKE_LP);
827 }
828 
829 // Return true if platform has structured control-flow instructions and IGC wants to use them.
hasSCF() const830 bool hasSCF() const
831 {
832     bool doscf = true;
833     return doscf;
834 }
835 
GetCaps()836 const SCompilerHwCaps& GetCaps() { return m_caps; }
837 
supportHeaderRTW() const838 bool supportHeaderRTW() const
839 {
840     return true;
841 }
842 
preemptionSupported() const843 bool preemptionSupported() const
844 {
845 
846     return GetPlatformFamily() >= IGFX_GEN9_CORE;
847 }
848 
849 // platform natively not support DW-DW multiply
noNativeDwordMulSupport() const850 bool noNativeDwordMulSupport() const
851 {
852     return m_platformInfo.eProductFamily == IGFX_BROXTON ||
853         m_platformInfo.eProductFamily == IGFX_GEMINILAKE ||
854         GetPlatformFamily() == IGFX_GEN11_CORE ||
855         GetPlatformFamily() == IGFX_GEN12LP_CORE;
856 }
857 
getURBFullWriteMinGranularity() const858 unsigned getURBFullWriteMinGranularity() const
859 {
860     unsigned overrideValue = IGC_GET_FLAG_VALUE(SetURBFullWriteGranularity);
861     if (overrideValue == 16 || overrideValue == 32)
862     {
863         return overrideValue;
864     }
865     return isXeHPSDVPlus() ? 16 : 32; // in bytes
866 }
867 
868 };
869 
870 }//namespace IGC
871