Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More readability and improve codegeneration by compiler #121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions Source/GmmLib/CachePolicy/GmmGen12dGPUCachePolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ GMM_STATUS GmmLib::GmmGen12dGPUCachePolicy::InitCachePolicy()
{
SetUpMOCSTable();
}

if(GFX_GET_CURRENT_PRODUCT(pGmmLibContext->GetPlatformInfo().Platform) == IGFX_PVC)

const GMM_PLATFORM_INFO &ContextInfo = pGmmLibContext->GetPlatformInfo();
if(GFX_GET_CURRENT_PRODUCT(ContextInfo.Platform) == IGFX_PVC)
{
SetupPAT();
}
Expand Down Expand Up @@ -135,7 +136,7 @@ GMM_STATUS GmmLib::GmmGen12dGPUCachePolicy::InitCachePolicy()
GMM_PRIVATE_PAT UsagePATElement = {0};


switch(GFX_GET_CURRENT_PRODUCT(pGmmLibContext->GetPlatformInfo().Platform))
switch(GFX_GET_CURRENT_PRODUCT(ContextInfo.Platform))
{
case IGFX_DG1:
case IGFX_XE_HP_SDV:
Expand All @@ -152,14 +153,14 @@ GMM_STATUS GmmLib::GmmGen12dGPUCachePolicy::InitCachePolicy()
}

// No Special MOCS handling for next platform
if(GFX_GET_CURRENT_PRODUCT(pGmmLibContext->GetPlatformInfo().Platform) < IGFX_DG2)
if(GFX_GET_CURRENT_PRODUCT(ContextInfo.Platform) < IGFX_DG2)
{
CPTblIdx = IsSpecialMOCSUsage((GMM_RESOURCE_USAGE_TYPE)Usage, SpecialMOCS);
}

// Applicable upto Xe_HP only
if(pCachePolicy[Usage].HDCL1 &&
(GFX_GET_CURRENT_PRODUCT(pGmmLibContext->GetPlatformInfo().Platform) <= IGFX_XE_HP_SDV))
(GFX_GET_CURRENT_PRODUCT(ContextInfo.Platform) <= IGFX_XE_HP_SDV))
{
UsageEle.HDCL1 = 1;
}
Expand All @@ -176,7 +177,7 @@ GMM_STATUS GmmLib::GmmGen12dGPUCachePolicy::InitCachePolicy()
UsageEle.L3.SCC = (uint16_t)pCachePolicy[Usage].L3_SCC;
}

if(GFX_GET_CURRENT_PRODUCT(pGmmLibContext->GetPlatformInfo().Platform) == IGFX_PVC)
if(GFX_GET_CURRENT_PRODUCT(ContextInfo.Platform) == IGFX_PVC)
{
pCachePolicy[Usage].GlbGo = 0;
pCachePolicy[Usage].UcLookup = 0;
Expand All @@ -187,7 +188,7 @@ GMM_STATUS GmmLib::GmmGen12dGPUCachePolicy::InitCachePolicy()
// Applicable for IGFX_XE_HP_SDV and DG2 only
if(!SpecialMOCS &&
(FROMPRODUCT(XE_HP_SDV)) &&
(GFX_GET_CURRENT_PRODUCT(pGmmLibContext->GetPlatformInfo().Platform) != IGFX_PVC))
(GFX_GET_CURRENT_PRODUCT(ContextInfo.Platform) != IGFX_PVC))
{
if(pCachePolicy[Usage].L3 == 0)
{
Expand Down Expand Up @@ -277,7 +278,7 @@ GMM_STATUS GmmLib::GmmGen12dGPUCachePolicy::InitCachePolicy()
pCachePolicy[Usage].PTE.DwordValue = PTEValue & 0xFFFFFFFF;
pCachePolicy[Usage].PTE.HighDwordValue = 0;

pCachePolicy[Usage].MemoryObjectOverride.Gen12.Index = CPTblIdx;
pCachePolicy[Usage].MemoryObjectOverride.Gen12.Index = CPTblIdx;

pCachePolicy[Usage].Override = ALWAYS_OVERRIDE;

Expand All @@ -286,7 +287,7 @@ GMM_STATUS GmmLib::GmmGen12dGPUCachePolicy::InitCachePolicy()
GMM_ASSERTDPF("Cache Policy Init Error: Invalid Cache Programming - Element %d", Usage);
}

if(GFX_GET_CURRENT_PRODUCT(pGmmLibContext->GetPlatformInfo().Platform) == IGFX_PVC)
if(GFX_GET_CURRENT_PRODUCT(ContextInfo.Platform) == IGFX_PVC)
{
// PAT data
{
Expand Down Expand Up @@ -369,7 +370,8 @@ void GmmLib::GmmGen12dGPUCachePolicy::SetUpMOCSTable()

// clang-format off

if (GFX_GET_CURRENT_PRODUCT(pGmmLibContext->GetPlatformInfo().Platform) == IGFX_DG1)
const GMM_PLATFORM_INFO &ContextInfo = pGmmLibContext->GetPlatformInfo();
if (GFX_GET_CURRENT_PRODUCT(ContextInfo.Platform) == IGFX_DG1)
{
//Default MOCS Table
for(int index = 0; index < GMM_MAX_NUMBER_MOCS_INDEXES; index++)
Expand Down Expand Up @@ -399,7 +401,7 @@ void GmmLib::GmmGen12dGPUCachePolicy::SetUpMOCSTable()
CurrentMaxSpecialMocsIndex = 63;

}
else if (GFX_GET_CURRENT_PRODUCT(pGmmLibContext->GetPlatformInfo().Platform) == IGFX_XE_HP_SDV)
else if (GFX_GET_CURRENT_PRODUCT(ContextInfo.Platform) == IGFX_XE_HP_SDV)
{
//Default MOCS Table
for(int index = 0; index < GMM_MAX_NUMBER_MOCS_INDEXES; index++)
Expand All @@ -425,7 +427,7 @@ void GmmLib::GmmGen12dGPUCachePolicy::SetUpMOCSTable()
CurrentMaxSpecialMocsIndex = 63;

}
else if ((GFX_GET_CURRENT_PRODUCT(pGmmLibContext->GetPlatformInfo().Platform) == IGFX_DG2))
else if ((GFX_GET_CURRENT_PRODUCT(ContextInfo.Platform) == IGFX_DG2))
{
//Default MOCS Table
for(int index = 0; index < GMM_MAX_NUMBER_MOCS_INDEXES; index++)
Expand All @@ -441,7 +443,7 @@ void GmmLib::GmmGen12dGPUCachePolicy::SetUpMOCSTable()

CurrentMaxMocsIndex = 3;
}
else if (GFX_GET_CURRENT_PRODUCT(pGmmLibContext->GetPlatformInfo().Platform) == IGFX_PVC)
else if (GFX_GET_CURRENT_PRODUCT(ContextInfo.Platform) == IGFX_PVC)
{
//Default MOCS Table
for(int index = 0; index < GMM_MAX_NUMBER_MOCS_INDEXES; index++)
Expand Down
9 changes: 5 additions & 4 deletions Source/GmmLib/CachePolicy/GmmXe2_LPGCachePolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,11 @@ void GmmLib::GmmXe2_LPGCachePolicy::GetL3L4(GMM_CACHE_POLICY_TBL_ELEMENT *pUsage
/////////////////////////////////////////////////////////////////////////////////////
uint32_t GMM_STDCALL GmmLib::GmmXe2_LPGCachePolicy::CachePolicyGetPATIndex(GMM_RESOURCE_INFO *pResInfo, GMM_RESOURCE_USAGE_TYPE Usage, bool *pCompressionEnable, bool IsCpuCacheable)
{
__GMM_ASSERT(pGmmLibContext->GetCachePolicyElement(Usage).Initialized);
const GMM_CACHE_POLICY_ELEMENT &CachePolicyElement = pGmmLibContext->GetCachePolicyElement(Usage);
__GMM_ASSERT(CachePolicyElement.Initialized);

uint32_t PATIndex = pGmmLibContext->GetCachePolicyElement(Usage).PATIndex;
GMM_CACHE_POLICY_ELEMENT TempElement = pGmmLibContext->GetCachePolicyElement(Usage);
uint32_t PATIndex = CachePolicyElement.PATIndex;
GMM_CACHE_POLICY_ELEMENT TempElement = CachePolicyElement;
uint32_t TempCoherentPATIndex = 0;

// This is to check if PATIndexCompressed, CoherentPATIndex are valid
Expand All @@ -364,7 +365,7 @@ uint32_t GMM_STDCALL GmmLib::GmmXe2_LPGCachePolicy::CachePolicyGetPATIndex(GMM_R
// Higher bit of CoherentPATIndex would tell us if its a valid or not.0--> valid, 1-->invalid
uint32_t CoherentPATIndex = (uint32_t)((GET_COHERENT_PATINDEX_HIGHER_BIT(TempCoherentPATIndex) == 1) ? GMM_PAT_ERROR : GET_COHERENT_PATINDEX_VALUE(pGmmLibContext, Usage));
//For PATIndexCompressed, rollover value would be 0 if its invalid
uint32_t PATIndexCompressed = (uint32_t)(TempElement.PATIndexCompressed == 0 ? GMM_PAT_ERROR : pGmmLibContext->GetCachePolicyElement(Usage).PATIndexCompressed);
uint32_t PATIndexCompressed = (uint32_t)(TempElement.PATIndexCompressed == 0 ? GMM_PAT_ERROR : CachePolicyElement.PATIndexCompressed);
uint32_t ReturnPATIndex = GMM_PAT_ERROR;
bool CompressionEnable = (pCompressionEnable) ? *pCompressionEnable : false;

Expand Down
7 changes: 4 additions & 3 deletions Source/GmmLib/GlobalInfo/GmmInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1057,17 +1057,18 @@ void GMM_STDCALL GmmLib::Context::DestroyContext()

void GMM_STDCALL GmmLib::Context::OverrideSkuWa()
{
if((GFX_GET_CURRENT_PRODUCT(this->GetPlatformInfo().Platform) < IGFX_XE_HP_SDV))
const GMM_PLATFORM_INFO &ContextInfo = this->GetPlatformInfo();
if((GFX_GET_CURRENT_PRODUCT(ContextInfo.Platform) < IGFX_XE_HP_SDV))
{
SkuTable.FtrTileY = true;
}

if(GFX_GET_CURRENT_PRODUCT(this->GetPlatformInfo().Platform) == IGFX_PVC)
if(GFX_GET_CURRENT_PRODUCT(ContextInfo.Platform) == IGFX_PVC)
{
SkuTable.Ftr57bGPUAddressing = true;
}

if (GFX_GET_CURRENT_PRODUCT(this->GetPlatformInfo().Platform) >= IGFX_LUNARLAKE)
if (GFX_GET_CURRENT_PRODUCT(ContextInfo.Platform) >= IGFX_LUNARLAKE)
{
// FtrL3TransientDataFlush is always enabled for XE2 adding GMM Override if UMDs might have reset this.
SkuTable.FtrL3TransientDataFlush = true;
Expand Down
15 changes: 8 additions & 7 deletions Source/GmmLib/Platform/GmmGen10Platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,13 @@ GmmLib::PlatformInfoGen10::PlatformInfoGen10(PLATFORM &Platform, Context *pGmmLi
// RT & Texture2DSurface restrictions. Inst Ref: SURFACE_STATE
// Greatest common restriction source comes from 8bpp RT
// --------------------------
const WA_TABLE &WaTable = pGmmLibContext->GetWaTable();
Data.Texture2DSurface.Alignment = PAGE_SIZE;
Data.Texture2DSurface.PitchAlignment = GMM_BYTES(32);
Data.Texture2DSurface.LockPitchAlignment = GMM_BYTES(32);
Data.Texture2DSurface.RenderPitchAlignment = GMM_BYTES(32);
Data.Texture2DSurface.MinPitch = GMM_BYTES(32);
Data.Texture2DSurface.MaxPitch = (pGmmLibContext->GetWaTable().WaRestrictPitch128KB) ? GMM_KBYTE(128) : GMM_KBYTE(256);
Data.Texture2DSurface.MaxPitch = (WaTable.WaRestrictPitch128KB) ? GMM_KBYTE(128) : GMM_KBYTE(256);
Data.Texture2DSurface.MinAllocationSize = PAGE_SIZE;
Data.Texture2DSurface.MinHeight = GMM_SCANLINES(1);
Data.Texture2DSurface.MinWidth = GMM_PIXELS(1);
Expand Down Expand Up @@ -277,7 +278,7 @@ GmmLib::PlatformInfoGen10::PlatformInfoGen10(PLATFORM &Platform, Context *pGmmLi
Data.CubeSurface.LockPitchAlignment = GMM_BYTES(32);
Data.CubeSurface.RenderPitchAlignment = GMM_BYTES(32);
Data.CubeSurface.MinPitch = GMM_BYTES(32);
Data.CubeSurface.MaxPitch = (pGmmLibContext->GetWaTable().WaRestrictPitch128KB) ? GMM_KBYTE(128) : GMM_KBYTE(256);
Data.CubeSurface.MaxPitch = (WaTable.WaRestrictPitch128KB) ? GMM_KBYTE(128) : GMM_KBYTE(256);
Data.CubeSurface.MinAllocationSize = PAGE_SIZE;
Data.CubeSurface.MinHeight = GMM_SCANLINES(1);
Data.CubeSurface.MinWidth = GMM_PIXELS(1);
Expand All @@ -296,7 +297,7 @@ GmmLib::PlatformInfoGen10::PlatformInfoGen10(PLATFORM &Platform, Context *pGmmLi
Data.Texture3DSurface.LockPitchAlignment = GMM_BYTES(32);
Data.Texture3DSurface.RenderPitchAlignment = GMM_BYTES(32);
Data.Texture3DSurface.MinPitch = GMM_BYTES(32);
Data.Texture3DSurface.MaxPitch = (pGmmLibContext->GetWaTable().WaRestrictPitch128KB) ? GMM_KBYTE(128) : GMM_KBYTE(256);
Data.Texture3DSurface.MaxPitch = (WaTable.WaRestrictPitch128KB) ? GMM_KBYTE(128) : GMM_KBYTE(256);
Data.Texture3DSurface.MinAllocationSize = PAGE_SIZE;
Data.Texture3DSurface.MinHeight = GMM_SCANLINES(1);
Data.Texture3DSurface.MinWidth = GMM_PIXELS(1);
Expand Down Expand Up @@ -328,7 +329,7 @@ GmmLib::PlatformInfoGen10::PlatformInfoGen10(PLATFORM &Platform, Context *pGmmLi
// --------------------------
// Cursor surface restricion. Register Ref: CURACNTR, CURABASE
// --------------------------
Data.Cursor.Alignment = pGmmLibContext->GetWaTable().WaCursor16K ? GMM_KBYTE(16) : PAGE_SIZE;
Data.Cursor.Alignment = WaTable.WaCursor16K ? GMM_KBYTE(16) : PAGE_SIZE;
Data.Cursor.PitchAlignment = 1;
Data.Cursor.LockPitchAlignment = 1;
Data.Cursor.RenderPitchAlignment = 1;
Expand Down Expand Up @@ -439,7 +440,7 @@ GmmLib::PlatformInfoGen10::PlatformInfoGen10(PLATFORM &Platform, Context *pGmmLi
//--------------------------
// Fence paramaters. Register Ref: FENCE
//--------------------------
Data.NumberFenceRegisters = pGmmLibContext->GetWaTable().Wa16TileFencesOnly ? 16 : 32;
Data.NumberFenceRegisters = WaTable.Wa16TileFencesOnly ? 16 : 32;
Data.FenceLowBoundShift = 12;
Data.FenceLowBoundMask = GFX_MASK(12, 31);
Data.MinFenceSize = GMM_MBYTE(1);
Expand Down Expand Up @@ -483,12 +484,12 @@ GmmLib::PlatformInfoGen10::PlatformInfoGen10(PLATFORM &Platform, Context *pGmmLi
// ----------------------------------
// Restrictions for Cross adapter resource
// ----------------------------------
Data.XAdapter.Alignment = GMM_KBYTE(64); //64KB for DX12/StdSwizzle�-Not worth special-casing.
Data.XAdapter.Alignment = GMM_KBYTE(64); //64KB for DX12/StdSwizzle�-Not worth special-casing.
Data.XAdapter.PitchAlignment = GMM_BYTES(D3DKMT_CROSS_ADAPTER_RESOURCE_PITCH_ALIGNMENT);
Data.XAdapter.RenderPitchAlignment = GMM_BYTES(D3DKMT_CROSS_ADAPTER_RESOURCE_PITCH_ALIGNMENT);
Data.XAdapter.LockPitchAlignment = GMM_BYTES(D3DKMT_CROSS_ADAPTER_RESOURCE_PITCH_ALIGNMENT);
Data.XAdapter.MinPitch = GMM_BYTES(32);
Data.XAdapter.MaxPitch = (pGmmLibContext->GetWaTable().WaRestrictPitch128KB) ? GMM_KBYTE(128) : GMM_KBYTE(256);
Data.XAdapter.MaxPitch = (WaTable.WaRestrictPitch128KB) ? GMM_KBYTE(128) : GMM_KBYTE(256);
Data.XAdapter.MinAllocationSize = PAGE_SIZE;
Data.XAdapter.MinHeight = GMM_SCANLINES(1);
Data.XAdapter.MinWidth = GMM_PIXELS(1);
Expand Down
13 changes: 7 additions & 6 deletions Source/GmmLib/Platform/GmmGen8Platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,13 @@ GmmLib::PlatformInfoGen8::PlatformInfoGen8(PLATFORM &Platform, Context *pGmmLibC
// RT & Texture2DSurface restrictions. Inst Ref: SURFACE_STATE
// Greatest common restriction source comes from 8bpp RT
// --------------------------
const WA_TABLE &WaTable = pGmmLibContext->GetWaTable();
Data.Texture2DSurface.Alignment = PAGE_SIZE;
Data.Texture2DSurface.PitchAlignment = GMM_BYTES(32);
Data.Texture2DSurface.LockPitchAlignment = GMM_BYTES(32);
Data.Texture2DSurface.RenderPitchAlignment = GMM_BYTES(32);
Data.Texture2DSurface.MinPitch = GMM_BYTES(32);
Data.Texture2DSurface.MaxPitch = (pGmmLibContext->GetWaTable().WaRestrictPitch128KB) ? GMM_KBYTE(128) : GMM_KBYTE(256);
Data.Texture2DSurface.MaxPitch = (WaTable.WaRestrictPitch128KB) ? GMM_KBYTE(128) : GMM_KBYTE(256);
Data.Texture2DSurface.MinAllocationSize = PAGE_SIZE;
Data.Texture2DSurface.MinHeight = GMM_SCANLINES(1);
Data.Texture2DSurface.MinWidth = GMM_PIXELS(1);
Expand Down Expand Up @@ -289,7 +290,7 @@ GmmLib::PlatformInfoGen8::PlatformInfoGen8(PLATFORM &Platform, Context *pGmmLibC
Data.CubeSurface.LockPitchAlignment = GMM_BYTES(32);
Data.CubeSurface.RenderPitchAlignment = GMM_BYTES(32);
Data.CubeSurface.MinPitch = GMM_BYTES(32);
Data.CubeSurface.MaxPitch = (pGmmLibContext->GetWaTable().WaRestrictPitch128KB) ? GMM_KBYTE(128) : GMM_KBYTE(256);
Data.CubeSurface.MaxPitch = (WaTable.WaRestrictPitch128KB) ? GMM_KBYTE(128) : GMM_KBYTE(256);
Data.CubeSurface.MinAllocationSize = PAGE_SIZE;
Data.CubeSurface.MinHeight = GMM_SCANLINES(1);
Data.CubeSurface.MinWidth = GMM_PIXELS(1);
Expand All @@ -308,7 +309,7 @@ GmmLib::PlatformInfoGen8::PlatformInfoGen8(PLATFORM &Platform, Context *pGmmLibC
Data.Texture3DSurface.LockPitchAlignment = GMM_BYTES(32);
Data.Texture3DSurface.RenderPitchAlignment = GMM_BYTES(32);
Data.Texture3DSurface.MinPitch = GMM_BYTES(32);
Data.Texture3DSurface.MaxPitch = (pGmmLibContext->GetWaTable().WaRestrictPitch128KB) ? GMM_KBYTE(128) : GMM_KBYTE(256);
Data.Texture3DSurface.MaxPitch = (WaTable.WaRestrictPitch128KB) ? GMM_KBYTE(128) : GMM_KBYTE(256);
Data.Texture3DSurface.MinAllocationSize = PAGE_SIZE;
Data.Texture3DSurface.MinHeight = GMM_SCANLINES(1);
Data.Texture3DSurface.MinWidth = GMM_PIXELS(1);
Expand Down Expand Up @@ -340,7 +341,7 @@ GmmLib::PlatformInfoGen8::PlatformInfoGen8(PLATFORM &Platform, Context *pGmmLibC
// --------------------------
// Cursor surface restricion. Register Ref: CURACNTR, CURABASE
// --------------------------
Data.Cursor.Alignment = pGmmLibContext->GetWaTable().WaCursor16K ? GMM_KBYTE(16) : PAGE_SIZE;
Data.Cursor.Alignment = WaTable.WaCursor16K ? GMM_KBYTE(16) : PAGE_SIZE;
Data.Cursor.PitchAlignment = 1;
Data.Cursor.LockPitchAlignment = 1;
Data.Cursor.RenderPitchAlignment = 1;
Expand All @@ -364,7 +365,7 @@ GmmLib::PlatformInfoGen8::PlatformInfoGen8(PLATFORM &Platform, Context *pGmmLibC
//--------------------------
// Fence paramaters. Register Ref: FENCE
//--------------------------
Data.NumberFenceRegisters = pGmmLibContext->GetWaTable().Wa16TileFencesOnly ? 16 : 32;
Data.NumberFenceRegisters = WaTable.Wa16TileFencesOnly ? 16 : 32;
Data.FenceLowBoundShift = 12;
Data.FenceLowBoundMask = GFX_MASK(12, 31);
Data.MinFenceSize = GMM_MBYTE(1);
Expand Down Expand Up @@ -413,7 +414,7 @@ GmmLib::PlatformInfoGen8::PlatformInfoGen8(PLATFORM &Platform, Context *pGmmLibC
Data.XAdapter.RenderPitchAlignment = GMM_BYTES(D3DKMT_CROSS_ADAPTER_RESOURCE_PITCH_ALIGNMENT);
Data.XAdapter.LockPitchAlignment = GMM_BYTES(D3DKMT_CROSS_ADAPTER_RESOURCE_PITCH_ALIGNMENT);
Data.XAdapter.MinPitch = GMM_BYTES(32);
Data.XAdapter.MaxPitch = (pGmmLibContext->GetWaTable().WaRestrictPitch128KB) ? GMM_KBYTE(128) : GMM_KBYTE(256);
Data.XAdapter.MaxPitch = (WaTable.WaRestrictPitch128KB) ? GMM_KBYTE(128) : GMM_KBYTE(256);
Data.XAdapter.MinAllocationSize = PAGE_SIZE;
Data.XAdapter.MinHeight = GMM_SCANLINES(1);
Data.XAdapter.MinWidth = GMM_PIXELS(1);
Expand Down
Loading