Generic texture calculation for HiZ

Change-Id: I94ba01620036bb6b3b34c8ce5b65d7e7572630a6
This commit is contained in:
lpriyank 2018-03-25 23:54:39 -07:00 committed by Prajapati, Dimpalben R
parent 2eea1a175a
commit 932fb0addd
7 changed files with 22 additions and 7 deletions

View File

@ -507,5 +507,6 @@ GmmLib::PlatformInfoGen10::PlatformInfoGen10(PLATFORM &Platform)
//--------------------------------------------- //---------------------------------------------
Data.SurfaceMaxSize = GMM_GBYTE(256); Data.SurfaceMaxSize = GMM_GBYTE(256);
Data.MaxGpuVirtualAddressBitsPerResource = 38; Data.MaxGpuVirtualAddressBitsPerResource = 38;
Data.HiZPixelsPerByte = 2;
} }
#endif // #if (IGFX_GEN >= IGFX_GEN10) #endif // #if (IGFX_GEN >= IGFX_GEN10)

View File

@ -430,4 +430,6 @@ GmmLib::PlatformInfoGen8::PlatformInfoGen8(PLATFORM &Platform)
Data.SurfaceMaxSize = GMM_GBYTE(2); Data.SurfaceMaxSize = GMM_GBYTE(2);
Data.MaxGpuVirtualAddressBitsPerResource = 31; Data.MaxGpuVirtualAddressBitsPerResource = 31;
Data.MaxSLMSize = GMM_KBYTE(384); Data.MaxSLMSize = GMM_KBYTE(384);
Data.HiZPixelsPerByte = 2;
} }

View File

@ -489,4 +489,6 @@ GmmLib::PlatformInfoGen9::PlatformInfoGen9(PLATFORM &Platform)
{ {
Data.MaxSLMSize = GMM_KBYTE(576); Data.MaxSLMSize = GMM_KBYTE(576);
} }
Data.HiZPixelsPerByte = 2;
} }

View File

@ -134,6 +134,8 @@ GMM_STATUS GMM_STDCALL GmmLib::GmmResourceInfoCommon::Create(Context &GmmLibCont
pGmmLibContext = reinterpret_cast<uint64_t>(&GmmLibContext); pGmmLibContext = reinterpret_cast<uint64_t>(&GmmLibContext);
#if(!defined(__GMM_KMD__) && !defined(GMM_UNIFIED_LIB)) #if(!defined(__GMM_KMD__) && !defined(GMM_UNIFIED_LIB))
// Client ULT does new on ResInfo without calling GmmInitGlobalContext. If they call create later, on the previously created
// ResInfo object set the clientContext for them, since clientContext wouldnt have been set
if(!pClientContext) if(!pClientContext)
{ {
pClientContext = pGmmGlobalContext->pGmmGlobalClientContext; pClientContext = pGmmGlobalContext->pGmmGlobalClientContext;
@ -763,7 +765,7 @@ uint32_t GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetQPitch()
// 2D/CUBE ==> distance in rows between array slices // 2D/CUBE ==> distance in rows between array slices
// 3D ==> distance in rows between R-slices // 3D ==> distance in rows between R-slices
// Compressed ==> one row contains a complete compression block vertically // Compressed ==> one row contains a complete compression block vertically
// HiZ ==> 2 * HZ_QPitch // HiZ ==> HZ_PxPerByte * HZ_QPitch
// Stencil ==> logical, i.e. not halved // Stencil ==> logical, i.e. not halved
if((GFX_GET_CURRENT_RENDERCORE(pPlatform->Platform) >= IGFX_GEN9_CORE) && if((GFX_GET_CURRENT_RENDERCORE(pPlatform->Platform) >= IGFX_GEN9_CORE) &&
@ -780,7 +782,7 @@ uint32_t GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetQPitch()
} }
else if(Surf.Flags.Gpu.HiZ) else if(Surf.Flags.Gpu.HiZ)
{ {
QPitch = Surf.Alignment.QPitch * 2; QPitch = Surf.Alignment.QPitch * pPlatform->HiZPixelsPerByte;
} }
else else
{ {

View File

@ -94,6 +94,7 @@ GMM_STATUS GmmLib::GmmTextureCalc::PreProcessTexSpecialCases(GMM_TEXTURE_INFO *p
{ {
uint32_t h0, h1, hL, i, NumSamples, QPitch, Z_HeightL; uint32_t h0, h1, hL, i, NumSamples, QPitch, Z_HeightL;
uint32_t HZ_HAlign = 16, HZ_VAlign = 8; uint32_t HZ_HAlign = 16, HZ_VAlign = 8;
uint8_t HZ_DepthRows = pPlatform->HiZPixelsPerByte;
// HZ operates in pixel space starting from SKL. So, it does not care // HZ operates in pixel space starting from SKL. So, it does not care
// whether the depth buffer is in MSAA mode or not. // whether the depth buffer is in MSAA mode or not.
@ -135,13 +136,13 @@ GMM_STATUS GmmLib::GmmTextureCalc::PreProcessTexSpecialCases(GMM_TEXTURE_INFO *p
(pTexInfo->MaxLod > 0) ? (pTexInfo->MaxLod > 0) ?
(h0 + GFX_MAX(h1, Z_HeightL)) : (h0 + GFX_MAX(h1, Z_HeightL)) :
h0; h0;
QPitch /= 2; QPitch /= HZ_DepthRows;
pTexInfo->ArraySize = Z_Depth; pTexInfo->ArraySize = Z_Depth;
pTexInfo->BaseHeight = QPitch; pTexInfo->BaseHeight = QPitch;
} }
pTexInfo->Alignment.HAlign = HZ_HAlign; pTexInfo->Alignment.HAlign = HZ_HAlign;
pTexInfo->Alignment.VAlign = HZ_VAlign / 2; pTexInfo->Alignment.VAlign = HZ_VAlign / HZ_DepthRows;
} }
else //if (GFX_GET_CURRENT_RENDERCORE(pPlatform->Platform) >= IGFX_GEN7_CORE) else //if (GFX_GET_CURRENT_RENDERCORE(pPlatform->Platform) >= IGFX_GEN7_CORE)
{ {

View File

@ -263,6 +263,8 @@ typedef struct __GMM_PLATFORM_RESOURCE_REC
int64_t SurfaceMaxSize; // int64_t - Surface size is 64 bit for all configurations int64_t SurfaceMaxSize; // int64_t - Surface size is 64 bit for all configurations
uint32_t MaxGpuVirtualAddressBitsPerResource; uint32_t MaxGpuVirtualAddressBitsPerResource;
uint32_t MaxSLMSize; uint32_t MaxSLMSize;
uint8_t HiZPixelsPerByte; //HiZ-Bpp is < 1, keep inverse
}__GMM_PLATFORM_RESOURCE, GMM_PLATFORM_INFO; }__GMM_PLATFORM_RESOURCE, GMM_PLATFORM_INFO;
//*************************************************************************** //***************************************************************************

View File

@ -137,7 +137,8 @@ namespace GmmLib
pClientContext() pClientContext()
{ {
#if (!defined(__GMM_KMD__) && !defined(GMM_UNIFIED_LIB)) #if (!defined(__GMM_KMD__) && !defined(GMM_UNIFIED_LIB))
if (pGmmGlobalContext) // For clients, who derive classes from GMM class and call their derived class constructors
if (pGmmGlobalContext) // Client ULT does new on ResInfo without calling GmmInitGlobalContext.
{ {
pClientContext = pGmmGlobalContext->pGmmGlobalClientContext; pClientContext = pGmmGlobalContext->pGmmGlobalClientContext;
GET_GMM_CLIENT_TYPE(pClientContext, ClientType); GET_GMM_CLIENT_TYPE(pClientContext, ClientType);
@ -383,6 +384,10 @@ namespace GmmLib
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
GMM_INLINE_VIRTUAL GMM_INLINE uint32_t GMM_STDCALL GetAuxQPitch() GMM_INLINE_VIRTUAL GMM_INLINE uint32_t GMM_STDCALL GetAuxQPitch()
{ {
const GMM_PLATFORM_INFO *pPlatform;
pPlatform = GMM_OVERRIDE_PLATFORM_INFO(&Surf);
if (Surf.Flags.Gpu.UnifiedAuxSurface) if (Surf.Flags.Gpu.UnifiedAuxSurface)
{ {
if (GmmIsPlanar(Surf.Format)) if (GmmIsPlanar(Surf.Format))
@ -391,8 +396,8 @@ namespace GmmLib
} }
else if (AuxSurf.Flags.Gpu.HiZ) else if (AuxSurf.Flags.Gpu.HiZ)
{ {
// HiZ ==> 2 * HZ_QPitch // HiZ ==> HZ_PxPerByte * HZ_QPitch
return AuxSurf.Alignment.QPitch * 2; return AuxSurf.Alignment.QPitch * pPlatform->HiZPixelsPerByte;
} }
else else
{ {