xref: /aosp_15_r20/external/gmmlib/Source/GmmLib/ULT/GmmGen12ResourceULT.cpp (revision 35ffd701415c9e32e53136d61a677a8d0a8fc4a5)
1 /*==============================================================================
2 Copyright(c) 2019 Intel Corporation
3 
4 Permission is hereby granted, free of charge, to any person obtaining a
5 copy of this software and associated documentation files(the "Software"),
6 to deal in the Software without restriction, including without limitation
7 the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 and / or sell copies of the Software, and to permit persons to whom the
9 Software is furnished to do so, subject to the following conditions:
10 
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
13 
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 OTHER DEALINGS IN THE SOFTWARE.
21 ============================================================================*/
22 
23 #include "GmmGen12ResourceULT.h"
24 
25 using namespace std;
26 
27 /////////////////////////////////////////////////////////////////////////////////////
28 /// Sets up common environment for Resource fixture tests. this is called once per
29 /// test case before executing all tests under resource fixture test case.
30 //  It also calls SetupTestCase from CommonULT to initialize global context and others.
31 ///
32 /// @see    CTestGen12Resource::SetUpTestCase()
33 ///
34 /////////////////////////////////////////////////////////////////////////////////////
SetUpTestCase()35 void CTestGen12Resource::SetUpTestCase()
36 {
37     printf("%s\n", __FUNCTION__);
38     GfxPlatform.eProductFamily    = IGFX_TIGERLAKE_LP;
39     GfxPlatform.eRenderCoreFamily = IGFX_GEN12_CORE;
40 
41     pGfxAdapterInfo = (ADAPTER_INFO *)malloc(sizeof(ADAPTER_INFO));
42     if(pGfxAdapterInfo)
43     {
44         memset(pGfxAdapterInfo, 0, sizeof(ADAPTER_INFO));
45 
46         pGfxAdapterInfo->SkuTable.FtrLinearCCS = 1; //legacy y =>0 - test both
47         pGfxAdapterInfo->SkuTable.FtrTileY     = 1;
48         pGfxAdapterInfo->SkuTable.FtrLLCBypass = 0;
49         pGfxAdapterInfo->WaTable.WaAuxTable64KGranular= 1;
50 	CommonULT::SetUpTestCase();
51     }
52 }
53 
54 /////////////////////////////////////////////////////////////////////////////////////
55 /// cleans up once all the tests finish execution.  It also calls TearDownTestCase
56 /// from CommonULT to destroy global context and others.
57 ///
58 /// @see    CTestGen12Resource::TearDownTestCase()
59 /////////////////////////////////////////////////////////////////////////////////////
TearDownTestCase()60 void CTestGen12Resource::TearDownTestCase()
61 {
62     printf("%s\n", __FUNCTION__);
63 
64     CommonULT::TearDownTestCase();
65 }
66 
67 /// @brief ULT for 2D TileYs Compressed Resource
68 /// tests both Separate and Unified CCS allcoation
TEST_F(CTestGen12Resource,Test2DTileYsCompressedResource)69 TEST_F(CTestGen12Resource, Test2DTileYsCompressedResource)
70 {
71     const uint32_t HAlign[TEST_BPP_MAX] = {256, 256, 128, 128, 64}; //REM-comment: YS-shape in pixels per-bpp
72     const uint32_t VAlign[TEST_BPP_MAX] = {256, 128, 128, 64, 64};
73 
74     const uint32_t TileSize[TEST_BPP_MAX][2] = {{256, 256}, //REM-comment: YS-shape in bytes per-bpp
75                                                 {512, 128},
76                                                 {512, 128},
77                                                 {1024, 64},
78                                                 {1024, 64}};
79 
80     GMM_RESCREATE_PARAMS gmmParams        = {};
81     gmmParams.Type                        = RESOURCE_2D;
82     gmmParams.NoGfxMemory                 = 1;
83     gmmParams.Flags.Info.TiledY           = 1;
84     gmmParams.Flags.Info.TiledYs          = 1;
85     gmmParams.Flags.Gpu.Texture           = 1;
86     gmmParams.Flags.Info.RenderCompressed = 1;
87     // Turn on .MC or .RC flag - mandatory to tell compression-type, for Yf its also used to pad surf
88     // to 4x1 tile (reqd by HW for perf reasons)
89     // If unifiedAuxSurf reqd (mandatory for displayable or cross-adapter shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
90 
91     //Allocate 1x1 surface
92     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
93     {
94         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
95         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
96 
97         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
98         GMM_TILE_MODE TileMode = DEFINE_TILE(YS_2D, bpp);
99         gmmParams.Format       = SetResourceFormat(bpp);
100         gmmParams.BaseWidth64  = 0x1;
101         gmmParams.BaseHeight   = 0x1;
102 
103         GMM_RESOURCE_INFO *ResourceInfo;
104         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
105 
106         VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
107         VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
108         VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0]); // As wide as 1 Tile
109         VerifyResourcePitchInTiles<true>(ResourceInfo, 1);       // 1 Tile wide
110         VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(64));   // 1 Tile Big
111         VerifyResourceQPitch<false>(ResourceInfo, 0);            // Not Tested
112 
113         //test main surface base alignment is 64KB
114         //For Yf test main surface pitch is 16KB aligned
115         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
116         //EXPECT_EQ(0, ResourceInfo->GetRenderPitchInTiles() % GMM_KBYTE(16));   // Check on YF only
117 
118         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
119         {
120             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
121             EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
122         }
123         else
124         {
125             //Test AuxSurf H/Valign, size etc (Not POR- can be removed)
126             ALIGNMENT UnitAlign;
127             pGmmULTClientContext->GetExtendedTextureAlign(CCS_MODE(TileMode), UnitAlign);
128 
129             EXPECT_EQ(UnitAlign.Width, ResourceInfo->GetAuxHAlign());
130             EXPECT_EQ(UnitAlign.Height, ResourceInfo->GetAuxVAlign());
131             EXPECT_EQ(0x80, ResourceInfo->GetUnifiedAuxPitch()); //TileY = 0x80 x 0x20
132         }
133         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
134 
135         { //separate Aux
136             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
137 
138             GMM_RESOURCE_INFO *AuxResourceInfo;
139             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
140             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
141             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
142             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
143             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeAllocation());
144 
145             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
146         }
147         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
148     }
149 
150     // Allocate surface that requires multi tiles in two dimension
151     // Allocate 2 tiles in X dimension
152     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
153     {
154         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
155         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
156 
157         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
158         GMM_TILE_MODE TileMode = DEFINE_TILE(YS_2D, bpp);
159         gmmParams.Format       = SetResourceFormat(bpp);
160         gmmParams.BaseWidth64  = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
161         gmmParams.BaseHeight   = 0x1;
162         gmmParams.Depth        = 0x1;
163 
164         GMM_RESOURCE_INFO *ResourceInfo;
165         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
166 
167         VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
168         VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
169         VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0] * 2); // As wide as 2 tile
170         VerifyResourcePitchInTiles<true>(ResourceInfo, 2);           // 2 tile wide
171         VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(64) * 2);   // 2 tile big
172 
173         VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
174 
175         //test main surface base alignment is 64KB
176         //For Yf test main surface pitch is 16KB aligned
177 
178         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
179         {
180             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
181             EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
182         }
183         else
184         { //Not POR
185         }
186         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
187 
188         { //separate Aux
189             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
190 
191             GMM_RESOURCE_INFO *AuxResourceInfo;
192             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
193             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
194             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
195             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
196             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
197             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
198         }
199         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
200     }
201 
202     // Allocate 2 tiles in X/Y dimension
203     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
204     {
205         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
206         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
207 
208         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
209         GMM_TILE_MODE TileMode = DEFINE_TILE(YS_2D, bpp);
210 
211         gmmParams.Format      = SetResourceFormat(bpp);
212         gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
213         gmmParams.BaseHeight  = TileSize[i][1] + 1;                      // 1 row larger than 1 tile height
214         gmmParams.Depth       = 0x1;
215 
216         GMM_RESOURCE_INFO *ResourceInfo;
217         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
218 
219         //**Not compression specific -BEGIN
220         VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
221         VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
222         VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0] * 2); // As wide as 2 tile
223         VerifyResourcePitchInTiles<true>(ResourceInfo, 2);           // 2 tile wide
224         VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(64) * 4);   // 4 tile big
225         VerifyResourceQPitch<false>(ResourceInfo, 0);                // Not tested
226         //**Not compression specific -END
227 
228         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
229         {
230             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
231             EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
232         }
233 
234         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
235 
236         { //separate Aux
237             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
238 
239             GMM_RESOURCE_INFO *AuxResourceInfo;
240             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
241             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
242             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
243             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
244             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
245             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
246         }
247         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
248     }
249 }
250 
251 /// @brief ULT for 2D TileYf Compressed Resource
TEST_F(CTestGen12Resource,Test2DTileYfCompressedResource)252 TEST_F(CTestGen12Resource, Test2DTileYfCompressedResource)
253 {
254     const uint32_t HAlign[TEST_BPP_MAX] = {64, 64, 32, 32, 16};
255     const uint32_t VAlign[TEST_BPP_MAX] = {64, 32, 32, 16, 16};
256 
257     const uint32_t TileSize[TEST_BPP_MAX][2] = {{64, 64},
258                                                 {128, 32},
259                                                 {128, 32},
260                                                 {256, 16},
261                                                 {256, 16}};
262 
263     GMM_RESCREATE_PARAMS gmmParams        = {};
264     gmmParams.Type                        = RESOURCE_2D;
265     gmmParams.NoGfxMemory                 = 1;
266     gmmParams.Flags.Info.TiledY           = 1;
267     gmmParams.Flags.Info.TiledYf          = 1;
268     gmmParams.Flags.Gpu.Texture           = 1;
269     gmmParams.Flags.Info.RenderCompressed = 1;
270     // Turn on .MC or .RC flag - mandatory to tell compression-type, for Yf its also used to pad surf
271     // to 4x1 tile (reqd by HW )
272     // If unifiedAuxSurf reqd (mandatory for displayable or cross-adapter shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
273 
274     //Allocate 1x1 surface
275     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
276     {
277         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
278         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
279 
280         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
281         GMM_TILE_MODE TileMode = DEFINE_TILE(YF_2D, bpp);
282         gmmParams.Format       = SetResourceFormat(bpp);
283         gmmParams.BaseWidth64  = 0x1;
284         gmmParams.BaseHeight   = 0x1;
285 
286         GMM_RESOURCE_INFO *ResourceInfo;
287         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
288 
289         VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
290         VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
291         VerifyResourcePitch<true>(ResourceInfo, 4 * TileSize[i][0]); // As wide as 4 Tile
292         VerifyResourcePitchInTiles<true>(ResourceInfo, 4);           // 4 Tile wide
293         VerifyResourceSize<true>(ResourceInfo, 4 * GMM_KBYTE(4));    // 4 Tile Big
294         VerifyResourceQPitch<false>(ResourceInfo, 0);                // Not Tested
295 
296         //test main surface base alignment is 64KB
297         //For Yf/Y test main surface pitch is 4-tileYF/Y aligned
298         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
299         EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4);
300 
301         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
302         {
303             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
304             EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
305         }
306 
307         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
308 
309         { //separate Aux
310             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
311 
312             GMM_RESOURCE_INFO *AuxResourceInfo;
313             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
314             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
315             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
316             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
317             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
318 
319             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
320         }
321         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
322     }
323 
324     // Allocate surface that requires multi tiles in two dimension
325     // Allocate 2 tiles in X dimension
326     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
327     {
328         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
329         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
330 
331         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
332         GMM_TILE_MODE TileMode = DEFINE_TILE(YF_2D, bpp);
333         gmmParams.Format       = SetResourceFormat(bpp);
334         gmmParams.BaseWidth64  = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
335         gmmParams.BaseHeight   = 0x1;
336         gmmParams.Depth        = 0x1;
337 
338         GMM_RESOURCE_INFO *ResourceInfo;
339         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
340 
341         VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
342         VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
343         VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0] * 4); // As wide as 2 tile, but 4-tile pitch alignment
344         VerifyResourcePitchInTiles<true>(ResourceInfo, 4);           // 2 tile wide, but 4-tile pitch alignment
345         VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * 4);    // 2 tile big, but 4-tile pitch alignment
346 
347         VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
348 
349         //test main surface base alignment is 64KB
350         //For Yf/Y test main surface pitch is 4-tileYF/Y aligned
351         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
352         EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4);
353 
354         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
355         {
356             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
357             EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
358         }
359 
360         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
361 
362         { //separate Aux
363             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
364 
365             GMM_RESOURCE_INFO *AuxResourceInfo;
366             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
367             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
368             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
369             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
370             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
371 
372             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
373         }
374         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
375     }
376 
377     // Allocate surface that requires multi tiles in two dimension
378     // Allocate 2 tiles in X/Y dimension
379     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
380     {
381         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
382         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
383 
384         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
385         GMM_TILE_MODE TileMode = DEFINE_TILE(YF_2D, bpp);
386         gmmParams.Format       = SetResourceFormat(bpp);
387         gmmParams.BaseWidth64  = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
388         gmmParams.BaseHeight   = TileSize[i][1] + 1;                      // 1 row larger than 1 tile height
389         gmmParams.Depth        = 0x1;
390 
391         GMM_RESOURCE_INFO *ResourceInfo;
392         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
393 
394         VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
395         VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
396         VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0] * 4);  // As wide as 2 tile, but 4-tile pitch alignment
397         VerifyResourcePitchInTiles<true>(ResourceInfo, 4);            // 2 tile wide, but 4-tile pitch alignment
398         VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * 4 * 2); // 4 tile wide; and 2-tile high
399 
400         VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
401                                                       //test main surface base alignment is 64KB
402                                                       //For Yf/Y test main surface pitch is 4-tileYF/Y aligned
403         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
404         EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4);
405 
406 
407         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
408         {
409             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
410             EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
411         }
412         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
413 
414         { //separate Aux
415             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
416 
417             GMM_RESOURCE_INFO *AuxResourceInfo;
418             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
419             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
420             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
421             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
422             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
423 
424             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
425         }
426         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
427     }
428 }
429 
430 /// @brief ULT for 2D TileY Compressed Resource
TEST_F(CTestGen12Resource,Test2DTileYCompressedResource)431 TEST_F(CTestGen12Resource, Test2DTileYCompressedResource)
432 {
433     const uint32_t HAlign = {16};
434     const uint32_t VAlign = {4};
435 
436     const uint32_t TileSize[2] = {128, 32};
437 
438     GMM_RESCREATE_PARAMS gmmParams = {};
439     gmmParams.Type                 = RESOURCE_2D;
440     gmmParams.NoGfxMemory          = 1;
441     gmmParams.Flags.Info.TiledY    = 1;
442 
443     gmmParams.Flags.Gpu.Texture           = 1;
444     gmmParams.Flags.Info.RenderCompressed = 1;
445     // Turn on .MC or .RC flag - mandatory to tell compression-type, for Yf/Y its also used to pad surf
446     // to 4x1 tile (reqd by HW for perf reasons)
447     // If unifiedAuxSurf reqd (mandatory for displayable or cross-adapter shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
448 
449     //Allocate 1x1 surface
450     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
451     {
452         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
453         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
454 
455         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
456         GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
457         gmmParams.Format       = SetResourceFormat(bpp);
458         gmmParams.BaseWidth64  = 0x1;
459         gmmParams.BaseHeight   = 0x1;
460 
461         GMM_RESOURCE_INFO *ResourceInfo;
462         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
463 
464         VerifyResourceHAlign<true>(ResourceInfo, HAlign);
465         VerifyResourceVAlign<true>(ResourceInfo, VAlign);
466         VerifyResourcePitch<true>(ResourceInfo, 4 * TileSize[0]); // As wide as 4 Tile
467         VerifyResourcePitchInTiles<true>(ResourceInfo, 4);        // 4 Tile wide
468         VerifyResourceSize<true>(ResourceInfo, 4 * GMM_KBYTE(4)); // 4 Tile Big
469         VerifyResourceQPitch<false>(ResourceInfo, 0);             // Not Tested
470 
471         //test main surface base alignment is 64KB
472         //For Yf/Y test main surface pitch is 4-tileYF/Y aligned
473         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
474         EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4);
475 
476         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
477         {
478             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
479             EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
480         }
481         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
482 
483         { //separate Aux
484             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
485 
486             GMM_RESOURCE_INFO *AuxResourceInfo;
487             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
488             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
489             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
490             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
491             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
492             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
493         }
494         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
495     }
496 
497     // Allocate surface that requires multi tiles in two dimension
498     // Allocate 2 tiles in X dimension
499     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
500     {
501         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
502         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
503 
504         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
505         GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
506         gmmParams.Format       = SetResourceFormat(bpp);
507         gmmParams.BaseWidth64  = (TileSize[0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
508         gmmParams.BaseHeight   = 0x1;
509         gmmParams.Depth        = 0x1;
510 
511         GMM_RESOURCE_INFO *ResourceInfo;
512         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
513 
514         VerifyResourceHAlign<true>(ResourceInfo, HAlign);
515         VerifyResourceVAlign<true>(ResourceInfo, VAlign);
516         VerifyResourcePitch<true>(ResourceInfo, TileSize[0] * 4); // As wide as 2 tile, but 4-tile pitch alignment
517         VerifyResourcePitchInTiles<true>(ResourceInfo, 4);        // 2 tile wide, but 4-tile pitch alignment
518         VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * 4); // 2 tile big, but 4-tile pitch alignment
519 
520         VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
521 
522         //test main surface base alignment is 64KB
523         //For Yf test main surface pitch is 4-tileYF aligned
524         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
525         EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
526 
527         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
528         {
529             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
530             EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
531         }
532         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
533 
534         { //separate Aux
535             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
536 
537             GMM_RESOURCE_INFO *AuxResourceInfo;
538             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
539             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
540             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
541             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
542             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
543 
544             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
545         }
546         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
547     }
548 
549     // Allocate surface that requires multi tiles in two dimension
550     // Allocate 2 tiles in X/Y dimension
551     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
552     {
553         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
554         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
555 
556         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
557         GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
558         gmmParams.Format       = SetResourceFormat(bpp);
559         gmmParams.BaseWidth64  = (TileSize[0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
560         gmmParams.BaseHeight   = TileSize[1] + 1;                      // 1 row larger than 1 tile height
561         gmmParams.Depth        = 0x1;
562 
563         GMM_RESOURCE_INFO *ResourceInfo;
564         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
565 
566         VerifyResourceHAlign<true>(ResourceInfo, HAlign);
567         VerifyResourceVAlign<true>(ResourceInfo, VAlign);
568         VerifyResourcePitch<true>(ResourceInfo, TileSize[0] * 4);     // As wide as 2 tile, but 4-tile pitch alignment
569         VerifyResourcePitchInTiles<true>(ResourceInfo, 4);            // 2 tile wide, but 4-tile pitch alignment
570         VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * 4 * 2); // 4 tile wide; and 2-tile high
571 
572         VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
573                                                       //test main surface base alignment is 64KB
574                                                       //For Yf/Y test main surface pitch is 4-tileYF/Y aligned
575         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
576         EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
577 
578         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
579         {
580             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
581             EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
582         }
583         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
584 
585         { //separate Aux
586             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
587 
588             GMM_RESOURCE_INFO *AuxResourceInfo;
589             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
590             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
591             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
592             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
593             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
594 
595             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
596         }
597         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
598     }
599 }
600 
601 /// @brief ULT for 2D TileY lossless Compressed lossy Resource
TEST_F(CTestGen12Resource,Test2DTileYLossyCompressedResource)602 TEST_F(CTestGen12Resource, Test2DTileYLossyCompressedResource)
603 {
604     const uint32_t HAlign = {4};
605     const uint32_t VAlign = {4};
606 
607     const uint32_t TileSize[2] = {128, 32};
608 
609     GMM_RESCREATE_PARAMS gmmParams = {};
610     gmmParams.Type                 = RESOURCE_2D;
611     gmmParams.NoGfxMemory          = 1;
612     gmmParams.Flags.Info.TiledY    = 1;
613 
614     gmmParams.Flags.Gpu.Texture           = 1;
615     gmmParams.Flags.Info.RenderCompressed = 1;
616     // Turn on .MC or .RC flag - mandatory to tell compression-type, for Yf its also used to pad surf
617     // to 4x1 tile (reqd by HW for perf reasons)
618     // If unifiedAuxSurf reqd (mandatory for displayable or cross-adapter shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
619 
620     //Allocate 1x1 surface
621     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
622     {
623         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
624         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
625 
626         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
627         GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
628         gmmParams.Format       = GMM_FORMAT_ETC2_RGB8;
629         gmmParams.BaseWidth64  = 0x80;
630         gmmParams.BaseHeight   = 0x20;
631 
632         GMM_RESOURCE_INFO *ResourceInfo;
633         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
634 
635         VerifyResourceHAlign<true>(ResourceInfo, HAlign);
636         VerifyResourceVAlign<true>(ResourceInfo, VAlign);
637         VerifyResourcePitch<true>(ResourceInfo, 4 * TileSize[0]); // As wide as 4 Tile
638         VerifyResourcePitchInTiles<true>(ResourceInfo, 4);        // 4 Tile wide
639         VerifyResourceSize<true>(ResourceInfo, 4 * GMM_KBYTE(4)); // 4 Tile Big
640         VerifyResourceQPitch<false>(ResourceInfo, 0);             // Not Tested
641 
642         //test main surface base alignment is 64KB
643         //For Yf/Y test main surface pitch is 4-tileYF/Y aligned
644         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
645         EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4);
646 
647         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
648         {
649             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
650             EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
651         }
652         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
653 
654         { //separate Aux
655             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
656 
657             GMM_RESOURCE_INFO *AuxResourceInfo;
658             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
659             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
660             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
661             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
662             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
663 
664             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
665         }
666         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
667     }
668 
669     // Allocate surface that requires multi tiles in two dimension
670     // Allocate 2 tiles in X dimension
671     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
672     {
673         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
674         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
675 
676         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
677         GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
678         gmmParams.Format       = GMM_FORMAT_ETC2_RGB8;
679         gmmParams.BaseWidth64  = (TileSize[0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
680         gmmParams.BaseHeight   = 0x1;
681         gmmParams.Depth        = 0x1;
682 
683         GMM_RESOURCE_INFO *ResourceInfo;
684         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
685 
686         VerifyResourceHAlign<true>(ResourceInfo, HAlign);
687         VerifyResourceVAlign<true>(ResourceInfo, VAlign);
688         VerifyResourcePitch<true>(ResourceInfo, TileSize[0] * 4); // As wide as 2 tile, but 4-tile pitch alignment
689         VerifyResourcePitchInTiles<true>(ResourceInfo, 4);        // 2 tile wide, but 4-tile pitch alignment
690         VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * 4); // 2 tile big, but 4-tile pitch alignment
691 
692         VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
693 
694         //test main surface base alignment is 64KB
695         //For Yf/Y test main surface pitch is 4-tileYF/Y aligned
696         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
697         EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4);
698 
699         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
700         {
701             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
702             EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
703         }
704 
705         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
706 
707         { //separate Aux
708             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
709 
710             GMM_RESOURCE_INFO *AuxResourceInfo;
711             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
712             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
713             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
714             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
715             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
716 
717             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
718         }
719         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
720     }
721 
722     // Allocate surface that requires multi tiles in two dimension
723     // Allocate 2 tiles in X/Y dimension
724     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
725     {
726         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
727         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
728 
729         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
730         GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
731         gmmParams.Format       = GMM_FORMAT_ETC2_RGB8;
732         gmmParams.BaseWidth64  = (TileSize[0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
733         gmmParams.BaseHeight   = TileSize[1] + 1;                      // 1 row larger than 1 tile height
734         gmmParams.Depth        = 0x1;
735 
736         GMM_RESOURCE_INFO *ResourceInfo;
737         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
738 
739         VerifyResourceHAlign<true>(ResourceInfo, HAlign);
740         VerifyResourceVAlign<true>(ResourceInfo, VAlign);
741         VerifyResourcePitch<true>(ResourceInfo, TileSize[0] * 4); // As wide as 2 tile, but 4-tile pitch alignment
742         VerifyResourcePitchInTiles<true>(ResourceInfo, 4);        // 2 tile wide, but 4-tile pitch alignment
743         VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * 4); // 4 tile wide; max compressed height = 0x24/4 = 9, so fits in 1 tile-height
744 
745         VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
746                                                       //test main surface base alignment is 64KB
747                                                       //For Yf/Y test main surface pitch is 4-tileYF/Y aligned
748         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
749         EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4);
750 
751         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
752         {
753             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
754             EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
755         }
756 
757         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
758 
759         { //separate Aux
760             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
761 
762             GMM_RESOURCE_INFO *AuxResourceInfo;
763             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
764             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
765             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
766             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
767             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
768 
769             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
770         }
771         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
772     }
773 }
774 
775 //Y416(64bpp -how is 10/12/16bit depth given?)
776 //Y410(32bpp), Y216(64bpp), YCRCB_NORMAL(16bpp), YCRCB_SWAPUV(16bpp),
777 //YCRCB_SWAPUVY(16bpp), YCRCB_SWAPY(16bpp)
778 
779 /// @brief ULT for Planar Compressed Resource
TEST_F(CTestGen12Resource,DISABLED_TestPlanarYfCompressedResource)780 TEST_F(CTestGen12Resource, DISABLED_TestPlanarYfCompressedResource)
781 {
782     const uint32_t TileSize[TEST_BPP_MAX][2] = {
783     {64, 64}, {128, 32}, {128, 32}, {256, 16}, {256, 16}}; // TileYf
784 
785     GMM_RESCREATE_PARAMS gmmParams = {};
786     gmmParams.Type                 = RESOURCE_2D;
787     gmmParams.NoGfxMemory          = 1;
788     gmmParams.Flags.Gpu.Texture    = 1;
789     //gmmParams.Flags.Gpu.MMC = 1;
790     gmmParams.Flags.Gpu.CCS              = 1;
791     gmmParams.Flags.Info.MediaCompressed = 1;
792     gmmParams.BaseWidth64                = 0x100;
793     gmmParams.BaseHeight                 = 0x50;
794     gmmParams.Depth                      = 0x1;
795     SetTileFlag(gmmParams, TEST_TILEYF); // TileYF only
796 
797     //UV-Packed formats
798     GMM_RESOURCE_FORMAT Format[4] = {GMM_FORMAT_NV12, GMM_FORMAT_NV21, GMM_FORMAT_P010, GMM_FORMAT_P016};
799     for(auto fmt : Format)
800     {
801         gmmParams.Format = fmt; // 8bpp (NV12, NV21), 16bpp (P016,P010)
802 
803         TEST_BPP Ybpp, UVbpp;
804         //Yf/Ys could be accessed on CPU/app where UV plane bpp is double
805         switch(pGmmULTClientContext->GetPlatformInfo().FormatTable[fmt].Element.BitsPer)
806         {
807             case 8:
808                 Ybpp  = TEST_BPP_8;
809                 UVbpp = TEST_BPP_16;
810                 break;
811             case 16:
812                 Ybpp  = TEST_BPP_16;
813                 UVbpp = TEST_BPP_32;
814                 break;
815             default:
816                 return;
817         }
818         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1;
819 
820         /*Aux is TileY (later Linear), not redescribing, its bytes are allocated using one bpp*/
821         GMM_TILE_MODE TileMode = DEFINE_TILE(YF_2D, Ybpp);
822 
823         GMM_RESOURCE_INFO *ResourceInfo;
824         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
825 
826         //Redescribed Pitch isn't modified unless Y, UV pitch differ
827         //But, original Pitch is padded to have even Tile, hence use Ybpp ExpectedPitch
828         //to verify Pitch, but redescribed size
829         uint32_t ExpectedPitch    = GMM_ULT_ALIGN(gmmParams.BaseWidth64 * (int)pow(2.0, Ybpp), TileSize[Ybpp][0] * 4);
830         uint32_t RedescribedPitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64 / 2 * (int)pow(2.0, UVbpp), TileSize[UVbpp][0] * 4);
831 
832         //ExpectedPitch = GMM_ULT_ALIGN(ExpectedPitch, 2 * TileSize[Ybpp][0]);   //pad to even tile
833         if(ExpectedPitch != RedescribedPitch)
834         {
835             ExpectedPitch = RedescribedPitch;
836         }
837 
838         VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
839         VerifyResourcePitchInTiles<true>(ResourceInfo, ExpectedPitch / TileSize[Ybpp][0]);
840 
841         int YSizeInTiles = (GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[Ybpp][1]) / TileSize[Ybpp][1]) *
842                            RedescribedPitch / TileSize[Ybpp][0];
843         int UVSizeInTiles = (GMM_ULT_ALIGN(gmmParams.BaseHeight / 2, TileSize[UVbpp][1]) / TileSize[UVbpp][1]) *
844                             RedescribedPitch / TileSize[UVbpp][0];
845 
846         VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * (YSizeInTiles + UVSizeInTiles));
847         VerifyResourceHAlign<true>(ResourceInfo, TileSize[UVbpp][0] / pow(2.0, UVbpp)); // For Yf/Ys planar redescription causes UV width, Y height alignment
848         VerifyResourceVAlign<true>(ResourceInfo, TileSize[Ybpp][1]);
849         VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-mipped surface
850 
851         //test main surface base alignment is 64KB
852         //For Yf test main surface pitch is 4-tileYF aligned
853         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
854         EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
855 
856         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
857         {
858             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
859             EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
860         }
861 
862         EXPECT_EQ(GMM_KBYTE(4) * 2, ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS)); // Y and UV Aux are on separate tiles
863 
864         { //separate Aux
865             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
866 
867             GMM_RESOURCE_INFO *AuxResourceInfo;
868             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
869 
870             EXPECT_EQ(GMM_KBYTE(4) * 2, AuxResourceInfo->GetSizeSurface());
871 
872             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
873         }
874         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
875     }
876 }
877 
878 /// @brief ULT for Planar Y Compressed Resource
TEST_F(CTestGen12Resource,TestPlanarYCompressedResource)879 TEST_F(CTestGen12Resource, TestPlanarYCompressedResource)
880 {
881     const uint32_t TileSize[2] = {128, 32};
882     const uint32_t HAlign      = 16;
883     const uint32_t VAlign      = 4;
884 
885     GMM_RESCREATE_PARAMS gmmParams         = {};
886     gmmParams.Type                         = RESOURCE_2D;
887     gmmParams.NoGfxMemory                  = 1;
888     gmmParams.Flags.Gpu.Texture            = 1;
889     gmmParams.Flags.Gpu.RenderTarget       = 1;
890     gmmParams.Flags.Gpu.MMC                = 1;
891     gmmParams.Flags.Gpu.CCS                = 1;
892     gmmParams.Flags.Gpu.IndirectClearColor = 1;
893     gmmParams.Flags.Info.MediaCompressed   = 1;
894     gmmParams.Flags.Info.NotLockable       = 1;
895     gmmParams.Flags.Info.Cacheable         = 1;
896     gmmParams.BaseWidth64                  = 0xB2;
897     gmmParams.BaseHeight                   = 0x92;
898     gmmParams.Depth                        = 0x1;
899     SetTileFlag(gmmParams, TEST_TILEY); // TileYF only
900 
901     GMM_RESOURCE_FORMAT Format[4] = {GMM_FORMAT_NV12, GMM_FORMAT_NV21, GMM_FORMAT_P010, GMM_FORMAT_P016};
902     for(auto fmt : Format)
903     {
904         gmmParams.Format = fmt; // 8bpp (NV12, NV21), 16bpp (P016, P010)
905 
906         TEST_BPP Ybpp, UVbpp;
907         //Yf/Ys could be accessed on CPU/app where UV plane bpp is double
908         switch(pGmmULTClientContext->GetPlatformInfo().FormatTable[fmt].Element.BitsPer)
909         {
910             case 8:
911                 Ybpp  = TEST_BPP_8;
912                 UVbpp = TEST_BPP_16;
913                 break;
914             case 16:
915                 Ybpp  = TEST_BPP_16;
916                 UVbpp = TEST_BPP_32;
917                 break;
918             default:
919                 return;
920         }
921         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1;
922 
923         GMM_TILE_MODE      TileMode = LEGACY_TILE_Y;
924         GMM_RESOURCE_INFO *ResourceInfo;
925         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
926 
927         //Redescribed Pitch isn't modified unless Y, UV pitch differ
928         //But, original Pitch is padded to have even Tile, hence use Ybpp ExpectedPitch
929         //to verify Pitch, but redescribed size
930         uint32_t ExpectedPitch    = GMM_ULT_ALIGN(gmmParams.BaseWidth64 * (int)pow(2.0, Ybpp), TileSize[0] * 4);
931         uint32_t RedescribedPitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64 / 2 * (int)pow(2.0, UVbpp), TileSize[0] * 4);
932 
933         //ExpectedPitch = GMM_ULT_ALIGN(ExpectedPitch, 2 * TileSize[Ybpp][0]);   //pad to even tile
934         if(ExpectedPitch != RedescribedPitch)
935         {
936             ExpectedPitch = RedescribedPitch;
937         }
938 
939         VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
940         VerifyResourcePitchInTiles<true>(ResourceInfo, ExpectedPitch / TileSize[0]);
941 
942         int YSizeInTiles = (GMM_ULT_ALIGN(gmmParams.BaseHeight, 4 * TileSize[1]) / TileSize[1]) * //Default 64K-alignment for Y/UV base (AuxT 64K)
943                            RedescribedPitch / TileSize[0];
944         int UVSizeInTiles = (GMM_ULT_ALIGN(gmmParams.BaseHeight / 2, 4 * TileSize[1]) / TileSize[1]) * //Default 64K-alignment for Y/UV base (AuxT 64K)
945                             RedescribedPitch / TileSize[0];
946 
947         VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * (YSizeInTiles + UVSizeInTiles)); //when main-surf planes are tile-aligned, make it verify-true
948         VerifyResourceHAlign<true>(ResourceInfo, HAlign);
949         VerifyResourceVAlign<true>(ResourceInfo, VAlign);
950         VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-mipped surface
951 
952         //test main surface base alignment is 64KB
953         //For Yf test main surface pitch is 4-tileY aligned
954         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
955         EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4);
956 
957         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
958         {
959             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
960             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_UV_CCS) % PAGE_SIZE);
961             EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
962         }
963         EXPECT_EQ(GMM_KBYTE(4) * 2, ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS)); // Y and UV Aux are on separate tiles
964 
965         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
966     }
967 }
968 
969 /// @brief ULT for Planar Ys Compressed resource
TEST_F(CTestGen12Resource,DISABLED_TestPlanarYsCompressedResource)970 TEST_F(CTestGen12Resource, DISABLED_TestPlanarYsCompressedResource)
971 {
972     const TEST_TILE_TYPE TileTypeSupported = {TEST_TILEYS};
973 
974     const uint32_t TileSize[TEST_BPP_MAX][2] = {
975     {256, 256}, {512, 128}, {512, 128}, {1024, 64}, {1024, 64}}; // TileYS
976 
977     GMM_RESCREATE_PARAMS gmmParams = {};
978     gmmParams.Type                 = RESOURCE_2D;
979     gmmParams.NoGfxMemory          = 1;
980     gmmParams.Flags.Gpu.Texture    = 1;
981     gmmParams.Flags.Gpu.MMC        = 1;
982     //gmmParams.Flags.Gpu.CCS = 1;
983     gmmParams.Flags.Gpu.UnifiedAuxSurface = 1;
984     gmmParams.Flags.Info.MediaCompressed  = 1;
985     gmmParams.BaseWidth64                 = 0x100;
986     gmmParams.BaseHeight                  = 0x50;
987     gmmParams.Depth                       = 0x1;
988     SetTileFlag(gmmParams, TEST_TILEYS); // TileYS only
989 
990     GMM_RESOURCE_FORMAT Format[4] = {GMM_FORMAT_NV12, GMM_FORMAT_NV21, GMM_FORMAT_P010, GMM_FORMAT_P016};
991     for(auto fmt : Format)
992     {
993         gmmParams.Format = fmt; // 8bpp(NV12) , P016 (16bpp), P010 (16bpp), NV21(8bpp)
994 
995         TEST_BPP Ybpp, UVbpp;
996         //Yf/Ys could be accessed on CPU/app where UV plane bpp is double
997         switch(pGmmULTClientContext->GetPlatformInfo().FormatTable[gmmParams.Format].Element.BitsPer)
998         {
999             case 8:
1000                 Ybpp  = TEST_BPP_8;
1001                 UVbpp = TEST_BPP_16;
1002                 break;
1003             case 16:
1004                 Ybpp  = TEST_BPP_16;
1005                 UVbpp = TEST_BPP_32;
1006                 break;
1007             default:
1008                 return;
1009         }
1010 
1011         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1;
1012         GMM_TILE_MODE TileMode                = DEFINE_TILE(YS_2D, Ybpp);
1013 
1014         GMM_RESOURCE_INFO *ResourceInfo;
1015         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1016 
1017         //Redescribed Pitch isn't modified unless Y, UV pitch differ
1018         //But, original Pitch is padded to have even Tile, hence use Ybpp ExpectedPitch
1019         //to verify Pitch, but redescribed pitch to verify size
1020         uint32_t ExpectedPitch    = GMM_ULT_ALIGN(gmmParams.BaseWidth64 * (int)pow(2.0, Ybpp), TileSize[Ybpp][0]);
1021         uint32_t RedescribedPitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64 / 2 * (int)pow(2.0, UVbpp), TileSize[UVbpp][0]);
1022 
1023         if(ExpectedPitch != RedescribedPitch)
1024         {
1025             ExpectedPitch = RedescribedPitch;
1026         }
1027         else
1028         {
1029             //ExpectedPitch = GMM_ULT_ALIGN(ExpectedPitch, 2 * TileSize[Ybpp][0]); //pad to even tile
1030             //ExpectedPitch = GMM_ULT_ALIGN(ExpectedPitch, (2 * TileSize[UVbpp][0]/ (int)pow(2.0, UVbpp))); //pad to even tile
1031         }
1032 
1033         VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
1034         VerifyResourcePitchInTiles<true>(ResourceInfo, ExpectedPitch / TileSize[Ybpp][0]);
1035 
1036         int YSizeInTiles = (GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[Ybpp][1]) / TileSize[Ybpp][1]) *
1037                            RedescribedPitch / TileSize[Ybpp][0];
1038         int UVSizeInTiles = (GMM_ULT_ALIGN(gmmParams.BaseHeight / 2, TileSize[UVbpp][1]) / TileSize[UVbpp][1]) *
1039                             RedescribedPitch / TileSize[UVbpp][0];
1040         VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(64) * (YSizeInTiles + UVSizeInTiles));
1041         VerifyResourceHAlign<true>(ResourceInfo, TileSize[UVbpp][0] / pow(2.0, UVbpp)); // For Yf/Ys planar redescription causes UV width, Y height alignment
1042         VerifyResourceVAlign<true>(ResourceInfo, TileSize[Ybpp][1]);
1043         VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-mipped surface
1044 
1045         //test main surface base alignment is 64KB
1046         //For Yf test main surface pitch is 4-tileYF aligned
1047         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1048         //EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4);   // Check on YF only
1049 
1050         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1051         {
1052             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1053             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_UV_CCS) % PAGE_SIZE);
1054             EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1055         }
1056 
1057         EXPECT_EQ(GMM_KBYTE(4) * 2, ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS)); // Y and UV Aux are on separate tiles
1058 
1059         { //separate Aux
1060             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1061 
1062             GMM_RESOURCE_INFO *AuxResourceInfo;
1063             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1064 
1065             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1066 
1067             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1068         }
1069         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1070     }
1071 }
1072 
1073 /// @brief ULT for 2D arrayed compressed Resource
TEST_F(CTestGen12Resource,TestArrayedCompressedResource)1074 TEST_F(CTestGen12Resource, TestArrayedCompressedResource)
1075 {
1076     //printf("%s\n", __FUNCTION__);
1077     //Test for 3D array
1078 }
1079 
1080 /// @brief ULT for mip-mapped compressed Resource
TEST_F(CTestGen12Resource,TestMipMapCompressedResource)1081 TEST_F(CTestGen12Resource, TestMipMapCompressedResource)
1082 {
1083     //printf("%s\n", __FUNCTION__);
1084 }
1085 
1086 /// @brief ULT for cube Compressed Resource
TEST_F(CTestGen12Resource,TestCubeCompressedResource)1087 TEST_F(CTestGen12Resource, TestCubeCompressedResource)
1088 {
1089     //Tests 2D array
1090     const uint32_t HAlign[5][TEST_BPP_MAX] = {{0}, {0}, {0}, {256, 256, 128, 128, 64}, {64, 64, 32, 32, 16}};
1091     const uint32_t VAlign[5][TEST_BPP_MAX] = {{0}, {0}, {0}, {256, 128, 128, 64, 64}, {64, 32, 32, 16, 16}};
1092 
1093     const TEST_TILE_TYPE TileTypeSupported[2] = {TEST_TILEYS, TEST_TILEYF};
1094 
1095     const uint32_t TileSize[5][TEST_BPP_MAX][2] = {
1096     {0},
1097     {0},
1098     {0},
1099     {{256, 256}, {512, 128}, {512, 128}, {1024, 64}, {1024, 64}}, // TileYS
1100     {{64, 64}, {128, 32}, {128, 32}, {256, 16}, {256, 16}}};      //TileYf
1101 
1102     GMM_RESCREATE_PARAMS gmmParams        = {};
1103     gmmParams.Type                        = RESOURCE_CUBE;
1104     gmmParams.NoGfxMemory                 = 1;
1105     gmmParams.Flags.Gpu.Texture           = 1;
1106     gmmParams.Flags.Info.RenderCompressed = 1;
1107 
1108     // Allocate 1x1 surface so that it occupies 1 Tile in X dimension
1109     for(auto Tiling : TileTypeSupported)
1110     {
1111         gmmParams.Flags.Info.TiledY  = 1;
1112         gmmParams.Flags.Info.TiledYf = (Tiling == TEST_TILEYF);
1113         gmmParams.Flags.Info.TiledYs = (Tiling == TEST_TILEYS);
1114         for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1115         {
1116             gmmParams.Flags.Gpu.UnifiedAuxSurface = 1;
1117             gmmParams.Flags.Gpu.CCS               = 1;
1118 
1119             TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
1120             GMM_TILE_MODE TileMode = (Tiling == TEST_TILEYF) ? DEFINE_TILE(YF_2D, bpp) : DEFINE_TILE(YS_2D, bpp);
1121 
1122             gmmParams.Format      = SetResourceFormat(bpp);
1123             gmmParams.BaseWidth64 = 0x1;
1124             gmmParams.BaseHeight  = 0x1;
1125             gmmParams.Depth       = 0x1;
1126 
1127             GMM_RESOURCE_INFO *ResourceInfo;
1128             ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1129 
1130             VerifyResourceHAlign<true>(ResourceInfo, HAlign[Tiling][i]);
1131             VerifyResourceVAlign<true>(ResourceInfo, VAlign[Tiling][i]);
1132 
1133             uint32_t ExpectedPitch = 4 * TileSize[TEST_TILEYF][i][0];
1134             VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);                          // As wide as 4 tile-YF
1135             VerifyResourcePitchInTiles<true>(ResourceInfo, (Tiling == TEST_TILEYF) ? 4 : 1); // 1 tile wide
1136 
1137             uint32_t ExpectedQPitch = VAlign[Tiling][i];
1138             VerifyResourceQPitch<true>(ResourceInfo, ExpectedQPitch); // Each face should be VAlign rows apart within a tile
1139 
1140             VerifyResourceSize<true>(ResourceInfo, // PitchInBytes * Rows where Rows = __GMM_MAX_CUBE_FACE x QPitch, then aligned to tile boundary
1141                                      ExpectedPitch *
1142                                      __GMM_MAX_CUBE_FACE * ExpectedQPitch);
1143 
1144             //test main surface base alignment is 64KB
1145             //For Yf test main surface pitch is 4-tileYF aligned
1146             EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1147             EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % ((Tiling == TEST_TILEYF) ? 4 : 1));
1148 
1149             if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1150             {
1151                 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1152                 EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1153             }
1154 
1155             EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1156 
1157             { //separate Aux
1158                 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1159 
1160                 GMM_RESOURCE_INFO *AuxResourceInfo;
1161                 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1162                 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
1163                 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
1164                 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
1165                 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1166                 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1167             }
1168 
1169             for(uint32_t CubeFaceIndex = 0; CubeFaceIndex < __GMM_MAX_CUBE_FACE; CubeFaceIndex++)
1170             {
1171                 GMM_REQ_OFFSET_INFO OffsetInfo = {};
1172                 OffsetInfo.ReqRender           = 1;
1173                 OffsetInfo.CubeFace            = static_cast<GMM_CUBE_FACE_ENUM>(CubeFaceIndex);
1174                 ResourceInfo->GetOffset(OffsetInfo);
1175 
1176                 EXPECT_EQ((CubeFaceIndex * ExpectedQPitch) * ExpectedPitch,
1177                           OffsetInfo.Render.Offset64);   // Render offset is tile's base address on which cube face begins.
1178                 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // X Offset should be 0 as cube face starts on tile boundary
1179                 EXPECT_EQ(0, OffsetInfo.Render.YOffset); // Y Offset should be 0 as cube face starts on tile boundary
1180                 EXPECT_EQ(0, OffsetInfo.Render.ZOffset); // Z offset N/A should be 0
1181             }
1182             pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1183         }
1184 
1185         // Allocate 2 tiles in X dimension.
1186         // Width and Height must be equal
1187         for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1188         {
1189             gmmParams.Flags.Gpu.UnifiedAuxSurface = 1;
1190             gmmParams.Flags.Gpu.CCS               = 1;
1191             TEST_BPP      bpp                     = static_cast<TEST_BPP>(i);
1192             GMM_TILE_MODE TileMode                = (Tiling == TEST_TILEYF) ? DEFINE_TILE(YF_2D, bpp) : DEFINE_TILE(YS_2D, bpp);
1193 
1194             gmmParams.Format      = SetResourceFormat(bpp);
1195             gmmParams.BaseWidth64 = (TileSize[Tiling][i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
1196             gmmParams.BaseHeight  = gmmParams.BaseWidth64;                           // Heigth must be equal to width.
1197             gmmParams.Depth       = 0x1;
1198 
1199             GMM_RESOURCE_INFO *ResourceInfo;
1200             ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1201 
1202             VerifyResourceHAlign<true>(ResourceInfo, HAlign[Tiling][i]);
1203             VerifyResourceVAlign<true>(ResourceInfo, VAlign[Tiling][i]);
1204 
1205             uint32_t ExpectedPitch = TileSize[Tiling][i][0] * 2 * ((Tiling == TEST_TILEYF) ? 2 : 1); // As wide as 2 tile, padded to 4 tile-pitch
1206             VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
1207             VerifyResourcePitchInTiles<true>(ResourceInfo, 2 * ((Tiling == TEST_TILEYF) ? 2 : 1)); // 2 tile wide
1208 
1209             uint32_t ExpectedQPitch = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign[Tiling][i]);
1210             VerifyResourceQPitch<true>(ResourceInfo, ExpectedQPitch); // Each face should be Valigned-BaseHeight rows apart
1211 
1212             VerifyResourceSize<true>(ResourceInfo, // PitchInBytes * Rows where Rows = __GMM_MAX_CUBE_FACE x QPitch, then aligned to tile boundary
1213                                      ExpectedPitch *
1214                                      __GMM_MAX_CUBE_FACE * ExpectedQPitch);
1215 
1216             //test main surface base alignment is 64KB
1217             //For Yf test main surface pitch is 4-tileYF aligned
1218             EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1219             EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % ((Tiling == TEST_TILEYF) ? 4 : 1)); // Check on YF only
1220 
1221             if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1222             {
1223                 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1224                 EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1225             }
1226 
1227             { //separate Aux
1228                 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1229 
1230                 GMM_RESOURCE_INFO *AuxResourceInfo;
1231                 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1232                 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
1233                 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
1234                 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
1235                 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1236                 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1237             }
1238 
1239             for(uint32_t CubeFaceIndex = 0; CubeFaceIndex < __GMM_MAX_CUBE_FACE; CubeFaceIndex++)
1240             {
1241                 GMM_REQ_OFFSET_INFO OffsetInfo = {};
1242                 OffsetInfo.ReqRender           = 1;
1243                 OffsetInfo.CubeFace            = static_cast<GMM_CUBE_FACE_ENUM>(CubeFaceIndex);
1244                 ResourceInfo->GetOffset(OffsetInfo);
1245                 EXPECT_EQ((CubeFaceIndex * ExpectedQPitch) * ExpectedPitch,
1246                           OffsetInfo.Render.Offset64);   // Render offset is tile's base address on which cube face begins.
1247                 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // X Offset should be 0 as cube face starts on tile boundary
1248                 EXPECT_EQ(0, OffsetInfo.Render.YOffset); // Y Offset should be 0 as cube face starts on tile boundary
1249                 EXPECT_EQ(0, OffsetInfo.Render.ZOffset); // Z offset N/A should be 0
1250             }
1251             pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1252         }
1253     }
1254 }
1255 
1256 /// @brief ULT for 3D TileYs Compressed Resource
TEST_F(CTestGen12Resource,Test3DTileYsCompressedResource)1257 TEST_F(CTestGen12Resource, Test3DTileYsCompressedResource)
1258 {
1259     if(!const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1260     {
1261         return;
1262     }
1263     // Horizontal/Vertical pixel alignment
1264     const uint32_t HAlign[TEST_BPP_MAX] = {64, 32, 32, 32, 16};
1265     const uint32_t VAlign[TEST_BPP_MAX] = {32, 32, 32, 16, 16};
1266 
1267     const uint32_t TileSize[TEST_BPP_MAX][3] = {{64, 32, 32},
1268                                                 {64, 32, 32},
1269                                                 {128, 32, 16},
1270                                                 {256, 16, 16},
1271                                                 {256, 16, 16}};
1272 
1273     GMM_RESCREATE_PARAMS gmmParams        = {};
1274     gmmParams.Type                        = RESOURCE_3D;
1275     gmmParams.NoGfxMemory                 = 1;
1276     gmmParams.Flags.Info.TiledY           = 1;
1277     gmmParams.Flags.Info.TiledYs          = 1;
1278     gmmParams.Flags.Gpu.Texture           = 1;
1279     gmmParams.Flags.Info.RenderCompressed = 1; // Turn on .MC or .RC flag - mandatory to tell compression-type, for Yf its also used to pad surf
1280                                                // to 4x1 tile (reqd by HW for perf reasons)
1281 
1282     // Allocate 1x1x1 surface
1283     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1284     {
1285         // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
1286         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
1287         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
1288 
1289         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
1290         GMM_TILE_MODE TileMode = DEFINE_TILE(YS_3D, bpp);
1291 
1292         gmmParams.Format      = SetResourceFormat(bpp);
1293         gmmParams.BaseWidth64 = 0x1;
1294         gmmParams.BaseHeight  = 0x1;
1295         gmmParams.Depth       = 0x1;
1296 
1297         GMM_RESOURCE_INFO *ResourceInfo;
1298         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1299 
1300         VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
1301         VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
1302         VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0]); // As wide as 1 tile
1303         VerifyResourcePitchInTiles<true>(ResourceInfo, 1);       // 1 tile wide
1304         VerifyResourceSize<false>(ResourceInfo, GMM_KBYTE(64));  // 1 tile big
1305 
1306         VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
1307 
1308         //test main surface base alignment is 64KB
1309         //For Yf test main surface pitch is 4-tileYF aligned
1310         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1311 
1312         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1313         {
1314             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1315             EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1316         }
1317         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1318 
1319         { //separate Aux
1320             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1321 
1322             GMM_RESOURCE_INFO *AuxResourceInfo;
1323             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1324             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
1325             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
1326             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
1327             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1328 
1329             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1330         }
1331         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1332     }
1333 
1334     // Allocate 2 tiles in X dimension
1335     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1336     {
1337         // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
1338         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
1339         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
1340 
1341         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
1342         GMM_TILE_MODE TileMode = DEFINE_TILE(YS_3D, bpp);
1343 
1344         gmmParams.Format      = SetResourceFormat(bpp);
1345         gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
1346         gmmParams.BaseHeight  = 0x1;
1347         gmmParams.Depth       = 0x1;
1348 
1349         GMM_RESOURCE_INFO *ResourceInfo;
1350         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1351 
1352         VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
1353         VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
1354         VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0] * 2); // As wide as 2 tile
1355         VerifyResourcePitchInTiles<true>(ResourceInfo, 2);           // 2 tile wide
1356         VerifyResourceSize<false>(ResourceInfo, GMM_KBYTE(64) * 2);  // 2 tile big
1357 
1358         VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
1359                                                       //test main surface base alignment is 64KB
1360                                                       //For Yf test main surface pitch is 4-tileYF aligned
1361         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1362 
1363         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1364         {
1365             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1366             EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1367         }
1368         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1369 
1370         { //separate Aux
1371             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1372 
1373             GMM_RESOURCE_INFO *AuxResourceInfo;
1374             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1375             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
1376             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
1377             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
1378             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1379 
1380             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1381         }
1382         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1383     }
1384 
1385     // Allocate 2 tiles in X/Y dimension
1386     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1387     {
1388         // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
1389         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
1390         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
1391 
1392         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
1393         GMM_TILE_MODE TileMode = DEFINE_TILE(YS_3D, bpp);
1394         gmmParams.Format       = SetResourceFormat(bpp);
1395         gmmParams.BaseWidth64  = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
1396         gmmParams.BaseHeight   = TileSize[i][1] + 1;                      // 1 row larger than 1 tile height
1397         gmmParams.Depth        = 0x1;
1398 
1399         GMM_RESOURCE_INFO *ResourceInfo;
1400         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1401 
1402         VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
1403         VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
1404         VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0] * 2); // As wide as 2 tile
1405         VerifyResourcePitchInTiles<true>(ResourceInfo, 2);           // 2 tile wide
1406         VerifyResourceSize<false>(ResourceInfo, GMM_KBYTE(64) * 4);  // 4 tile big
1407 
1408         VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
1409 
1410         //test main surface base alignment is 64KB
1411         //For Yf test main surface pitch is 4-tileYF aligned
1412         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1413 
1414         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1415         {
1416             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1417             EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1418         }
1419         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1420 
1421         { //separate Aux
1422             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1423 
1424             GMM_RESOURCE_INFO *AuxResourceInfo;
1425             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1426             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
1427             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
1428             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
1429             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1430             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1431         }
1432         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1433     }
1434 
1435     // Allocate 2 tiles in X/Y/Z dimension
1436     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1437     {
1438         // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
1439         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
1440         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
1441 
1442         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
1443         GMM_TILE_MODE TileMode = DEFINE_TILE(YS_3D, bpp);
1444 
1445         gmmParams.Format      = SetResourceFormat(bpp);
1446         gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
1447         gmmParams.BaseHeight  = TileSize[i][1] + 1;                      // 1 row larger than 1 tile height
1448         gmmParams.Depth       = TileSize[i][2] + 1;                      // 1 plane larger than 1 tile depth
1449 
1450         GMM_RESOURCE_INFO *ResourceInfo;
1451         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1452 
1453         VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
1454         VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
1455         VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0] * 2); // As wide as 2 tile
1456         VerifyResourcePitchInTiles<true>(ResourceInfo, 2);           // 2 tile wide
1457         VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(64) * 8);   // 8 tile big
1458 
1459         VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
1460                                                       //test main surface base alignment is 64KB
1461                                                       //For Yf test main surface pitch is 4-tileYF aligned
1462         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1463 
1464         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1465         {
1466             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1467             EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1468         }
1469         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1470 
1471         { //separate Aux
1472             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1473 
1474             GMM_RESOURCE_INFO *AuxResourceInfo;
1475             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1476             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
1477             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
1478             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
1479             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1480             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1481         }
1482         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1483     }
1484 }
1485 
1486 /// @brief ULT for 3D TileYf Compressed Resource
TEST_F(CTestGen12Resource,Test3DTileYfCompressedResource)1487 TEST_F(CTestGen12Resource, Test3DTileYfCompressedResource)
1488 {
1489     if(!const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1490     {
1491         return;
1492     }
1493     // Horizontal/Verticle pixel alignment
1494     const uint32_t HAlign[TEST_BPP_MAX]      = {16, 8, 8, 8, 4};
1495     const uint32_t VAlign[TEST_BPP_MAX]      = {16, 16, 16, 8, 8};
1496     const uint32_t TileSize[TEST_BPP_MAX][3] = {{16, 16, 16},
1497                                                 {16, 16, 16},
1498                                                 {32, 16, 8},
1499                                                 {64, 8, 8},
1500                                                 {64, 8, 8}};
1501 
1502     GMM_RESCREATE_PARAMS gmmParams        = {};
1503     gmmParams.Type                        = RESOURCE_3D;
1504     gmmParams.NoGfxMemory                 = 1;
1505     gmmParams.Flags.Info.TiledY           = 1;
1506     gmmParams.Flags.Info.TiledYf          = 1;
1507     gmmParams.Flags.Gpu.Texture           = 1;
1508     gmmParams.Flags.Info.RenderCompressed = 1; // Turn on .MC or .RC flag - mandatory to tell compression-type, for Yf its also used to pad surf
1509                                                // to 4x1 tile (reqd by HW for perf reasons)
1510 
1511     // Allocate 1x1x1 surface
1512     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1513     {
1514         // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
1515         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
1516         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
1517                                                    //gmmParams.Flags.Gpu.MMC = 0;              //Turn on to check unifiedaux creation
1518 
1519         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
1520         GMM_TILE_MODE TileMode = DEFINE_TILE(YF_3D, bpp);
1521 
1522         gmmParams.Format = SetResourceFormat(bpp);
1523         //gmmParams.BaseWidth64 = 0x30;
1524         //gmmParams.BaseHeight = 0x30;
1525         //gmmParams.Depth = 0x20;
1526         gmmParams.BaseWidth64         = 1;
1527         gmmParams.BaseHeight          = 1;
1528         gmmParams.Depth               = 1;
1529         const uint32_t PitchAlignment = 32;
1530 
1531         GMM_RESOURCE_INFO *ResourceInfo;
1532         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1533 
1534         VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
1535         VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
1536         VerifyResourcePitch<true>(ResourceInfo, GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[i][0] * 4));
1537         VerifyResourcePitchInTiles<true>(ResourceInfo, GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[i][0] * 4) / TileSize[i][0]);
1538         VerifyResourceSize<true>(ResourceInfo, (GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[i][0] * 4) / TileSize[i][0]) *
1539                                                (GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[i][1]) / TileSize[i][1]) *
1540                                                (GMM_ULT_ALIGN(gmmParams.Depth, TileSize[i][2]) / TileSize[i][2]) * GMM_KBYTE(4));
1541         VerifyResourceQPitch<true>(ResourceInfo, (GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[i][1])));
1542 
1543         //test main surface base alignment is 64KB
1544         //For Yf test main surface pitch is 4-tileYF aligned
1545         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1546         EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
1547 
1548         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1549         {
1550             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1551             EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1552         }
1553         ASSERT_LE(GMM_ULT_ALIGN(ResourceInfo->GetSizeMainSurface() / (GMM_KBYTE(16) / GMM_BYTES(64)), GMM_KBYTE(4)),
1554                   ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1555 
1556         { //separate Aux
1557             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1558 
1559             GMM_RESOURCE_INFO *AuxResourceInfo;
1560             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1561             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
1562             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
1563             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
1564             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1565             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1566         }
1567         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1568     }
1569 
1570     // Allocate 2 tiles in X dimension
1571     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1572     {
1573         // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
1574         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
1575         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
1576 
1577         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
1578         GMM_TILE_MODE TileMode = DEFINE_TILE(YF_3D, bpp);
1579 
1580         gmmParams.Format              = SetResourceFormat(bpp);
1581         gmmParams.BaseWidth64         = (TileSize[i][0] / GetBppValue(bpp)) + 1;
1582         gmmParams.BaseHeight          = 0x1;
1583         gmmParams.Depth               = 0x1;
1584         const uint32_t PitchAlignment = 32;
1585 
1586 
1587         GMM_RESOURCE_INFO *ResourceInfo;
1588         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1589 
1590         VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
1591         VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
1592         VerifyResourcePitch<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 4, PitchAlignment));
1593         VerifyResourcePitchInTiles<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 4, PitchAlignment) / TileSize[i][0]);
1594         VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 4, PitchAlignment) / TileSize[i][0] * GMM_KBYTE(4));
1595         VerifyResourceQPitch<true>(ResourceInfo, TileSize[i][1]);
1596         //test main surface base alignment is 64KB
1597         //For Yf test main surface pitch is 4-tileYF aligned
1598         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1599         EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
1600 
1601         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1602         {
1603             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1604             EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1605         }
1606         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1607         ASSERT_LE(GMM_ULT_ALIGN(ResourceInfo->GetSizeMainSurface() / (GMM_KBYTE(16) / GMM_BYTES(64)), GMM_KBYTE(4)),
1608                   ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1609 
1610         { //separate Aux
1611             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1612 
1613             GMM_RESOURCE_INFO *AuxResourceInfo;
1614             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1615             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
1616             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
1617             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
1618             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1619             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1620         }
1621         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1622     }
1623 
1624     // Allocate 2 tiles in X/Y dimension
1625     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1626     {
1627         // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
1628         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
1629         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
1630 
1631         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
1632         GMM_TILE_MODE TileMode = DEFINE_TILE(YF_3D, bpp);
1633 
1634         gmmParams.Format              = SetResourceFormat(bpp);
1635         gmmParams.BaseWidth64         = (TileSize[i][0] / GetBppValue(bpp)) + 1;
1636         gmmParams.BaseHeight          = TileSize[i][1] + 1;
1637         gmmParams.Depth               = 0x1;
1638         const uint32_t PitchAlignment = 32;
1639 
1640         GMM_RESOURCE_INFO *ResourceInfo;
1641         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1642 
1643         VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
1644         VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
1645         VerifyResourcePitch<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 4, PitchAlignment));
1646         VerifyResourcePitchInTiles<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 4, PitchAlignment) / TileSize[i][0]);
1647         VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 4, PitchAlignment) / TileSize[i][0] * 2 * GMM_KBYTE(4));
1648         VerifyResourceQPitch<true>(ResourceInfo, TileSize[i][1] * 2);
1649         //test main surface base alignment is 64KB
1650         //For Yf test main surface pitch is 4-tileYF aligned
1651         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1652         EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
1653 
1654         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1655         {
1656             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1657             EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1658         }
1659         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1660         ASSERT_LE(GMM_ULT_ALIGN(ResourceInfo->GetSizeMainSurface() / (GMM_KBYTE(16) / GMM_BYTES(64)), GMM_KBYTE(4)),
1661                   ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1662 
1663         { //separate Aux
1664             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1665 
1666             GMM_RESOURCE_INFO *AuxResourceInfo;
1667             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1668             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
1669             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
1670             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
1671             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1672             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1673         }
1674         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1675     }
1676 
1677     // Allocate 2 tiles in X/Y/Z dimension
1678     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1679     {
1680         // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
1681         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
1682         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
1683 
1684         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
1685         GMM_TILE_MODE TileMode = DEFINE_TILE(YF_3D, bpp);
1686 
1687         gmmParams.Format              = SetResourceFormat(bpp);
1688         gmmParams.BaseWidth64         = (TileSize[i][0] / GetBppValue(bpp)) + 1;
1689         gmmParams.BaseHeight          = TileSize[i][1] + 1;
1690         gmmParams.Depth               = TileSize[i][2] + 1;
1691         const uint32_t PitchAlignment = 32;
1692 
1693         GMM_RESOURCE_INFO *ResourceInfo;
1694         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1695 
1696         VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
1697         VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
1698         VerifyResourcePitch<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 4, PitchAlignment));
1699         VerifyResourcePitchInTiles<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 4, PitchAlignment) / TileSize[i][0]);
1700         VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 4, PitchAlignment) / TileSize[i][0] * 2 * 2 * GMM_KBYTE(4));
1701         VerifyResourceQPitch<true>(ResourceInfo, TileSize[i][1] * 2);
1702         //test main surface base alignment is 64KB
1703         //For Yf test main surface pitch is 4-tileYF aligned
1704         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1705         EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
1706 
1707         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1708         {
1709             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1710             EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1711         }
1712         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1713         ASSERT_LE(GMM_ULT_ALIGN(ResourceInfo->GetSizeMainSurface() / (GMM_KBYTE(16) / GMM_BYTES(64)), GMM_KBYTE(4)),
1714                   ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1715 
1716         { //separate Aux
1717             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1718 
1719             GMM_RESOURCE_INFO *AuxResourceInfo;
1720             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1721             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
1722             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
1723             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
1724             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1725             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1726         }
1727         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1728     }
1729 }
1730 
1731 /// @brief ULT for 3D TileY Compressed Resource
TEST_F(CTestGen12Resource,Test3DTileYCompressedResource)1732 TEST_F(CTestGen12Resource, Test3DTileYCompressedResource)
1733 {
1734     if(!const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1735     {
1736         return;
1737     }
1738     // Horizontal/Verticle pixel alignment
1739     const uint32_t HAlign      = {16};
1740     const uint32_t VAlign      = {4};
1741     const uint32_t TileSize[3] = {128, 32, 1};
1742 
1743     GMM_RESCREATE_PARAMS gmmParams        = {};
1744     gmmParams.Type                        = RESOURCE_3D;
1745     gmmParams.NoGfxMemory                 = 1;
1746     gmmParams.Flags.Info.TiledY           = 1;
1747     gmmParams.Flags.Gpu.Texture           = 1;
1748     gmmParams.Flags.Info.RenderCompressed = 1; // Turn on .MC or .RC flag - mandatory to tell compression-type, for Yf its also used to pad surf
1749                                                // to 4x1 tile (reqd by HW for perf reasons)
1750 
1751     // Allocate 1x1x1 surface
1752     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1753     {
1754         // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
1755         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
1756         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
1757 
1758         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
1759         GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
1760 
1761         gmmParams.Format = SetResourceFormat(bpp);
1762         //gmmParams.BaseWidth64 = 0x30;
1763         //gmmParams.BaseHeight = 0x30;
1764         //gmmParams.Depth = 0x20;
1765         gmmParams.BaseWidth64         = 1;
1766         gmmParams.BaseHeight          = 1;
1767         gmmParams.Depth               = 1;
1768         const uint32_t PitchAlignment = 32;
1769 
1770         GMM_RESOURCE_INFO *ResourceInfo;
1771         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1772 
1773         VerifyResourceHAlign<true>(ResourceInfo, HAlign);
1774         VerifyResourceVAlign<true>(ResourceInfo, VAlign);
1775         VerifyResourcePitch<true>(ResourceInfo, GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[0] * 4));
1776         VerifyResourcePitchInTiles<true>(ResourceInfo, GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[0] * 4) / TileSize[0]);
1777         VerifyResourceSize<true>(ResourceInfo, (GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[0] * 4) / TileSize[0]) *
1778                                                (GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[1]) / TileSize[1]) *
1779                                                (GMM_ULT_ALIGN(gmmParams.Depth, TileSize[2]) / TileSize[2]) * GMM_KBYTE(4));
1780         VerifyResourceQPitch<true>(ResourceInfo, (GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[1])));
1781 
1782         //test main surface base alignment is 64KB
1783         //For Yf test main surface pitch is 4-tileYF aligned
1784         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1785         EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
1786 
1787         EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1788         ASSERT_LE(GMM_ULT_ALIGN(ResourceInfo->GetSizeMainSurface() / (GMM_KBYTE(16) / GMM_BYTES(64)), GMM_KBYTE(4)),
1789                   ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1790 
1791         { //separate Aux
1792             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1793 
1794             GMM_RESOURCE_INFO *AuxResourceInfo;
1795             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1796             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
1797             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
1798             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
1799             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1800             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1801         }
1802         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1803     }
1804 
1805     // Allocate 2 tiles in X dimension
1806     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1807     {
1808         // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
1809         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
1810         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
1811 
1812         TEST_BPP      bpp             = static_cast<TEST_BPP>(i);
1813         GMM_TILE_MODE TileMode        = LEGACY_TILE_Y;
1814         gmmParams.Format              = SetResourceFormat(bpp);
1815         gmmParams.BaseWidth64         = (TileSize[0] / GetBppValue(bpp)) + 1;
1816         gmmParams.BaseHeight          = 0x1;
1817         gmmParams.Depth               = 0x1;
1818         const uint32_t PitchAlignment = 32;
1819 
1820 
1821         GMM_RESOURCE_INFO *ResourceInfo;
1822         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1823 
1824         VerifyResourceHAlign<true>(ResourceInfo, HAlign);
1825         VerifyResourceVAlign<true>(ResourceInfo, VAlign);
1826         VerifyResourcePitch<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[0] * 4, PitchAlignment));
1827         VerifyResourcePitchInTiles<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[0] * 4, PitchAlignment) / TileSize[0]);
1828         VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[0] * 4, PitchAlignment) / TileSize[0] * GMM_KBYTE(4));
1829         VerifyResourceQPitch<true>(ResourceInfo, TileSize[1]);
1830         //test main surface base alignment is 64KB
1831         //For Yf test main surface pitch is 4-tileYF aligned
1832         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1833         EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
1834 
1835         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1836         ASSERT_LE(GMM_ULT_ALIGN(ResourceInfo->GetSizeMainSurface() / (GMM_KBYTE(16) / GMM_BYTES(64)), GMM_KBYTE(4)),
1837                   ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1838 
1839         { //separate Aux
1840             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1841 
1842             GMM_RESOURCE_INFO *AuxResourceInfo;
1843             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1844             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
1845             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
1846             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
1847             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1848             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1849         }
1850         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1851     }
1852 
1853     // Allocate 2 tiles in X/Y dimension
1854     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1855     {
1856         // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
1857         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
1858         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
1859 
1860         TEST_BPP      bpp             = static_cast<TEST_BPP>(i);
1861         GMM_TILE_MODE TileMode        = LEGACY_TILE_Y;
1862         gmmParams.Format              = SetResourceFormat(bpp);
1863         gmmParams.BaseWidth64         = (TileSize[0] / GetBppValue(bpp)) + 1;
1864         gmmParams.BaseHeight          = TileSize[1] + 1;
1865         gmmParams.Depth               = 0x1;
1866         const uint32_t PitchAlignment = 32;
1867 
1868         GMM_RESOURCE_INFO *ResourceInfo;
1869         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1870 
1871         VerifyResourceHAlign<true>(ResourceInfo, HAlign);
1872         VerifyResourceVAlign<true>(ResourceInfo, VAlign);
1873         VerifyResourcePitch<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[0] * 4, PitchAlignment));
1874         VerifyResourcePitchInTiles<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[0] * 4, PitchAlignment) / TileSize[0]);
1875         VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[0] * 4, PitchAlignment) / TileSize[0] * 2 * GMM_KBYTE(4));
1876         VerifyResourceQPitch<true>(ResourceInfo, TileSize[1] * 2);
1877         //test main surface base alignment is 64KB
1878         //For Yf test main surface pitch is 4-tileYF aligned
1879         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1880         EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
1881 
1882         EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1883         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1884         ASSERT_LE(GMM_ULT_ALIGN(ResourceInfo->GetSizeMainSurface() / (GMM_KBYTE(16) / GMM_BYTES(64)), GMM_KBYTE(4)),
1885                   ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1886 
1887         { //separate Aux
1888             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1889 
1890             GMM_RESOURCE_INFO *AuxResourceInfo;
1891             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1892             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
1893             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
1894             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
1895             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1896             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1897         }
1898         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1899     }
1900 
1901     // Allocate 2 tiles in X/Y/Z dimension
1902     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1903     {
1904         // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
1905         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
1906         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
1907 
1908         TEST_BPP      bpp             = static_cast<TEST_BPP>(i);
1909         GMM_TILE_MODE TileMode        = LEGACY_TILE_Y;
1910         gmmParams.Format              = SetResourceFormat(bpp);
1911         gmmParams.BaseWidth64         = (TileSize[0] / GetBppValue(bpp)) + 1;
1912         gmmParams.BaseHeight          = TileSize[1] + 1;
1913         gmmParams.Depth               = TileSize[2] + 1;
1914         const uint32_t PitchAlignment = 32;
1915 
1916         GMM_RESOURCE_INFO *ResourceInfo;
1917         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1918 
1919         VerifyResourceHAlign<true>(ResourceInfo, HAlign);
1920         VerifyResourceVAlign<true>(ResourceInfo, VAlign);
1921         VerifyResourcePitch<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[0] * 4, PitchAlignment));
1922         VerifyResourcePitchInTiles<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[0] * 4, PitchAlignment) / TileSize[0]);
1923         VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[0] * 4, PitchAlignment) / TileSize[0] * 2 * 2 * GMM_KBYTE(4));
1924         VerifyResourceQPitch<true>(ResourceInfo, TileSize[1] * 2);
1925         //test main surface base alignment is 64KB
1926         //For Yf test main surface pitch is 4-tileYF aligned
1927         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1928         EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
1929 
1930         EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1931         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1932         ASSERT_LE(GMM_ULT_ALIGN(ResourceInfo->GetSizeMainSurface() / (GMM_KBYTE(16) / GMM_BYTES(64)), GMM_KBYTE(4)),
1933                   ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1934 
1935         { //separate Aux
1936             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1937 
1938             GMM_RESOURCE_INFO *AuxResourceInfo;
1939             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1940             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
1941             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
1942             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
1943             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1944             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1945         }
1946         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1947     }
1948 }
1949 
1950 /// @brief ULT for 2D Yf mipped compressed resource
TEST_F(CTestGen12Resource,Test2DTileYfMippedCompressedResource)1951 TEST_F(CTestGen12Resource, Test2DTileYfMippedCompressedResource)
1952 {
1953     if(!const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1954     {
1955         return;
1956     }
1957     const uint32_t HAlign[TEST_BPP_MAX] = {64, 64, 32, 32, 16};
1958     const uint32_t VAlign[TEST_BPP_MAX] = {64, 32, 32, 16, 16};
1959 
1960     const uint32_t TileSize[TEST_BPP_MAX][2] = {{64, 64},
1961                                                 {128, 32},
1962                                                 {128, 32},
1963                                                 {256, 16},
1964                                                 {256, 16}};
1965 
1966     const uint32_t MtsWidth[TEST_BPP_MAX]  = {32, 32, 16, 16, 8};
1967     const uint32_t MtsHeight[TEST_BPP_MAX] = {64, 32, 32, 16, 16};
1968 
1969     GMM_RESCREATE_PARAMS gmmParams        = {};
1970     gmmParams.Type                        = RESOURCE_2D;
1971     gmmParams.NoGfxMemory                 = 1;
1972     gmmParams.Flags.Info.TiledY           = 1;
1973     gmmParams.Flags.Info.TiledYf          = 1;
1974     gmmParams.Flags.Gpu.Texture           = 1;
1975     gmmParams.Flags.Info.RenderCompressed = 1; // Turn on .MC or .RC flag - mandatory to tell compression-type, for Yf its also used to pad surf
1976                                                // to 4x1 tile (reqd by HW for perf reasons)
1977     gmmParams.MaxLod    = 4;
1978     gmmParams.ArraySize = 4;
1979 
1980     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1981     {
1982         uint32_t AlignedWidth    = 0;
1983         uint32_t AlignedHeight   = 0;
1984         uint32_t ExpectedPitch   = 0;
1985         uint32_t MipTailStartLod = 0;
1986         // Valigned Mip Heights
1987         uint32_t Mip0Height    = 0;
1988         uint32_t Mip1Height    = 0;
1989         uint32_t Mip2Height    = 0;
1990         uint32_t Mip3Height    = 0;
1991         uint32_t Mip2Higher    = 0; // Sum of aligned heights of Mip2 and above
1992         uint32_t MipTailHeight = 0;
1993         // Haligned Mip Widths
1994         uint32_t Mip0Width = 0;
1995         uint32_t Mip1Width = 0;
1996         uint32_t Mip2Width = 0;
1997 
1998         TEST_BPP bpp          = static_cast<TEST_BPP>(i);
1999         gmmParams.Format      = SetResourceFormat(bpp);
2000         gmmParams.BaseWidth64 = 0x38;
2001         gmmParams.BaseHeight  = 0x38;
2002 
2003         // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
2004         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
2005         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
2006 
2007         GMM_RESOURCE_INFO *ResourceInfo;
2008         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2009 
2010         VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
2011         VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
2012 
2013         // find the miptail start level
2014         {
2015             uint32_t MipWidth  = gmmParams.BaseWidth64;
2016             uint32_t MipHeight = gmmParams.BaseHeight;
2017             while(!(MipWidth <= MtsWidth[i] && MipHeight <= MtsHeight[i]))
2018             {
2019                 MipTailStartLod++;
2020                 MipWidth  = (uint32_t)(GMM_ULT_MAX(1, gmmParams.BaseWidth64 >> MipTailStartLod));
2021                 MipHeight = GMM_ULT_MAX(1, gmmParams.BaseHeight >> MipTailStartLod);
2022             }
2023         }
2024 
2025         // Mip resource Aligned Width calculation
2026         Mip0Width  = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign[i]);
2027         Mip0Height = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign[i]);
2028 
2029         if(MipTailStartLod == 1)
2030         {
2031             EXPECT_EQ(1, ResourceInfo->GetPackedMipTailStartLod());
2032             // Block height...Mip0Height + Max(Mip1Height, Sum of Mip2Height..MipnHeight)
2033             Mip1Height   = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 1, VAlign[i]);
2034             AlignedWidth = Mip0Width;
2035         }
2036         if(MipTailStartLod == 2)
2037         {
2038             EXPECT_EQ(2, ResourceInfo->GetPackedMipTailStartLod());
2039             // Block height...Mip0Height + Max(Mip1Height, Sum of Mip2Height..MipnHeight)
2040             Mip1Height = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 1, VAlign[i]);
2041             Mip2Height = Mip2Higher = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 2, VAlign[i]);
2042 
2043             Mip1Width    = GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> 1, HAlign[i]);
2044             Mip2Width    = GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> 2, HAlign[i]);
2045             AlignedWidth = GMM_ULT_MAX(Mip0Width, Mip1Width + Mip2Width);
2046         }
2047         if(MipTailStartLod == 3)
2048         {
2049             EXPECT_EQ(3, ResourceInfo->GetPackedMipTailStartLod());
2050             // Block height...Mip0Height + Max(Mip1Height, Sum of Mip2Height..MipnHeight)
2051             Mip1Height = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 1, VAlign[i]);
2052             Mip2Height = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 2, VAlign[i]);
2053             // Miptail started lod
2054             MipTailHeight = VAlign[i];
2055             Mip2Higher    = Mip2Height + Mip3Height + MipTailHeight;
2056 
2057             Mip1Width    = GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> 1, HAlign[i]);
2058             Mip2Width    = GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> 2, HAlign[i]);
2059             AlignedWidth = GMM_ULT_MAX(Mip0Width, Mip1Width + Mip2Width);
2060         }
2061 
2062         uint32_t MaxHeight = GMM_ULT_MAX(Mip1Height, Mip2Higher);
2063         AlignedHeight      = Mip0Height + MaxHeight;
2064         AlignedHeight      = GMM_ULT_ALIGN(AlignedHeight, VAlign[i]);
2065 
2066         ExpectedPitch = AlignedWidth * GetBppValue(bpp);
2067         ExpectedPitch = GMM_ULT_ALIGN(ExpectedPitch, GMM_BYTES(32));
2068         ExpectedPitch = GMM_ULT_ALIGN(ExpectedPitch, TileSize[i][0] * 4); //Only for displayables - 16K pitch align
2069         VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
2070 
2071         VerifyResourcePitchInTiles<true>(ResourceInfo, static_cast<uint32_t>(ExpectedPitch / TileSize[i][0]));
2072         VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(ExpectedPitch * AlignedHeight * gmmParams.ArraySize, PAGE_SIZE));
2073         VerifyResourceQPitch<false>(ResourceInfo, AlignedHeight);
2074         //test main surface base alignment is 64KB
2075         //For Yf test main surface pitch is 4-tileYF aligned
2076         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
2077         EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
2078 
2079         //Aux-size enough to cover all
2080         if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
2081         {
2082             EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
2083         }
2084 
2085         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2086         ASSERT_LE(GMM_ULT_ALIGN(ResourceInfo->GetSizeMainSurface() / (GMM_KBYTE(16) / GMM_BYTES(64)), GMM_KBYTE(4)),
2087                   ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2088 
2089         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2090     }
2091 }
2092 
2093 /// @brief ULT for Linear Buffer Compressed Resource
TEST_F(CTestGen12Resource,TestLinearCompressedResource)2094 TEST_F(CTestGen12Resource, TestLinearCompressedResource)
2095 {
2096     // Horizontal pixel alignment
2097     const uint32_t MinPitch = 32;
2098 
2099     GMM_RESCREATE_PARAMS gmmParams        = {};
2100     gmmParams.Type                        = RESOURCE_BUFFER;
2101     gmmParams.NoGfxMemory                 = 1;
2102     gmmParams.Flags.Info.Linear           = 1;
2103     gmmParams.Flags.Gpu.Texture           = 1;
2104     gmmParams.Flags.Info.RenderCompressed = 1;
2105 
2106     // Allocate 1x1 surface
2107     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2108     {
2109         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
2110         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
2111 
2112         TEST_BPP bpp                             = static_cast<TEST_BPP>(i);
2113         gmmParams.Format                         = SetResourceFormat(bpp);
2114         gmmParams.BaseWidth64                    = 0x1;
2115         gmmParams.BaseHeight                     = 1;
2116         gmmParams.Flags.Info.AllowVirtualPadding = (bpp != TEST_BPP_8); //OCL uses 8bpp buffers. doc doesn't comment if Linear buffer compr allowed or not on bpp!=8.
2117 
2118         GMM_RESOURCE_INFO *ResourceInfo;
2119         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2120 
2121         uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, MinPitch);
2122         uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
2123         uint32_t AlignedSize  = GMM_ULT_ALIGN(PitchInBytes, PAGE_SIZE);
2124 
2125         VerifyResourceHAlign<false>(ResourceInfo, 0);
2126         VerifyResourceVAlign<false>(ResourceInfo, 0);       // N/A for buffer
2127         VerifyResourcePitch<false>(ResourceInfo, 0);        // N/A for buffer
2128         VerifyResourcePitchInTiles<false>(ResourceInfo, 0); // N/A for linear
2129         VerifyResourceSize<true>(ResourceInfo, AlignedSize);
2130         VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-arrayed
2131 
2132         //test main surface base alignment is 64KB
2133         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
2134 
2135         EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
2136         ASSERT_LE(GMM_ULT_ALIGN(ResourceInfo->GetSizeMainSurface() / (GMM_KBYTE(16) / GMM_BYTES(64)), GMM_KBYTE(4)),
2137                   ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2138 
2139         { //separate Aux
2140             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
2141 
2142             GMM_RESOURCE_INFO *AuxResourceInfo;
2143             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2144             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
2145             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
2146             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
2147             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
2148             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
2149         }
2150         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2151     }
2152 
2153 
2154     // Allocate more than 1 page
2155     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2156     {
2157         TEST_BPP bpp                             = static_cast<TEST_BPP>(i);
2158         gmmParams.Format                         = SetResourceFormat(bpp);
2159         gmmParams.BaseWidth64                    = 0x1001;
2160         gmmParams.BaseHeight                     = 1;
2161         gmmParams.Flags.Info.AllowVirtualPadding = (bpp != TEST_BPP_8); //OCL uses 8bpp buffers. document doesn't comment if Linear buffer compr allowed or not on bpp!=8.
2162         gmmParams.Flags.Gpu.UnifiedAuxSurface    = 1;          //Turn off for separate aux creation
2163         gmmParams.Flags.Gpu.CCS                  = 1;
2164 
2165         GMM_RESOURCE_INFO *ResourceInfo;
2166         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2167 
2168         uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, MinPitch);
2169         uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
2170         uint32_t AlignedSize  = GMM_ULT_ALIGN(PitchInBytes, PAGE_SIZE);
2171 
2172         VerifyResourceHAlign<false>(ResourceInfo, MinPitch);
2173         VerifyResourceVAlign<false>(ResourceInfo, 0);       // N/A for buffer
2174         VerifyResourcePitch<false>(ResourceInfo, 0);        // N/A for buffer
2175         VerifyResourcePitchInTiles<false>(ResourceInfo, 0); // N/A for linear
2176         VerifyResourceSize<true>(ResourceInfo, AlignedSize);
2177         VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-arrayed
2178 
2179         //test main surface base alignment is 64KB
2180         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
2181 
2182         EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
2183         ASSERT_LE(GMM_ULT_ALIGN(ResourceInfo->GetSizeMainSurface() / (GMM_KBYTE(16) / GMM_BYTES(64)), GMM_KBYTE(4)),
2184                   ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2185 
2186         { //separate Aux
2187             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
2188 
2189             GMM_RESOURCE_INFO *AuxResourceInfo;
2190             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2191             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
2192             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
2193             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
2194             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
2195             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
2196         }
2197         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2198     }
2199 }
2200 ///TODO Add MSAA/Depth Compressed Resource tests
TEST_F(CTestGen12Resource,TestLosslessMSAACompressedResource)2201 TEST_F(CTestGen12Resource, TestLosslessMSAACompressedResource)
2202 {
2203 }
2204 
TEST_F(CTestGen12Resource,TestDepthHiZNotCompressedResource)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 }
2383 ///TODO Add MSAA/Depth Compressed Resource tests
TEST_F(CTestGen12Resource,DISABLED_TestDepthCompressedResource)2384 TEST_F(CTestGen12Resource, DISABLED_TestDepthCompressedResource)
2385 {
2386     const uint32_t HAlign = 8; //HiZ alignment (16x4 ie general alignment), [Depth 16bit: 8x8; ow 8x4]
2387     uint32_t       VAlign = 4; // 8; Need to debug why driver uses VAlign/2
2388 
2389     //const uint32_t DepthTileSize[1][2] = { 64, 64 };  //Depth/Stencil buffer should be TileY/Ys/Yf only (16,24,32 bpp only) no 3D or MSAA
2390     const uint32_t AllocTileSize[1][2] = {128, 32}; //HiZ is TileY
2391 
2392     GMM_RESCREATE_PARAMS gmmParams         = {};
2393     gmmParams.NoGfxMemory                  = 1;
2394     gmmParams.Flags.Info.TiledY            = 1; //Not supported for Depth buffer, but HiZ output is TileY
2395     gmmParams.Flags.Gpu.Depth              = 1; //GPU Flags= Depth/SeparateStencil + HiZ
2396     gmmParams.Flags.Gpu.HiZ                = 1;
2397     gmmParams.Flags.Gpu.IndirectClearColor = 1;
2398     gmmParams.Flags.Gpu.CCS                = 1;
2399     gmmParams.Flags.Info.RenderCompressed  = 1;
2400     gmmParams.Flags.Gpu.UnifiedAuxSurface  = 1;
2401 
2402     // Allocate 1x1 surface so that it occupies 1 Tile in X dimension
2403     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
2404     {
2405         {
2406             VAlign = (j == TEST_BPP_16) ? 8 : 4;
2407         }
2408         gmmParams.Format = SetResourceFormat(static_cast<TEST_BPP>(j)); //Only 16,24,32 supported; But driver creates the resource even for other bpps without failing
2409         for(uint32_t i = RESOURCE_2D; i <= RESOURCE_CUBE; i++)          //3D doesn't support HiZ - test driver returns proper?
2410         {
2411             gmmParams.Type        = static_cast<GMM_RESOURCE_TYPE>(i);
2412             gmmParams.BaseWidth64 = 0x1;
2413             gmmParams.BaseHeight  = 0x1; //0x24; //not 1 tile
2414             //gmmParams.MaxLod      = 6; --add expectedheight calc- mip0+max{mip1, sum{mip2,...n}}
2415             gmmParams.Depth = 0x1;
2416             if(i == RESOURCE_1D || i == RESOURCE_3D)
2417             {
2418                 gmmParams.Flags.Gpu.HiZ = 0;
2419             }
2420 
2421             GMM_RESOURCE_INFO *ResourceInfo = NULL;
2422             ResourceInfo                    = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2423             //EXPECT_NE(NULL, ResourceInfo);
2424 
2425             VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2426             VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2427             uint32_t ExpectedPitch = AllocTileSize[0][0] * 4;
2428             VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
2429             VerifyResourcePitchInTiles<true>(ResourceInfo, 4); // 1 tileY wide
2430             uint32_t ExpectedHeight = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign);
2431 
2432             if(gmmParams.ArraySize > 1 || gmmParams.Type == RESOURCE_CUBE)
2433             {
2434                 uint32_t ExpectedQPitch = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign); //Apply formula as per specification
2435                 ExpectedQPitch          = GMM_ULT_ALIGN(ExpectedQPitch / 2, VAlign);
2436                 ExpectedHeight *= (gmmParams.Type == RESOURCE_CUBE) ? 6 : 1;
2437 
2438                 VerifyResourceQPitch<false>(ResourceInfo, ExpectedQPitch); // Each face should be VAlign rows apart within a tile, Turn on verification after clarity
2439             }
2440 
2441             VerifyResourceSize<true>(ResourceInfo,
2442                                      GFX_ALIGN(ExpectedPitch * ExpectedHeight, 4 * PAGE_SIZE)); //1 Tile should be enough
2443             pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2444         }
2445 
2446         // Allocate 2 tiles in X dimension. (muti-tiles Tiles in Y dimension for cube/array)
2447         for(uint32_t i = RESOURCE_2D; i <= RESOURCE_CUBE; i++)
2448         {
2449             gmmParams.Type        = static_cast<GMM_RESOURCE_TYPE>(i);
2450             gmmParams.BaseWidth64 = AllocTileSize[0][0] + 0x1;
2451             gmmParams.BaseHeight  = (gmmParams.Type == RESOURCE_1D) ? 0x1 :
2452                                                                      (gmmParams.Type == RESOURCE_CUBE) ? gmmParams.BaseWidth64 :
2453                                                                                                          VAlign / 2;
2454             gmmParams.ArraySize = (gmmParams.Type != RESOURCE_3D) ? VAlign : 1; // Gen8 doesn't support 3D-arrays (so HiZ not supported) [test 3d arrays once -- HiZ would fail but ResCreate doesn't?]
2455             gmmParams.Depth     = 0x1;
2456 
2457             GMM_RESOURCE_INFO *ResourceInfo;
2458             ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2459 
2460             VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2461             VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2462             uint32_t ExpectedPitch = GFX_ALIGN(gmmParams.BaseWidth * (int)pow(2, j), AllocTileSize[0][0] * 4);
2463             VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
2464             VerifyResourcePitchInTiles<true>(ResourceInfo, 4); // 2 tileY wide
2465 
2466             uint32_t ExpectedQPitch = 0;
2467             if(gmmParams.ArraySize > 1 || gmmParams.Type == RESOURCE_CUBE)
2468             {
2469                 ExpectedQPitch = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign);
2470                 //ExpectedQPitch = GMM_ULT_ALIGN(ExpectedQPitch / 2, VAlign);
2471 
2472                 VerifyResourceQPitch<false>(ResourceInfo, ExpectedQPitch); // Each face should be VAlign rows apart within a tile. Turn on verification after clarity
2473             }
2474 
2475             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
2476                                      ((gmmParams.Type == RESOURCE_CUBE) ?
2477                                       ExpectedPitch * GMM_ULT_ALIGN(ExpectedQPitch * gmmParams.ArraySize * __GMM_MAX_CUBE_FACE, AllocTileSize[0][1]) : //cube
2478                                       ((gmmParams.ArraySize > 1) ?
2479                                        ExpectedPitch * GMM_ULT_ALIGN(ExpectedQPitch * gmmParams.ArraySize, AllocTileSize[0][1]) : //array
2480                                        4 * GMM_KBYTE(4))));
2481 
2482             pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2483         }
2484 
2485         // Allocate 2 tiles in X/Y dimension (non-arrayed) Multi-tiles for 3D
2486         for(uint32_t i = RESOURCE_2D; i <= RESOURCE_3D; i++)
2487         {
2488             gmmParams.Type        = static_cast<GMM_RESOURCE_TYPE>(i);
2489             gmmParams.BaseWidth64 = AllocTileSize[0][0] + 0x1;
2490             gmmParams.BaseHeight  = 2 * AllocTileSize[0][1] + 0x1; //Half-Depth Height or QPitch (lod!=0), aligned to 8 required by HW
2491             gmmParams.Depth       = (gmmParams.Type == RESOURCE_2D) ? 0x1 :
2492                                                                 VAlign + 1;
2493             gmmParams.ArraySize = 1;
2494 
2495             GMM_RESOURCE_INFO *ResourceInfo;
2496             ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2497 
2498             VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2499             VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2500             uint32_t ExpectedPitch = AllocTileSize[0][0] * 4;
2501             VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
2502             VerifyResourcePitchInTiles<true>(ResourceInfo, 4); // 2 tile wide
2503 
2504             uint32_t TwoDQPitch, ExpectedQPitch = 0;
2505             if(gmmParams.Type == RESOURCE_3D)
2506             {
2507                 TwoDQPitch     = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign);
2508                 ExpectedQPitch = gmmParams.Depth * GMM_ULT_ALIGN(TwoDQPitch / 2, VAlign); //Depth slices arranged as 2D-arrayed slices.
2509             }
2510             else
2511             {
2512                 //HiZ for 3D not supported. Driver still allocates like IVB/HSW. (should Qpitch or only overall buffer height be Valigned ?)
2513                 VerifyResourceSize<true>(ResourceInfo,
2514                                          ((gmmParams.Type == RESOURCE_3D) ?
2515                                           ExpectedPitch * GMM_ULT_ALIGN(ExpectedQPitch, AllocTileSize[0][1]) :
2516                                           2 * 2 * GMM_KBYTE(4)));
2517             }
2518             pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2519         }
2520     }
2521 }
2522 
TEST_F(CTestGen12Resource,TestStencilCompressedResource)2523 TEST_F(CTestGen12Resource, TestStencilCompressedResource)
2524 {
2525     const uint32_t HAlign = {16};
2526     const uint32_t VAlign = {8};
2527 
2528     const uint32_t TileSize[2] = {128, 32};
2529 
2530     GMM_RESCREATE_PARAMS gmmParams = {};
2531     gmmParams.Type                 = RESOURCE_2D;
2532     gmmParams.NoGfxMemory          = 1;
2533     gmmParams.Flags.Info.TiledY    = 1;
2534     //gmmParams.ArraySize = 4;
2535 
2536     gmmParams.Flags.Gpu.SeparateStencil   = 1;
2537     gmmParams.Flags.Info.RenderCompressed = 1;
2538     // Turn on .MC or .RC flag - mandatory to tell compression-type, for Yf its also used to pad surf
2539     // to 4x1 tile (reqd by HW for perf reasons)
2540     // If unifiedAuxSurf reqd (mandatory for displayable or cross-adapter shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
2541 
2542     //Allocate 1x1 surface
2543     {
2544         gmmParams.Flags.Gpu.UnifiedAuxSurface  = 1; //Turn off for separate aux creation
2545         gmmParams.Flags.Gpu.CCS                = 1; //Turn off for separate aux creation
2546         gmmParams.Flags.Gpu.IndirectClearColor = 1;
2547 
2548         TEST_BPP      bpp      = static_cast<TEST_BPP>(TEST_BPP_8);
2549         GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
2550         gmmParams.Format       = SetResourceFormat(bpp);
2551         gmmParams.BaseWidth64  = 0x1;
2552         gmmParams.BaseHeight   = 0x1;
2553 
2554         GMM_RESOURCE_INFO *ResourceInfo;
2555         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2556 
2557         VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2558         VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2559         VerifyResourcePitch<true>(ResourceInfo, 4 * TileSize[0]); // As wide as 4 Tile
2560         VerifyResourcePitchInTiles<true>(ResourceInfo, 4);        // 4 Tile wide
2561         VerifyResourceSize<true>(ResourceInfo, 4 * GMM_KBYTE(4)); // 4 Tile Big
2562         VerifyResourceQPitch<false>(ResourceInfo, 0);             // Not Tested
2563 
2564         //test main surface base alignment is 64KB
2565         //For Yf test main surface pitch is 4-tileYF aligned
2566         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
2567         EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
2568 
2569         EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
2570         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2571 
2572         { //separate Aux
2573             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
2574 
2575             GMM_RESOURCE_INFO *AuxResourceInfo;
2576             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2577             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
2578             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
2579             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
2580             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
2581             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
2582         }
2583         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2584     }
2585 
2586     // Allocate surface that requires multi tiles in two dimension
2587     // Allocate 2 tiles in X dimension
2588     {
2589         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
2590         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
2591 
2592         TEST_BPP      bpp      = static_cast<TEST_BPP>(TEST_BPP_8);
2593         GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
2594         gmmParams.Format       = SetResourceFormat(bpp);
2595         gmmParams.BaseWidth64  = (TileSize[0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
2596         gmmParams.BaseHeight   = 0x1;
2597         gmmParams.Depth        = 0x1;
2598 
2599         GMM_RESOURCE_INFO *ResourceInfo;
2600         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2601 
2602         VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2603         VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2604         VerifyResourcePitch<true>(ResourceInfo, TileSize[0] * 4); // As wide as 2 tile, but 4-tile pitch alignment
2605         VerifyResourcePitchInTiles<true>(ResourceInfo, 4);        // 2 tile wide, but 4-tile pitch alignment
2606         VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * 4); // 2 tile big, but 4-tile pitch alignment
2607 
2608         VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
2609 
2610         //test main surface base alignment is 64KB
2611         //For Y test main surface pitch is 4-tileY aligned
2612         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
2613         EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4);
2614         EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
2615         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2616 
2617         { //separate Aux
2618             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
2619 
2620             GMM_RESOURCE_INFO *AuxResourceInfo;
2621             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2622             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
2623             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
2624             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
2625             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
2626             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
2627         }
2628         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2629     }
2630 
2631     // Allocate surface that requires multi tiles in two dimension
2632     // Allocate 2 tiles in X/Y dimension
2633     {
2634         gmmParams.Flags.Gpu.UnifiedAuxSurface  = 1; //Turn off for separate aux creation
2635         gmmParams.Flags.Gpu.CCS                = 1; //Turn off for separate aux creation
2636         gmmParams.Flags.Gpu.IndirectClearColor = 1;
2637 
2638         TEST_BPP      bpp      = static_cast<TEST_BPP>(TEST_BPP_8);
2639         GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
2640         gmmParams.Format       = SetResourceFormat(bpp);
2641         gmmParams.BaseWidth64  = (TileSize[0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
2642         gmmParams.BaseHeight   = TileSize[1] + 1;                      // 1 row larger than 1 tile height
2643         gmmParams.Depth        = 0x1;
2644 
2645         GMM_RESOURCE_INFO *ResourceInfo;
2646         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2647 
2648         VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2649         VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2650         VerifyResourcePitch<true>(ResourceInfo, TileSize[0] * 4);     // As wide as 2 tile, but 4-tile pitch alignment
2651         VerifyResourcePitchInTiles<true>(ResourceInfo, 4);            // 2 tile wide, but 4-tile pitch alignment
2652         VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * 4 * 2); // 4 tile wide; and 2-tile high
2653 
2654         VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
2655                                                       //test main surface base alignment is 64KB
2656                                                       //For Y test main surface pitch is 4-tileY aligned
2657         EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
2658         EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4);
2659         EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
2660         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2661 
2662         { //separate Aux
2663             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
2664 
2665             GMM_RESOURCE_INFO *AuxResourceInfo;
2666             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2667             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
2668             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
2669             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
2670             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
2671             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
2672         }
2673         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2674     }
2675 }
2676 
2677 
2678 /// @brief ULT for 2D TileYf Compressed Resource
TEST_F(CTestGen12Resource,Test2DTileYfAMFSResource)2679 TEST_F(CTestGen12Resource, Test2DTileYfAMFSResource)
2680 {
2681     const uint32_t HAlign[TEST_BPP_MAX] = {64, 64, 32, 32, 16};
2682     const uint32_t VAlign[TEST_BPP_MAX] = {64, 32, 32, 16, 16};
2683 
2684     const uint32_t TileSize[TEST_BPP_MAX][2] = {{64, 64},
2685                                                 {128, 32},
2686                                                 {128, 32},
2687                                                 {256, 16},
2688                                                 {256, 16}};
2689 
2690     GMM_RESCREATE_PARAMS gmmParams        = {};
2691     gmmParams.Type                        = RESOURCE_2D;
2692     gmmParams.NoGfxMemory                 = 1;
2693     gmmParams.Flags.Info.TiledY           = 1;
2694     gmmParams.Flags.Info.TiledYf          = 1;
2695     gmmParams.Flags.Gpu.Texture           = 1;
2696     gmmParams.Flags.Gpu.ProceduralTexture = 1;
2697     // If unifiedAuxSurf reqd (mandatory for displayable or cross-adapter shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
2698 
2699     //Allocate 1x1 surface
2700     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2701     {
2702         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
2703         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
2704                                                    //gmmParams.Flags.Gpu.MMC = 0;              //Turn on to check unifiedaux creation
2705 
2706         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
2707         GMM_TILE_MODE TileMode = DEFINE_TILE(YF_2D, bpp);
2708         gmmParams.Format       = SetResourceFormat(bpp);
2709         gmmParams.BaseWidth64  = 0x1;
2710         gmmParams.BaseHeight   = 0x1;
2711 
2712         GMM_RESOURCE_INFO *ResourceInfo;
2713         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2714 
2715         VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
2716         VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
2717         VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0]); // As wide as 1 Tile
2718         VerifyResourcePitchInTiles<true>(ResourceInfo, 1);       // 1 Tile wide
2719         //VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4));    // 1 Tile Big,  old behaviour consuming bytes for main-surface (paired Texture dimensions) only used to obtain GPUVA for indirect (Auxtable mapped) CCS access by sampler.
2720 	VerifyResourceSize<true>(ResourceInfo, 0);    // New behaviour, optimized SFT size, sampler doesn't access CCS via main.. kernels refer the CCS-via its GPUVA (w/o main).
2721         VerifyResourceQPitch<false>(ResourceInfo, 0);            // Not Tested
2722 
2723         //test main surface base alignment is 4KB, since AMFS PT isn't compressed
2724         //but uses same linear CCS as compression
2725         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetBaseAlignment());
2726         EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
2727         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2728 
2729 
2730         { //separate Aux
2731             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
2732 
2733             GMM_RESOURCE_INFO *AuxResourceInfo;
2734             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2735             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
2736             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
2737             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
2738             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
2739             EXPECT_EQ(0, AuxResourceInfo->GmmGetTileMode());
2740             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
2741         }
2742         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2743     }
2744 
2745     // Allocate surface that requires multi tiles in two dimension
2746     // Allocate 2 tiles in X dimension
2747     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2748     {
2749         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
2750         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
2751 
2752         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
2753         GMM_TILE_MODE TileMode = DEFINE_TILE(YF_2D, bpp);
2754 
2755         gmmParams.Format      = SetResourceFormat(bpp);
2756         gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
2757         gmmParams.BaseHeight  = 0x1;
2758         gmmParams.Depth       = 0x1;
2759 
2760         GMM_RESOURCE_INFO *ResourceInfo;
2761         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2762 
2763         VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
2764         VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
2765         VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0] * 2); // As wide as 2 tile
2766         VerifyResourcePitchInTiles<true>(ResourceInfo, 2);           // 2 tile wide
2767         //VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * 2);    // 2 tile big, old behaviour consuming bytes for main-surface (paired Texture dimensions) only used to obtain GPUVA for indirect (Auxtable mapped) CCS access by sampler.
2768         VerifyResourceSize<true>(ResourceInfo, 0); // New behaviour, optimized SFT size, sampler doesn't access CCS via main.. kernels refer the CCS-via its GPUVA (w/o main).
2769 
2770         VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
2771 
2772         //test main surface base alignment is 4KB
2773         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetBaseAlignment());
2774         EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
2775         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2776 
2777         { //separate Aux
2778             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
2779 
2780             GMM_RESOURCE_INFO *AuxResourceInfo;
2781             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2782             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
2783             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
2784             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
2785             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
2786             EXPECT_EQ(0, AuxResourceInfo->GmmGetTileMode());
2787 
2788             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
2789         }
2790         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2791     }
2792 
2793     // Allocate surface that requires multi tiles in two dimension
2794     // Allocate 2 tiles in X/Y dimension
2795     for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2796     {
2797         gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
2798         gmmParams.Flags.Gpu.CCS               = 1; //Turn off for separate aux creation
2799 
2800         TEST_BPP      bpp      = static_cast<TEST_BPP>(i);
2801         GMM_TILE_MODE TileMode = DEFINE_TILE(YF_2D, bpp);
2802         gmmParams.Format       = SetResourceFormat(bpp);
2803         gmmParams.BaseWidth64  = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
2804         gmmParams.BaseHeight   = TileSize[i][1] + 1;                      // 1 row larger than 1 tile height
2805         gmmParams.Depth        = 0x1;
2806 
2807         GMM_RESOURCE_INFO *ResourceInfo;
2808         ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2809 
2810         VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
2811         VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
2812         VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0] * 2);  // As wide as 2 tile
2813         VerifyResourcePitchInTiles<true>(ResourceInfo, 2);            // 2 tile wide
2814         //VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * 2 * 2); // 2 tile wide; and 2-tile high, old behaviour consuming bytes for main-surface (paired Texture dimensions) only used to obtain GPUVA for indirect (Auxtable mapped) CCS access by sampler.
2815         VerifyResourceSize<true>(ResourceInfo, 0); // New behaviour, optimized SFT size, sampler doesn't access CCS via main.. kernels refer the CCS-via its GPUVA (w/o main).
2816 
2817         VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
2818                                                       //test main surface base alignment is 4KB
2819         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetBaseAlignment());
2820         EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
2821         EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2822 
2823         { //separate Aux
2824             gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
2825 
2826             GMM_RESOURCE_INFO *AuxResourceInfo;
2827             AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2828             EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
2829             EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
2830             EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
2831             EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
2832             EXPECT_EQ(0, AuxResourceInfo->GmmGetTileMode());
2833             pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
2834         }
2835         pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2836     }
2837 }
2838 
2839 /// @brief ULT for MSAA Resource - TODO adddepth MSAA, MCS surf param verificaton, compression case
TEST_F(CTestGen12Resource,TestColorMSAA)2840 TEST_F(CTestGen12Resource, TestColorMSAA)
2841 {
2842     //Tile dimensions in Bytes
2843     const uint32_t MCSTileSize[1][2] = {128, 32}; //MCS is TileY
2844 
2845     const uint32_t TestDimensions[4][2] = {
2846     //Input dimensions in #Tiles
2847     {15, 20}, //16 Tiles x 20 <Max Width: Depth MSS crosses Pitch limit beyond this>
2848     {0, 0},   //1x1x1
2849     {1, 0},   //2 Tilesx1
2850     {1, 1},   //2 Tiles x 2
2851     };
2852 
2853     uint32_t TestArraySize[2] = {1, 5};
2854     uint32_t MinPitch         = 32;
2855 
2856     uint32_t HAlign, VAlign, TileDimX, TileDimY, MCSHAlign, MCSVAlign, TileSize;
2857     uint32_t ExpectedMCSBpp;
2858     std::vector<tuple<int, int, int, bool, int, int>> List; //TEST_TILE_TYPE, TEST_BPP, TEST_RESOURCE_TYPE, Depth or RT, TestDimension index, ArraySize
2859     auto Size = BuildInputIterator(List, 4, 2, false);      // Size of arrays TestDimensions, TestArraySize
2860 
2861     for(auto element : List)
2862     {
2863         GMM_RESCREATE_PARAMS gmmParams = {};
2864         gmmParams.Flags.Info           = {0};
2865 
2866         TEST_TILE_TYPE     Tiling     = (TEST_TILE_TYPE)std::get<0>(element);
2867         TEST_BPP           Bpp        = (TEST_BPP)std::get<1>(element);
2868         TEST_RESOURCE_TYPE ResType    = (TEST_RESOURCE_TYPE)std::get<2>(element);
2869         bool               IsRT       = std::get<3>(element); // True for RT, False for Depth
2870         int                TestDimIdx = std::get<4>(element); //index into TestDimensions array
2871         int                ArrayIdx   = std::get<5>(element); //index into TestArraySize
2872         TileSize                      = (Tiling == TEST_TILEYS) ? GMM_KBYTE(64) : GMM_KBYTE(4);
2873 
2874         //Discard un-supported Tiling/Res_type/bpp for this test
2875         if(ResType != TEST_RESOURCE_2D ||                            //No 1D/3D/Cube. Supported 2D mip-maps/array
2876            (!IsRT && (Tiling == TEST_TILEX ||                        // doesn't support TileX for Depth
2877                       !(Bpp == TEST_BPP_16 || Bpp == TEST_BPP_32)))) //depth supported on 16bit, 32bit formats only
2878             continue;
2879 
2880         if(!IsRT)
2881             continue; //comment depth msaa for now (requires change in h/v align)
2882 
2883         SetTileFlag(gmmParams, Tiling);
2884         SetResType(gmmParams, ResType);
2885         SetResGpuFlags(gmmParams, IsRT);
2886         SetResArraySize(gmmParams, TestArraySize[ArrayIdx]);
2887 
2888         gmmParams.NoGfxMemory = 1;
2889         gmmParams.Format      = SetResourceFormat(Bpp);
2890         for(uint32_t k = MSAA_2x; k <= MSAA_16x; k++)
2891         {
2892             GetAlignmentAndTileDimensionsForMSAA(Bpp, IsRT, Tiling, (TEST_MSAA)k,
2893                                                  TileDimX, TileDimY, HAlign, VAlign,
2894                                                  ExpectedMCSBpp, MCSHAlign, MCSVAlign);
2895 
2896             //gmmParams.BaseWidth64 = TestDimensions[TestDimIdx][0] * TileDimX + 0x1;
2897             //gmmParams.BaseHeight = TestDimensions[TestDimIdx][1] * TileDimY + 0x1;
2898             gmmParams.BaseWidth64     = 4;
2899             gmmParams.BaseHeight      = 4;
2900             gmmParams.Depth           = 0x1;
2901             gmmParams.MSAA.NumSamples = static_cast<uint32_t>(pow((double)2, k));
2902             gmmParams.Flags.Gpu.MCS   = 0;
2903 
2904             //MSS surface
2905             GMM_RESOURCE_INFO *MSSResourceInfo;
2906             MSSResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2907 
2908             if(MSSResourceInfo)
2909             {
2910                 VerifyResourceHAlign<true>(MSSResourceInfo, HAlign);
2911                 VerifyResourceVAlign<true>(MSSResourceInfo, VAlign);
2912                 if(IsRT) //Arrayed MSS
2913                 {
2914                     uint32_t ExpectedPitch = 0, ExpectedQPitch = 0;
2915                     ExpectedPitch = GMM_ULT_ALIGN(GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign) * (int)pow(2.0, Bpp), TileDimX); // Aligned width * bpp, aligned to TileWidth
2916                     ExpectedPitch = GFX_MAX(ExpectedPitch, MinPitch);
2917                     VerifyResourcePitch<true>(MSSResourceInfo, ExpectedPitch);
2918                     if(Tiling != TEST_LINEAR)
2919                         VerifyResourcePitchInTiles<true>(MSSResourceInfo, ExpectedPitch / TileDimX);
2920 
2921                     ExpectedQPitch = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign);
2922                     if(gmmParams.ArraySize > 1) //Gen9: Qpitch is distance between array slices (not sample slices)
2923                     {
2924                         VerifyResourceQPitch<true>(MSSResourceInfo, ExpectedQPitch);
2925                     }
2926 
2927                     uint32_t ExpectedHeight = GMM_ULT_ALIGN(ExpectedQPitch * gmmParams.MSAA.NumSamples * gmmParams.ArraySize, TileDimY); //Align Height =ExpectedPitch * NumSamples * ExpectedQPitch, to Tile-Height
2928                     VerifyResourceSize<true>(MSSResourceInfo, GMM_ULT_ALIGN(ExpectedPitch * ExpectedHeight, TileSize));
2929                 }
2930             }
2931 
2932             pGmmULTClientContext->DestroyResInfoObject(MSSResourceInfo);
2933         } //NumSamples = k
2934     }     //Iterate through all Input types
2935 
2936     //Mip-mapped, MSAA case:
2937 }
2938