From 932fb0addd7c5898b579874c0ea43e9051b531b7 Mon Sep 17 00:00:00 2001 From: lpriyank Date: Sun, 25 Mar 2018 23:54:39 -0700 Subject: [PATCH] Generic texture calculation for HiZ Change-Id: I94ba01620036bb6b3b34c8ce5b65d7e7572630a6 --- Source/GmmLib/Platform/GmmGen10Platform.cpp | 1 + Source/GmmLib/Platform/GmmGen8Platform.cpp | 2 ++ Source/GmmLib/Platform/GmmGen9Platform.cpp | 2 ++ Source/GmmLib/Resource/GmmResourceInfoCommon.cpp | 6 ++++-- Source/GmmLib/Texture/GmmTextureSpecialCases.cpp | 5 +++-- Source/GmmLib/inc/External/Common/GmmPlatformExt.h | 2 ++ .../inc/External/Common/GmmResourceInfoCommon.h | 11 ++++++++--- 7 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Source/GmmLib/Platform/GmmGen10Platform.cpp b/Source/GmmLib/Platform/GmmGen10Platform.cpp index b343886..5652e8e 100644 --- a/Source/GmmLib/Platform/GmmGen10Platform.cpp +++ b/Source/GmmLib/Platform/GmmGen10Platform.cpp @@ -507,5 +507,6 @@ GmmLib::PlatformInfoGen10::PlatformInfoGen10(PLATFORM &Platform) //--------------------------------------------- Data.SurfaceMaxSize = GMM_GBYTE(256); Data.MaxGpuVirtualAddressBitsPerResource = 38; + Data.HiZPixelsPerByte = 2; } #endif // #if (IGFX_GEN >= IGFX_GEN10) diff --git a/Source/GmmLib/Platform/GmmGen8Platform.cpp b/Source/GmmLib/Platform/GmmGen8Platform.cpp index e283450..c8d6737 100644 --- a/Source/GmmLib/Platform/GmmGen8Platform.cpp +++ b/Source/GmmLib/Platform/GmmGen8Platform.cpp @@ -430,4 +430,6 @@ GmmLib::PlatformInfoGen8::PlatformInfoGen8(PLATFORM &Platform) Data.SurfaceMaxSize = GMM_GBYTE(2); Data.MaxGpuVirtualAddressBitsPerResource = 31; Data.MaxSLMSize = GMM_KBYTE(384); + + Data.HiZPixelsPerByte = 2; } \ No newline at end of file diff --git a/Source/GmmLib/Platform/GmmGen9Platform.cpp b/Source/GmmLib/Platform/GmmGen9Platform.cpp index 8f6e416..0020658 100644 --- a/Source/GmmLib/Platform/GmmGen9Platform.cpp +++ b/Source/GmmLib/Platform/GmmGen9Platform.cpp @@ -489,4 +489,6 @@ GmmLib::PlatformInfoGen9::PlatformInfoGen9(PLATFORM &Platform) { Data.MaxSLMSize = GMM_KBYTE(576); } + + Data.HiZPixelsPerByte = 2; } diff --git a/Source/GmmLib/Resource/GmmResourceInfoCommon.cpp b/Source/GmmLib/Resource/GmmResourceInfoCommon.cpp index f8339f5..dfefabf 100644 --- a/Source/GmmLib/Resource/GmmResourceInfoCommon.cpp +++ b/Source/GmmLib/Resource/GmmResourceInfoCommon.cpp @@ -134,6 +134,8 @@ GMM_STATUS GMM_STDCALL GmmLib::GmmResourceInfoCommon::Create(Context &GmmLibCont pGmmLibContext = reinterpret_cast(&GmmLibContext); #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) { pClientContext = pGmmGlobalContext->pGmmGlobalClientContext; @@ -763,7 +765,7 @@ uint32_t GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetQPitch() // 2D/CUBE ==> distance in rows between array slices // 3D ==> distance in rows between R-slices // Compressed ==> one row contains a complete compression block vertically - // HiZ ==> 2 * HZ_QPitch + // HiZ ==> HZ_PxPerByte * HZ_QPitch // Stencil ==> logical, i.e. not halved 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) { - QPitch = Surf.Alignment.QPitch * 2; + QPitch = Surf.Alignment.QPitch * pPlatform->HiZPixelsPerByte; } else { diff --git a/Source/GmmLib/Texture/GmmTextureSpecialCases.cpp b/Source/GmmLib/Texture/GmmTextureSpecialCases.cpp index 7177ca2..bbef6f2 100644 --- a/Source/GmmLib/Texture/GmmTextureSpecialCases.cpp +++ b/Source/GmmLib/Texture/GmmTextureSpecialCases.cpp @@ -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 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 // 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) ? (h0 + GFX_MAX(h1, Z_HeightL)) : h0; - QPitch /= 2; + QPitch /= HZ_DepthRows; pTexInfo->ArraySize = Z_Depth; pTexInfo->BaseHeight = QPitch; } 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) { diff --git a/Source/GmmLib/inc/External/Common/GmmPlatformExt.h b/Source/GmmLib/inc/External/Common/GmmPlatformExt.h index 85ba0dd..6ca9332 100644 --- a/Source/GmmLib/inc/External/Common/GmmPlatformExt.h +++ b/Source/GmmLib/inc/External/Common/GmmPlatformExt.h @@ -263,6 +263,8 @@ typedef struct __GMM_PLATFORM_RESOURCE_REC int64_t SurfaceMaxSize; // int64_t - Surface size is 64 bit for all configurations uint32_t MaxGpuVirtualAddressBitsPerResource; uint32_t MaxSLMSize; + + uint8_t HiZPixelsPerByte; //HiZ-Bpp is < 1, keep inverse }__GMM_PLATFORM_RESOURCE, GMM_PLATFORM_INFO; //*************************************************************************** diff --git a/Source/GmmLib/inc/External/Common/GmmResourceInfoCommon.h b/Source/GmmLib/inc/External/Common/GmmResourceInfoCommon.h index b3f35ad..3942a8f 100644 --- a/Source/GmmLib/inc/External/Common/GmmResourceInfoCommon.h +++ b/Source/GmmLib/inc/External/Common/GmmResourceInfoCommon.h @@ -137,7 +137,8 @@ namespace GmmLib pClientContext() { #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; GET_GMM_CLIENT_TYPE(pClientContext, ClientType); @@ -383,6 +384,10 @@ namespace GmmLib ///////////////////////////////////////////////////////////////////////////////////// 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 (GmmIsPlanar(Surf.Format)) @@ -391,8 +396,8 @@ namespace GmmLib } else if (AuxSurf.Flags.Gpu.HiZ) { - // HiZ ==> 2 * HZ_QPitch - return AuxSurf.Alignment.QPitch * 2; + // HiZ ==> HZ_PxPerByte * HZ_QPitch + return AuxSurf.Alignment.QPitch * pPlatform->HiZPixelsPerByte; } else {