1 /*==============================================================================
2 Copyright(c) 2020 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 "GmmGen12dGPUResourceULT.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 CTestGen12dGPUResource::SetUpTestCase()
33 ///
34 /////////////////////////////////////////////////////////////////////////////////////
SetUpTestCase()35 void CTestGen12dGPUResource::SetUpTestCase()
36 {
37 printf("%s\n", __FUNCTION__);
38 GfxPlatform.eProductFamily = IGFX_XE_HP_SDV;
39 GfxPlatform.eRenderCoreFamily = IGFX_XE_HP_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.FtrStandardMipTailFormat = 1;
48 pGfxAdapterInfo->SkuTable.FtrTileY = 1;
49 pGfxAdapterInfo->SkuTable.FtrTile64Optimization = 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 CTestGen12dGPUResource::TearDownTestCase()
59 /////////////////////////////////////////////////////////////////////////////////////
TearDownTestCase()60 void CTestGen12dGPUResource::TearDownTestCase()
61 {
62 printf("%s\n", __FUNCTION__);
63
64 CommonULT::TearDownTestCase();
65 }
66
TEST_F(CTestGen12dGPUResource,DISABLED_Test1DLinearResource)67 TEST_F(CTestGen12dGPUResource, DISABLED_Test1DLinearResource)
68 {
69 // Horizontal pixel alignment
70 const uint32_t HAlign[] = {128, 64, 32, 16, 8}; //128Bytes/(bpp>>3)
71
72 GMM_RESCREATE_PARAMS gmmParams = {};
73 gmmParams.Type = RESOURCE_1D;
74 gmmParams.NoGfxMemory = 1;
75 gmmParams.Flags.Info.Linear = 1;
76 gmmParams.Flags.Gpu.Texture = 1;
77
78 // Allocate 1x1 surface
79 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
80 {
81 TEST_BPP bpp = static_cast<TEST_BPP>(i);
82 gmmParams.Format = SetResourceFormat(bpp);
83 gmmParams.BaseWidth64 = 0x1;
84 gmmParams.BaseHeight = 1;
85
86 GMM_RESOURCE_INFO *ResourceInfo;
87 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
88
89 uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign[i]);
90 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
91 uint32_t AlignedSize = GMM_ULT_ALIGN(PitchInBytes, PAGE_SIZE);
92
93 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
94 VerifyResourceVAlign<false>(ResourceInfo, 0); // N/A for 1D
95 VerifyResourcePitch<false>(ResourceInfo, 0); // N/A for 1D
96 VerifyResourcePitchInTiles<false>(ResourceInfo, 0); // N/A for linear
97 VerifyResourceSize<true>(ResourceInfo, AlignedSize);
98 VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-arrayed
99
100 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
101 }
102
103
104 // Allocate more than 1 page
105 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
106 {
107 TEST_BPP bpp = static_cast<TEST_BPP>(i);
108 gmmParams.Format = SetResourceFormat(bpp);
109 gmmParams.BaseWidth64 = 0x1001;
110 gmmParams.BaseHeight = 1;
111
112 GMM_RESOURCE_INFO *ResourceInfo;
113 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
114
115 uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign[i]);
116 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
117 uint32_t AlignedSize = GMM_ULT_ALIGN(PitchInBytes, PAGE_SIZE);
118
119 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
120 VerifyResourceVAlign<false>(ResourceInfo, 0); // N/A for 1D
121 VerifyResourcePitch<false>(ResourceInfo, 0); // N/A for 1D
122 VerifyResourcePitchInTiles<false>(ResourceInfo, 0); // N/A for linear
123 VerifyResourceSize<true>(ResourceInfo, AlignedSize);
124 VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-arrayed
125
126 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
127 }
128 }
129
130 /// @brief ULT for 1D Linear Resource Arrays
TEST_F(CTestGen12dGPUResource,DISABLED_Test1DLinearResourceArrays)131 TEST_F(CTestGen12dGPUResource, DISABLED_Test1DLinearResourceArrays)
132 {
133 // Horizontal pixel alignment
134 const uint32_t HAlign[] = {128, 64, 32, 16, 8}; //128Bytes/(bpp>>3)
135
136 GMM_RESCREATE_PARAMS gmmParams = {};
137 gmmParams.Type = RESOURCE_1D;
138 gmmParams.NoGfxMemory = 1;
139 gmmParams.Flags.Info.Linear = 1;
140 gmmParams.Flags.Gpu.Texture = 1;
141 gmmParams.ArraySize = 4;
142
143 // Allocate more than 1 page
144 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
145 {
146 TEST_BPP bpp = static_cast<TEST_BPP>(i);
147 gmmParams.Format = SetResourceFormat(bpp);
148 gmmParams.BaseWidth64 = 0x1001;
149 gmmParams.BaseHeight = 1;
150
151 GMM_RESOURCE_INFO *ResourceInfo;
152 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
153
154 uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign[i]);
155 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
156 uint32_t AlignedSize = GMM_ULT_ALIGN(PitchInBytes * gmmParams.ArraySize, PAGE_SIZE);
157
158 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
159 VerifyResourceVAlign<false>(ResourceInfo, 0); // N/A for 1D
160 VerifyResourcePitch<false>(ResourceInfo, 0); // N/A for 1D
161 VerifyResourcePitchInTiles<false>(ResourceInfo, 0); // N/A for linear
162 VerifyResourceSize<true>(ResourceInfo, AlignedSize);
163 VerifyResourceQPitch<true>(ResourceInfo, AlignedWidth);
164
165 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
166 }
167 }
168
169 /// @brief ULT for 1D Mipped Linear Resource
TEST_F(CTestGen12dGPUResource,DISABLED_Test1DLinearResourceMips)170 TEST_F(CTestGen12dGPUResource, DISABLED_Test1DLinearResourceMips)
171 {
172 // Horizontal pixel alignment
173 const uint32_t HAlign[] = {128, 64, 32, 16, 8}; //128Bytes/(bpp>>3)
174
175 GMM_RESCREATE_PARAMS gmmParams = {};
176 gmmParams.Type = RESOURCE_1D;
177 gmmParams.NoGfxMemory = 1;
178 gmmParams.Flags.Info.Linear = 1;
179 gmmParams.Flags.Gpu.Texture = 1;
180 gmmParams.MaxLod = 5;
181
182 // Allocate 256x1 surface
183 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
184 {
185 TEST_BPP bpp = static_cast<TEST_BPP>(i);
186 gmmParams.Format = SetResourceFormat(bpp);
187 gmmParams.BaseWidth64 = 0x100;
188 gmmParams.BaseHeight = 0x1;
189
190 GMM_RESOURCE_INFO *ResourceInfo;
191 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
192
193 uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign[i]);
194 for(int mip = 1; mip <= gmmParams.MaxLod; mip++)
195 {
196 // Since 1D doesn't have a height, mips are just based on width
197 AlignedWidth += GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> mip, HAlign[i]);
198 }
199 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
200 uint32_t AlignedSize = GMM_ULT_ALIGN(PitchInBytes, PAGE_SIZE);
201
202 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
203 VerifyResourceVAlign<false>(ResourceInfo, 0); // N/A for 1D
204 VerifyResourcePitch<false>(ResourceInfo, 0); // N/A for 1D
205 VerifyResourcePitchInTiles<false>(ResourceInfo, 0); // N/A for linear
206 VerifyResourceSize<true>(ResourceInfo, AlignedSize);
207 VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-arrayed
208
209 // Mip0 should be at offset 0. X/Y/Z Offset should be 0 for linear.
210 GMM_REQ_OFFSET_INFO OffsetInfo = {};
211 OffsetInfo.ReqRender = 1;
212 OffsetInfo.MipLevel = 0; //Mip 0
213 ResourceInfo->GetOffset(OffsetInfo);
214 EXPECT_EQ(0, OffsetInfo.Render.Offset64);
215 EXPECT_EQ(0, OffsetInfo.Render.XOffset);
216 EXPECT_EQ(0, OffsetInfo.Render.YOffset);
217 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
218
219 // All mips should be right after one another linearly
220 uint32_t StartOfMip = 0;
221 for(int mip = 1; mip <= gmmParams.MaxLod; mip++)
222 {
223 OffsetInfo = {};
224 OffsetInfo.ReqRender = 1;
225 OffsetInfo.MipLevel = mip;
226 ResourceInfo->GetOffset(OffsetInfo);
227 StartOfMip += GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> (mip - 1), HAlign[i]) * GetBppValue(bpp);
228 EXPECT_EQ(StartOfMip, OffsetInfo.Render.Offset64);
229 EXPECT_EQ(0, OffsetInfo.Render.XOffset);
230 EXPECT_EQ(0, OffsetInfo.Render.YOffset);
231 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
232 }
233
234 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
235 }
236 }
237
238 /// @brief ULT for 1D Mipped TileYS Resource
TEST_F(CTestGen12dGPUResource,DISABLED_Test1DTileTiledResourceMips)239 TEST_F(CTestGen12dGPUResource, DISABLED_Test1DTileTiledResourceMips)
240 {
241 const uint32_t TileSize[TEST_BPP_MAX] = {65536, 32768, 16384, 8192, 4096};
242 const uint32_t Mts[TEST_BPP_MAX] = {16384, 8192, 4096, 2048, 1024};
243
244 GMM_RESCREATE_PARAMS gmmParams = {};
245 gmmParams.Type = RESOURCE_1D;
246 gmmParams.NoGfxMemory = 1;
247 gmmParams.Flags.Gpu.TiledResource = 1;
248 gmmParams.Flags.Gpu.Texture = 1;
249 gmmParams.MaxLod = 5;
250
251 // Allocate all mips in 1 tile or multiple tiles, depending on the bpp
252 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
253 {
254 TEST_BPP bpp = static_cast<TEST_BPP>(i);
255 gmmParams.Format = SetResourceFormat(bpp);
256 gmmParams.BaseWidth64 = 16 * 1024; // 16K is the max width you can specify
257 gmmParams.BaseHeight = 0x1;
258
259 GMM_RESOURCE_INFO *ResourceInfo;
260 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
261
262 uint32_t MaxMip;
263 uint32_t MipTailStart = gmmParams.MaxLod;
264 for(MaxMip = 0; MaxMip <= gmmParams.MaxLod; MaxMip++)
265 {
266 if((gmmParams.BaseWidth64 >> MaxMip) <= Mts[i])
267 {
268 MipTailStart = MaxMip;
269 break;
270 }
271 }
272
273 uint32_t AlignedWidth = 0;
274 for(int mip = 0; mip <= MaxMip; mip++)
275 {
276 // Since 1D doesn't have a height, mips are just based on width
277 AlignedWidth += GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> mip, TileSize[i]);
278 ;
279 }
280
281 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
282 uint32_t AlignedSize = GMM_ULT_ALIGN(PitchInBytes, PAGE_SIZE);
283
284 VerifyResourceHAlign<true>(ResourceInfo, TileSize[i]);
285 VerifyResourceVAlign<false>(ResourceInfo, 0); // N/A for 1D
286 VerifyResourcePitch<false>(ResourceInfo, 0); // N/A for 1D
287 VerifyResourcePitchInTiles<false>(ResourceInfo, 0); // N/A for linear
288 VerifyResourceSize<true>(ResourceInfo, AlignedSize);
289 VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-arrayed
290
291 // All mips should be right after one another linearly, until the miptail
292 uint32_t StartOfMip = 0;
293 int mip;
294 for(mip = 0; mip < MaxMip; mip++)
295 {
296 GMM_REQ_OFFSET_INFO OffsetInfo = {};
297 OffsetInfo.ReqRender = 1;
298 OffsetInfo.MipLevel = mip;
299 ResourceInfo->GetOffset(OffsetInfo);
300 StartOfMip += (mip == 0 ? 0 : GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> (mip - 1), TileSize[i]) * GetBppValue(bpp));
301 EXPECT_EQ(StartOfMip, OffsetInfo.Render.Offset64);
302 EXPECT_EQ(0, OffsetInfo.Render.XOffset);
303 EXPECT_EQ(0, OffsetInfo.Render.YOffset);
304 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
305 }
306
307 uint32_t MipTailOffsets[GMM_ULT_MAX_MIPMAP] = {32768, 16384, 8192, 4096, 2048, 1536, 1280, 1024, 768, 512, 256, 0, 64, 128, 196};
308 // Check for offset inside miptails.
309 EXPECT_EQ(MipTailStart, ResourceInfo->GetPackedMipTailStartLod());
310 StartOfMip += GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> (mip - 1), TileSize[i]) * GetBppValue(bpp); // Start of MipTail
311 for(int slot = 0; mip <= gmmParams.MaxLod; mip++, slot++)
312 {
313 GMM_REQ_OFFSET_INFO OffsetInfo = {};
314 OffsetInfo.ReqRender = 1;
315 OffsetInfo.MipLevel = mip;
316 ResourceInfo->GetOffset(OffsetInfo);
317 EXPECT_EQ(StartOfMip, OffsetInfo.Render.Offset64); // Start of Miptail
318 EXPECT_EQ(MipTailOffsets[slot], OffsetInfo.Render.XOffset); // Offset within miptail
319 EXPECT_EQ(0, OffsetInfo.Render.YOffset);
320 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
321 }
322
323 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
324 }
325 }
326
327 /// @brief ULT for 2D Tile64 Resource Optimization
TEST_F(CTestGen12dGPUResource,DISABLED_TestTile64ResourceOptimization)328 TEST_F(CTestGen12dGPUResource, DISABLED_TestTile64ResourceOptimization)
329 {
330 const uint32_t TileSize[TEST_BPP_MAX][2] = {{256, 256},
331 {512, 128},
332 {512, 128},
333 {1024, 64},
334 {1024, 64}};
335
336 GMM_RESCREATE_PARAMS gmmParams = {};
337
338 gmmParams.Type = RESOURCE_2D;
339 gmmParams.Format = GMM_FORMAT_R8G8B8A8_UNORM;
340 gmmParams.NoGfxMemory = 1;
341 gmmParams.Flags.Gpu.Texture = 1;
342 // TiledResource set 0 - allow to enter in Tile64 optimization logic
343 gmmParams.Flags.Gpu.TiledResource = 0;
344 gmmParams.ArraySize = 6;
345 gmmParams.BaseWidth64 = 1;
346 gmmParams.BaseHeight = 1;
347 // set any valid Usage
348 gmmParams.Usage = GMM_RESOURCE_USAGE_RENDER_TARGET;
349
350 GMM_RESOURCE_INFO *ResourceInfo;
351
352 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
353 // Check if Tile4 info flag
354 VerifyResourceTile4<true>(ResourceInfo, true);
355 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
356
357 gmmParams.Type = RESOURCE_2D;
358 gmmParams.BaseWidth64 = 128;
359 gmmParams.BaseHeight = 128;
360 gmmParams.NoGfxMemory = 1;
361 gmmParams.Flags.Gpu.Texture = 1;
362 // TiledResource set 0 - allow to enter in Tile64 optimization logic
363 gmmParams.Flags.Gpu.TiledResource = 0;
364 gmmParams.ArraySize = 960;
365 gmmParams.Flags.Info.Tile4 = 0;
366 gmmParams.Flags.Info.Tile64 = 0;
367
368 gmmParams.Format = GMM_FORMAT_BC6H;
369 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
370 // Check if Tile4 info flag
371 VerifyResourceTile4<true>(ResourceInfo, true);
372 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
373
374
375 // Allocate surface that requires multi tiles in two dimension
376 // Allocate 2 tiles in X dimension
377 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
378 {
379 TEST_BPP bpp = static_cast<TEST_BPP>(i);
380 gmmParams.Format = SetResourceFormat(bpp);
381 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
382 gmmParams.BaseHeight = 0x1;
383 gmmParams.Depth = 0x1;
384 // TiledResource set 0 - allow to enter in Tile64 optimization logic
385 gmmParams.Flags.Gpu.TiledResource = 0;
386 gmmParams.Flags.Info.Tile4 = 0;
387 gmmParams.Flags.Info.Tile64 = 0;
388
389 GMM_RESOURCE_INFO *ResourceInfo;
390 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
391
392 // Check if Tile4 is set or not
393 VerifyResourceTile4<true>(ResourceInfo, true);
394
395 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
396 }
397
398 // Allocate 2 tiles in X/Y dimension
399 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
400 {
401 TEST_BPP bpp = static_cast<TEST_BPP>(i);
402 gmmParams.Format = GMM_FORMAT_R8G8B8A8_UNORM; //SetResourceFormat(bpp);
403 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
404 gmmParams.BaseHeight = TileSize[i][1] + 1; // 1 row larger than 1 tile height
405 gmmParams.Depth = 0x1;
406 gmmParams.Flags.Info.Tile4 = 0;
407 gmmParams.Flags.Info.Tile64 = 0;
408
409 GMM_RESOURCE_INFO *ResourceInfo;
410 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
411
412 // Check if Tile4 is set or not
413 VerifyResourceTile4<true>(ResourceInfo, true);
414
415 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
416 }
417 }
418
419 /// @brief ULT for 2D Tile64 Resource with Mips
TEST_F(CTestGen12dGPUResource,DISABLED_Test2DTile64MippedResourceOptimization)420 TEST_F(CTestGen12dGPUResource, DISABLED_Test2DTile64MippedResourceOptimization)
421 {
422 const uint32_t HAlign[TEST_BPP_MAX] = {256, 256, 128, 128, 64};
423 const uint32_t VAlign[TEST_BPP_MAX] = {256, 128, 128, 64, 64};
424
425 const uint32_t TileSize[TEST_BPP_MAX][2] = {{256, 256},
426 {512, 128},
427 {512, 128},
428 {1024, 64},
429 {1024, 64}};
430
431 const uint32_t MtsWidth[TEST_BPP_MAX] = {128, 128, 64, 64, 32};
432 const uint32_t MtsHeight[TEST_BPP_MAX] = {256, 128, 128, 64, 64};
433
434 GMM_RESCREATE_PARAMS gmmParams = {};
435 gmmParams.Type = RESOURCE_2D;
436 gmmParams.NoGfxMemory = 1;
437 // TiledResource set 0 - allow to enter in Tile64 optimization logic
438 gmmParams.Flags.Gpu.TiledResource = 0;
439 gmmParams.Flags.Gpu.Texture = 1;
440 gmmParams.MaxLod = 5;
441 gmmParams.ArraySize = 4;
442 // set any valid Usage
443 gmmParams.Usage = GMM_RESOURCE_USAGE_RENDER_TARGET;
444
445 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
446 {
447 uint32_t AlignedWidth = 0;
448 uint32_t AlignedHeight = 0;
449 uint32_t ExpectedPitch = 0;
450 uint32_t MipTailStartLod = 0;
451 // Valigned Mip Heights
452 uint32_t Mip0Height = 0;
453 uint32_t Mip1Height = 0;
454 uint32_t Mip2Height = 0;
455 uint32_t Mip3Height = 0;
456 uint32_t Mip2Higher = 0; // Sum of aligned heights of Mip2 and above
457 uint32_t MipTailHeight = 0;
458 // Haligned Mip Widths
459 uint32_t Mip0Width = 0;
460 uint32_t Mip1Width = 0;
461 uint32_t Mip2Width = 0;
462
463 TEST_BPP bpp = static_cast<TEST_BPP>(i);
464 gmmParams.Format = SetResourceFormat(bpp);
465 gmmParams.BaseWidth64 = 0x120;
466 gmmParams.BaseHeight = 0x120;
467 // TiledResource set 0 - allow to enter in Tile64 optimization logic
468 gmmParams.Flags.Gpu.TiledResource = 0;
469 gmmParams.Flags.Info.Tile4 = 0;
470 gmmParams.Flags.Info.Tile64 = 0;
471
472 GMM_RESOURCE_INFO *ResourceInfo;
473 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
474 VerifyResourceTile4<true>(ResourceInfo, true);
475
476 // find the miptail start level
477 {
478 uint32_t MipWidth = gmmParams.BaseWidth64;
479 uint32_t MipHeight = gmmParams.BaseHeight;
480 while(!(MipWidth <= MtsWidth[i] && MipHeight <= MtsHeight[i]))
481 {
482 MipTailStartLod++;
483 MipWidth = (uint32_t)(GMM_ULT_MAX(1, gmmParams.BaseWidth64 >> MipTailStartLod));
484 MipHeight = GMM_ULT_MAX(1, gmmParams.BaseHeight >> MipTailStartLod);
485 }
486 }
487
488 // Mip resource Aligned Width calculation
489 Mip0Width = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign[i]);
490 Mip1Width = GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> 1, HAlign[i]);
491 Mip2Width = GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> 2, HAlign[i]);
492 AlignedWidth = GMM_ULT_MAX(Mip0Width, Mip1Width + Mip2Width);
493
494 Mip0Height = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign[i]);
495 if(MipTailStartLod == 2)
496 {
497 //EXPECT_EQ(2, ResourceInfo->GetPackedMipTailStartLod());
498 // Block height...Mip0Height + Max(Mip1Height, Sum of Mip2Height..MipnHeight)
499 Mip1Height = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 1, VAlign[i]);
500 Mip2Height = Mip2Higher = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 2, VAlign[i]);
501 }
502 else if(MipTailStartLod == 3)
503 {
504 //EXPECT_EQ(3, ResourceInfo->GetPackedMipTailStartLod());
505 // Block height...Mip0Height + Max(Mip1Height, Sum of Mip2Height..MipnHeight)
506 Mip1Height = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 1, VAlign[i]);
507 Mip2Height = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 2, VAlign[i]);
508 // Miptail started lod
509 MipTailHeight = VAlign[i];
510 Mip2Higher = Mip2Height + MipTailHeight;
511 }
512 else if(MipTailStartLod == 4)
513 {
514 //EXPECT_EQ(4, ResourceInfo->GetPackedMipTailStartLod());
515 // Block height...Mip0Height + Max(Mip1Height, Sum of Mip2Height..MipnHeight)
516 Mip1Height = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 1, VAlign[i]);
517 Mip2Height = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 2, VAlign[i]);
518 Mip3Height = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 3, VAlign[i]);
519 // Miptail started lod
520 MipTailHeight = VAlign[i];
521 Mip2Higher = Mip2Height + Mip3Height + MipTailHeight;
522 }
523
524 uint32_t MaxHeight = GMM_ULT_MAX(Mip1Height, Mip2Higher);
525 AlignedHeight = Mip0Height + MaxHeight;
526 AlignedHeight = GMM_ULT_ALIGN(AlignedHeight, VAlign[i]);
527
528 ExpectedPitch = AlignedWidth * GetBppValue(bpp);
529 ExpectedPitch = GMM_ULT_ALIGN(ExpectedPitch, GMM_BYTES(32));
530 //VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
531
532 //VerifyResourcePitchInTiles<true>(ResourceInfo, static_cast<uint32_t>(ExpectedPitch / TileSize[i][0]));
533 //VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(ExpectedPitch * AlignedHeight * gmmParams.ArraySize, PAGE_SIZE));
534 //VerifyResourceQPitch<false>(ResourceInfo, AlignedHeight);
535
536 // Mip 0 offsets, offset is 0,0
537 GMM_REQ_OFFSET_INFO ReqInfo = {0};
538 ReqInfo.MipLevel = 0;
539 ReqInfo.ReqRender = 1;
540 ResourceInfo->GetOffset(ReqInfo);
541 uint32_t Mip0Size = ExpectedPitch * Mip0Height;
542 //EXPECT_EQ(0, ReqInfo.Render.Offset64);
543 //EXPECT_EQ(0, ReqInfo.Render.XOffset);
544 //EXPECT_EQ(0, ReqInfo.Render.YOffset);
545
546 // Mip 1 offsets
547 ReqInfo = {0};
548 ReqInfo.MipLevel = 1;
549 ReqInfo.ReqRender = 1;
550 ResourceInfo->GetOffset(ReqInfo);
551 uint32_t Mip1Offset = Mip0Size;
552 //EXPECT_EQ(Mip1Offset, ReqInfo.Render.Offset64);
553 //EXPECT_EQ(0, ReqInfo.Render.XOffset);
554 //EXPECT_EQ(0, ReqInfo.Render.YOffset);
555
556 // Mip 2 offset
557 ReqInfo = {0};
558 ReqInfo.MipLevel = 2;
559 ReqInfo.ReqRender = 1;
560 ResourceInfo->GetOffset(ReqInfo);
561 uint32_t Mip2Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
562 uint32_t Mip2X = GFX_ALIGN_FLOOR(uint32_t(Mip2Offset % ExpectedPitch), TileSize[i][0]);
563 uint32_t Mip2Y = GFX_ALIGN_FLOOR(uint32_t(Mip2Offset / ExpectedPitch), TileSize[i][1]);
564 uint32_t Mip2RenderAlignedOffset = Mip2Y * ExpectedPitch + (Mip2X / TileSize[i][0]) * (TileSize[i][0] * TileSize[i][1]);
565 //EXPECT_EQ(Mip2RenderAlignedOffset, ReqInfo.Render.Offset64);
566 switch(bpp)
567 {
568 case TEST_BPP_8:
569 //EXPECT_EQ(128, ReqInfo.Render.XOffset);
570 //EXPECT_EQ(0, ReqInfo.Render.YOffset);
571 break;
572 case TEST_BPP_16:
573 //EXPECT_EQ(256, ReqInfo.Render.XOffset);
574 //EXPECT_EQ(0, ReqInfo.Render.YOffset);
575 break;
576 case TEST_BPP_32:
577 //EXPECT_EQ(0, ReqInfo.Render.XOffset);
578 //EXPECT_EQ(0, ReqInfo.Render.YOffset);
579 break;
580 case TEST_BPP_64:
581 //EXPECT_EQ(0, ReqInfo.Render.XOffset);
582 //EXPECT_EQ(0, ReqInfo.Render.YOffset);
583 break;
584 case TEST_BPP_128:
585 //EXPECT_EQ(0, ReqInfo.Render.XOffset);
586 //EXPECT_EQ(0, ReqInfo.Render.YOffset);
587 break;
588 default:
589 break;
590 }
591
592 // Mip 3 offset
593 ReqInfo = {0};
594 ReqInfo.MipLevel = 3;
595 ReqInfo.ReqRender = 1;
596 ResourceInfo->GetOffset(ReqInfo);
597 uint32_t Mip3Offset = 0;
598 switch(bpp)
599 {
600 case TEST_BPP_8:
601 Mip3Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
602 //EXPECT_EQ(0, ReqInfo.Render.XOffset);
603 //EXPECT_EQ(128, ReqInfo.Render.YOffset);
604 break;
605 case TEST_BPP_16:
606 Mip3Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
607 //EXPECT_EQ(0, ReqInfo.Render.XOffset);
608 //EXPECT_EQ(64, ReqInfo.Render.YOffset);
609 break;
610 case TEST_BPP_32:
611 Mip3Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + Mip2Height) * ExpectedPitch;
612 //EXPECT_EQ(256, ReqInfo.Render.XOffset);
613 //EXPECT_EQ(0, ReqInfo.Render.YOffset);
614 break;
615 case TEST_BPP_64:
616 Mip3Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + Mip2Height) * ExpectedPitch;
617 //EXPECT_EQ(512, ReqInfo.Render.XOffset);
618 //EXPECT_EQ(0, ReqInfo.Render.YOffset);
619 break;
620 case TEST_BPP_128:
621 Mip3Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + Mip2Height) * ExpectedPitch;
622 //EXPECT_EQ(0, ReqInfo.Render.XOffset);
623 //EXPECT_EQ(0, ReqInfo.Render.YOffset);
624 break;
625 default:
626 break;
627 }
628 uint32_t Mip3X = GFX_ALIGN_FLOOR(uint32_t(Mip3Offset % ExpectedPitch), TileSize[i][0]);
629 uint32_t Mip3Y = GFX_ALIGN_FLOOR(uint32_t(Mip3Offset / ExpectedPitch), TileSize[i][1]);
630 uint32_t Mip3RenderAlignedOffset = Mip3Y * ExpectedPitch + (Mip3X / TileSize[i][0]) * (TileSize[i][0] * TileSize[i][1]);
631 //EXPECT_EQ(Mip3RenderAlignedOffset, ReqInfo.Render.Offset64);
632
633 // Mip 4 offset
634 ReqInfo = {0};
635 ReqInfo.MipLevel = 4;
636 ReqInfo.ReqRender = 1;
637 ResourceInfo->GetOffset(ReqInfo);
638 uint32_t Mip4Offset = 0;
639 switch(bpp)
640 {
641 case TEST_BPP_8:
642 Mip4Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
643 //EXPECT_EQ(64, ReqInfo.Render.XOffset);
644 //EXPECT_EQ(0, ReqInfo.Render.YOffset);
645 break;
646 case TEST_BPP_16:
647 Mip4Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
648 //EXPECT_EQ(128, ReqInfo.Render.XOffset);
649 //EXPECT_EQ(0, ReqInfo.Render.YOffset);
650 break;
651 case TEST_BPP_32:
652 Mip4Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + Mip2Height) * ExpectedPitch;
653 //EXPECT_EQ(0, ReqInfo.Render.XOffset);
654 //EXPECT_EQ(64, ReqInfo.Render.YOffset);
655 break;
656 case TEST_BPP_64:
657 Mip4Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + Mip2Height) * ExpectedPitch;
658 //EXPECT_EQ(0, ReqInfo.Render.XOffset);
659 //EXPECT_EQ(32, ReqInfo.Render.YOffset);
660 break;
661 case TEST_BPP_128:
662 Mip4Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + Mip2Height + Mip3Height) * ExpectedPitch;
663 //EXPECT_EQ(512, ReqInfo.Render.XOffset);
664 //EXPECT_EQ(0, ReqInfo.Render.YOffset);
665 break;
666 default:
667 break;
668 }
669 uint32_t Mip4X = GFX_ALIGN_FLOOR(uint32_t(Mip4Offset % ExpectedPitch), TileSize[i][0]);
670 uint32_t Mip4Y = GFX_ALIGN_FLOOR(uint32_t(Mip4Offset / ExpectedPitch), TileSize[i][1]);
671 uint32_t Mip4RenderAlignedOffset = Mip4Y * ExpectedPitch + (Mip4X / TileSize[i][0]) * (TileSize[i][0] * TileSize[i][1]);
672 //EXPECT_EQ(Mip4RenderAlignedOffset, ReqInfo.Render.Offset64);
673
674 // Mip 5 offset
675 ReqInfo = {0};
676 ReqInfo.MipLevel = 4;
677 ReqInfo.ReqRender = 1;
678 ResourceInfo->GetOffset(ReqInfo);
679 uint32_t Mip5Offset = 0;
680 switch(bpp)
681 {
682 case TEST_BPP_8:
683 Mip5Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
684 //EXPECT_EQ(64, ReqInfo.Render.XOffset);
685 //EXPECT_EQ(0, ReqInfo.Render.YOffset);
686 break;
687 case TEST_BPP_16:
688 Mip5Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
689 //EXPECT_EQ(128, ReqInfo.Render.XOffset);
690 //EXPECT_EQ(0, ReqInfo.Render.YOffset);
691 break;
692 case TEST_BPP_32:
693 Mip5Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + Mip2Height) * ExpectedPitch;
694 //EXPECT_EQ(0, ReqInfo.Render.XOffset);
695 //EXPECT_EQ(64, ReqInfo.Render.YOffset);
696 break;
697 case TEST_BPP_64:
698 Mip5Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + Mip2Height) * ExpectedPitch;
699 //EXPECT_EQ(0, ReqInfo.Render.XOffset);
700 //EXPECT_EQ(32, ReqInfo.Render.YOffset);
701 break;
702 case TEST_BPP_128:
703 Mip5Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + Mip2Height + Mip3Height) * ExpectedPitch;
704 //EXPECT_EQ(512, ReqInfo.Render.XOffset);
705 //EXPECT_EQ(0, ReqInfo.Render.YOffset);
706 break;
707 default:
708 break;
709 }
710 uint32_t Mip5X = GFX_ALIGN_FLOOR(uint32_t(Mip4Offset % ExpectedPitch), TileSize[i][0]);
711 uint32_t Mip5Y = GFX_ALIGN_FLOOR(uint32_t(Mip4Offset / ExpectedPitch), TileSize[i][1]);
712 uint32_t Mip5RenderAlignedOffset = Mip5Y * ExpectedPitch + (Mip5X / TileSize[i][0]) * (TileSize[i][0] * TileSize[i][1]);
713 //EXPECT_EQ(Mip5RenderAlignedOffset, ReqInfo.Render.Offset64);
714
715 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
716 }
717 }
718
719 /// @brief ULT for 3D Tile64 Resource Optimization
TEST_F(CTestGen12dGPUResource,DISABLED_Test3DTile64ResourceOptimization)720 TEST_F(CTestGen12dGPUResource, DISABLED_Test3DTile64ResourceOptimization)
721 {
722 const uint32_t TileSize[TEST_BPP_MAX][2] = {{256, 256},
723 {512, 128},
724 {512, 128},
725 {1024, 64},
726 {1024, 64}};
727
728 GMM_RESCREATE_PARAMS gmmParams = {};
729
730 gmmParams.Type = RESOURCE_3D;
731 gmmParams.Format = GMM_FORMAT_R8G8B8A8_UNORM;
732 gmmParams.NoGfxMemory = 1;
733 gmmParams.Flags.Gpu.Texture = 1;
734 // TiledResource set 0 - allow to enter in Tile64 optimization logic
735 gmmParams.Flags.Gpu.TiledResource = 0;
736 gmmParams.ArraySize = 6;
737 gmmParams.BaseWidth64 = 1;
738 gmmParams.BaseHeight = 1;
739 gmmParams.Depth = 1;
740
741 GMM_RESOURCE_INFO *ResourceInfo;
742
743 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
744 // Check if Tile4 info flag
745 VerifyResourceTile4<true>(ResourceInfo, true);
746 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
747
748 gmmParams.Type = RESOURCE_3D;
749 gmmParams.BaseWidth64 = 128;
750 gmmParams.BaseHeight = 128;
751 gmmParams.NoGfxMemory = 1;
752 gmmParams.Flags.Gpu.Texture = 1;
753 gmmParams.Depth = 1;
754 // TiledResource set 0 - allow to enter in Tile64 optimization logic
755 gmmParams.Flags.Gpu.TiledResource = 0;
756 gmmParams.ArraySize = 960;
757 gmmParams.Flags.Info.Tile4 = 0;
758 gmmParams.Flags.Info.Tile64 = 0;
759
760 gmmParams.Format = GMM_FORMAT_BC6H;
761 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
762 // Check if Tile4 info flag
763 VerifyResourceTile4<true>(ResourceInfo, true);
764 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
765
766
767 // Allocate surface that requires multi tiles in two dimension
768 // Allocate 2 tiles in X dimension
769 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
770 {
771 TEST_BPP bpp = static_cast<TEST_BPP>(i);
772 gmmParams.Type = RESOURCE_3D;
773 gmmParams.Format = SetResourceFormat(bpp);
774 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
775 gmmParams.BaseHeight = 0x1;
776 gmmParams.Depth = 0x1;
777 // TiledResource set 0 - allow to enter in Tile64 optimization logic
778 gmmParams.Flags.Gpu.TiledResource = 0;
779 gmmParams.Flags.Info.Tile4 = 0;
780 gmmParams.Flags.Info.Tile64 = 0;
781
782 GMM_RESOURCE_INFO *ResourceInfo;
783 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
784
785 // Check if Tile4 is set or not
786 VerifyResourceTile4<true>(ResourceInfo, true);
787
788 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
789 }
790
791 // Allocate 2 tiles in X/Y dimension
792 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
793 {
794 TEST_BPP bpp = static_cast<TEST_BPP>(i);
795 gmmParams.Type = RESOURCE_3D;
796 gmmParams.Format = GMM_FORMAT_R8G8B8A8_UNORM; //SetResourceFormat(bpp);
797 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
798 gmmParams.BaseHeight = TileSize[i][1] + 1; // 1 row larger than 1 tile height
799 gmmParams.Depth = 0x1;
800 gmmParams.Flags.Info.Tile4 = 0;
801 gmmParams.Flags.Info.Tile64 = 0;
802
803 GMM_RESOURCE_INFO *ResourceInfo;
804 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
805
806 // Check if Tile4 is set or not
807 VerifyResourceTile4<true>(ResourceInfo, true);
808
809 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
810 }
811 }
812
813 /// @brief ULT for 2D TileYf Compressed Resource
TEST_F(CTestGen12dGPUResource,DISABLED_Test2DTileYfCompressedResource)814 TEST_F(CTestGen12dGPUResource, DISABLED_Test2DTileYfCompressedResource)
815 {
816 const uint32_t HAlign[TEST_BPP_MAX] = {64, 64, 32, 32, 16};
817 const uint32_t VAlign[TEST_BPP_MAX] = {64, 32, 32, 16, 16};
818
819 const uint32_t TileSize[TEST_BPP_MAX][2] = {{64, 64},
820 {128, 32},
821 {128, 32},
822 {256, 16},
823 {256, 16}};
824
825 GMM_RESCREATE_PARAMS gmmParams = {};
826 gmmParams.Type = RESOURCE_2D;
827 gmmParams.NoGfxMemory = 1;
828 gmmParams.Flags.Info.TiledY = 1;
829 gmmParams.Flags.Info.TiledYf = 1;
830 gmmParams.Flags.Gpu.Texture = 1;
831 gmmParams.Flags.Info.RenderCompressed = 1;
832 // Turn on .MC or .RC flag - mandatory to tell compression-type, for Yf its also used to pad surf
833 // to 4x1 tile (reqd by HW )
834 // If unifiedAuxSurf reqd (mandatory for displayable or cross-adapter shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
835
836 //Allocate 1x1 surface
837 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
838 {
839 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
840 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
841
842 TEST_BPP bpp = static_cast<TEST_BPP>(i);
843 GMM_TILE_MODE TileMode = DEFINE_TILE(YF_2D, bpp);
844 gmmParams.Format = SetResourceFormat(bpp);
845 gmmParams.BaseWidth64 = 0x1;
846 gmmParams.BaseHeight = 0x1;
847
848 GMM_RESOURCE_INFO *ResourceInfo;
849 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
850
851 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
852 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
853 VerifyResourcePitch<true>(ResourceInfo, 4 * TileSize[i][0]); // As wide as 4 Tile
854 VerifyResourcePitchInTiles<true>(ResourceInfo, 4); // 4 Tile wide
855 VerifyResourceSize<true>(ResourceInfo, 4 * GMM_KBYTE(4)); // 4 Tile Big
856 VerifyResourceQPitch<false>(ResourceInfo, 0);
857
858 //test main surface base alignment is 16KB
859 //For Yf/Y test main surface pitch is 4-tileYF/Y aligned
860 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
861 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4);
862
863 if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
864 {
865 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
866 EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
867 }
868
869 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
870
871 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
872 }
873
874 // Allocate surface that requires multi tiles in two dimension
875 // Allocate 2 tiles in X dimension
876 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
877 {
878 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
879 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
880
881 TEST_BPP bpp = static_cast<TEST_BPP>(i);
882 GMM_TILE_MODE TileMode = DEFINE_TILE(YF_2D, bpp);
883 gmmParams.Format = SetResourceFormat(bpp);
884 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
885 gmmParams.BaseHeight = 0x1;
886 gmmParams.Depth = 0x1;
887
888 GMM_RESOURCE_INFO *ResourceInfo;
889 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
890
891 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
892 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
893 VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0] * 4); // As wide as 2 tile, but 4-tile pitch alignment
894 VerifyResourcePitchInTiles<true>(ResourceInfo, 4); // 2 tile wide, but 4-tile pitch alignment
895 VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * 4); // 2 tile big, but 4-tile pitch alignment
896
897 VerifyResourceQPitch<false>(ResourceInfo, 0);
898
899 //test main surface base alignment is 16KB
900 //For Yf/Y test main surface pitch is 4-tileYF/Y aligned
901 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
902 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4);
903
904 if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
905 {
906 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
907 EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
908 }
909
910 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
911
912 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
913 }
914
915 // Allocate surface that requires multi tiles in two dimension
916 // Allocate 2 tiles in X/Y dimension
917 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
918 {
919 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
920 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
921
922 TEST_BPP bpp = static_cast<TEST_BPP>(i);
923 GMM_TILE_MODE TileMode = DEFINE_TILE(YF_2D, bpp);
924 gmmParams.Format = SetResourceFormat(bpp);
925 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
926 gmmParams.BaseHeight = TileSize[i][1] + 1; // 1 row larger than 1 tile height
927 gmmParams.Depth = 0x1;
928
929 GMM_RESOURCE_INFO *ResourceInfo;
930 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
931
932 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
933 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
934 VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0] * 4); // As wide as 2 tile, but 4-tile pitch alignment
935 VerifyResourcePitchInTiles<true>(ResourceInfo, 4); // 2 tile wide, but 4-tile pitch alignment
936 VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * 4 * 2); // 4 tile wide; and 2-tile high
937
938 VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
939 //test main surface base alignment is 16KB
940 //For Yf/Y test main surface pitch is 4-tileYF/Y aligned
941 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
942 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4);
943
944
945 if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
946 {
947 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
948 EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
949 }
950 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
951
952 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
953 }
954 }
955
956 /// @brief ULT for 2D TileY Compressed Resource
TEST_F(CTestGen12dGPUResource,DISABLED_Test2DTileYCompressedResource)957 TEST_F(CTestGen12dGPUResource, DISABLED_Test2DTileYCompressedResource)
958 {
959 const uint32_t HAlign = {16};
960 const uint32_t VAlign = {4};
961
962 const uint32_t TileSize[2] = {128, 32};
963
964 GMM_RESCREATE_PARAMS gmmParams = {};
965 gmmParams.Type = RESOURCE_2D;
966 gmmParams.NoGfxMemory = 1;
967 gmmParams.Flags.Info.TiledY = 1;
968
969 gmmParams.Flags.Gpu.Texture = 1;
970 gmmParams.Flags.Info.RenderCompressed = 1;
971 // Turn on .MC or .RC flag - mandatory to tell compression-type, for Yf/Y its also used to pad surf
972 // to 4x1 tile (reqd by HW for perf reasons)
973 // If unifiedAuxSurf reqd (mandatory for displayable or cross-adapter shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
974
975 //Allocate 1x1 surface
976 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
977 {
978 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
979 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
980
981 TEST_BPP bpp = static_cast<TEST_BPP>(i);
982 GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
983 gmmParams.Format = SetResourceFormat(bpp);
984 gmmParams.BaseWidth64 = 0x1;
985 gmmParams.BaseHeight = 0x1;
986
987 GMM_RESOURCE_INFO *ResourceInfo;
988 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
989
990 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
991 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
992 VerifyResourcePitch<true>(ResourceInfo, 4 * TileSize[0]); // As wide as 4 Tile
993 VerifyResourcePitchInTiles<true>(ResourceInfo, 4); // 4 Tile wide
994 VerifyResourceSize<true>(ResourceInfo, 4 * GMM_KBYTE(4)); // 4 Tile Big
995 VerifyResourceQPitch<false>(ResourceInfo, 0);
996
997 //test main surface base alignment is 16KB
998 //For Yf/Y test main surface pitch is 4-tileYF/Y aligned
999 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1000 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4);
1001
1002 if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1003 {
1004 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1005 EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1006 }
1007 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1008
1009 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1010 }
1011
1012 // Allocate surface that requires multi tiles in two dimension
1013 // Allocate 2 tiles in X dimension
1014 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1015 {
1016 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
1017 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
1018
1019 TEST_BPP bpp = static_cast<TEST_BPP>(i);
1020 GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
1021 gmmParams.Format = SetResourceFormat(bpp);
1022 gmmParams.BaseWidth64 = (TileSize[0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
1023 gmmParams.BaseHeight = 0x1;
1024 gmmParams.Depth = 0x1;
1025
1026 GMM_RESOURCE_INFO *ResourceInfo;
1027 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1028
1029 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
1030 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
1031 VerifyResourcePitch<true>(ResourceInfo, TileSize[0] * 4); // As wide as 2 tile, but 4-tile pitch alignment
1032 VerifyResourcePitchInTiles<true>(ResourceInfo, 4); // 2 tile wide, but 4-tile pitch alignment
1033 VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * 4); // 2 tile big, but 4-tile pitch alignment
1034
1035 VerifyResourceQPitch<false>(ResourceInfo, 0);
1036
1037 //test main surface base alignment is 16KB
1038 //For Yf test main surface pitch is 4-tileYF aligned
1039 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1040 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
1041
1042 if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1043 {
1044 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1045 EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1046 }
1047 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1048
1049 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1050 }
1051
1052 // Allocate surface that requires multi tiles in two dimension
1053 // Allocate 2 tiles in X/Y dimension
1054 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1055 {
1056 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
1057 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
1058
1059 TEST_BPP bpp = static_cast<TEST_BPP>(i);
1060 GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
1061 gmmParams.Format = SetResourceFormat(bpp);
1062 gmmParams.BaseWidth64 = (TileSize[0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
1063 gmmParams.BaseHeight = TileSize[1] + 1; // 1 row larger than 1 tile height
1064 gmmParams.Depth = 0x1;
1065
1066 GMM_RESOURCE_INFO *ResourceInfo;
1067 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1068
1069 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
1070 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
1071 VerifyResourcePitch<true>(ResourceInfo, TileSize[0] * 4); // As wide as 2 tile, but 4-tile pitch alignment
1072 VerifyResourcePitchInTiles<true>(ResourceInfo, 4); // 2 tile wide, but 4-tile pitch alignment
1073 VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * 4 * 2); // 4 tile wide; and 2-tile high
1074
1075 VerifyResourceQPitch<false>(ResourceInfo, 0);
1076 //test main surface base alignment is 16KB
1077 //For Yf/Y test main surface pitch is 4-tileYF/Y aligned
1078 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1079 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
1080
1081 if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1082 {
1083 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1084 EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1085 }
1086 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1087
1088 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1089 }
1090 }
1091
1092 /// @brief ULT for 2D TileY lossless Compressed lossy Resource
TEST_F(CTestGen12dGPUResource,DISABLED_Test2DTileYLossyCompressedResource)1093 TEST_F(CTestGen12dGPUResource, DISABLED_Test2DTileYLossyCompressedResource)
1094 {
1095 const uint32_t HAlign = {4};
1096 const uint32_t VAlign = {4};
1097
1098 const uint32_t TileSize[2] = {128, 32};
1099
1100 GMM_RESCREATE_PARAMS gmmParams = {};
1101 gmmParams.Type = RESOURCE_2D;
1102 gmmParams.NoGfxMemory = 1;
1103 gmmParams.Flags.Info.TiledY = 1;
1104
1105 gmmParams.Flags.Gpu.Texture = 1;
1106 gmmParams.Flags.Info.RenderCompressed = 1;
1107 // Turn on .MC or .RC flag - mandatory to tell compression-type, for Yf its also used to pad surf
1108 // to 4x1 tile (reqd by HW for perf reasons)
1109 // If unifiedAuxSurf reqd (mandatory for displayable or cross-adapter shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
1110
1111 //Allocate 1x1 surface
1112 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1113 {
1114 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
1115 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
1116
1117 TEST_BPP bpp = static_cast<TEST_BPP>(i);
1118 GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
1119 gmmParams.Format = GMM_FORMAT_ETC2_RGB8;
1120 gmmParams.BaseWidth64 = 0x80;
1121 gmmParams.BaseHeight = 0x20;
1122
1123 GMM_RESOURCE_INFO *ResourceInfo;
1124 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1125
1126 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
1127 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
1128 VerifyResourcePitch<true>(ResourceInfo, 4 * TileSize[0]); // As wide as 4 Tile
1129 VerifyResourcePitchInTiles<true>(ResourceInfo, 4); // 4 Tile wide
1130 VerifyResourceSize<true>(ResourceInfo, 4 * GMM_KBYTE(4)); // 4 Tile Big
1131 VerifyResourceQPitch<false>(ResourceInfo, 0);
1132
1133 //test main surface base alignment is 16KB
1134 //For Yf/Y test main surface pitch is 4-tileYF/Y aligned
1135 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1136 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4);
1137
1138 if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1139 {
1140 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1141 EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1142 }
1143 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1144
1145 { //separate Aux
1146 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1147
1148 GMM_RESOURCE_INFO *AuxResourceInfo;
1149 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1150 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
1151 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
1152 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
1153 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1154
1155 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1156 }
1157 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1158 }
1159
1160 // Allocate surface that requires multi tiles in two dimension
1161 // Allocate 2 tiles in X dimension
1162 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1163 {
1164 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
1165 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
1166
1167 TEST_BPP bpp = static_cast<TEST_BPP>(i);
1168 GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
1169 gmmParams.Format = GMM_FORMAT_ETC2_RGB8;
1170 gmmParams.BaseWidth64 = (TileSize[0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
1171 gmmParams.BaseHeight = 0x1;
1172 gmmParams.Depth = 0x1;
1173
1174 GMM_RESOURCE_INFO *ResourceInfo;
1175 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1176
1177 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
1178 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
1179 VerifyResourcePitch<true>(ResourceInfo, TileSize[0] * 4); // As wide as 2 tile, but 4-tile pitch alignment
1180 VerifyResourcePitchInTiles<true>(ResourceInfo, 4); // 2 tile wide, but 4-tile pitch alignment
1181 VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * 4); // 2 tile big, but 4-tile pitch alignment
1182
1183 VerifyResourceQPitch<false>(ResourceInfo, 0);
1184
1185 //test main surface base alignment is 16KB
1186 //For Yf/Y test main surface pitch is 4-tileYF/Y aligned
1187 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1188 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4);
1189
1190 if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1191 {
1192 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1193 EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1194 }
1195
1196 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1197
1198 { //separate Aux
1199 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1200
1201 GMM_RESOURCE_INFO *AuxResourceInfo;
1202 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1203 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
1204 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
1205 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
1206 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1207
1208 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1209 }
1210 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1211 }
1212
1213 // Allocate surface that requires multi tiles in two dimension
1214 // Allocate 2 tiles in X/Y dimension
1215 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1216 {
1217 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
1218 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
1219
1220 TEST_BPP bpp = static_cast<TEST_BPP>(i);
1221 GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
1222 gmmParams.Format = GMM_FORMAT_ETC2_RGB8;
1223 gmmParams.BaseWidth64 = (TileSize[0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
1224 gmmParams.BaseHeight = TileSize[1] + 1; // 1 row larger than 1 tile height
1225 gmmParams.Depth = 0x1;
1226
1227 GMM_RESOURCE_INFO *ResourceInfo;
1228 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1229
1230 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
1231 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
1232 VerifyResourcePitch<true>(ResourceInfo, TileSize[0] * 4); // As wide as 2 tile, but 4-tile pitch alignment
1233 VerifyResourcePitchInTiles<true>(ResourceInfo, 4); // 2 tile wide, but 4-tile pitch alignment
1234 VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * 4); // 4 tile wide; max compressed height = 0x24/4 = 9, so fits in 1 tile-height
1235
1236 VerifyResourceQPitch<false>(ResourceInfo, 0);
1237 //test main surface base alignment is 16KB
1238 //For Yf/Y test main surface pitch is 4-tileYF/Y aligned
1239 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1240 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4);
1241
1242 if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1243 {
1244 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1245 EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1246 }
1247
1248 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1249
1250 { //separate Aux
1251 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1252
1253 GMM_RESOURCE_INFO *AuxResourceInfo;
1254 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1255 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
1256 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
1257 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
1258 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1259
1260 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1261 }
1262 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1263 }
1264 }
1265
1266 //Y416(64bpp -how is 10/12/16bit depth given?)
1267 //Y410(32bpp), Y216(64bpp), YCRCB_NORMAL(16bpp), YCRCB_SWAPUV(16bpp),
1268 //YCRCB_SWAPUVY(16bpp), YCRCB_SWAPY(16bpp)
1269
1270 /// @brief ULT for Planar Compressed Resource
TEST_F(CTestGen12dGPUResource,DISABLED_TestPlanarYfCompressedResource)1271 TEST_F(CTestGen12dGPUResource, DISABLED_TestPlanarYfCompressedResource)
1272 {
1273 const uint32_t TileSize[TEST_BPP_MAX][2] = {
1274 {64, 64}, {128, 32}, {128, 32}, {256, 16}, {256, 16}}; // TileYf
1275
1276 GMM_RESCREATE_PARAMS gmmParams = {};
1277 gmmParams.Type = RESOURCE_2D;
1278 gmmParams.NoGfxMemory = 1;
1279 gmmParams.Flags.Gpu.Texture = 1;
1280 //gmmParams.Flags.Gpu.MMC = 1;
1281 gmmParams.Flags.Gpu.CCS = 1;
1282 gmmParams.Flags.Info.MediaCompressed = 1;
1283 gmmParams.BaseWidth64 = 0x100;
1284 gmmParams.BaseHeight = 0x50;
1285 gmmParams.Depth = 0x1;
1286 SetTileFlag(gmmParams, TEST_TILEYF); // TileYF only
1287
1288 //UV-Packed formats
1289 GMM_RESOURCE_FORMAT Format[4] = {GMM_FORMAT_NV12, GMM_FORMAT_NV21, GMM_FORMAT_P010, GMM_FORMAT_P016};
1290 for(auto fmt : Format)
1291 {
1292 gmmParams.Format = fmt; // 8bpp (NV12, NV21), 16bpp (P016,P010)
1293
1294 TEST_BPP Ybpp, UVbpp;
1295 //Yf/Ys could be accessed on CPU/app where UV plane bpp is double
1296 switch(pGmmULTClientContext->GetPlatformInfo().FormatTable[fmt].Element.BitsPer)
1297 {
1298 case 8:
1299 Ybpp = TEST_BPP_8;
1300 UVbpp = TEST_BPP_16;
1301 break;
1302 case 16:
1303 Ybpp = TEST_BPP_16;
1304 UVbpp = TEST_BPP_32;
1305 break;
1306 default:
1307 return;
1308 }
1309 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1;
1310
1311 /*Aux is TileY (later Linear), not redescribing, its bytes are allocated using one bpp*/
1312 GMM_TILE_MODE TileMode = DEFINE_TILE(YF_2D, Ybpp);
1313
1314 GMM_RESOURCE_INFO *ResourceInfo;
1315 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1316
1317 //Redescribed Pitch isn't modified unless Y, UV pitch differ
1318 //But, original Pitch is padded to have even Tile, hence use Ybpp ExpectedPitch
1319 //to verify Pitch, but redescribed size
1320 uint32_t ExpectedPitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64 * (int)pow(2.0, Ybpp), TileSize[Ybpp][0] * 4);
1321 uint32_t RedescribedPitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64 / 2 * (int)pow(2.0, UVbpp), TileSize[UVbpp][0] * 4);
1322
1323 //ExpectedPitch = GMM_ULT_ALIGN(ExpectedPitch, 2 * TileSize[Ybpp][0]); //pad to even tile
1324 if(ExpectedPitch != RedescribedPitch)
1325 {
1326 ExpectedPitch = RedescribedPitch;
1327 }
1328
1329 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
1330 VerifyResourcePitchInTiles<true>(ResourceInfo, ExpectedPitch / TileSize[Ybpp][0]);
1331
1332 int YSizeInTiles = (GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[Ybpp][1]) / TileSize[Ybpp][1]) *
1333 RedescribedPitch / TileSize[Ybpp][0];
1334 int UVSizeInTiles = (GMM_ULT_ALIGN(gmmParams.BaseHeight / 2, TileSize[UVbpp][1]) / TileSize[UVbpp][1]) *
1335 RedescribedPitch / TileSize[UVbpp][0];
1336
1337 VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * (YSizeInTiles + UVSizeInTiles));
1338 VerifyResourceHAlign<true>(ResourceInfo, TileSize[UVbpp][0] / pow(2.0, UVbpp)); // For Yf/Ys planar redescription causes UV width, Y height alignment
1339 VerifyResourceVAlign<true>(ResourceInfo, TileSize[Ybpp][1]);
1340 VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-mipped surface
1341
1342 //test main surface base alignment is 16KB
1343 //For Yf test main surface pitch is 4-tileYF aligned
1344 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1345 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
1346
1347 if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1348 {
1349 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1350 EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1351 }
1352
1353 EXPECT_EQ(GMM_KBYTE(4) * 2, ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS)); // Y and UV Aux are on separate tiles
1354
1355 { //separate Aux
1356 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1357
1358 GMM_RESOURCE_INFO *AuxResourceInfo;
1359 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1360
1361 EXPECT_EQ(GMM_KBYTE(4) * 2, AuxResourceInfo->GetSizeSurface());
1362
1363 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1364 }
1365 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1366 }
1367 }
1368
1369 /// @brief ULT for Planar Y Compressed Resource
TEST_F(CTestGen12dGPUResource,DISABLED_TestPlanarYCompressedResource)1370 TEST_F(CTestGen12dGPUResource, DISABLED_TestPlanarYCompressedResource)
1371 {
1372 const uint32_t TileSize[2] = {128, 32};
1373 const uint32_t HAlign = 16;
1374 const uint32_t VAlign = 4;
1375
1376 GMM_RESCREATE_PARAMS gmmParams = {};
1377 gmmParams.Type = RESOURCE_2D;
1378 gmmParams.NoGfxMemory = 1;
1379 gmmParams.Flags.Gpu.Texture = 1;
1380 gmmParams.Flags.Gpu.RenderTarget = 1;
1381 gmmParams.Flags.Gpu.MMC = 1;
1382 gmmParams.Flags.Gpu.CCS = 1;
1383 gmmParams.Flags.Gpu.IndirectClearColor = 1;
1384 gmmParams.Flags.Info.MediaCompressed = 1;
1385 gmmParams.Flags.Info.NotLockable = 1;
1386 gmmParams.Flags.Info.Cacheable = 1;
1387 gmmParams.BaseWidth64 = 0xB2;
1388 gmmParams.BaseHeight = 0x92;
1389 gmmParams.Depth = 0x1;
1390 SetTileFlag(gmmParams, TEST_TILEY); // TileYF only
1391
1392 GMM_RESOURCE_FORMAT Format[4] = {GMM_FORMAT_NV12, GMM_FORMAT_NV21, GMM_FORMAT_P010, GMM_FORMAT_P016};
1393 for(auto fmt : Format)
1394 {
1395 gmmParams.Format = fmt; // 8bpp (NV12, NV21), 16bpp (P016, P010)
1396
1397 TEST_BPP Ybpp, UVbpp;
1398 //Yf/Ys could be accessed on CPU/app where UV plane bpp is double
1399 switch(pGmmULTClientContext->GetPlatformInfo().FormatTable[fmt].Element.BitsPer)
1400 {
1401 case 8:
1402 Ybpp = TEST_BPP_8;
1403 UVbpp = TEST_BPP_16;
1404 break;
1405 case 16:
1406 Ybpp = TEST_BPP_16;
1407 UVbpp = TEST_BPP_32;
1408 break;
1409 default:
1410 return;
1411 }
1412 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1;
1413
1414 GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
1415 GMM_RESOURCE_INFO *ResourceInfo;
1416 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1417
1418 //Redescribed Pitch isn't modified unless Y, UV pitch differ
1419 //But, original Pitch is padded to have even Tile, hence use Ybpp ExpectedPitch
1420 //to verify Pitch, but redescribed size
1421 uint32_t ExpectedPitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64 * (int)pow(2.0, Ybpp), TileSize[0] * 4);
1422 uint32_t RedescribedPitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64 / 2 * (int)pow(2.0, UVbpp), TileSize[0] * 4);
1423
1424 //ExpectedPitch = GMM_ULT_ALIGN(ExpectedPitch, 2 * TileSize[Ybpp][0]); //pad to even tile
1425 if(ExpectedPitch != RedescribedPitch)
1426 {
1427 ExpectedPitch = RedescribedPitch;
1428 }
1429
1430 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
1431 VerifyResourcePitchInTiles<true>(ResourceInfo, ExpectedPitch / TileSize[0]);
1432
1433 int YSizeInTiles = (GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[1]) / TileSize[1]) *
1434 RedescribedPitch / TileSize[0];
1435 int UVSizeInTiles = (GMM_ULT_ALIGN(gmmParams.BaseHeight / 2, TileSize[1]) / TileSize[1]) *
1436 RedescribedPitch / TileSize[0];
1437
1438 VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * (YSizeInTiles + UVSizeInTiles)); //when main-surf planes are tile-aligned, make it verify-true
1439 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
1440 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
1441 VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-mipped surface
1442
1443 //test main surface base alignment is 16KB
1444 //For Yf test main surface pitch is 4-tileY aligned
1445 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1446 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4);
1447
1448 if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1449 {
1450 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1451 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_UV_CCS) % PAGE_SIZE);
1452 EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1453 }
1454 EXPECT_EQ(GMM_KBYTE(4) * 2, ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS)); // Y and UV Aux are on separate tiles
1455
1456 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1457 }
1458 }
1459
1460 /// @brief ULT for Planar Ys Compressed resource
TEST_F(CTestGen12dGPUResource,TestPlanarTile64CompressedResource)1461 TEST_F(CTestGen12dGPUResource, TestPlanarTile64CompressedResource)
1462 {
1463
1464 const uint32_t TileSize[TEST_BPP_MAX][2] = {
1465 {256, 256}, {512, 128}, {512, 128}, {1024, 64}, {1024, 64}}; // TileYS
1466
1467 GMM_RESCREATE_PARAMS gmmParams = {};
1468 gmmParams.Type = RESOURCE_2D;
1469 gmmParams.NoGfxMemory = 1;
1470 gmmParams.Flags.Gpu.Texture = 1;
1471 gmmParams.Flags.Gpu.MMC = 1;
1472 //gmmParams.Flags.Gpu.CCS = 1;
1473 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1;
1474 gmmParams.Flags.Info.MediaCompressed = 1;
1475 gmmParams.BaseWidth64 = 0x64;
1476 gmmParams.BaseHeight = 0x64;
1477 gmmParams.Depth = 0x1;
1478 gmmParams.ArraySize = 2;
1479
1480 GMM_RESOURCE_FORMAT Format[4] = {GMM_FORMAT_NV12, GMM_FORMAT_NV21, GMM_FORMAT_P010, GMM_FORMAT_P016};
1481 for(auto fmt : Format)
1482 {
1483 gmmParams.Format = fmt; // 8bpp(NV12) , P016 (16bpp), P010 (16bpp), NV21(8bpp)
1484
1485 TEST_BPP Ybpp, UVbpp;
1486 //could be accessed on CPU/app where UV plane bpp is double
1487 switch(pGmmULTClientContext->GetPlatformInfo().FormatTable[gmmParams.Format].Element.BitsPer)
1488 {
1489 case 8:
1490 Ybpp = TEST_BPP_8;
1491 UVbpp = TEST_BPP_16;
1492 break;
1493 case 16:
1494 Ybpp = TEST_BPP_16;
1495 UVbpp = TEST_BPP_32;
1496 break;
1497 default:
1498 return;
1499 }
1500
1501 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1;
1502
1503 GMM_RESOURCE_INFO *ResourceInfo;
1504 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1505
1506 GMM_REQ_OFFSET_INFO OffsetInfo = {};
1507
1508 OffsetInfo.ReqLock = 1;
1509 OffsetInfo.ReqRender = 1;
1510 OffsetInfo.Plane = GMM_PLANE_Y;
1511 OffsetInfo.ArrayIndex = 1;
1512 OffsetInfo.ReqStdLayout = 0;
1513 ResourceInfo->GetOffset(OffsetInfo);
1514
1515 // ToDo: add verification
1516 //{ //separate Aux
1517 // gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1518 // GMM_RESOURCE_INFO *AuxResourceInfo;
1519 // AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1520 // EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->G
1521
1522 // add verification
1523
1524 //{ //separate Aux
1525 // gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1526
1527 // GMM_RESOURCE_INFO *AuxResourceInfo;
1528 // AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1529
1530 // EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1531
1532 // pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1533 //}
1534
1535 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1536 }
1537 }
1538
1539 /// @brief ULT for 2D arrayed compressed Resource
TEST_F(CTestGen12dGPUResource,TestArrayedCompressedResource)1540 TEST_F(CTestGen12dGPUResource, TestArrayedCompressedResource)
1541 {
1542 //printf("%s\n", __FUNCTION__);
1543 //Test for 3D array
1544 }
1545
1546 /// @brief ULT for mip-mapped compressed Resource
TEST_F(CTestGen12dGPUResource,TestMipMapCompressedResource)1547 TEST_F(CTestGen12dGPUResource, TestMipMapCompressedResource)
1548 {
1549 //printf("%s\n", __FUNCTION__);
1550 }
1551
1552 /// @brief ULT for cube Compressed Resource
TEST_F(CTestGen12dGPUResource,DISABLED_TestCubeCompressedResource)1553 TEST_F(CTestGen12dGPUResource, DISABLED_TestCubeCompressedResource)
1554 {
1555 //Tests 2D array
1556 const uint32_t HAlign[5][TEST_BPP_MAX] = {{0}, {0}, {0}, {256, 256, 128, 128, 64}, {64, 64, 32, 32, 16}};
1557 const uint32_t VAlign[5][TEST_BPP_MAX] = {{0}, {0}, {0}, {256, 128, 128, 64, 64}, {64, 32, 32, 16, 16}};
1558
1559 const TEST_TILE_TYPE TileTypeSupported[2] = {TEST_TILEYS, TEST_TILEYF};
1560
1561 const uint32_t TileSize[5][TEST_BPP_MAX][2] = {
1562 {0},
1563 {0},
1564 {0},
1565 {{256, 256}, {512, 128}, {512, 128}, {1024, 64}, {1024, 64}}, // TileYS
1566 {{64, 64}, {128, 32}, {128, 32}, {256, 16}, {256, 16}}}; //TileYf
1567
1568 GMM_RESCREATE_PARAMS gmmParams = {};
1569 gmmParams.Type = RESOURCE_CUBE;
1570 gmmParams.NoGfxMemory = 1;
1571 gmmParams.Flags.Gpu.Texture = 1;
1572 gmmParams.Flags.Info.RenderCompressed = 1;
1573
1574 // Allocate 1x1 surface so that it occupies 1 Tile in X dimension
1575 for(auto Tiling : TileTypeSupported)
1576 {
1577 gmmParams.Flags.Info.TiledY = 1;
1578 gmmParams.Flags.Info.TiledYf = (Tiling == TEST_TILEYF);
1579 gmmParams.Flags.Info.TiledYs = (Tiling == TEST_TILEYS);
1580 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1581 {
1582 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1;
1583 gmmParams.Flags.Gpu.CCS = 1;
1584
1585 TEST_BPP bpp = static_cast<TEST_BPP>(i);
1586 GMM_TILE_MODE TileMode = (Tiling == TEST_TILEYF) ? DEFINE_TILE(YF_2D, bpp) : DEFINE_TILE(YS_2D, bpp);
1587
1588 gmmParams.Format = SetResourceFormat(bpp);
1589 gmmParams.BaseWidth64 = 0x1;
1590 gmmParams.BaseHeight = 0x1;
1591 gmmParams.Depth = 0x1;
1592
1593 GMM_RESOURCE_INFO *ResourceInfo;
1594 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1595
1596 VerifyResourceHAlign<true>(ResourceInfo, HAlign[Tiling][i]);
1597 VerifyResourceVAlign<true>(ResourceInfo, VAlign[Tiling][i]);
1598
1599 uint32_t ExpectedPitch = 4 * TileSize[TEST_TILEYF][i][0];
1600 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch); // As wide as 4 tile-YF
1601 VerifyResourcePitchInTiles<true>(ResourceInfo, (Tiling == TEST_TILEYF) ? 4 : 1); // 1 tile wide
1602
1603 uint32_t ExpectedQPitch = VAlign[Tiling][i];
1604 VerifyResourceQPitch<true>(ResourceInfo, ExpectedQPitch); // Each face should be VAlign rows apart within a tile
1605
1606 VerifyResourceSize<true>(ResourceInfo, // PitchInBytes * Rows where Rows = __GMM_MAX_CUBE_FACE x QPitch, then aligned to tile boundary
1607 ExpectedPitch *
1608 __GMM_MAX_CUBE_FACE * ExpectedQPitch);
1609
1610 //test main surface base alignment is 16KB
1611 //For Yf test main surface pitch is 4-tileYF aligned
1612 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1613 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % ((Tiling == TEST_TILEYF) ? 4 : 1));
1614
1615 if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1616 {
1617 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1618 EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1619 }
1620
1621 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1622
1623 { //separate Aux
1624 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1625
1626 GMM_RESOURCE_INFO *AuxResourceInfo;
1627 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1628 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
1629 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
1630 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
1631 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1632 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1633 }
1634
1635 for(uint32_t CubeFaceIndex = 0; CubeFaceIndex < __GMM_MAX_CUBE_FACE; CubeFaceIndex++)
1636 {
1637 GMM_REQ_OFFSET_INFO OffsetInfo = {};
1638 OffsetInfo.ReqRender = 1;
1639 OffsetInfo.CubeFace = static_cast<GMM_CUBE_FACE_ENUM>(CubeFaceIndex);
1640 ResourceInfo->GetOffset(OffsetInfo);
1641
1642 EXPECT_EQ((CubeFaceIndex * ExpectedQPitch) * ExpectedPitch,
1643 OffsetInfo.Render.Offset64); // Render offset is tile's base address on which cube face begins.
1644 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // X Offset should be 0 as cube face starts on tile boundary
1645 EXPECT_EQ(0, OffsetInfo.Render.YOffset); // Y Offset should be 0 as cube face starts on tile boundary
1646 EXPECT_EQ(0, OffsetInfo.Render.ZOffset); // Z offset N/A should be 0
1647 }
1648 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1649 }
1650
1651 // Allocate 2 tiles in X dimension.
1652 // Width and Height must be equal
1653 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1654 {
1655 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1;
1656 gmmParams.Flags.Gpu.CCS = 1;
1657 TEST_BPP bpp = static_cast<TEST_BPP>(i);
1658 GMM_TILE_MODE TileMode = (Tiling == TEST_TILEYF) ? DEFINE_TILE(YF_2D, bpp) : DEFINE_TILE(YS_2D, bpp);
1659
1660 gmmParams.Format = SetResourceFormat(bpp);
1661 gmmParams.BaseWidth64 = (TileSize[Tiling][i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
1662 gmmParams.BaseHeight = gmmParams.BaseWidth64; // Heigth must be equal to width.
1663 gmmParams.Depth = 0x1;
1664
1665 GMM_RESOURCE_INFO *ResourceInfo;
1666 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1667
1668 VerifyResourceHAlign<true>(ResourceInfo, HAlign[Tiling][i]);
1669 VerifyResourceVAlign<true>(ResourceInfo, VAlign[Tiling][i]);
1670
1671 uint32_t ExpectedPitch = TileSize[Tiling][i][0] * 2 * ((Tiling == TEST_TILEYF) ? 2 : 1); // As wide as 2 tile, padded to 4 tile-pitch
1672 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
1673 VerifyResourcePitchInTiles<true>(ResourceInfo, 2 * ((Tiling == TEST_TILEYF) ? 2 : 1)); // 2 tile wide
1674
1675 uint32_t ExpectedQPitch = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign[Tiling][i]);
1676 VerifyResourceQPitch<true>(ResourceInfo, ExpectedQPitch); // Each face should be Valigned-BaseHeight rows apart
1677
1678 VerifyResourceSize<true>(ResourceInfo, // PitchInBytes * Rows where Rows = __GMM_MAX_CUBE_FACE x QPitch, then aligned to tile boundary
1679 ExpectedPitch *
1680 __GMM_MAX_CUBE_FACE * ExpectedQPitch);
1681
1682 //test main surface base alignment is 16KB
1683 //For Yf test main surface pitch is 4-tileYF aligned
1684 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1685 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % ((Tiling == TEST_TILEYF) ? 4 : 1)); // Check on YF only
1686
1687 if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1688 {
1689 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1690 EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1691 }
1692
1693 { //separate Aux
1694 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1695
1696 GMM_RESOURCE_INFO *AuxResourceInfo;
1697 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1698 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
1699 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
1700 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
1701 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1702 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1703 }
1704
1705 for(uint32_t CubeFaceIndex = 0; CubeFaceIndex < __GMM_MAX_CUBE_FACE; CubeFaceIndex++)
1706 {
1707 GMM_REQ_OFFSET_INFO OffsetInfo = {};
1708 OffsetInfo.ReqRender = 1;
1709 OffsetInfo.CubeFace = static_cast<GMM_CUBE_FACE_ENUM>(CubeFaceIndex);
1710 ResourceInfo->GetOffset(OffsetInfo);
1711 EXPECT_EQ((CubeFaceIndex * ExpectedQPitch) * ExpectedPitch,
1712 OffsetInfo.Render.Offset64); // Render offset is tile's base address on which cube face begins.
1713 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // X Offset should be 0 as cube face starts on tile boundary
1714 EXPECT_EQ(0, OffsetInfo.Render.YOffset); // Y Offset should be 0 as cube face starts on tile boundary
1715 EXPECT_EQ(0, OffsetInfo.Render.ZOffset); // Z offset N/A should be 0
1716 }
1717 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1718 }
1719 }
1720 }
1721
1722 /// @brief ULT for 3D TileYs Compressed Resource
TEST_F(CTestGen12dGPUResource,DISABLED_Test3DTileYsCompressedResource)1723 TEST_F(CTestGen12dGPUResource, DISABLED_Test3DTileYsCompressedResource)
1724 {
1725 if(!const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1726 {
1727 return;
1728 }
1729 // Horizontal/Vertical pixel alignment
1730 const uint32_t HAlign[TEST_BPP_MAX] = {64, 32, 32, 32, 16};
1731 const uint32_t VAlign[TEST_BPP_MAX] = {32, 32, 32, 16, 16};
1732
1733 const uint32_t TileSize[TEST_BPP_MAX][3] = {{64, 32, 32},
1734 {64, 32, 32},
1735 {128, 32, 16},
1736 {256, 16, 16},
1737 {256, 16, 16}};
1738
1739 GMM_RESCREATE_PARAMS gmmParams = {};
1740 gmmParams.Type = RESOURCE_3D;
1741 gmmParams.NoGfxMemory = 1;
1742 gmmParams.Flags.Info.TiledY = 1;
1743 gmmParams.Flags.Info.TiledYs = 1;
1744 gmmParams.Flags.Gpu.Texture = 1;
1745 gmmParams.Flags.Info.RenderCompressed = 1; // Turn on .MC or .RC flag - mandatory to tell compression-type, for Yf its also used to pad surf
1746 // to 4x1 tile (reqd by HW for perf reasons)
1747
1748 // Allocate 1x1x1 surface
1749 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1750 {
1751 // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
1752 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
1753 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
1754
1755 TEST_BPP bpp = static_cast<TEST_BPP>(i);
1756 GMM_TILE_MODE TileMode = DEFINE_TILE(YS_3D, bpp);
1757
1758 gmmParams.Format = SetResourceFormat(bpp);
1759 gmmParams.BaseWidth64 = 0x1;
1760 gmmParams.BaseHeight = 0x1;
1761 gmmParams.Depth = 0x1;
1762
1763 GMM_RESOURCE_INFO *ResourceInfo;
1764 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1765
1766 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
1767 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
1768 VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0]); // As wide as 1 tile
1769 VerifyResourcePitchInTiles<true>(ResourceInfo, 1); // 1 tile wide
1770 VerifyResourceSize<false>(ResourceInfo, GMM_KBYTE(64)); // 1 tile big
1771
1772 VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
1773
1774 //test main surface base alignment is 16KB
1775 //For Yf test main surface pitch is 4-tileYF aligned
1776 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1777
1778 if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1779 {
1780 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1781 EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1782 }
1783 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1784
1785 { //separate Aux
1786 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1787
1788 GMM_RESOURCE_INFO *AuxResourceInfo;
1789 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1790 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
1791 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
1792 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
1793 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1794
1795 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1796 }
1797 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1798 }
1799
1800 // Allocate 2 tiles in X dimension
1801 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1802 {
1803 // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
1804 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
1805 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
1806
1807 TEST_BPP bpp = static_cast<TEST_BPP>(i);
1808 GMM_TILE_MODE TileMode = DEFINE_TILE(YS_3D, bpp);
1809
1810 gmmParams.Format = SetResourceFormat(bpp);
1811 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
1812 gmmParams.BaseHeight = 0x1;
1813 gmmParams.Depth = 0x1;
1814
1815 GMM_RESOURCE_INFO *ResourceInfo;
1816 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1817
1818 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
1819 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
1820 VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0] * 2); // As wide as 2 tile
1821 VerifyResourcePitchInTiles<true>(ResourceInfo, 2); // 2 tile wide
1822 VerifyResourceSize<false>(ResourceInfo, GMM_KBYTE(64) * 2); // 2 tile big
1823
1824 VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
1825 //test main surface base alignment is 16KB
1826 //For Yf test main surface pitch is 4-tileYF aligned
1827 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1828
1829 if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1830 {
1831 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1832 EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1833 }
1834 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1835
1836 { //separate Aux
1837 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1838
1839 GMM_RESOURCE_INFO *AuxResourceInfo;
1840 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1841 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
1842 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
1843 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
1844 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1845
1846 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1847 }
1848 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1849 }
1850
1851 // Allocate 2 tiles in X/Y dimension
1852 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1853 {
1854 // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
1855 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
1856 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
1857
1858 TEST_BPP bpp = static_cast<TEST_BPP>(i);
1859 GMM_TILE_MODE TileMode = DEFINE_TILE(YS_3D, bpp);
1860 gmmParams.Format = SetResourceFormat(bpp);
1861 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
1862 gmmParams.BaseHeight = TileSize[i][1] + 1; // 1 row larger than 1 tile height
1863 gmmParams.Depth = 0x1;
1864
1865 GMM_RESOURCE_INFO *ResourceInfo;
1866 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1867
1868 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
1869 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
1870 VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0] * 2); // As wide as 2 tile
1871 VerifyResourcePitchInTiles<true>(ResourceInfo, 2); // 2 tile wide
1872 VerifyResourceSize<false>(ResourceInfo, GMM_KBYTE(64) * 4); // 4 tile big
1873
1874 VerifyResourceQPitch<false>(ResourceInfo, 0);
1875
1876 //test main surface base alignment is 16KB
1877 //For Yf test main surface pitch is 4-tileYF aligned
1878 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1879
1880 if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1881 {
1882 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1883 EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1884 }
1885 EXPECT_EQ(GMM_KBYTE(4), 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 = DEFINE_TILE(YS_3D, bpp);
1910
1911 gmmParams.Format = SetResourceFormat(bpp);
1912 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
1913 gmmParams.BaseHeight = TileSize[i][1] + 1; // 1 row larger than 1 tile height
1914 gmmParams.Depth = TileSize[i][2] + 1; // 1 plane larger than 1 tile depth
1915
1916 GMM_RESOURCE_INFO *ResourceInfo;
1917 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1918
1919 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
1920 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
1921 VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0] * 2); // As wide as 2 tile
1922 VerifyResourcePitchInTiles<true>(ResourceInfo, 2); // 2 tile wide
1923 VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(64) * 8); // 8 tile big
1924
1925 VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
1926 //test main surface base alignment is 16KB
1927 //For Yf test main surface pitch is 4-tileYF aligned
1928 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
1929
1930 if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1931 {
1932 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
1933 EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
1934 }
1935 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
1936
1937 { //separate Aux
1938 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
1939
1940 GMM_RESOURCE_INFO *AuxResourceInfo;
1941 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1942 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
1943 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
1944 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
1945 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
1946 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
1947 }
1948 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1949 }
1950 }
1951
1952 /// @brief ULT for 3D TileYf Compressed Resource
TEST_F(CTestGen12dGPUResource,DISABLED_Test3DTileYfCompressedResource)1953 TEST_F(CTestGen12dGPUResource, DISABLED_Test3DTileYfCompressedResource)
1954 {
1955 if(!const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
1956 {
1957 return;
1958 }
1959 // Horizontal/Verticle pixel alignment
1960 const uint32_t HAlign[TEST_BPP_MAX] = {16, 8, 8, 8, 4};
1961 const uint32_t VAlign[TEST_BPP_MAX] = {16, 16, 16, 8, 8};
1962 const uint32_t TileSize[TEST_BPP_MAX][3] = {{16, 16, 16},
1963 {16, 16, 16},
1964 {32, 16, 8},
1965 {64, 8, 8},
1966 {64, 8, 8}};
1967
1968 GMM_RESCREATE_PARAMS gmmParams = {};
1969 gmmParams.Type = RESOURCE_3D;
1970 gmmParams.NoGfxMemory = 1;
1971 gmmParams.Flags.Info.TiledY = 1;
1972 gmmParams.Flags.Info.TiledYf = 1;
1973 gmmParams.Flags.Gpu.Texture = 1;
1974 gmmParams.Flags.Info.RenderCompressed = 1; // Turn on .MC or .RC flag - mandatory to tell compression-type, for Yf its also used to pad surf
1975 // to 4x1 tile (reqd by HW for perf reasons)
1976
1977 // Allocate 1x1x1 surface
1978 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1979 {
1980 // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
1981 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
1982 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
1983 //gmmParams.Flags.Gpu.MMC = 0; //Turn on to check unifiedaux creation
1984
1985 TEST_BPP bpp = static_cast<TEST_BPP>(i);
1986 GMM_TILE_MODE TileMode = DEFINE_TILE(YF_3D, bpp);
1987
1988 gmmParams.Format = SetResourceFormat(bpp);
1989 //gmmParams.BaseWidth64 = 0x30;
1990 //gmmParams.BaseHeight = 0x30;
1991 //gmmParams.Depth = 0x20;
1992 gmmParams.BaseWidth64 = 1;
1993 gmmParams.BaseHeight = 1;
1994 gmmParams.Depth = 1;
1995 const uint32_t PitchAlignment = 32;
1996
1997 GMM_RESOURCE_INFO *ResourceInfo;
1998 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1999
2000 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
2001 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
2002 VerifyResourcePitch<true>(ResourceInfo, GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[i][0] * 4));
2003 VerifyResourcePitchInTiles<true>(ResourceInfo, GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[i][0] * 4) / TileSize[i][0]);
2004 VerifyResourceSize<true>(ResourceInfo, (GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[i][0] * 4) / TileSize[i][0]) *
2005 (GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[i][1]) / TileSize[i][1]) *
2006 (GMM_ULT_ALIGN(gmmParams.Depth, TileSize[i][2]) / TileSize[i][2]) * GMM_KBYTE(4));
2007 VerifyResourceQPitch<true>(ResourceInfo, (GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[i][1])));
2008
2009 //test main surface base alignment is 16KB
2010 //For Yf test main surface pitch is 4-tileYF aligned
2011 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
2012 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
2013
2014 if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
2015 {
2016 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
2017 EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
2018 }
2019 ASSERT_LE(GMM_ULT_ALIGN(ResourceInfo->GetSizeMainSurface() / (GMM_KBYTE(16) / GMM_BYTES(64)), GMM_KBYTE(4)),
2020 ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2021
2022 { //separate Aux
2023 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
2024
2025 GMM_RESOURCE_INFO *AuxResourceInfo;
2026 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2027 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
2028 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
2029 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
2030 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
2031 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
2032 }
2033 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2034 }
2035
2036 // Allocate 2 tiles in X dimension
2037 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2038 {
2039 // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
2040 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
2041 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
2042
2043 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2044 GMM_TILE_MODE TileMode = DEFINE_TILE(YF_3D, bpp);
2045
2046 gmmParams.Format = SetResourceFormat(bpp);
2047 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1;
2048 gmmParams.BaseHeight = 0x1;
2049 gmmParams.Depth = 0x1;
2050 const uint32_t PitchAlignment = 32;
2051
2052
2053 GMM_RESOURCE_INFO *ResourceInfo;
2054 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2055
2056 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
2057 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
2058 VerifyResourcePitch<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 4, PitchAlignment));
2059 VerifyResourcePitchInTiles<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 4, PitchAlignment) / TileSize[i][0]);
2060 VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 4, PitchAlignment) / TileSize[i][0] * GMM_KBYTE(4));
2061 VerifyResourceQPitch<true>(ResourceInfo, TileSize[i][1]);
2062 //test main surface base alignment is 16KB
2063 //For Yf test main surface pitch is 4-tileYF aligned
2064 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
2065 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
2066
2067 if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
2068 {
2069 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
2070 EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
2071 }
2072 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2073 ASSERT_LE(GMM_ULT_ALIGN(ResourceInfo->GetSizeMainSurface() / (GMM_KBYTE(16) / GMM_BYTES(64)), GMM_KBYTE(4)),
2074 ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2075
2076 { //separate Aux
2077 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
2078
2079 GMM_RESOURCE_INFO *AuxResourceInfo;
2080 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2081 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
2082 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
2083 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
2084 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
2085 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
2086 }
2087 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2088 }
2089
2090 // Allocate 2 tiles in X/Y dimension
2091 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2092 {
2093 // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
2094 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
2095 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
2096
2097 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2098 GMM_TILE_MODE TileMode = DEFINE_TILE(YF_3D, bpp);
2099
2100 gmmParams.Format = SetResourceFormat(bpp);
2101 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1;
2102 gmmParams.BaseHeight = TileSize[i][1] + 1;
2103 gmmParams.Depth = 0x1;
2104 const uint32_t PitchAlignment = 32;
2105
2106 GMM_RESOURCE_INFO *ResourceInfo;
2107 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2108
2109 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
2110 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
2111 VerifyResourcePitch<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 4, PitchAlignment));
2112 VerifyResourcePitchInTiles<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 4, PitchAlignment) / TileSize[i][0]);
2113 VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 4, PitchAlignment) / TileSize[i][0] * 2 * GMM_KBYTE(4));
2114 VerifyResourceQPitch<true>(ResourceInfo, TileSize[i][1] * 2);
2115 //test main surface base alignment is 16KB
2116 //For Yf test main surface pitch is 4-tileYF aligned
2117 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
2118 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
2119
2120 if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
2121 {
2122 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
2123 EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
2124 }
2125 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2126 ASSERT_LE(GMM_ULT_ALIGN(ResourceInfo->GetSizeMainSurface() / (GMM_KBYTE(16) / GMM_BYTES(64)), GMM_KBYTE(4)),
2127 ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2128
2129 { //separate Aux
2130 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
2131
2132 GMM_RESOURCE_INFO *AuxResourceInfo;
2133 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2134 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
2135 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
2136 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
2137 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
2138 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
2139 }
2140 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2141 }
2142
2143 // Allocate 2 tiles in X/Y/Z dimension
2144 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2145 {
2146 // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
2147 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
2148 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
2149
2150 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2151 GMM_TILE_MODE TileMode = DEFINE_TILE(YF_3D, bpp);
2152
2153 gmmParams.Format = SetResourceFormat(bpp);
2154 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1;
2155 gmmParams.BaseHeight = TileSize[i][1] + 1;
2156 gmmParams.Depth = TileSize[i][2] + 1;
2157 const uint32_t PitchAlignment = 32;
2158
2159 GMM_RESOURCE_INFO *ResourceInfo;
2160 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2161
2162 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
2163 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
2164 VerifyResourcePitch<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 4, PitchAlignment));
2165 VerifyResourcePitchInTiles<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 4, PitchAlignment) / TileSize[i][0]);
2166 VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 4, PitchAlignment) / TileSize[i][0] * 2 * 2 * GMM_KBYTE(4));
2167 VerifyResourceQPitch<true>(ResourceInfo, TileSize[i][1] * 2);
2168 //test main surface base alignment is 16KB
2169 //For Yf test main surface pitch is 4-tileYF aligned
2170 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
2171 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
2172
2173 if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
2174 {
2175 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
2176 EXPECT_GE(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), ResourceInfo->GetSizeMainSurface() >> 8);
2177 }
2178 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2179 ASSERT_LE(GMM_ULT_ALIGN(ResourceInfo->GetSizeMainSurface() / (GMM_KBYTE(16) / GMM_BYTES(64)), GMM_KBYTE(4)),
2180 ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2181
2182 { //separate Aux
2183 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
2184
2185 GMM_RESOURCE_INFO *AuxResourceInfo;
2186 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2187 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
2188 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
2189 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
2190 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
2191 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
2192 }
2193 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2194 }
2195 }
2196
2197 /// @brief ULT for 3D TileY Compressed Resource
TEST_F(CTestGen12dGPUResource,DISABLED_Test3DTileYCompressedResource)2198 TEST_F(CTestGen12dGPUResource, DISABLED_Test3DTileYCompressedResource)
2199 {
2200 if(!const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
2201 {
2202 return;
2203 }
2204 // Horizontal/Verticle pixel alignment
2205 const uint32_t HAlign = {16};
2206 const uint32_t VAlign = {4};
2207 const uint32_t TileSize[3] = {128, 32, 1};
2208
2209 GMM_RESCREATE_PARAMS gmmParams = {};
2210 gmmParams.Type = RESOURCE_3D;
2211 gmmParams.NoGfxMemory = 1;
2212 gmmParams.Flags.Info.TiledY = 1;
2213 gmmParams.Flags.Gpu.Texture = 1;
2214 gmmParams.Flags.Info.RenderCompressed = 1; // Turn on .MC or .RC flag - mandatory to tell compression-type, for Yf its also used to pad surf
2215 // to 4x1 tile (reqd by HW for perf reasons)
2216
2217 // Allocate 1x1x1 surface
2218 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2219 {
2220 // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
2221 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
2222 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
2223
2224 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2225 GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
2226
2227 gmmParams.Format = SetResourceFormat(bpp);
2228 //gmmParams.BaseWidth64 = 0x30;
2229 //gmmParams.BaseHeight = 0x30;
2230 //gmmParams.Depth = 0x20;
2231 gmmParams.BaseWidth64 = 1;
2232 gmmParams.BaseHeight = 1;
2233 gmmParams.Depth = 1;
2234 const uint32_t PitchAlignment = 32;
2235
2236 GMM_RESOURCE_INFO *ResourceInfo;
2237 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2238
2239 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2240 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2241 VerifyResourcePitch<true>(ResourceInfo, GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[0] * 4));
2242 VerifyResourcePitchInTiles<true>(ResourceInfo, GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[0] * 4) / TileSize[0]);
2243 VerifyResourceSize<true>(ResourceInfo, (GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[0] * 4) / TileSize[0]) *
2244 (GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[1]) / TileSize[1]) *
2245 (GMM_ULT_ALIGN(gmmParams.Depth, TileSize[2]) / TileSize[2]) * GMM_KBYTE(4));
2246 VerifyResourceQPitch<true>(ResourceInfo, (GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[1])));
2247
2248 //test main surface base alignment is 16KB
2249 //For Yf test main surface pitch is 4-tileYF aligned
2250 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
2251 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
2252
2253 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
2254 ASSERT_LE(GMM_ULT_ALIGN(ResourceInfo->GetSizeMainSurface() / (GMM_KBYTE(16) / GMM_BYTES(64)), GMM_KBYTE(4)),
2255 ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2256
2257 { //separate Aux
2258 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
2259
2260 GMM_RESOURCE_INFO *AuxResourceInfo;
2261 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2262 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
2263 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
2264 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
2265 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
2266 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
2267 }
2268 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2269 }
2270
2271 // Allocate 2 tiles in X dimension
2272 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2273 {
2274 // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
2275 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
2276 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
2277
2278 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2279 GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
2280 gmmParams.Format = SetResourceFormat(bpp);
2281 gmmParams.BaseWidth64 = (TileSize[0] / GetBppValue(bpp)) + 1;
2282 gmmParams.BaseHeight = 0x1;
2283 gmmParams.Depth = 0x1;
2284 const uint32_t PitchAlignment = 32;
2285
2286
2287 GMM_RESOURCE_INFO *ResourceInfo;
2288 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2289
2290 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2291 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2292 VerifyResourcePitch<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[0] * 4, PitchAlignment));
2293 VerifyResourcePitchInTiles<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[0] * 4, PitchAlignment) / TileSize[0]);
2294 VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[0] * 4, PitchAlignment) / TileSize[0] * GMM_KBYTE(4));
2295 VerifyResourceQPitch<true>(ResourceInfo, TileSize[1]);
2296 //test main surface base alignment is 16KB
2297 //For Yf test main surface pitch is 4-tileYF aligned
2298 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
2299 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
2300
2301 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2302 ASSERT_LE(GMM_ULT_ALIGN(ResourceInfo->GetSizeMainSurface() / (GMM_KBYTE(16) / GMM_BYTES(64)), GMM_KBYTE(4)),
2303 ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2304
2305 { //separate Aux
2306 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
2307
2308 GMM_RESOURCE_INFO *AuxResourceInfo;
2309 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2310 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
2311 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
2312 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
2313 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
2314 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
2315 }
2316 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2317 }
2318
2319 // Allocate 2 tiles in X/Y dimension
2320 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2321 {
2322 // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
2323 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
2324 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
2325
2326 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2327 GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
2328 gmmParams.Format = SetResourceFormat(bpp);
2329 gmmParams.BaseWidth64 = (TileSize[0] / GetBppValue(bpp)) + 1;
2330 gmmParams.BaseHeight = TileSize[1] + 1;
2331 gmmParams.Depth = 0x1;
2332 const uint32_t PitchAlignment = 32;
2333
2334 GMM_RESOURCE_INFO *ResourceInfo;
2335 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2336
2337 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2338 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2339 VerifyResourcePitch<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[0] * 4, PitchAlignment));
2340 VerifyResourcePitchInTiles<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[0] * 4, PitchAlignment) / TileSize[0]);
2341 VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[0] * 4, PitchAlignment) / TileSize[0] * 2 * GMM_KBYTE(4));
2342 VerifyResourceQPitch<true>(ResourceInfo, TileSize[1] * 2);
2343 //test main surface base alignment is 16KB
2344 //For Yf test main surface pitch is 4-tileYF aligned
2345 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
2346 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
2347
2348 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
2349 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2350 ASSERT_LE(GMM_ULT_ALIGN(ResourceInfo->GetSizeMainSurface() / (GMM_KBYTE(16) / GMM_BYTES(64)), GMM_KBYTE(4)),
2351 ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2352
2353 { //separate Aux
2354 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
2355
2356 GMM_RESOURCE_INFO *AuxResourceInfo;
2357 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2358 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
2359 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
2360 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
2361 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
2362 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
2363 }
2364 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2365 }
2366
2367 // Allocate 2 tiles in X/Y/Z dimension
2368 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2369 {
2370 // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
2371 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
2372 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
2373
2374 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2375 GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
2376 gmmParams.Format = SetResourceFormat(bpp);
2377 gmmParams.BaseWidth64 = (TileSize[0] / GetBppValue(bpp)) + 1;
2378 gmmParams.BaseHeight = TileSize[1] + 1;
2379 gmmParams.Depth = TileSize[2] + 1;
2380 const uint32_t PitchAlignment = 32;
2381
2382 GMM_RESOURCE_INFO *ResourceInfo;
2383 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2384
2385 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2386 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2387 VerifyResourcePitch<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[0] * 4, PitchAlignment));
2388 VerifyResourcePitchInTiles<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[0] * 4, PitchAlignment) / TileSize[0]);
2389 VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[0] * 4, PitchAlignment) / TileSize[0] * 2 * 2 * GMM_KBYTE(4));
2390 VerifyResourceQPitch<true>(ResourceInfo, TileSize[1] * 2);
2391 //test main surface base alignment is 16KB
2392 //For Yf test main surface pitch is 4-tileYF aligned
2393 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
2394 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
2395
2396 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
2397 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2398 ASSERT_LE(GMM_ULT_ALIGN(ResourceInfo->GetSizeMainSurface() / (GMM_KBYTE(16) / GMM_BYTES(64)), GMM_KBYTE(4)),
2399 ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2400
2401 { //separate Aux
2402 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
2403
2404 GMM_RESOURCE_INFO *AuxResourceInfo;
2405 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2406 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
2407 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
2408 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
2409 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
2410 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
2411 }
2412 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2413 }
2414 }
2415
2416 /// @brief ULT for 2D Yf mipped compressed resource
TEST_F(CTestGen12dGPUResource,DISABLED_Test2DTileYfMippedCompressedResource)2417 TEST_F(CTestGen12dGPUResource, DISABLED_Test2DTileYfMippedCompressedResource)
2418 {
2419 if(!const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
2420 {
2421 return;
2422 }
2423 const uint32_t HAlign[TEST_BPP_MAX] = {64, 64, 32, 32, 16};
2424 const uint32_t VAlign[TEST_BPP_MAX] = {64, 32, 32, 16, 16};
2425
2426 const uint32_t TileSize[TEST_BPP_MAX][2] = {{64, 64},
2427 {128, 32},
2428 {128, 32},
2429 {256, 16},
2430 {256, 16}};
2431
2432 const uint32_t MtsWidth[TEST_BPP_MAX] = {32, 32, 16, 16, 8};
2433 const uint32_t MtsHeight[TEST_BPP_MAX] = {64, 32, 32, 16, 16};
2434
2435 GMM_RESCREATE_PARAMS gmmParams = {};
2436 gmmParams.Type = RESOURCE_2D;
2437 gmmParams.NoGfxMemory = 1;
2438 gmmParams.Flags.Info.TiledY = 1;
2439 gmmParams.Flags.Info.TiledYf = 1;
2440 gmmParams.Flags.Gpu.Texture = 1;
2441 gmmParams.Flags.Info.RenderCompressed = 1; // Turn on .MC or .RC flag - mandatory to tell compression-type, for Yf its also used to pad surf
2442 // to 4x1 tile (reqd by HW for perf reasons)
2443 gmmParams.MaxLod = 4;
2444 gmmParams.ArraySize = 4;
2445
2446 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2447 {
2448 uint32_t AlignedWidth = 0;
2449 uint32_t AlignedHeight = 0;
2450 uint32_t ExpectedPitch = 0;
2451 uint32_t MipTailStartLod = 0;
2452 // Valigned Mip Heights
2453 uint32_t Mip0Height = 0;
2454 uint32_t Mip1Height = 0;
2455 uint32_t Mip2Height = 0;
2456 uint32_t Mip3Height = 0;
2457 uint32_t Mip2Higher = 0; // Sum of aligned heights of Mip2 and above
2458 uint32_t MipTailHeight = 0;
2459 // Haligned Mip Widths
2460 uint32_t Mip0Width = 0;
2461 uint32_t Mip1Width = 0;
2462 uint32_t Mip2Width = 0;
2463
2464 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2465 gmmParams.Format = SetResourceFormat(bpp);
2466 gmmParams.BaseWidth64 = 0x38;
2467 gmmParams.BaseHeight = 0x38;
2468
2469 // If unifiedAuxSurf reqd (mandatory for displayable or cross-device shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
2470 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
2471 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
2472
2473 GMM_RESOURCE_INFO *ResourceInfo;
2474 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2475
2476 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
2477 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
2478
2479 // find the miptail start level
2480 {
2481 uint32_t MipWidth = gmmParams.BaseWidth64;
2482 uint32_t MipHeight = gmmParams.BaseHeight;
2483 while(!(MipWidth <= MtsWidth[i] && MipHeight <= MtsHeight[i]))
2484 {
2485 MipTailStartLod++;
2486 MipWidth = (uint32_t)(GMM_ULT_MAX(1, gmmParams.BaseWidth64 >> MipTailStartLod));
2487 MipHeight = GMM_ULT_MAX(1, gmmParams.BaseHeight >> MipTailStartLod);
2488 }
2489 }
2490
2491 // Mip resource Aligned Width calculation
2492 Mip0Width = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign[i]);
2493 Mip0Height = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign[i]);
2494
2495 if(MipTailStartLod == 1)
2496 {
2497 EXPECT_EQ(1, ResourceInfo->GetPackedMipTailStartLod());
2498 // Block height...Mip0Height + Max(Mip1Height, Sum of Mip2Height..MipnHeight)
2499 Mip1Height = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 1, VAlign[i]);
2500 AlignedWidth = Mip0Width;
2501 }
2502 if(MipTailStartLod == 2)
2503 {
2504 EXPECT_EQ(2, ResourceInfo->GetPackedMipTailStartLod());
2505 // Block height...Mip0Height + Max(Mip1Height, Sum of Mip2Height..MipnHeight)
2506 Mip1Height = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 1, VAlign[i]);
2507 Mip2Height = Mip2Higher = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 2, VAlign[i]);
2508
2509 Mip1Width = GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> 1, HAlign[i]);
2510 Mip2Width = GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> 2, HAlign[i]);
2511 AlignedWidth = GMM_ULT_MAX(Mip0Width, Mip1Width + Mip2Width);
2512 }
2513 if(MipTailStartLod == 3)
2514 {
2515 EXPECT_EQ(3, ResourceInfo->GetPackedMipTailStartLod());
2516 // Block height...Mip0Height + Max(Mip1Height, Sum of Mip2Height..MipnHeight)
2517 Mip1Height = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 1, VAlign[i]);
2518 Mip2Height = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 2, VAlign[i]);
2519 // Miptail started lod
2520 MipTailHeight = VAlign[i];
2521 Mip2Higher = Mip2Height + Mip3Height + MipTailHeight;
2522
2523 Mip1Width = GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> 1, HAlign[i]);
2524 Mip2Width = GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> 2, HAlign[i]);
2525 AlignedWidth = GMM_ULT_MAX(Mip0Width, Mip1Width + Mip2Width);
2526 }
2527
2528 uint32_t MaxHeight = GMM_ULT_MAX(Mip1Height, Mip2Higher);
2529 AlignedHeight = Mip0Height + MaxHeight;
2530 AlignedHeight = GMM_ULT_ALIGN(AlignedHeight, VAlign[i]);
2531
2532 ExpectedPitch = AlignedWidth * GetBppValue(bpp);
2533 ExpectedPitch = GMM_ULT_ALIGN(ExpectedPitch, GMM_BYTES(32));
2534 ExpectedPitch = GMM_ULT_ALIGN(ExpectedPitch, TileSize[i][0] * 4); //Only for displayables - 16K pitch align
2535 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
2536
2537 VerifyResourcePitchInTiles<true>(ResourceInfo, static_cast<uint32_t>(ExpectedPitch / TileSize[i][0]));
2538 VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(ExpectedPitch * AlignedHeight * gmmParams.ArraySize, PAGE_SIZE));
2539 VerifyResourceQPitch<false>(ResourceInfo, AlignedHeight);
2540 //test main surface base alignment is 16KB
2541 //For Yf test main surface pitch is 4-tileYF aligned
2542 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
2543 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
2544
2545 //Aux-size enough to cover all
2546 if(const_cast<SKU_FEATURE_TABLE &>(pGfxAdapterInfo->SkuTable).FtrLinearCCS)
2547 {
2548 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
2549 }
2550
2551 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2552 ASSERT_LE(GMM_ULT_ALIGN(ResourceInfo->GetSizeMainSurface() / (GMM_KBYTE(16) / GMM_BYTES(64)), GMM_KBYTE(4)),
2553 ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2554
2555 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2556 }
2557 }
2558
2559 /// @brief ULT for Linear Buffer Compressed Resource
TEST_F(CTestGen12dGPUResource,DISABLED_TestLinearCompressedResource)2560 TEST_F(CTestGen12dGPUResource, DISABLED_TestLinearCompressedResource)
2561 {
2562 // Horizontal pixel alignment
2563 const uint32_t MinPitch = 32;
2564
2565 GMM_RESCREATE_PARAMS gmmParams = {};
2566 gmmParams.Type = RESOURCE_BUFFER;
2567 gmmParams.NoGfxMemory = 1;
2568 gmmParams.Flags.Info.Linear = 1;
2569 gmmParams.Flags.Gpu.Texture = 1;
2570 gmmParams.Flags.Info.RenderCompressed = 1;
2571
2572 // Allocate 1x1 surface
2573 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2574 {
2575 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
2576 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
2577
2578 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2579 gmmParams.Format = SetResourceFormat(bpp);
2580 gmmParams.BaseWidth64 = 0x1;
2581 gmmParams.BaseHeight = 1;
2582 gmmParams.Flags.Info.AllowVirtualPadding = (bpp != TEST_BPP_8); //OCL uses 8bpp buffers. Specification doesn't comment if Linear buffer compr allowed or not on bpp!=8.
2583
2584 GMM_RESOURCE_INFO *ResourceInfo;
2585 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2586
2587 uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, MinPitch);
2588 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
2589 uint32_t AlignedSize = GMM_ULT_ALIGN(PitchInBytes, PAGE_SIZE);
2590
2591 VerifyResourceHAlign<false>(ResourceInfo, 0);
2592 VerifyResourceVAlign<false>(ResourceInfo, 0); // N/A for buffer
2593 VerifyResourcePitch<false>(ResourceInfo, 0); // N/A for buffer
2594 VerifyResourcePitchInTiles<false>(ResourceInfo, 0); // N/A for linear
2595 VerifyResourceSize<true>(ResourceInfo, AlignedSize);
2596 VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-arrayed
2597
2598 //test main surface base alignment is 16KB
2599 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
2600
2601 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
2602 ASSERT_LE(GMM_ULT_ALIGN(ResourceInfo->GetSizeMainSurface() / (GMM_KBYTE(16) / GMM_BYTES(64)), GMM_KBYTE(4)),
2603 ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2604
2605 { //separate Aux
2606 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
2607
2608 GMM_RESOURCE_INFO *AuxResourceInfo;
2609 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2610 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
2611 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
2612 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
2613 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
2614 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
2615 }
2616 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2617 }
2618
2619
2620 // Allocate more than 1 page
2621 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2622 {
2623 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2624 gmmParams.Format = SetResourceFormat(bpp);
2625 gmmParams.BaseWidth64 = 0x1001;
2626 gmmParams.BaseHeight = 1;
2627 gmmParams.Flags.Info.AllowVirtualPadding = (bpp != TEST_BPP_8); //OCL uses 8bpp buffers. Specification doesn't comment if Linear buffer compr allowed or not on bpp!=8.
2628 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
2629 gmmParams.Flags.Gpu.CCS = 1;
2630
2631 GMM_RESOURCE_INFO *ResourceInfo;
2632 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2633
2634 uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, MinPitch);
2635 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
2636 uint32_t AlignedSize = GMM_ULT_ALIGN(PitchInBytes, PAGE_SIZE);
2637
2638 VerifyResourceHAlign<false>(ResourceInfo, MinPitch);
2639 VerifyResourceVAlign<false>(ResourceInfo, 0); // N/A for buffer
2640 VerifyResourcePitch<false>(ResourceInfo, 0); // N/A for buffer
2641 VerifyResourcePitchInTiles<false>(ResourceInfo, 0); // N/A for linear
2642 VerifyResourceSize<true>(ResourceInfo, AlignedSize);
2643 VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-arrayed
2644
2645 //test main surface base alignment is 16KB
2646 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
2647
2648 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
2649 ASSERT_LE(GMM_ULT_ALIGN(ResourceInfo->GetSizeMainSurface() / (GMM_KBYTE(16) / GMM_BYTES(64)), GMM_KBYTE(4)),
2650 ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2651
2652 { //separate Aux
2653 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
2654
2655 GMM_RESOURCE_INFO *AuxResourceInfo;
2656 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2657 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
2658 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
2659 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
2660 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
2661 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
2662 }
2663 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2664 }
2665 }
2666 ///Add MSAA/Depth Compressed Resource tests
TEST_F(CTestGen12dGPUResource,DISABLED_TestLosslessMSAACompressedResource)2667 TEST_F(CTestGen12dGPUResource, DISABLED_TestLosslessMSAACompressedResource)
2668 {
2669 }
2670
2671 ///Add MSAA/Depth Compressed Resource tests
TEST_F(CTestGen12dGPUResource,DISABLED_TestDepthCompressedResource)2672 TEST_F(CTestGen12dGPUResource, DISABLED_TestDepthCompressedResource)
2673 {
2674 const uint32_t HAlign = 8;
2675 uint32_t VAlign = 4;
2676
2677 //const uint32_t DepthTileSize[1][2] = { 64, 64 };
2678 const uint32_t AllocTileSize[1][2] = {128, 32}; //HiZ is TileY
2679
2680 GMM_RESCREATE_PARAMS gmmParams = {};
2681 gmmParams.NoGfxMemory = 1;
2682 gmmParams.Flags.Info.TiledY = 1; //Not supported for Depth buffer, but HiZ output is TileY
2683 gmmParams.Flags.Gpu.Depth = 1; //GPU Flags= Depth/SeparateStencil + HiZ
2684 gmmParams.Flags.Gpu.HiZ = 1;
2685 gmmParams.Flags.Gpu.IndirectClearColor = 1;
2686 gmmParams.Flags.Gpu.CCS = 1;
2687 gmmParams.Flags.Info.RenderCompressed = 1;
2688 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1;
2689
2690 // Allocate 1x1 surface so that it occupies 1 Tile in X dimension
2691 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
2692 {
2693 {
2694 VAlign = (j == TEST_BPP_16) ? 8 : 4;
2695 }
2696 gmmParams.Format = SetResourceFormat(static_cast<TEST_BPP>(j)); //Only 16,24,32 supported; But driver creates the resource even for other bpps without failing
2697 for(uint32_t i = RESOURCE_2D; i <= RESOURCE_CUBE; i++) //3D doesn't support HiZ - test driver returns proper?
2698 {
2699 gmmParams.Type = static_cast<GMM_RESOURCE_TYPE>(i);
2700 gmmParams.BaseWidth64 = 0x1;
2701 gmmParams.BaseHeight = 0x1; //0x24; //not 1 tile
2702 //gmmParams.MaxLod = 6; --add expectedheight calc- mip0+max{mip1, sum{mip2,...n}}
2703 gmmParams.Depth = 0x1;
2704 if(i == RESOURCE_1D || i == RESOURCE_3D)
2705 {
2706 gmmParams.Flags.Gpu.HiZ = 0;
2707 }
2708
2709 GMM_RESOURCE_INFO *ResourceInfo = NULL;
2710 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2711 //EXPECT_NE(NULL, ResourceInfo);
2712
2713 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2714 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2715 uint32_t ExpectedPitch = AllocTileSize[0][0] * 4;
2716 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
2717 VerifyResourcePitchInTiles<true>(ResourceInfo, 4); // 1 tileY wide
2718 uint32_t ExpectedHeight = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign);
2719
2720 if(gmmParams.ArraySize > 1 || gmmParams.Type == RESOURCE_CUBE)
2721 {
2722 uint32_t ExpectedQPitch = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign); //Apply formula on Specification
2723 ExpectedQPitch = GMM_ULT_ALIGN(ExpectedQPitch / 2, VAlign);
2724 ExpectedHeight *= (gmmParams.Type == RESOURCE_CUBE) ? 6 : 1;
2725
2726 VerifyResourceQPitch<false>(ResourceInfo, ExpectedQPitch); // Each face should be VAlign rows apart within a tile, Turn on verification after clarity
2727 }
2728
2729 VerifyResourceSize<true>(ResourceInfo,
2730 GFX_ALIGN(ExpectedPitch * ExpectedHeight, 4 * PAGE_SIZE)); //1 Tile should be enough
2731 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2732 }
2733
2734 // Allocate 2 tiles in X dimension. (muti-tiles Tiles in Y dimension for cube/array)
2735 for(uint32_t i = RESOURCE_2D; i <= RESOURCE_CUBE; i++)
2736 {
2737 gmmParams.Type = static_cast<GMM_RESOURCE_TYPE>(i);
2738 gmmParams.BaseWidth64 = AllocTileSize[0][0] + 0x1;
2739 gmmParams.BaseHeight = (gmmParams.Type == RESOURCE_1D) ? 0x1 :
2740 (gmmParams.Type == RESOURCE_CUBE) ? gmmParams.BaseWidth64 :
2741 VAlign / 2;
2742 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?]
2743 gmmParams.Depth = 0x1;
2744
2745 GMM_RESOURCE_INFO *ResourceInfo;
2746 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2747
2748 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2749 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2750 uint32_t ExpectedPitch = GFX_ALIGN(gmmParams.BaseWidth * (int)pow(2, j), AllocTileSize[0][0] * 4);
2751 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
2752 VerifyResourcePitchInTiles<true>(ResourceInfo, 4); // 2 tileY wide
2753
2754 uint32_t ExpectedQPitch = 0;
2755 if(gmmParams.ArraySize > 1 || gmmParams.Type == RESOURCE_CUBE)
2756 {
2757 ExpectedQPitch = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign);
2758 //ExpectedQPitch = GMM_ULT_ALIGN(ExpectedQPitch / 2, VAlign);
2759
2760 VerifyResourceQPitch<false>(ResourceInfo, ExpectedQPitch); // Each face should be VAlign rows apart within a tile. Turn on verification after clarity
2761 }
2762
2763 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
2764 ((gmmParams.Type == RESOURCE_CUBE) ?
2765 ExpectedPitch * GMM_ULT_ALIGN(ExpectedQPitch * gmmParams.ArraySize * __GMM_MAX_CUBE_FACE, AllocTileSize[0][1]) : //cube
2766 ((gmmParams.ArraySize > 1) ?
2767 ExpectedPitch * GMM_ULT_ALIGN(ExpectedQPitch * gmmParams.ArraySize, AllocTileSize[0][1]) : //array
2768 4 * GMM_KBYTE(4))));
2769
2770 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2771 }
2772
2773 // Allocate 2 tiles in X/Y dimension (non-arrayed) Multi-tiles for 3D
2774 for(uint32_t i = RESOURCE_2D; i <= RESOURCE_3D; i++)
2775 {
2776 gmmParams.Type = static_cast<GMM_RESOURCE_TYPE>(i);
2777 gmmParams.BaseWidth64 = AllocTileSize[0][0] + 0x1;
2778 gmmParams.BaseHeight = 2 * AllocTileSize[0][1] + 0x1; //Half-Depth Height or QPitch (lod!=0), aligned to 8 required by HW
2779 gmmParams.Depth = (gmmParams.Type == RESOURCE_2D) ? 0x1 :
2780 VAlign + 1;
2781 gmmParams.ArraySize = 1;
2782
2783 GMM_RESOURCE_INFO *ResourceInfo;
2784 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2785
2786 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2787 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2788 uint32_t ExpectedPitch = AllocTileSize[0][0] * 4;
2789 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
2790 VerifyResourcePitchInTiles<true>(ResourceInfo, 4); // 2 tile wide
2791
2792 uint32_t TwoDQPitch, ExpectedQPitch = 0;
2793 if(gmmParams.Type == RESOURCE_3D)
2794 {
2795 TwoDQPitch = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign);
2796 ExpectedQPitch = gmmParams.Depth * GMM_ULT_ALIGN(TwoDQPitch / 2, VAlign); //Depth slices arranged as 2D-arrayed slices.
2797 }
2798 else
2799 {
2800 //HiZ for 3D not supported. Driver still allocates like IVB/HSW. (should Qpitch or only overall buffer height be Valigned ?)
2801 VerifyResourceSize<true>(ResourceInfo,
2802 ((gmmParams.Type == RESOURCE_3D) ?
2803 ExpectedPitch * GMM_ULT_ALIGN(ExpectedQPitch, AllocTileSize[0][1]) :
2804 2 * 2 * GMM_KBYTE(4)));
2805 }
2806 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2807 }
2808 }
2809 }
2810
TEST_F(CTestGen12dGPUResource,DISABLED_TestStencilCompressedResource)2811 TEST_F(CTestGen12dGPUResource, DISABLED_TestStencilCompressedResource)
2812 {
2813 const uint32_t HAlign = {16};
2814 const uint32_t VAlign = {8};
2815
2816 const uint32_t TileSize[2] = {128, 32};
2817
2818 GMM_RESCREATE_PARAMS gmmParams = {};
2819 gmmParams.Type = RESOURCE_2D;
2820 gmmParams.NoGfxMemory = 1;
2821 gmmParams.Flags.Info.TiledY = 1;
2822 //gmmParams.ArraySize = 4;
2823
2824 gmmParams.Flags.Gpu.SeparateStencil = 1;
2825 gmmParams.Flags.Info.RenderCompressed = 1;
2826 // Turn on .MC or .RC flag - mandatory to tell compression-type, for Yf its also used to pad surf
2827 // to 4x1 tile
2828 // If unifiedAuxSurf reqd (mandatory for displayable or cross-adapter shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
2829
2830 //Allocate 1x1 surface
2831 {
2832 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
2833 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
2834 gmmParams.Flags.Gpu.IndirectClearColor = 1;
2835
2836 TEST_BPP bpp = static_cast<TEST_BPP>(TEST_BPP_8);
2837 GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
2838 gmmParams.Format = SetResourceFormat(bpp);
2839 gmmParams.BaseWidth64 = 0x1;
2840 gmmParams.BaseHeight = 0x1;
2841
2842 GMM_RESOURCE_INFO *ResourceInfo;
2843 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2844
2845 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2846 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2847 VerifyResourcePitch<true>(ResourceInfo, 4 * TileSize[0]); // As wide as 4 Tile
2848 VerifyResourcePitchInTiles<true>(ResourceInfo, 4); // 4 Tile wide
2849 VerifyResourceSize<true>(ResourceInfo, 4 * GMM_KBYTE(4)); // 4 Tile Big
2850 VerifyResourceQPitch<false>(ResourceInfo, 0); // Not Tested
2851
2852 //test main surface base alignment is 16KB
2853 //For Yf test main surface pitch is 4-tileYF aligned
2854 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
2855 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4); // Check on YF only
2856
2857 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
2858 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2859
2860 { //separate Aux
2861 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
2862
2863 GMM_RESOURCE_INFO *AuxResourceInfo;
2864 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2865 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
2866 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
2867 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
2868 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
2869 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
2870 }
2871 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2872 }
2873
2874 // Allocate surface that requires multi tiles in two dimension
2875 // Allocate 2 tiles in X dimension
2876 {
2877 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
2878 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
2879
2880 TEST_BPP bpp = static_cast<TEST_BPP>(TEST_BPP_8);
2881 GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
2882 gmmParams.Format = SetResourceFormat(bpp);
2883 gmmParams.BaseWidth64 = (TileSize[0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
2884 gmmParams.BaseHeight = 0x1;
2885 gmmParams.Depth = 0x1;
2886
2887 GMM_RESOURCE_INFO *ResourceInfo;
2888 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2889
2890 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2891 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2892 VerifyResourcePitch<true>(ResourceInfo, TileSize[0] * 4); // As wide as 2 tile, but 4-tile pitch alignment
2893 VerifyResourcePitchInTiles<true>(ResourceInfo, 4); // 2 tile wide, but 4-tile pitch alignment
2894 VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * 4); // 2 tile big, but 4-tile pitch alignment
2895
2896 VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
2897
2898 //test main surface base alignment is 16KB
2899 //For Y test main surface pitch is 4-tileY aligned
2900 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
2901 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4);
2902 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
2903 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2904
2905 { //separate Aux
2906 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
2907
2908 GMM_RESOURCE_INFO *AuxResourceInfo;
2909 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2910 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
2911 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
2912 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
2913 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
2914 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
2915 }
2916 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2917 }
2918
2919 // Allocate surface that requires multi tiles in two dimension
2920 // Allocate 2 tiles in X/Y dimension
2921 {
2922 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
2923 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
2924 gmmParams.Flags.Gpu.IndirectClearColor = 1;
2925
2926 TEST_BPP bpp = static_cast<TEST_BPP>(TEST_BPP_8);
2927 GMM_TILE_MODE TileMode = LEGACY_TILE_Y;
2928 gmmParams.Format = SetResourceFormat(bpp);
2929 gmmParams.BaseWidth64 = (TileSize[0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
2930 gmmParams.BaseHeight = TileSize[1] + 1; // 1 row larger than 1 tile height
2931 gmmParams.Depth = 0x1;
2932
2933 GMM_RESOURCE_INFO *ResourceInfo;
2934 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2935
2936 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2937 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2938 VerifyResourcePitch<true>(ResourceInfo, TileSize[0] * 4); // As wide as 2 tile, but 4-tile pitch alignment
2939 VerifyResourcePitchInTiles<true>(ResourceInfo, 4); // 2 tile wide, but 4-tile pitch alignment
2940 VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * 4 * 2); // 4 tile wide; and 2-tile high
2941
2942 VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
2943 //test main surface base alignment is 16KB
2944 //For Y test main surface pitch is 4-tileY aligned
2945 EXPECT_EQ(GMM_KBYTE(64), ResourceInfo->GetBaseAlignment());
2946 EXPECT_EQ(0, ResourceInfo->GetRenderPitchTiles() % 4);
2947 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
2948 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
2949
2950 { //separate Aux
2951 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
2952
2953 GMM_RESOURCE_INFO *AuxResourceInfo;
2954 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2955 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
2956 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
2957 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
2958 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
2959 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
2960 }
2961 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2962 }
2963 }
2964
2965
2966 /// @brief ULT for 2D TileYf Compressed Resource
TEST_F(CTestGen12dGPUResource,DISABLED_Test2DTileYfAMFSResource)2967 TEST_F(CTestGen12dGPUResource, DISABLED_Test2DTileYfAMFSResource)
2968 {
2969 const uint32_t HAlign[TEST_BPP_MAX] = {64, 64, 32, 32, 16};
2970 const uint32_t VAlign[TEST_BPP_MAX] = {64, 32, 32, 16, 16};
2971
2972 const uint32_t TileSize[TEST_BPP_MAX][2] = {{64, 64},
2973 {128, 32},
2974 {128, 32},
2975 {256, 16},
2976 {256, 16}};
2977
2978 GMM_RESCREATE_PARAMS gmmParams = {};
2979 gmmParams.Type = RESOURCE_2D;
2980 gmmParams.NoGfxMemory = 1;
2981 gmmParams.Flags.Info.TiledY = 1;
2982 gmmParams.Flags.Info.TiledYf = 1;
2983 gmmParams.Flags.Gpu.Texture = 1;
2984 gmmParams.Flags.Gpu.ProceduralTexture = 1;
2985 // If unifiedAuxSurf reqd (mandatory for displayable or cross-adapter shared), turn on .CCS/.MMC and .UnifiedAuxSurface too
2986
2987 //Allocate 1x1 surface
2988 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2989 {
2990 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
2991 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
2992 //gmmParams.Flags.Gpu.MMC = 0; //Turn on to check unifiedaux creation
2993
2994 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2995 GMM_TILE_MODE TileMode = DEFINE_TILE(YF_2D, bpp);
2996 gmmParams.Format = SetResourceFormat(bpp);
2997 gmmParams.BaseWidth64 = 0x1;
2998 gmmParams.BaseHeight = 0x1;
2999
3000 GMM_RESOURCE_INFO *ResourceInfo;
3001 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
3002
3003 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
3004 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
3005 VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0]); // As wide as 1 Tile
3006 VerifyResourcePitchInTiles<true>(ResourceInfo, 1); // 1 Tile wide
3007 VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4)); // 1 Tile Big
3008 VerifyResourceQPitch<false>(ResourceInfo, 0); // Not Tested
3009
3010 //test main surface base alignment is 4KB, since AMFS PT isn't compressed
3011 //but uses same linear CCS as compression
3012 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetBaseAlignment());
3013 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
3014 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
3015
3016
3017 { //separate Aux
3018 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
3019
3020 GMM_RESOURCE_INFO *AuxResourceInfo;
3021 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
3022 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
3023 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
3024 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
3025 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
3026 EXPECT_EQ(0, AuxResourceInfo->GmmGetTileMode());
3027 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
3028 }
3029 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
3030 }
3031
3032 // Allocate surface that requires multi tiles in two dimension
3033 // Allocate 2 tiles in X dimension
3034 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
3035 {
3036 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
3037 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
3038
3039 TEST_BPP bpp = static_cast<TEST_BPP>(i);
3040 GMM_TILE_MODE TileMode = DEFINE_TILE(YF_2D, bpp);
3041
3042 gmmParams.Format = SetResourceFormat(bpp);
3043 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
3044 gmmParams.BaseHeight = 0x1;
3045 gmmParams.Depth = 0x1;
3046
3047 GMM_RESOURCE_INFO *ResourceInfo;
3048 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
3049
3050 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
3051 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
3052 VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0] * 2); // As wide as 2 tile
3053 VerifyResourcePitchInTiles<true>(ResourceInfo, 2); // 2 tile wide
3054 VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * 2); // 2 tile big
3055
3056 VerifyResourceQPitch<false>(ResourceInfo, 0);
3057
3058 //test main surface base alignment is 4KB
3059 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetBaseAlignment());
3060 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
3061 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
3062
3063 { //separate Aux
3064 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
3065
3066 GMM_RESOURCE_INFO *AuxResourceInfo;
3067 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
3068 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
3069 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
3070 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
3071 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
3072 EXPECT_EQ(0, AuxResourceInfo->GmmGetTileMode());
3073
3074 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
3075 }
3076 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
3077 }
3078
3079 // Allocate surface that requires multi tiles in two dimension
3080 // Allocate 2 tiles in X/Y dimension
3081 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
3082 {
3083 gmmParams.Flags.Gpu.UnifiedAuxSurface = 1; //Turn off for separate aux creation
3084 gmmParams.Flags.Gpu.CCS = 1; //Turn off for separate aux creation
3085
3086 TEST_BPP bpp = static_cast<TEST_BPP>(i);
3087 GMM_TILE_MODE TileMode = DEFINE_TILE(YF_2D, bpp);
3088 gmmParams.Format = SetResourceFormat(bpp);
3089 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
3090 gmmParams.BaseHeight = TileSize[i][1] + 1; // 1 row larger than 1 tile height
3091 gmmParams.Depth = 0x1;
3092
3093 GMM_RESOURCE_INFO *ResourceInfo;
3094 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
3095
3096 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
3097 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
3098 VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0] * 2); // As wide as 2 tile
3099 VerifyResourcePitchInTiles<true>(ResourceInfo, 2); // 2 tile wide
3100 VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * 2 * 2); // 2 tile wide; and 2-tile high
3101
3102 VerifyResourceQPitch<false>(ResourceInfo, 0);
3103 //test main surface base alignment is 4KB
3104 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetBaseAlignment());
3105 EXPECT_EQ(0, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS) % PAGE_SIZE);
3106 EXPECT_EQ(GMM_KBYTE(4), ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
3107
3108 { //separate Aux
3109 gmmParams.Flags.Gpu.UnifiedAuxSurface = 0;
3110
3111 GMM_RESOURCE_INFO *AuxResourceInfo;
3112 AuxResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
3113 EXPECT_EQ(ResourceInfo->GetAuxHAlign(), AuxResourceInfo->GetHAlign());
3114 EXPECT_EQ(ResourceInfo->GetAuxVAlign(), AuxResourceInfo->GetVAlign());
3115 EXPECT_EQ(ResourceInfo->GetUnifiedAuxPitch(), AuxResourceInfo->GetRenderPitch());
3116 EXPECT_EQ(ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS), AuxResourceInfo->GetSizeSurface());
3117 EXPECT_EQ(0, AuxResourceInfo->GmmGetTileMode());
3118 pGmmULTClientContext->DestroyResInfoObject(AuxResourceInfo);
3119 }
3120 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
3121 }
3122 }
3123
3124 /// @brief ULT for MSAA Resource - adddepth MSAA, MCS surf param verificaton, compression case
TEST_F(CTestGen12dGPUResource,DISABLED_TestColorMSAA)3125 TEST_F(CTestGen12dGPUResource, DISABLED_TestColorMSAA)
3126 {
3127 //Tile dimensions in Bytes
3128 const uint32_t MCSTileSize[1][2] = {128, 32}; //MCS is TileY
3129
3130 const uint32_t TestDimensions[4][2] = {
3131 //Input dimensions in #Tiles
3132 {15, 20}, //16 Tiles x 20 <Max Width: Depth MSS crosses Pitch limit beyond this>
3133 {0, 0}, //1x1x1
3134 {1, 0}, //2 Tilesx1
3135 {1, 1}, //2 Tiles x 2
3136 };
3137
3138 uint32_t TestArraySize[2] = {1, 5};
3139 uint32_t MinPitch = 32;
3140
3141 uint32_t HAlign, VAlign, TileDimX, TileDimY, MCSHAlign, MCSVAlign, TileSize;
3142 uint32_t ExpectedMCSBpp;
3143 std::vector<tuple<int, int, int, bool, int, int>> List; //TEST_TILE_TYPE, TEST_BPP, TEST_RESOURCE_TYPE, Depth or RT, TestDimension index, ArraySize
3144 auto Size = BuildInputIterator(List, 4, 2, false); // Size of arrays TestDimensions, TestArraySize
3145
3146 for(auto element : List)
3147 {
3148 GMM_RESCREATE_PARAMS gmmParams = {};
3149 gmmParams.Flags.Info = {0};
3150
3151 TEST_TILE_TYPE Tiling = (TEST_TILE_TYPE)std::get<0>(element);
3152 TEST_BPP Bpp = (TEST_BPP)std::get<1>(element);
3153 TEST_RESOURCE_TYPE ResType = (TEST_RESOURCE_TYPE)std::get<2>(element);
3154 bool IsRT = std::get<3>(element); // True for RT, False for Depth
3155 int TestDimIdx = std::get<4>(element); //index into TestDimensions array
3156 int ArrayIdx = std::get<5>(element); //index into TestArraySize
3157 TileSize = (Tiling == TEST_TILEYS) ? GMM_KBYTE(64) : GMM_KBYTE(4);
3158
3159 //Discard un-supported Tiling/Res_type/bpp for this test
3160 if(ResType != TEST_RESOURCE_2D || //No 1D/3D/Cube. Supported 2D mip-maps/array
3161 (!IsRT && (Tiling == TEST_TILEX || //Specifications doesn't support TileX for Depth
3162 !(Bpp == TEST_BPP_16 || Bpp == TEST_BPP_32)))) //depth supported on 16bit, 32bit formats only
3163 continue;
3164
3165 if(!IsRT)
3166 continue; //comment depth msaa for now (requires change in h/v align)
3167
3168 SetTileFlag(gmmParams, Tiling);
3169 SetResType(gmmParams, ResType);
3170 SetResGpuFlags(gmmParams, IsRT);
3171 SetResArraySize(gmmParams, TestArraySize[ArrayIdx]);
3172
3173 gmmParams.NoGfxMemory = 1;
3174 gmmParams.Format = SetResourceFormat(Bpp);
3175 for(uint32_t k = MSAA_2x; k <= MSAA_16x; k++)
3176 {
3177 GetAlignmentAndTileDimensionsForMSAA(Bpp, IsRT, Tiling, (TEST_MSAA)k,
3178 TileDimX, TileDimY, HAlign, VAlign,
3179 ExpectedMCSBpp, MCSHAlign, MCSVAlign);
3180
3181 //gmmParams.BaseWidth64 = TestDimensions[TestDimIdx][0] * TileDimX + 0x1;
3182 //gmmParams.BaseHeight = TestDimensions[TestDimIdx][1] * TileDimY + 0x1;
3183 gmmParams.BaseWidth64 = 4;
3184 gmmParams.BaseHeight = 4;
3185 gmmParams.Depth = 0x1;
3186 gmmParams.MSAA.NumSamples = static_cast<uint32_t>(pow((double)2, k));
3187 gmmParams.Flags.Gpu.MCS = 0;
3188
3189 //MSS surface
3190 GMM_RESOURCE_INFO *MSSResourceInfo;
3191 MSSResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
3192
3193 if(MSSResourceInfo)
3194 {
3195 VerifyResourceHAlign<true>(MSSResourceInfo, HAlign);
3196 VerifyResourceVAlign<true>(MSSResourceInfo, VAlign);
3197 if(IsRT) //Arrayed MSS
3198 {
3199 uint32_t ExpectedPitch = 0, ExpectedQPitch = 0;
3200 ExpectedPitch = GMM_ULT_ALIGN(GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign) * (int)pow(2.0, Bpp), TileDimX); // Aligned width * bpp, aligned to TileWidth
3201 ExpectedPitch = GFX_MAX(ExpectedPitch, MinPitch);
3202 VerifyResourcePitch<true>(MSSResourceInfo, ExpectedPitch);
3203 if(Tiling != TEST_LINEAR)
3204 VerifyResourcePitchInTiles<true>(MSSResourceInfo, ExpectedPitch / TileDimX);
3205
3206 ExpectedQPitch = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign);
3207 if(gmmParams.ArraySize > 1) //Gen9: Qpitch is distance between array slices (not sample slices)
3208 {
3209 VerifyResourceQPitch<true>(MSSResourceInfo, ExpectedQPitch);
3210 }
3211
3212 uint32_t ExpectedHeight = GMM_ULT_ALIGN(ExpectedQPitch * gmmParams.MSAA.NumSamples * gmmParams.ArraySize, TileDimY); //Align Height =ExpectedPitch * NumSamples * ExpectedQPitch, to Tile-Height
3213 VerifyResourceSize<true>(MSSResourceInfo, GMM_ULT_ALIGN(ExpectedPitch * ExpectedHeight, TileSize));
3214 }
3215 }
3216
3217 pGmmULTClientContext->DestroyResInfoObject(MSSResourceInfo);
3218 } //NumSamples = k
3219 } //Iterate through all Input types
3220
3221 //Mip-mapped, MSAA case:
3222 }
3223 /// @brief ULT for auto-tile selction in Gmm.
TEST_F(CTestGen12dGPUResource,Test2DMippedResourceAutoTiling)3224 TEST_F(CTestGen12dGPUResource, Test2DMippedResourceAutoTiling)
3225 {
3226 GMM_RESCREATE_PARAMS gmmParams = {};
3227 gmmParams.Type = RESOURCE_2D;
3228 gmmParams.NoGfxMemory = 1;
3229 gmmParams.Flags.Gpu.Texture = 1;
3230 gmmParams.MaxLod = 5;
3231 gmmParams.ArraySize = 4;
3232
3233 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
3234 {
3235 TEST_BPP bpp = static_cast<TEST_BPP>(i);
3236 gmmParams.Format = SetResourceFormat(bpp);
3237 gmmParams.BaseWidth64 = 0x120;
3238 gmmParams.BaseHeight = 0x120;
3239
3240 GMM_RESOURCE_INFO *ResourceInfo;
3241 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
3242
3243 GMM_RESOURCE_INFO *ResourceInfo2;
3244 ResourceInfo2 = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
3245
3246 //Verify Gmm tile-selection able to get same tiling mode for resources created with same GmmParams
3247 //... where 1st iteration uses auto-tile-selection, and next creates with previouly selected tile-mode.
3248 //Below ensures, Gmm modified gmmParams to final tile-mode, or left it at initial (no tiling selection).
3249 EXPECT_EQ(ResourceInfo->GmmGetTileMode(), ResourceInfo2->GmmGetTileMode());
3250
3251 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
3252 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo2);
3253 }
3254 }
3255