Skip to content

Commit 29da856

Browse files
authored
Add support for UnifiedAux+Depth+HiZ w/o CCS
1 parent cf26fa2 commit 29da856

File tree

3 files changed

+200
-1
lines changed

3 files changed

+200
-1
lines changed

Source/GmmLib/Resource/GmmResourceInfoCommonEx.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,13 @@ bool GmmLib::GmmResourceInfoCommon::CopyClientParams(GMM_RESCREATE_PARAMS &Creat
318318
AuxSurf.Type = (AuxSurf.Flags.Gpu.HiZ) ? AuxSurf.Type : RESOURCE_INVALID;
319319
AuxSurf.Flags.Info.RenderCompressed = AuxSurf.Flags.Info.MediaCompressed = 0;
320320
}
321-
else if(Surf.Flags.Gpu.SeparateStencil && Surf.Flags.Gpu.CCS) //Stencil compression
321+
else if(Surf.Flags.Gpu.Depth && Surf.Flags.Gpu.HiZ && !Surf.Flags.Gpu.CCS) // Depth + HiZ only, CCS is disabled
322+
{
323+
// main surface is depth, AuxSurf is HiZ
324+
Surf.Flags.Gpu.HiZ = 0; //depth buffer, clear HiZ
325+
AuxSurf.Flags.Gpu.IndirectClearColor = 0; //Clear fastClear from HiZ
326+
}
327+
else if(Surf.Flags.Gpu.SeparateStencil && Surf.Flags.Gpu.CCS) //Stencil compression
322328
{
323329
AuxSurf.Flags.Gpu.SeparateStencil = 0;
324330
Surf.Flags.Gpu.CCS = 0;

Source/GmmLib/ULT/GmmGen12ResourceULT.cpp

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2202,6 +2202,184 @@ TEST_F(CTestGen12Resource, TestLosslessMSAACompressedResource)
22022202
{
22032203
}
22042204

2205+
TEST_F(CTestGen12Resource, TestDepthHiZNotCompressedResource)
2206+
{
2207+
const uint32_t HAlign = 8; //HiZ alignment (16x4 ie general alignment), [Depth 16bit: 8x8; ow 8x4]
2208+
uint32_t VAlign = 4;
2209+
2210+
const uint32_t AllocTileSize[1][2] = {128, 32}; //HiZ is TileY
2211+
2212+
GMM_RESCREATE_PARAMS gmmParams = {};
2213+
gmmParams.NoGfxMemory = 1;
2214+
gmmParams.Flags.Info.TiledY = 1; //Not supported for Depth buffer, but HiZ output is TileY
2215+
gmmParams.Flags.Gpu.Depth = 1; //GPU Flags= Depth + HiZ
2216+
gmmParams.Flags.Gpu.HiZ = 1;
2217+
gmmParams.Flags.Gpu.CCS = 0;
2218+
gmmParams.Flags.Info.RenderCompressed = 0;
2219+
gmmParams.Flags.Gpu.UnifiedAuxSurface = 1;
2220+
2221+
for(uint32_t k = 0; k <= 1; k++)
2222+
{
2223+
gmmParams.Flags.Gpu.IndirectClearColor = k;
2224+
2225+
// Allocate 1x1 surface so that it occupies 1 Tile in X dimension
2226+
for(uint32_t j = TEST_BPP_8; j <= TEST_BPP_128; j++) //Depth bpp doesn't matter, Depth px dimensions decide HiZ size in HW
2227+
{
2228+
{
2229+
VAlign = (j == TEST_BPP_16) ? 8 : 4;
2230+
}
2231+
gmmParams.Format = SetResourceFormat(static_cast<TEST_BPP>(j)); //Only 16,24,32 supported; But driver creates the resource even for other bpps without failing
2232+
for(uint32_t i = RESOURCE_2D; i <= RESOURCE_CUBE; i++) //3D doesn't support HiZ
2233+
{
2234+
gmmParams.Type = static_cast<GMM_RESOURCE_TYPE>(i);
2235+
gmmParams.BaseWidth64 = 0x1;
2236+
gmmParams.BaseHeight = 0x1; //0x24; //not 1 tile
2237+
//gmmParams.MaxLod = 6; --add expectedheight calc- mip0+max{mip1, sum{mip2,...n}}
2238+
gmmParams.Depth = 0x1;
2239+
2240+
if(i == RESOURCE_1D || i == RESOURCE_3D) // SKL+ 1D and 3D do not support HiZ
2241+
{
2242+
gmmParams.Flags.Gpu.HiZ = 0;
2243+
}
2244+
else
2245+
{
2246+
gmmParams.Flags.Gpu.HiZ = 1;
2247+
}
2248+
2249+
GMM_RESOURCE_INFO *ResourceInfo = NULL;
2250+
ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2251+
//EXPECT_NE(NULL, ResourceInfo);
2252+
2253+
VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2254+
VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2255+
uint32_t ExpectedPitch = AllocTileSize[0][0];
2256+
VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
2257+
VerifyResourcePitchInTiles<true>(ResourceInfo, 1); // 1 tileY wide
2258+
uint32_t ExpectedHeight = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign);
2259+
2260+
if(gmmParams.ArraySize > 1 || gmmParams.Type == RESOURCE_CUBE)
2261+
{
2262+
uint32_t ExpectedQPitch = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign);
2263+
ExpectedHeight *= (gmmParams.Type == RESOURCE_CUBE) ? 6 : 1;
2264+
2265+
VerifyResourceQPitch<true>(ResourceInfo, ExpectedQPitch); // Each face should be VAlign rows apart within a tile,
2266+
}
2267+
2268+
VerifyResourceSize<true>(ResourceInfo,
2269+
GFX_ALIGN(ExpectedPitch * ExpectedHeight, 1 * PAGE_SIZE)); //1 Tile should be enough
2270+
2271+
if(gmmParams.Flags.Gpu.IndirectClearColor)
2272+
{
2273+
VerifyResourceAuxCCSize<true>(ResourceInfo, PAGE_SIZE);
2274+
}
2275+
else
2276+
{
2277+
VerifyResourceAuxCCSize<true>(ResourceInfo, 0);
2278+
}
2279+
2280+
pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2281+
}
2282+
2283+
// Allocate 2 tiles in X dimension. (muti-tiles Tiles in Y dimension for cube/array)
2284+
for(uint32_t i = RESOURCE_2D; i <= RESOURCE_CUBE; i++)
2285+
{
2286+
gmmParams.Type = static_cast<GMM_RESOURCE_TYPE>(i);
2287+
gmmParams.BaseWidth64 = AllocTileSize[0][0] + 0x1;
2288+
gmmParams.BaseHeight = (gmmParams.Type == RESOURCE_1D) ? 0x1 :
2289+
(gmmParams.Type == RESOURCE_CUBE) ? gmmParams.BaseWidth64 :
2290+
VAlign / 2;
2291+
gmmParams.ArraySize = (gmmParams.Type != RESOURCE_3D) ? VAlign : 1;
2292+
gmmParams.Depth = 0x1;
2293+
2294+
if(i == RESOURCE_1D || i == RESOURCE_3D)
2295+
{
2296+
gmmParams.Flags.Gpu.HiZ = 0;
2297+
}
2298+
else
2299+
{
2300+
gmmParams.Flags.Gpu.HiZ = 1;
2301+
}
2302+
2303+
GMM_RESOURCE_INFO *ResourceInfo;
2304+
ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2305+
2306+
VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2307+
VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2308+
uint32_t ExpectedPitch = GFX_ALIGN(gmmParams.BaseWidth * (int)pow(2, j), AllocTileSize[0][0]);
2309+
VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
2310+
VerifyResourcePitchInTiles<true>(ResourceInfo, ExpectedPitch / AllocTileSize[0][0]);
2311+
2312+
uint32_t ExpectedQPitch = 0;
2313+
if(gmmParams.ArraySize > 1 || gmmParams.Type == RESOURCE_CUBE)
2314+
{
2315+
ExpectedQPitch = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign);
2316+
VerifyResourceQPitch<true>(ResourceInfo, ExpectedQPitch); // Each face should be VAlign rows apart within a tile.
2317+
}
2318+
2319+
VerifyResourceSize<true>(ResourceInfo, // PitchInBytes * Rows where Rows = (__GMM_MAX_CUBE_FACE x QPitch) /2 (Stencil height = halved due to interleaving), then aligned to tile boundary
2320+
((gmmParams.Type == RESOURCE_CUBE) ?
2321+
ExpectedPitch * GMM_ULT_ALIGN(ExpectedQPitch * gmmParams.ArraySize * __GMM_MAX_CUBE_FACE, AllocTileSize[0][1]) : //cube
2322+
((gmmParams.ArraySize > 1) ?
2323+
ExpectedPitch * GMM_ULT_ALIGN(ExpectedQPitch * gmmParams.ArraySize, AllocTileSize[0][1]) : //array
2324+
ExpectedPitch * GMM_ULT_ALIGN(gmmParams.BaseHeight, AllocTileSize[0][1]))));
2325+
2326+
if(gmmParams.Flags.Gpu.IndirectClearColor)
2327+
{
2328+
VerifyResourceAuxCCSize<true>(ResourceInfo, PAGE_SIZE);
2329+
}
2330+
else
2331+
{
2332+
VerifyResourceAuxCCSize<true>(ResourceInfo, 0);
2333+
}
2334+
2335+
pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2336+
}
2337+
2338+
// Allocate 2 tiles in X, 3 tiles in Y dimension (non-arrayed) Multi-tiles for 3D
2339+
for(uint32_t i = RESOURCE_2D; i <= RESOURCE_3D; i++)
2340+
{
2341+
gmmParams.Type = static_cast<GMM_RESOURCE_TYPE>(i);
2342+
gmmParams.BaseWidth64 = AllocTileSize[0][0] + 0x1;
2343+
gmmParams.BaseHeight = 2 * AllocTileSize[0][1] + 0x1; //Half-Depth Height or QPitch (lod!=0), aligned to 8 required by HW
2344+
gmmParams.Depth = (gmmParams.Type == RESOURCE_2D) ? 0x1 :
2345+
VAlign + 1;
2346+
gmmParams.ArraySize = 1;
2347+
2348+
if(i == RESOURCE_1D || i == RESOURCE_3D)
2349+
{
2350+
gmmParams.Flags.Gpu.HiZ = 0;
2351+
}
2352+
else
2353+
{
2354+
gmmParams.Flags.Gpu.HiZ = 1;
2355+
}
2356+
2357+
GMM_RESOURCE_INFO *ResourceInfo;
2358+
ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2359+
2360+
VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2361+
VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2362+
uint32_t ExpectedPitch = GFX_ALIGN(gmmParams.BaseWidth * (int)pow(2, j), AllocTileSize[0][0]);
2363+
VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
2364+
VerifyResourcePitchInTiles<true>(ResourceInfo, ExpectedPitch / AllocTileSize[0][0]); // 2 tile wide
2365+
2366+
uint32_t TwoDQPitch, ExpectedQPitch = 0;
2367+
if(gmmParams.Type == RESOURCE_3D)
2368+
{
2369+
TwoDQPitch = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign);
2370+
ExpectedQPitch = GFX_ALIGN(TwoDQPitch, AllocTileSize[0][1]); //Depth slices arranged as 2D-arrayed slices.
2371+
VerifyResourceQPitch<true>(ResourceInfo, ExpectedQPitch);
2372+
}
2373+
else
2374+
{
2375+
//HiZ for 3D not supported. Driver still allocates like IVB/HSW.
2376+
VerifyResourceSize<true>(ResourceInfo, ExpectedPitch * GMM_ULT_ALIGN(gmmParams.BaseHeight, AllocTileSize[0][1]));
2377+
}
2378+
pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2379+
}
2380+
}
2381+
}
2382+
}
22052383
///TODO Add MSAA/Depth Compressed Resource tests
22062384
TEST_F(CTestGen12Resource, DISABLED_TestDepthCompressedResource)
22072385
{

Source/GmmLib/ULT/GmmResourceULT.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,21 @@ class CTestResource : public CommonULT
448448
}
449449
}
450450

451+
/////////////////////////////////////////////////////////////////////////////////////
452+
/// Verifies if AuxCCSize matches the expected value. Fails test if value doesn't match
453+
///
454+
/// @param[in] ResourceInfo: ResourceInfo returned by GmmLib
455+
/// @param[in] ExpectedValue: expected value to check against
456+
/////////////////////////////////////////////////////////////////////////////////////
457+
template <bool Verify>
458+
void VerifyResourceAuxCCSize(GMM_RESOURCE_INFO *ResourceInfo, uint64_t ExpectedValue)
459+
{
460+
if(Verify)
461+
{
462+
EXPECT_EQ(ExpectedValue, ResourceInfo->GetSizeAuxSurface(GMM_AUX_CC));
463+
}
464+
}
465+
451466
/////////////////////////////////////////////////////////////////////////////////////
452467
/// Verifies if QPitch matches the expected value. Fails test if value doesn't match
453468
///

0 commit comments

Comments
 (0)