Skip to content

Commit 37cac4f

Browse files
authored
Handle Coherent and compressible resources (#235)
1 parent ba1de54 commit 37cac4f

File tree

4 files changed

+48
-4
lines changed

4 files changed

+48
-4
lines changed

Source/GmmLib/CachePolicy/GmmXe2_LPGCachePolicy.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,20 @@ uint32_t GMM_STDCALL GmmLib::GmmXe2_LPGCachePolicy::CachePolicyGetPATIndex(GMM_R
400400
// requested compressed and coherent
401401
if (CompressionEnable && IsCpuCacheable)
402402
{
403-
// return coherent uncompressed
404-
ReturnPATIndex = CoherentPATIndex;
405-
CompressionEnable = false;
406-
GMM_ASSERTDPF(false, "Coherent Compressed is not supported on Xe2. However, respecting the coherency and returning CoherentPATIndex");
403+
if (ONE_WAY_COHERENT_COMPRESSION_MODE(pGmmLibContext->GetPlatformInfo().Platform.eProductFamily, pGmmLibContext->GetWaTable().WaNoCpuCoherentCompression))
404+
{
405+
#define COHERENT_COMPRESSED_PATIDX 16
406+
// return coherent compressed PAT which is 16
407+
ReturnPATIndex = COHERENT_COMPRESSED_PATIDX;
408+
CompressionEnable = true;
409+
}
410+
else
411+
{
412+
// return coherent uncompressed
413+
ReturnPATIndex = CoherentPATIndex;
414+
CompressionEnable = false;
415+
GMM_ASSERTDPF(false, "For Coherent Compressed resources combination on Xe2, respecting the coherency and returning CoherentPATIndex");
416+
}
407417
}
408418
// requested compressed only
409419
else if (CompressionEnable)
@@ -605,6 +615,11 @@ GMM_STATUS GmmLib::GmmXe2_LPGCachePolicy::SetupPAT()
605615

606616
CurrentMaxPATIndex = 31;
607617

618+
if (ONE_WAY_COHERENT_COMPRESSION_MODE(pGmmLibContext->GetPlatformInfo().Platform.eProductFamily, pGmmLibContext->GetWaTable().WaNoCpuCoherentCompression))
619+
{
620+
GMM_DEFINE_PAT_ELEMENT( 16 , 2 , L4_UC , L3_WB , 0 , 1 , 0) // | L3_WB | 1 way coherent | Compression
621+
}
622+
608623
// clang-format on
609624
#undef GMM_DEFINE_PAT
610625
#undef L4_WB

Source/GmmLib/Resource/GmmResourceInfoCommonEx.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,20 @@ bool GmmLib::GmmResourceInfoCommon::CopyClientParams(GMM_RESCREATE_PARAMS &Creat
265265
Surf.Flags.Info.SVM &&
266266
!(GetGmmLibContext()->GetSkuTable().FtrWddm2GpuMmu ||
267267
GetGmmLibContext()->GetSkuTable().FtrWddm2Svm);
268+
269+
if (GetGmmLibContext()->GetSkuTable().FtrXe2Compression &&
270+
!(ONE_WAY_COHERENT_COMPRESSION_MODE(GetGmmLibContext()->GetPlatformInfo().Platform.eProductFamily, GetGmmLibContext()->GetWaTable().WaNoCpuCoherentCompression)))
271+
{
272+
if (!CreateParams.Flags.Info.NotCompressed && CreateParams.Flags.Info.Cacheable)
273+
{
274+
// Disable compression
275+
Surf.Flags.Info.NotCompressed = 1;
276+
Surf.Flags.Gpu.CCS = 0;
277+
Surf.Flags.Gpu.UnifiedAuxSurface = 0;
278+
Surf.Flags.Gpu.IndirectClearColor = 0;
279+
Surf.Flags.Gpu.MCS = 0;
280+
}
281+
}
268282

269283
#if !__GMM_KMD__ && LHDM
270284
if(GetGmmLibContext()->GetWaTable().WaLLCCachingUnsupported)
@@ -1023,6 +1037,14 @@ uint8_t GMM_STDCALL GmmLib::GmmResourceInfoCommon::ValidateParams()
10231037
break;
10241038
}
10251039

1040+
if (GetGmmLibContext()->GetSkuTable().FtrXe2Compression &&
1041+
!(ONE_WAY_COHERENT_COMPRESSION_MODE(GetGmmLibContext()->GetPlatformInfo().Platform.eProductFamily, GetGmmLibContext()->GetWaTable().WaNoCpuCoherentCompression)) &&
1042+
Surf.Flags.Info.Cacheable && !Surf.Flags.Info.NotCompressed)
1043+
{
1044+
GMM_ASSERTDPF(0, "Invalid combination Cpu Cacheable and Compression set on a platform");
1045+
goto ERROR_CASE;
1046+
}
1047+
10261048
GMM_DPF_EXIT;
10271049
return 1;
10281050

Source/GmmLib/inc/External/Common/GmmUtil.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,4 @@ OTHER DEALINGS IN THE SOFTWARE.
106106
#define GMM_OVERRIDE_SIZE_64KB_ALLOC(pGmmLibContext) if(((GmmClientContext*)pClientContext)->GetSkuTable().FtrPpgtt64KBWalkOptimization){ return (this->GetSizeAllocation());}
107107
#endif
108108

109+
#define ONE_WAY_COHERENT_COMPRESSION_MODE(Platform, WaNoCpuCoherentCompression) ((Platform >= IGFX_PTL) && (!WaNoCpuCoherentCompression))

Source/inc/common/sku_wa.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,12 @@ typedef struct _WA_TABLE
569569
"WA for supporting failure seen in BMG with Mufasa",
570570
WA_BUG_TYPE_FUNCTIONAL,
571571
WA_BUG_PERF_IMPACT_UNKNOWN, WA_COMPONENT_UNKNOWN)
572+
573+
WA_DECLARE(
574+
WaNoCpuCoherentCompression,
575+
"Deny compression for coherent surfaces",
576+
WA_BUG_TYPE_UNKNOWN,
577+
WA_BUG_PERF_IMPACT_UNKNOWN, WA_COMPONENT_UNKNOWN)
572578

573579
} WA_TABLE, *PWA_TABLE;
574580

0 commit comments

Comments
 (0)