1 /*==============================================================================
2 Copyright(c) 2017 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 "GmmGen9ResourceULT.h"
24
25 using namespace std;
26
27
28 /////////////////////////////////////////////////////////////////////////////////////
29 /// CTestGen9Resource Constructor
30 ///
31 /////////////////////////////////////////////////////////////////////////////////////
CTestGen9Resource()32 CTestGen9Resource::CTestGen9Resource()
33 {
34 }
35
36 /////////////////////////////////////////////////////////////////////////////////////
37 /// CTestGen9Resource Destructor
38 ///
39 /////////////////////////////////////////////////////////////////////////////////////
~CTestGen9Resource()40 CTestGen9Resource::~CTestGen9Resource()
41 {
42 }
43
44 /////////////////////////////////////////////////////////////////////////////////////
45 /// Sets up common environment for Resource fixture tests. this is called once per
46 /// test case before executing all tests under resource fixture test case.
47 /// It also calls SetupTestCase from CommonULT to initialize global context and others.
48 /////////////////////////////////////////////////////////////////////////////////////
SetUpTestCase()49 void CTestGen9Resource::SetUpTestCase()
50 {
51 GfxPlatform.eProductFamily = IGFX_SKYLAKE;
52 GfxPlatform.eRenderCoreFamily = IGFX_GEN9_CORE;
53
54 CommonULT::SetUpTestCase();
55
56 printf("%s\n", __FUNCTION__);
57 }
58
59 /////////////////////////////////////////////////////////////////////////////////////
60 /// cleans up once all the tests finish execution. It also calls TearDownTestCase
61 /// from CommonULT to destroy global context and others.
62 /////////////////////////////////////////////////////////////////////////////////////
TearDownTestCase()63 void CTestGen9Resource::TearDownTestCase()
64 {
65 printf("%s\n", __FUNCTION__);
66
67 CommonULT::TearDownTestCase();
68 }
69
70 // ********************************************************************************//
71
72 /// @brief ULT for 1D Linear Resource
TEST_F(CTestGen9Resource,Test1DLinearResource)73 TEST_F(CTestGen9Resource, Test1DLinearResource)
74 {
75 // Horizontal pixel alignment
76 const uint32_t HAlign = 64;
77
78 GMM_RESCREATE_PARAMS gmmParams = {};
79 gmmParams.Type = RESOURCE_1D;
80 gmmParams.NoGfxMemory = 1;
81 gmmParams.Flags.Info.Linear = 1;
82 gmmParams.Flags.Gpu.Texture = 1;
83
84 // Allocate 1x1 surface
85 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
86 {
87 TEST_BPP bpp = static_cast<TEST_BPP>(i);
88 gmmParams.Format = SetResourceFormat(bpp);
89 gmmParams.BaseWidth64 = 0x1;
90 gmmParams.BaseHeight = 1;
91
92 GMM_RESOURCE_INFO *ResourceInfo;
93 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
94
95 uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign);
96 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
97 uint32_t AlignedSize = GMM_ULT_ALIGN(PitchInBytes, PAGE_SIZE);
98
99 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
100 VerifyResourceVAlign<false>(ResourceInfo, 0); // N/A for 1D
101 VerifyResourcePitch<false>(ResourceInfo, 0); // N/A for 1D
102 VerifyResourcePitchInTiles<false>(ResourceInfo, 0); // N/A for linear
103 VerifyResourceSize<true>(ResourceInfo, AlignedSize);
104 VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-arrayed
105
106 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
107 }
108
109
110 // Allocate more than 1 page
111 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
112 {
113 TEST_BPP bpp = static_cast<TEST_BPP>(i);
114 gmmParams.Format = SetResourceFormat(bpp);
115 gmmParams.BaseWidth64 = 0x1001;
116 gmmParams.BaseHeight = 1;
117
118 GMM_RESOURCE_INFO *ResourceInfo;
119 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
120
121 uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign);
122 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
123 uint32_t AlignedSize = GMM_ULT_ALIGN(PitchInBytes, PAGE_SIZE);
124
125 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
126 VerifyResourceVAlign<false>(ResourceInfo, 0); // N/A for 1D
127 VerifyResourcePitch<false>(ResourceInfo, 0); // N/A for 1D
128 VerifyResourcePitchInTiles<false>(ResourceInfo, 0); // N/A for linear
129 VerifyResourceSize<true>(ResourceInfo, AlignedSize);
130 VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-arrayed
131
132 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
133 }
134 }
135
136 /// @brief ULT for 1D Linear Resource Arrays
TEST_F(CTestGen9Resource,Test1DLinearResourceArrays)137 TEST_F(CTestGen9Resource, Test1DLinearResourceArrays)
138 {
139 // Horizontal pixel alignment
140 const uint32_t HAlign = 64;
141
142 GMM_RESCREATE_PARAMS gmmParams = {};
143 gmmParams.Type = RESOURCE_1D;
144 gmmParams.NoGfxMemory = 1;
145 gmmParams.Flags.Info.Linear = 1;
146 gmmParams.Flags.Gpu.Texture = 1;
147 gmmParams.ArraySize = 4;
148
149 // Allocate more than 1 page
150 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
151 {
152 TEST_BPP bpp = static_cast<TEST_BPP>(i);
153 gmmParams.Format = SetResourceFormat(bpp);
154 gmmParams.BaseWidth64 = 0x1001;
155 gmmParams.BaseHeight = 1;
156
157 GMM_RESOURCE_INFO *ResourceInfo;
158 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
159
160 uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign);
161 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
162 uint32_t AlignedSize = GMM_ULT_ALIGN(PitchInBytes * gmmParams.ArraySize, PAGE_SIZE);
163
164 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
165 VerifyResourceVAlign<false>(ResourceInfo, 0); // N/A for 1D
166 VerifyResourcePitch<false>(ResourceInfo, 0); // N/A for 1D
167 VerifyResourcePitchInTiles<false>(ResourceInfo, 0); // N/A for linear
168 VerifyResourceSize<true>(ResourceInfo, AlignedSize);
169 VerifyResourceQPitch<true>(ResourceInfo, AlignedWidth);
170
171 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
172 }
173 }
174
175 /// @brief ULT for 1D Mipped Linear Resource
TEST_F(CTestGen9Resource,Test1DLinearResourceMips)176 TEST_F(CTestGen9Resource, Test1DLinearResourceMips)
177 {
178 // Horizontal pixel alignment
179 const uint32_t HAlign = 64;
180
181 GMM_RESCREATE_PARAMS gmmParams = {};
182 gmmParams.Type = RESOURCE_1D;
183 gmmParams.NoGfxMemory = 1;
184 gmmParams.Flags.Info.Linear = 1;
185 gmmParams.Flags.Gpu.Texture = 1;
186 gmmParams.MaxLod = 5;
187
188 // Allocate 256x1 surface
189 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
190 {
191 TEST_BPP bpp = static_cast<TEST_BPP>(i);
192 gmmParams.Format = SetResourceFormat(bpp);
193 gmmParams.BaseWidth64 = 0x100;
194 gmmParams.BaseHeight = 0x1;
195
196 GMM_RESOURCE_INFO *ResourceInfo;
197 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
198
199 uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign);
200 for(int mip = 1; mip <= gmmParams.MaxLod; mip++)
201 {
202 // Since 1D doesn't have a height, mips are just based on width
203 AlignedWidth += GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> mip, HAlign);
204 }
205 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
206 uint32_t AlignedSize = GMM_ULT_ALIGN(PitchInBytes, PAGE_SIZE);
207
208 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
209 VerifyResourceVAlign<false>(ResourceInfo, 0); // N/A for 1D
210 VerifyResourcePitch<false>(ResourceInfo, 0); // N/A for 1D
211 VerifyResourcePitchInTiles<false>(ResourceInfo, 0); // N/A for linear
212 VerifyResourceSize<true>(ResourceInfo, AlignedSize);
213 VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-arrayed
214
215 // Mip0 should be at offset 0. X/Y/Z Offset should be 0 for linear.
216 GMM_REQ_OFFSET_INFO OffsetInfo = {};
217 OffsetInfo.ReqRender = 1;
218 OffsetInfo.MipLevel = 0; //Mip 0
219 ResourceInfo->GetOffset(OffsetInfo);
220 EXPECT_EQ(0, OffsetInfo.Render.Offset64);
221 EXPECT_EQ(0, OffsetInfo.Render.XOffset);
222 EXPECT_EQ(0, OffsetInfo.Render.YOffset);
223 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
224
225 // All mips should be right after one another linearly
226 uint32_t StartOfMip = 0;
227 for(int mip = 1; mip <= gmmParams.MaxLod; mip++)
228 {
229 OffsetInfo = {};
230 OffsetInfo.ReqRender = 1;
231 OffsetInfo.MipLevel = mip;
232 ResourceInfo->GetOffset(OffsetInfo);
233 StartOfMip += GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> (mip - 1), HAlign) * GetBppValue(bpp);
234 EXPECT_EQ(StartOfMip, OffsetInfo.Render.Offset64);
235 EXPECT_EQ(0, OffsetInfo.Render.XOffset);
236 EXPECT_EQ(0, OffsetInfo.Render.YOffset);
237 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
238 }
239
240 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
241 }
242 }
243
244 /// @brief ULT for 1D TileYs Resource -TRMODE_64KB
TEST_F(CTestGen9Resource,Test1DTileYsResource)245 TEST_F(CTestGen9Resource, Test1DTileYsResource)
246 {
247 const uint32_t TileSize[TEST_BPP_MAX] = {65536, 32768, 16384, 8192, 4096};
248
249 GMM_RESCREATE_PARAMS gmmParams = {};
250 gmmParams.Type = RESOURCE_1D;
251 gmmParams.NoGfxMemory = 1;
252 gmmParams.Flags.Info.TiledYs = 1;
253 gmmParams.Flags.Gpu.Texture = 1;
254
255 // Allocate 1x1 surface
256 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
257 {
258 TEST_BPP bpp = static_cast<TEST_BPP>(i);
259 gmmParams.Format = SetResourceFormat(bpp);
260 gmmParams.BaseWidth64 = 0x1;
261 gmmParams.BaseHeight = 1;
262
263 GMM_RESOURCE_INFO *ResourceInfo;
264 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
265
266 uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[i]);
267 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
268 uint32_t AlignedSize = GMM_ULT_ALIGN(PitchInBytes, PAGE_SIZE);
269
270 VerifyResourceHAlign<true>(ResourceInfo, TileSize[i]);
271 VerifyResourceVAlign<false>(ResourceInfo, 0); // N/A for 1D
272 VerifyResourcePitch<false>(ResourceInfo, 0); // N/A for 1D
273 VerifyResourcePitchInTiles<false>(ResourceInfo, 0); // N/A for linear
274 VerifyResourceSize<true>(ResourceInfo, AlignedSize);
275 VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-arrayed
276
277 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
278 }
279
280 // Allocate more than 1 "tile", where applicable. Max width of the surface can only be
281 // 16K (see RENDER_SURFACE_STATE). Depending on the bpp, 16K width may not use more than
282 // 1 "tile" (only 64/128 will use "multi-tile").
283 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
284 {
285 TEST_BPP bpp = static_cast<TEST_BPP>(i);
286 gmmParams.Format = SetResourceFormat(bpp);
287 gmmParams.BaseWidth64 = 16 * 1024; // 16K is the max width you can specify
288 gmmParams.BaseHeight = 1;
289
290 GMM_RESOURCE_INFO *ResourceInfo;
291 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
292
293 uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[i]);
294 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
295 uint32_t AlignedSize = GMM_ULT_ALIGN(PitchInBytes, PAGE_SIZE);
296
297 VerifyResourceHAlign<true>(ResourceInfo, TileSize[i]);
298 VerifyResourceVAlign<false>(ResourceInfo, 0); // N/A for 1D
299 VerifyResourcePitch<false>(ResourceInfo, 0); // N/A for 1D
300 VerifyResourcePitchInTiles<false>(ResourceInfo, 0); // N/A for linear
301 VerifyResourceSize<true>(ResourceInfo, AlignedSize);
302 VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-arrayed
303
304 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
305 }
306 }
307
308 /// @brief ULT for 1D TileYS Resource Arrays
TEST_F(CTestGen9Resource,Test1DTileYsResourceArrays)309 TEST_F(CTestGen9Resource, Test1DTileYsResourceArrays)
310 {
311 const uint32_t TileSize[TEST_BPP_MAX] = {65536, 32768, 16384, 8192, 4096};
312
313 GMM_RESCREATE_PARAMS gmmParams = {};
314 gmmParams.Type = RESOURCE_1D;
315 gmmParams.NoGfxMemory = 1;
316 gmmParams.Flags.Info.TiledYs = 1;
317 gmmParams.Flags.Gpu.Texture = 1;
318 gmmParams.ArraySize = 4;
319
320 // Allocate more than 1 page
321 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
322 {
323 TEST_BPP bpp = static_cast<TEST_BPP>(i);
324 gmmParams.Format = SetResourceFormat(bpp);
325 gmmParams.BaseWidth64 = 16 * 1024; // 16K is the max width you can specify
326 gmmParams.BaseHeight = 1;
327
328 GMM_RESOURCE_INFO *ResourceInfo;
329 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
330
331 uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[i]);
332 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
333 uint32_t AlignedSize = GMM_ULT_ALIGN(PitchInBytes * gmmParams.ArraySize, PAGE_SIZE);
334
335 VerifyResourceHAlign<true>(ResourceInfo, TileSize[i]);
336 VerifyResourceVAlign<false>(ResourceInfo, 0); // N/A for 1D
337 VerifyResourcePitch<false>(ResourceInfo, 0); // N/A for 1D
338 VerifyResourcePitchInTiles<false>(ResourceInfo, 0); // N/A for linear
339 VerifyResourceSize<true>(ResourceInfo, AlignedSize);
340 VerifyResourceQPitch<true>(ResourceInfo, AlignedWidth);
341
342 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
343 }
344 }
345
346 /// @brief ULT for 1D Mipped TileYS Resource
TEST_F(CTestGen9Resource,Test1DTileYsResourceMips)347 TEST_F(CTestGen9Resource, Test1DTileYsResourceMips)
348 {
349 const uint32_t TileSize[TEST_BPP_MAX] = {65536, 32768, 16384, 8192, 4096};
350 const uint32_t Mts[TEST_BPP_MAX] = {32768, 16384, 8192, 4096, 2048};
351
352 GMM_RESCREATE_PARAMS gmmParams = {};
353 gmmParams.Type = RESOURCE_1D;
354 gmmParams.NoGfxMemory = 1;
355 gmmParams.Flags.Info.TiledYs = 1;
356 gmmParams.Flags.Gpu.Texture = 1;
357 gmmParams.MaxLod = 5;
358
359 // Allocate all mips in 1 tile or multiple tiles, depending on the bpp
360 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
361 {
362 TEST_BPP bpp = static_cast<TEST_BPP>(i);
363 gmmParams.Format = SetResourceFormat(bpp);
364 gmmParams.BaseWidth64 = 16 * 1024; // 16K is the max width you can specify
365 gmmParams.BaseHeight = 0x1;
366
367 GMM_RESOURCE_INFO *ResourceInfo;
368 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
369
370 uint32_t MaxMip;
371 uint32_t MipTailStart = gmmParams.MaxLod;
372 for(MaxMip = 0; MaxMip <= gmmParams.MaxLod; MaxMip++)
373 {
374 if((gmmParams.BaseWidth64 >> MaxMip) <= Mts[i])
375 {
376 MipTailStart = MaxMip;
377 break;
378 }
379 }
380
381 uint32_t AlignedWidth = 0;
382 for(int mip = 0; mip <= MaxMip; mip++)
383 {
384 // Since 1D doesn't have a height, mips are just based on width
385 AlignedWidth += GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> mip, TileSize[i]);
386 ;
387 }
388
389 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
390 uint32_t AlignedSize = GMM_ULT_ALIGN(PitchInBytes, PAGE_SIZE);
391
392 VerifyResourceHAlign<true>(ResourceInfo, TileSize[i]);
393 VerifyResourceVAlign<false>(ResourceInfo, 0); // N/A for 1D
394 VerifyResourcePitch<false>(ResourceInfo, 0); // N/A for 1D
395 VerifyResourcePitchInTiles<false>(ResourceInfo, 0); // N/A for linear
396 VerifyResourceSize<true>(ResourceInfo, AlignedSize);
397 VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-arrayed
398
399 // All mips should be right after one another linearly, until the miptail
400 uint32_t StartOfMip = 0;
401 int mip;
402 for(mip = 0; mip < MaxMip; mip++)
403 {
404 GMM_REQ_OFFSET_INFO OffsetInfo = {};
405 OffsetInfo.ReqRender = 1;
406 OffsetInfo.MipLevel = mip;
407 ResourceInfo->GetOffset(OffsetInfo);
408 StartOfMip += (mip == 0 ? 0 : GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> (mip - 1), TileSize[i]) * GetBppValue(bpp));
409 EXPECT_EQ(StartOfMip, OffsetInfo.Render.Offset64);
410 EXPECT_EQ(0, OffsetInfo.Render.XOffset);
411 EXPECT_EQ(0, OffsetInfo.Render.YOffset);
412 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
413 }
414
415 uint32_t MipTailOffsets[GMM_ULT_MAX_MIPMAP] = {32768, 16384, 8192, 4096, 2048, 1024, 768, 512, 448, 384, 320, 256, 192, 128, 64};
416 // Check for offset inside miptails.
417 EXPECT_EQ(MipTailStart, ResourceInfo->GetPackedMipTailStartLod());
418 StartOfMip += GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> (mip - 1), TileSize[i]) * GetBppValue(bpp); // Start of MipTail
419 for(int slot = 0; mip <= gmmParams.MaxLod; mip++, slot++)
420 {
421 GMM_REQ_OFFSET_INFO OffsetInfo = {};
422 OffsetInfo.ReqRender = 1;
423 OffsetInfo.MipLevel = mip;
424 ResourceInfo->GetOffset(OffsetInfo);
425 EXPECT_EQ(StartOfMip, OffsetInfo.Render.Offset64); // Start of Miptail
426 EXPECT_EQ(MipTailOffsets[slot], OffsetInfo.Render.XOffset); // Offset within miptail
427 EXPECT_EQ(0, OffsetInfo.Render.YOffset);
428 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
429 }
430
431 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
432 }
433 }
434
435 /// @brief ULT for 1D TileYs Resource -TRMODE_4KB
TEST_F(CTestGen9Resource,Test1DTileYfResource)436 TEST_F(CTestGen9Resource, Test1DTileYfResource)
437 {
438 const uint32_t TileSize[TEST_BPP_MAX] = {4096, 2048, 1024, 512, 256};
439
440 GMM_RESCREATE_PARAMS gmmParams = {};
441 gmmParams.Type = RESOURCE_1D;
442 gmmParams.NoGfxMemory = 1;
443 gmmParams.Flags.Info.TiledYf = 1;
444 gmmParams.Flags.Gpu.Texture = 1;
445
446 // Allocate 1x1 surface
447 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
448 {
449 TEST_BPP bpp = static_cast<TEST_BPP>(i);
450 gmmParams.Format = SetResourceFormat(bpp);
451 gmmParams.BaseWidth64 = 0x1;
452 gmmParams.BaseHeight = 1;
453
454 GMM_RESOURCE_INFO *ResourceInfo;
455 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
456
457 uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[i]);
458 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
459 uint32_t AlignedSize = GMM_ULT_ALIGN(PitchInBytes, PAGE_SIZE);
460
461 VerifyResourceHAlign<true>(ResourceInfo, TileSize[i]);
462 VerifyResourceVAlign<false>(ResourceInfo, 0); // N/A for 1D
463 VerifyResourcePitch<false>(ResourceInfo, 0); // N/A for 1D
464 VerifyResourcePitchInTiles<false>(ResourceInfo, 0); // N/A for linear
465 VerifyResourceSize<true>(ResourceInfo, AlignedSize);
466 VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-arrayed
467
468 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
469 }
470
471 // Allocate more than 1 "tile"
472 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
473 {
474 TEST_BPP bpp = static_cast<TEST_BPP>(i);
475 gmmParams.Format = SetResourceFormat(bpp);
476 gmmParams.BaseWidth64 = TileSize[i] + 1;
477 gmmParams.BaseHeight = 1;
478
479 GMM_RESOURCE_INFO *ResourceInfo;
480 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
481
482 uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[i]);
483 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
484 uint32_t AlignedSize = GMM_ULT_ALIGN(PitchInBytes, PAGE_SIZE);
485
486 VerifyResourceHAlign<true>(ResourceInfo, TileSize[i]);
487 VerifyResourceVAlign<false>(ResourceInfo, 0); // N/A for 1D
488 VerifyResourcePitch<false>(ResourceInfo, 0); // N/A for 1D
489 VerifyResourcePitchInTiles<false>(ResourceInfo, 0); // N/A for linear
490 VerifyResourceSize<true>(ResourceInfo, AlignedSize);
491 VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-arrayed
492
493 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
494 }
495 }
496
497 /// @brief ULT for 1D TileYF Resource Arrays
TEST_F(CTestGen9Resource,Test1DTileYfResourceArrays)498 TEST_F(CTestGen9Resource, Test1DTileYfResourceArrays)
499 {
500 const uint32_t TileSize[TEST_BPP_MAX] = {4096, 2048, 1024, 512, 256};
501
502 GMM_RESCREATE_PARAMS gmmParams = {};
503 gmmParams.Type = RESOURCE_1D;
504 gmmParams.NoGfxMemory = 1;
505 gmmParams.Flags.Info.TiledYf = 1;
506 gmmParams.Flags.Gpu.Texture = 1;
507 gmmParams.ArraySize = 4;
508
509 // Allocate more than 1 page
510 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
511 {
512 TEST_BPP bpp = static_cast<TEST_BPP>(i);
513 gmmParams.Format = SetResourceFormat(bpp);
514 gmmParams.BaseWidth64 = 16 * 1024; // 16K is the max width you can specify
515 gmmParams.BaseHeight = 1;
516
517 GMM_RESOURCE_INFO *ResourceInfo;
518 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
519
520 uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[i]);
521 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
522 uint32_t AlignedSize = GMM_ULT_ALIGN(PitchInBytes * gmmParams.ArraySize, PAGE_SIZE);
523
524 VerifyResourceHAlign<true>(ResourceInfo, TileSize[i]);
525 VerifyResourceVAlign<false>(ResourceInfo, 0); // N/A for 1D
526 VerifyResourcePitch<false>(ResourceInfo, 0); // N/A for 1D
527 VerifyResourcePitchInTiles<false>(ResourceInfo, 0); // N/A for linear
528 VerifyResourceSize<true>(ResourceInfo, AlignedSize);
529 VerifyResourceQPitch<true>(ResourceInfo, AlignedWidth);
530
531 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
532 }
533 }
534
535 /// @brief ULT for 1D Mipped TileYF Resource
TEST_F(CTestGen9Resource,Test1DTileYfResourceMips)536 TEST_F(CTestGen9Resource, Test1DTileYfResourceMips)
537 {
538 const uint32_t TileSize[TEST_BPP_MAX] = {4096, 2048, 1024, 512, 256};
539 const uint32_t Mts[TEST_BPP_MAX] = {2048, 1024, 512, 256, 128};
540
541 GMM_RESCREATE_PARAMS gmmParams = {};
542 gmmParams.Type = RESOURCE_1D;
543 gmmParams.NoGfxMemory = 1;
544 gmmParams.Flags.Info.TiledYf = 1;
545 gmmParams.Flags.Gpu.Texture = 1;
546 gmmParams.MaxLod = 8;
547
548 // Allocate all mips in 1 tile or multiple tiles, depending on the bpp
549 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
550 {
551 TEST_BPP bpp = static_cast<TEST_BPP>(i);
552 gmmParams.Format = SetResourceFormat(bpp);
553 gmmParams.BaseWidth64 = 16 * 1024; // 16K is the max width you can specify
554 gmmParams.BaseHeight = 0x1;
555
556 GMM_RESOURCE_INFO *ResourceInfo;
557 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
558
559 uint32_t MaxMip;
560 uint32_t MipTailStart = gmmParams.MaxLod;
561 for(MaxMip = 0; MaxMip <= gmmParams.MaxLod; MaxMip++)
562 {
563 if((gmmParams.BaseWidth64 >> MaxMip) <= Mts[i])
564 {
565 MipTailStart = MaxMip;
566 break;
567 }
568 }
569
570 uint32_t AlignedWidth = 0;
571 for(int mip = 0; mip <= MaxMip; mip++)
572 {
573 // Since 1D doesn't have a height, mips are just based on width
574 AlignedWidth += GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> mip, TileSize[i]);
575 }
576
577 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
578 uint32_t AlignedSize = GMM_ULT_ALIGN(PitchInBytes, PAGE_SIZE);
579
580 VerifyResourceHAlign<true>(ResourceInfo, TileSize[i]);
581 VerifyResourceVAlign<false>(ResourceInfo, 0); // N/A for 1D
582 VerifyResourcePitch<false>(ResourceInfo, 0); // N/A for 1D
583 VerifyResourcePitchInTiles<false>(ResourceInfo, 0); // N/A for linear
584 VerifyResourceSize<true>(ResourceInfo, AlignedSize);
585 VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-arrayed
586
587 // All mips should be right after one another linearly, until the miptail
588 uint32_t StartOfMip = 0;
589 int mip;
590 for(mip = 0; mip < MaxMip; mip++)
591 {
592 GMM_REQ_OFFSET_INFO OffsetInfo = {};
593 OffsetInfo.ReqRender = 1;
594 OffsetInfo.MipLevel = mip;
595 ResourceInfo->GetOffset(OffsetInfo);
596 StartOfMip += (mip == 0 ? 0 : GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> (mip - 1), TileSize[i]) * GetBppValue(bpp));
597 EXPECT_EQ(StartOfMip, OffsetInfo.Render.Offset64);
598 EXPECT_EQ(0, OffsetInfo.Render.XOffset);
599 EXPECT_EQ(0, OffsetInfo.Render.YOffset);
600 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
601 }
602
603 uint32_t MipTailOffsets[12] = {2048, 1024, 768, 512, 448, 384, 320, 256, 192, 128, 64, 0};
604 // Check for offset inside miptails.
605 EXPECT_EQ(MipTailStart, ResourceInfo->GetPackedMipTailStartLod());
606 StartOfMip += GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> (mip - 1), TileSize[i]) * GetBppValue(bpp); // Start of MipTail
607 for(int slot = 0; mip <= gmmParams.MaxLod; mip++, slot++)
608 {
609 GMM_REQ_OFFSET_INFO OffsetInfo = {};
610 OffsetInfo.ReqRender = 1;
611 OffsetInfo.MipLevel = mip;
612 ResourceInfo->GetOffset(OffsetInfo);
613 EXPECT_EQ(StartOfMip, OffsetInfo.Render.Offset64); // Start of Miptail
614 EXPECT_EQ(MipTailOffsets[slot], OffsetInfo.Render.XOffset); // Offset within miptail
615 EXPECT_EQ(0, OffsetInfo.Render.YOffset);
616 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
617 }
618
619 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
620 }
621 }
622
623 // ********************************************************************************//
624
625 /// @brief ULT for 2D TileYs Resource
TEST_F(CTestGen9Resource,Test2DTileYsResource)626 TEST_F(CTestGen9Resource, Test2DTileYsResource)
627 {
628
629 const uint32_t HAlign[TEST_BPP_MAX] = {256, 256, 128, 128, 64};
630 const uint32_t VAlign[TEST_BPP_MAX] = {256, 128, 128, 64, 64};
631
632 const uint32_t TileSize[TEST_BPP_MAX][2] = {{256, 256},
633 {512, 128},
634 {512, 128},
635 {1024, 64},
636 {1024, 64}};
637
638 GMM_RESCREATE_PARAMS gmmParams = {};
639 gmmParams.Type = RESOURCE_2D;
640 gmmParams.NoGfxMemory = 1;
641 gmmParams.Flags.Info.TiledY = 1;
642 gmmParams.Flags.Info.TiledYs = 1;
643 gmmParams.Flags.Gpu.Texture = 1;
644
645 //Allocate 1x1 surface
646 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
647 {
648 TEST_BPP bpp = static_cast<TEST_BPP>(i);
649 gmmParams.Format = SetResourceFormat(bpp);
650 gmmParams.BaseWidth64 = 0x1;
651 gmmParams.BaseHeight = 0x1;
652
653 GMM_RESOURCE_INFO *ResourceInfo;
654 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
655
656 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
657 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
658 VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0]); // As wide as 1 Tile
659 VerifyResourcePitchInTiles<true>(ResourceInfo, 1); // 1 Tile wide
660 VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(64)); // 1 Tile Big
661 VerifyResourceQPitch<false>(ResourceInfo, 0); // Not Tested
662
663 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
664 }
665
666 // Allocate surface that requires multi tiles in two dimension
667 // Allocate 2 tiles in X dimension
668 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
669 {
670 TEST_BPP bpp = static_cast<TEST_BPP>(i);
671 gmmParams.Format = SetResourceFormat(bpp);
672 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
673 gmmParams.BaseHeight = 0x1;
674 gmmParams.Depth = 0x1;
675
676 GMM_RESOURCE_INFO *ResourceInfo;
677 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
678
679 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
680 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
681 VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0] * 2); // As wide as 2 tile
682 VerifyResourcePitchInTiles<true>(ResourceInfo, 2); // 2 tile wide
683 VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(64) * 2); // 2 tile big
684
685 VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
686
687 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
688 }
689
690 // Allocate 2 tiles in X/Y dimension
691 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
692 {
693 TEST_BPP bpp = static_cast<TEST_BPP>(i);
694 gmmParams.Format = SetResourceFormat(bpp);
695 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
696 gmmParams.BaseHeight = TileSize[i][1] + 1; // 1 row larger than 1 tile height
697 gmmParams.Depth = 0x1;
698
699 GMM_RESOURCE_INFO *ResourceInfo;
700 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
701
702 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
703 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
704 VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0] * 2); // As wide as 2 tile
705 VerifyResourcePitchInTiles<true>(ResourceInfo, 2); // 2 tile wide
706 VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(64) * 4); // 4 tile big
707
708 VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
709
710 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
711 }
712 }
713
714 /// @brief ULT for 2D TileYs Resource with Mips
TEST_F(CTestGen9Resource,Test2DTileYsMippedResource)715 TEST_F(CTestGen9Resource, Test2DTileYsMippedResource)
716 {
717 const uint32_t HAlign[TEST_BPP_MAX] = {256, 256, 128, 128, 64};
718 const uint32_t VAlign[TEST_BPP_MAX] = {256, 128, 128, 64, 64};
719
720 const uint32_t TileSize[TEST_BPP_MAX][2] = {{256, 256},
721 {512, 128},
722 {512, 128},
723 {1024, 64},
724 {1024, 64}};
725
726 const uint32_t MtsWidth[TEST_BPP_MAX] = {128, 128, 64, 64, 32};
727 const uint32_t MtsHeight[TEST_BPP_MAX] = {256, 128, 128, 64, 64};
728
729 GMM_RESCREATE_PARAMS gmmParams = {};
730 gmmParams.Type = RESOURCE_2D;
731 gmmParams.NoGfxMemory = 1;
732 gmmParams.Flags.Info.TiledY = 1;
733 gmmParams.Flags.Info.TiledYs = 1;
734 gmmParams.Flags.Gpu.Texture = 1;
735 gmmParams.MaxLod = 5;
736 gmmParams.ArraySize = 4;
737
738 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
739 {
740 uint32_t AlignedWidth = 0;
741 uint32_t AlignedHeight = 0;
742 uint32_t ExpectedPitch = 0;
743 uint32_t MipTailStartLod = 0;
744 // Valigned Mip Heights
745 uint32_t Mip0Height = 0;
746 uint32_t Mip1Height = 0;
747 uint32_t Mip2Height = 0;
748 uint32_t Mip3Height = 0;
749 uint32_t Mip2Higher = 0; // Sum of aligned heights of Mip2 and above
750 uint32_t MipTailHeight = 0;
751 // Haligned Mip Widths
752 uint32_t Mip0Width = 0;
753 uint32_t Mip1Width = 0;
754 uint32_t Mip2Width = 0;
755
756 TEST_BPP bpp = static_cast<TEST_BPP>(i);
757 gmmParams.Format = SetResourceFormat(bpp);
758 gmmParams.BaseWidth64 = 0x120;
759 gmmParams.BaseHeight = 0x120;
760
761 GMM_RESOURCE_INFO *ResourceInfo;
762 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
763
764 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
765 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
766
767 // find the miptail start level
768 {
769 uint32_t MipWidth = gmmParams.BaseWidth64;
770 uint32_t MipHeight = gmmParams.BaseHeight;
771 while(!(MipWidth <= MtsWidth[i] && MipHeight <= MtsHeight[i]))
772 {
773 MipTailStartLod++;
774 MipWidth = (uint32_t)(GMM_ULT_MAX(1, gmmParams.BaseWidth64 >> MipTailStartLod));
775 MipHeight = GMM_ULT_MAX(1, gmmParams.BaseHeight >> MipTailStartLod);
776 }
777 }
778
779 // Mip resource Aligned Width calculation
780 Mip0Width = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign[i]);
781 Mip1Width = GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> 1, HAlign[i]);
782 Mip2Width = GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> 2, HAlign[i]);
783 AlignedWidth = GMM_ULT_MAX(Mip0Width, Mip1Width + Mip2Width);
784
785 Mip0Height = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign[i]);
786 if(MipTailStartLod == 2)
787 {
788 EXPECT_EQ(2, ResourceInfo->GetPackedMipTailStartLod());
789 // Block height...Mip0Height + Max(Mip1Height, Sum of Mip2Height..MipnHeight)
790 Mip1Height = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 1, VAlign[i]);
791 Mip2Height = Mip2Higher = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 2, VAlign[i]);
792 }
793 else if(MipTailStartLod == 3)
794 {
795 EXPECT_EQ(3, ResourceInfo->GetPackedMipTailStartLod());
796 // Block height...Mip0Height + Max(Mip1Height, Sum of Mip2Height..MipnHeight)
797 Mip1Height = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 1, VAlign[i]);
798 Mip2Height = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 2, VAlign[i]);
799 // Miptail started lod
800 MipTailHeight = VAlign[i];
801 Mip2Higher = Mip2Height + MipTailHeight;
802 }
803 else if(MipTailStartLod == 4)
804 {
805 EXPECT_EQ(4, ResourceInfo->GetPackedMipTailStartLod());
806 // Block height...Mip0Height + Max(Mip1Height, Sum of Mip2Height..MipnHeight)
807 Mip1Height = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 1, VAlign[i]);
808 Mip2Height = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 2, VAlign[i]);
809 Mip3Height = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 3, VAlign[i]);
810 // Miptail started lod
811 MipTailHeight = VAlign[i];
812 Mip2Higher = Mip2Height + Mip3Height + MipTailHeight;
813 }
814
815 uint32_t MaxHeight = GMM_ULT_MAX(Mip1Height, Mip2Higher);
816 AlignedHeight = Mip0Height + MaxHeight;
817 AlignedHeight = GMM_ULT_ALIGN(AlignedHeight, VAlign[i]);
818
819 ExpectedPitch = AlignedWidth * GetBppValue(bpp);
820 ExpectedPitch = GMM_ULT_ALIGN(ExpectedPitch, GMM_BYTES(32));
821 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
822
823 VerifyResourcePitchInTiles<true>(ResourceInfo, static_cast<uint32_t>(ExpectedPitch / TileSize[i][0]));
824 VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(ExpectedPitch * AlignedHeight * gmmParams.ArraySize, PAGE_SIZE));
825 VerifyResourceQPitch<false>(ResourceInfo, AlignedHeight);
826
827 // Mip 0 offsets, offset is 0,0
828 GMM_REQ_OFFSET_INFO ReqInfo = {0};
829 ReqInfo.MipLevel = 0;
830 ReqInfo.ReqRender = 1;
831 ResourceInfo->GetOffset(ReqInfo);
832 uint32_t Mip0Size = ExpectedPitch * Mip0Height;
833 EXPECT_EQ(0, ReqInfo.Render.Offset64);
834 EXPECT_EQ(0, ReqInfo.Render.XOffset);
835 EXPECT_EQ(0, ReqInfo.Render.YOffset);
836
837 // Mip 1 offsets
838 ReqInfo = {0};
839 ReqInfo.MipLevel = 1;
840 ReqInfo.ReqRender = 1;
841 ResourceInfo->GetOffset(ReqInfo);
842 uint32_t Mip1Offset = Mip0Size;
843 EXPECT_EQ(Mip1Offset, ReqInfo.Render.Offset64);
844 EXPECT_EQ(0, ReqInfo.Render.XOffset);
845 EXPECT_EQ(0, ReqInfo.Render.YOffset);
846
847 // Mip 2 offset
848 ReqInfo = {0};
849 ReqInfo.MipLevel = 2;
850 ReqInfo.ReqRender = 1;
851 ResourceInfo->GetOffset(ReqInfo);
852 uint32_t Mip2Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
853 uint32_t Mip2X = GFX_ALIGN_FLOOR(uint32_t(Mip2Offset % ExpectedPitch), TileSize[i][0]);
854 uint32_t Mip2Y = GFX_ALIGN_FLOOR(uint32_t(Mip2Offset / ExpectedPitch), TileSize[i][1]);
855 uint32_t Mip2RenderAlignedOffset = Mip2Y * ExpectedPitch + (Mip2X / TileSize[i][0]) * (TileSize[i][0] * TileSize[i][1]);
856 EXPECT_EQ(Mip2RenderAlignedOffset, ReqInfo.Render.Offset64);
857 switch(bpp)
858 {
859 case TEST_BPP_8:
860 EXPECT_EQ(128, ReqInfo.Render.XOffset);
861 EXPECT_EQ(0, ReqInfo.Render.YOffset);
862 break;
863 case TEST_BPP_16:
864 EXPECT_EQ(256, ReqInfo.Render.XOffset);
865 EXPECT_EQ(0, ReqInfo.Render.YOffset);
866 break;
867 case TEST_BPP_32:
868 EXPECT_EQ(0, ReqInfo.Render.XOffset);
869 EXPECT_EQ(0, ReqInfo.Render.YOffset);
870 break;
871 case TEST_BPP_64:
872 EXPECT_EQ(0, ReqInfo.Render.XOffset);
873 EXPECT_EQ(0, ReqInfo.Render.YOffset);
874 break;
875 case TEST_BPP_128:
876 EXPECT_EQ(0, ReqInfo.Render.XOffset);
877 EXPECT_EQ(0, ReqInfo.Render.YOffset);
878 break;
879 default:
880 break;
881 }
882
883 // Mip 3 offset
884 ReqInfo = {0};
885 ReqInfo.MipLevel = 3;
886 ReqInfo.ReqRender = 1;
887 ResourceInfo->GetOffset(ReqInfo);
888 uint32_t Mip3Offset = 0;
889 switch(bpp)
890 {
891 case TEST_BPP_8:
892 Mip3Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
893 EXPECT_EQ(0, ReqInfo.Render.XOffset);
894 EXPECT_EQ(128, ReqInfo.Render.YOffset);
895 break;
896 case TEST_BPP_16:
897 Mip3Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
898 EXPECT_EQ(0, ReqInfo.Render.XOffset);
899 EXPECT_EQ(64, ReqInfo.Render.YOffset);
900 break;
901 case TEST_BPP_32:
902 Mip3Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + Mip2Height) * ExpectedPitch;
903 EXPECT_EQ(256, ReqInfo.Render.XOffset);
904 EXPECT_EQ(0, ReqInfo.Render.YOffset);
905 break;
906 case TEST_BPP_64:
907 Mip3Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + Mip2Height) * ExpectedPitch;
908 EXPECT_EQ(512, ReqInfo.Render.XOffset);
909 EXPECT_EQ(0, ReqInfo.Render.YOffset);
910 break;
911 case TEST_BPP_128:
912 Mip3Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + Mip2Height) * ExpectedPitch;
913 EXPECT_EQ(0, ReqInfo.Render.XOffset);
914 EXPECT_EQ(0, ReqInfo.Render.YOffset);
915 break;
916 default:
917 break;
918 }
919 uint32_t Mip3X = GFX_ALIGN_FLOOR(uint32_t(Mip3Offset % ExpectedPitch), TileSize[i][0]);
920 uint32_t Mip3Y = GFX_ALIGN_FLOOR(uint32_t(Mip3Offset / ExpectedPitch), TileSize[i][1]);
921 uint32_t Mip3RenderAlignedOffset = Mip3Y * ExpectedPitch + (Mip3X / TileSize[i][0]) * (TileSize[i][0] * TileSize[i][1]);
922 EXPECT_EQ(Mip3RenderAlignedOffset, ReqInfo.Render.Offset64);
923
924 // Mip 4 offset
925 ReqInfo = {0};
926 ReqInfo.MipLevel = 4;
927 ReqInfo.ReqRender = 1;
928 ResourceInfo->GetOffset(ReqInfo);
929 uint32_t Mip4Offset = 0;
930 switch(bpp)
931 {
932 case TEST_BPP_8:
933 Mip4Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
934 EXPECT_EQ(64, ReqInfo.Render.XOffset);
935 EXPECT_EQ(0, ReqInfo.Render.YOffset);
936 break;
937 case TEST_BPP_16:
938 Mip4Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
939 EXPECT_EQ(128, ReqInfo.Render.XOffset);
940 EXPECT_EQ(0, ReqInfo.Render.YOffset);
941 break;
942 case TEST_BPP_32:
943 Mip4Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + Mip2Height) * ExpectedPitch;
944 EXPECT_EQ(0, ReqInfo.Render.XOffset);
945 EXPECT_EQ(64, ReqInfo.Render.YOffset);
946 break;
947 case TEST_BPP_64:
948 Mip4Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + Mip2Height) * ExpectedPitch;
949 EXPECT_EQ(0, ReqInfo.Render.XOffset);
950 EXPECT_EQ(32, ReqInfo.Render.YOffset);
951 break;
952 case TEST_BPP_128:
953 Mip4Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + Mip2Height + Mip3Height) * ExpectedPitch;
954 EXPECT_EQ(512, ReqInfo.Render.XOffset);
955 EXPECT_EQ(0, ReqInfo.Render.YOffset);
956 break;
957 default:
958 break;
959 }
960 uint32_t Mip4X = GFX_ALIGN_FLOOR(uint32_t(Mip4Offset % ExpectedPitch), TileSize[i][0]);
961 uint32_t Mip4Y = GFX_ALIGN_FLOOR(uint32_t(Mip4Offset / ExpectedPitch), TileSize[i][1]);
962 uint32_t Mip4RenderAlignedOffset = Mip4Y * ExpectedPitch + (Mip4X / TileSize[i][0]) * (TileSize[i][0] * TileSize[i][1]);
963 EXPECT_EQ(Mip4RenderAlignedOffset, ReqInfo.Render.Offset64);
964
965 // Mip 5 offset
966 ReqInfo = {0};
967 ReqInfo.MipLevel = 4;
968 ReqInfo.ReqRender = 1;
969 ResourceInfo->GetOffset(ReqInfo);
970 uint32_t Mip5Offset = 0;
971 switch(bpp)
972 {
973 case TEST_BPP_8:
974 Mip5Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
975 EXPECT_EQ(64, ReqInfo.Render.XOffset);
976 EXPECT_EQ(0, ReqInfo.Render.YOffset);
977 break;
978 case TEST_BPP_16:
979 Mip5Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
980 EXPECT_EQ(128, ReqInfo.Render.XOffset);
981 EXPECT_EQ(0, ReqInfo.Render.YOffset);
982 break;
983 case TEST_BPP_32:
984 Mip5Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + Mip2Height) * ExpectedPitch;
985 EXPECT_EQ(0, ReqInfo.Render.XOffset);
986 EXPECT_EQ(64, ReqInfo.Render.YOffset);
987 break;
988 case TEST_BPP_64:
989 Mip5Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + Mip2Height) * ExpectedPitch;
990 EXPECT_EQ(0, ReqInfo.Render.XOffset);
991 EXPECT_EQ(32, ReqInfo.Render.YOffset);
992 break;
993 case TEST_BPP_128:
994 Mip5Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + Mip2Height + Mip3Height) * ExpectedPitch;
995 EXPECT_EQ(512, ReqInfo.Render.XOffset);
996 EXPECT_EQ(0, ReqInfo.Render.YOffset);
997 break;
998 default:
999 break;
1000 }
1001 uint32_t Mip5X = GFX_ALIGN_FLOOR(uint32_t(Mip4Offset % ExpectedPitch), TileSize[i][0]);
1002 uint32_t Mip5Y = GFX_ALIGN_FLOOR(uint32_t(Mip4Offset / ExpectedPitch), TileSize[i][1]);
1003 uint32_t Mip5RenderAlignedOffset = Mip5Y * ExpectedPitch + (Mip5X / TileSize[i][0]) * (TileSize[i][0] * TileSize[i][1]);
1004 EXPECT_EQ(Mip5RenderAlignedOffset, ReqInfo.Render.Offset64);
1005
1006 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1007 }
1008 }
1009
1010 /// @brief ULT for 2D TileYf Resource
TEST_F(CTestGen9Resource,Test2DTileYfResource)1011 TEST_F(CTestGen9Resource, Test2DTileYfResource)
1012 {
1013 const uint32_t HAlign[TEST_BPP_MAX] = {64, 64, 32, 32, 16};
1014 const uint32_t VAlign[TEST_BPP_MAX] = {64, 32, 32, 16, 16};
1015
1016 const uint32_t TileSize[TEST_BPP_MAX][2] = {{64, 64},
1017 {128, 32},
1018 {128, 32},
1019 {256, 16},
1020 {256, 16}};
1021
1022 GMM_RESCREATE_PARAMS gmmParams = {};
1023 gmmParams.Type = RESOURCE_2D;
1024 gmmParams.NoGfxMemory = 1;
1025 gmmParams.Flags.Info.TiledY = 1;
1026 gmmParams.Flags.Info.TiledYf = 1;
1027 gmmParams.Flags.Gpu.Texture = 1;
1028
1029 //Allocate 1x1 surface
1030 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1031 {
1032 TEST_BPP bpp = static_cast<TEST_BPP>(i);
1033 gmmParams.Format = SetResourceFormat(bpp);
1034 gmmParams.BaseWidth64 = 0x1;
1035 gmmParams.BaseHeight = 0x1;
1036
1037 GMM_RESOURCE_INFO *ResourceInfo;
1038 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1039
1040 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
1041 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
1042 VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0]); // As wide as 1 Tile
1043 VerifyResourcePitchInTiles<true>(ResourceInfo, 1); // 1 Tile wide
1044 VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4)); // 1 Tile Big
1045 VerifyResourceQPitch<false>(ResourceInfo, 0); // Not Tested
1046
1047 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1048 }
1049
1050 // Allocate surface that requires multi tiles in two dimension
1051 // Allocate 2 tiles in X dimension
1052 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1053 {
1054 TEST_BPP bpp = static_cast<TEST_BPP>(i);
1055 gmmParams.Format = SetResourceFormat(bpp);
1056 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
1057 gmmParams.BaseHeight = 0x1;
1058 gmmParams.Depth = 0x1;
1059
1060 GMM_RESOURCE_INFO *ResourceInfo;
1061 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1062
1063 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
1064 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
1065 VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0] * 2); // As wide as 2 tile
1066 VerifyResourcePitchInTiles<true>(ResourceInfo, 2); // 2 tile wide
1067 VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * 2); // 2 tile big
1068
1069 VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
1070
1071 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1072 }
1073
1074 // Allocate 2 tiles in X/Y dimension
1075 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1076 {
1077 TEST_BPP bpp = static_cast<TEST_BPP>(i);
1078 gmmParams.Format = SetResourceFormat(bpp);
1079 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
1080 gmmParams.BaseHeight = TileSize[i][1] + 1; // 1 row larger than 1 tile height
1081 gmmParams.Depth = 0x1;
1082
1083 GMM_RESOURCE_INFO *ResourceInfo;
1084 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1085
1086 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
1087 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
1088 VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0] * 2); // As wide as 2 tile
1089 VerifyResourcePitchInTiles<true>(ResourceInfo, 2); // 2 tile wide
1090 VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4) * 4); // 4 tile big
1091
1092 VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
1093
1094 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1095 }
1096 }
1097
1098 /// @brief ULT for 2D TileYf Mipped Resource
TEST_F(CTestGen9Resource,Test2DTileYfMippedResource)1099 TEST_F(CTestGen9Resource, Test2DTileYfMippedResource)
1100 {
1101 const uint32_t HAlign[TEST_BPP_MAX] = {64, 64, 32, 32, 16};
1102 const uint32_t VAlign[TEST_BPP_MAX] = {64, 32, 32, 16, 16};
1103
1104 const uint32_t TileSize[TEST_BPP_MAX][2] = {{64, 64},
1105 {128, 32},
1106 {128, 32},
1107 {256, 16},
1108 {256, 16}};
1109
1110 const uint32_t MtsWidth[TEST_BPP_MAX] = {32, 32, 16, 16, 8};
1111 const uint32_t MtsHeight[TEST_BPP_MAX] = {64, 32, 32, 16, 16};
1112
1113 GMM_RESCREATE_PARAMS gmmParams = {};
1114 gmmParams.Type = RESOURCE_2D;
1115 gmmParams.NoGfxMemory = 1;
1116 gmmParams.Flags.Info.TiledY = 1;
1117 gmmParams.Flags.Info.TiledYf = 1;
1118 gmmParams.Flags.Gpu.Texture = 1;
1119 gmmParams.MaxLod = 4;
1120 gmmParams.ArraySize = 4;
1121
1122 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1123 {
1124 uint32_t AlignedWidth = 0;
1125 uint32_t AlignedHeight = 0;
1126 uint32_t ExpectedPitch = 0;
1127 uint32_t MipTailStartLod = 0;
1128 // Valigned Mip Heights
1129 uint32_t Mip0Height = 0;
1130 uint32_t Mip1Height = 0;
1131 uint32_t Mip2Height = 0;
1132 uint32_t Mip3Height = 0;
1133 uint32_t Mip2Higher = 0; // Sum of aligned heights of Mip2 and above
1134 uint32_t MipTailHeight = 0;
1135 // Haligned Mip Widths
1136 uint32_t Mip0Width = 0;
1137 uint32_t Mip1Width = 0;
1138 uint32_t Mip2Width = 0;
1139
1140 TEST_BPP bpp = static_cast<TEST_BPP>(i);
1141 gmmParams.Format = SetResourceFormat(bpp);
1142 gmmParams.BaseWidth64 = 0x38;
1143 gmmParams.BaseHeight = 0x38;
1144
1145 GMM_RESOURCE_INFO *ResourceInfo;
1146 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1147
1148 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
1149 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
1150
1151 // find the miptail start level
1152 {
1153 uint32_t MipWidth = gmmParams.BaseWidth64;
1154 uint32_t MipHeight = gmmParams.BaseHeight;
1155 while(!(MipWidth <= MtsWidth[i] && MipHeight <= MtsHeight[i]))
1156 {
1157 MipTailStartLod++;
1158 MipWidth = (uint32_t)(GMM_ULT_MAX(1, gmmParams.BaseWidth64 >> MipTailStartLod));
1159 MipHeight = GMM_ULT_MAX(1, gmmParams.BaseHeight >> MipTailStartLod);
1160 }
1161 }
1162
1163 // Mip resource Aligned Width calculation
1164 Mip0Width = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign[i]);
1165 Mip0Height = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign[i]);
1166
1167 if(MipTailStartLod == 1)
1168 {
1169 EXPECT_EQ(1, ResourceInfo->GetPackedMipTailStartLod());
1170 // Block height...Mip0Height + Max(Mip1Height, Sum of Mip2Height..MipnHeight)
1171 Mip1Height = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 1, VAlign[i]);
1172 AlignedWidth = Mip0Width;
1173 }
1174 if(MipTailStartLod == 2)
1175 {
1176 EXPECT_EQ(2, ResourceInfo->GetPackedMipTailStartLod());
1177 // Block height...Mip0Height + Max(Mip1Height, Sum of Mip2Height..MipnHeight)
1178 Mip1Height = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 1, VAlign[i]);
1179 Mip2Height = Mip2Higher = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 2, VAlign[i]);
1180
1181 Mip1Width = GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> 1, HAlign[i]);
1182 Mip2Width = GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> 2, HAlign[i]);
1183 AlignedWidth = GMM_ULT_MAX(Mip0Width, Mip1Width + Mip2Width);
1184 }
1185 if(MipTailStartLod == 3)
1186 {
1187 EXPECT_EQ(3, ResourceInfo->GetPackedMipTailStartLod());
1188 // Block height...Mip0Height + Max(Mip1Height, Sum of Mip2Height..MipnHeight)
1189 Mip1Height = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 1, VAlign[i]);
1190 Mip2Height = GMM_ULT_ALIGN(gmmParams.BaseHeight >> 2, VAlign[i]);
1191 // Miptail started lod
1192 MipTailHeight = VAlign[i];
1193 Mip2Higher = Mip2Height + Mip3Height + MipTailHeight;
1194
1195 Mip1Width = GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> 1, HAlign[i]);
1196 Mip2Width = GMM_ULT_ALIGN(gmmParams.BaseWidth64 >> 2, HAlign[i]);
1197 AlignedWidth = GMM_ULT_MAX(Mip0Width, Mip1Width + Mip2Width);
1198 }
1199
1200 uint32_t MaxHeight = GMM_ULT_MAX(Mip1Height, Mip2Higher);
1201 AlignedHeight = Mip0Height + MaxHeight;
1202 AlignedHeight = GMM_ULT_ALIGN(AlignedHeight, VAlign[i]);
1203
1204 ExpectedPitch = AlignedWidth * GetBppValue(bpp);
1205 ExpectedPitch = GMM_ULT_ALIGN(ExpectedPitch, GMM_BYTES(32));
1206 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
1207
1208 VerifyResourcePitchInTiles<true>(ResourceInfo, static_cast<uint32_t>(ExpectedPitch / TileSize[i][0]));
1209 VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(ExpectedPitch * AlignedHeight * gmmParams.ArraySize, PAGE_SIZE));
1210 VerifyResourceQPitch<false>(ResourceInfo, AlignedHeight);
1211
1212 // Mip 0 offsets, offset is 0,0
1213 GMM_REQ_OFFSET_INFO ReqInfo = {0};
1214 ReqInfo.MipLevel = 0;
1215 ReqInfo.ReqRender = 1;
1216 ResourceInfo->GetOffset(ReqInfo);
1217 uint32_t Mip0Size = ExpectedPitch * Mip0Height;
1218 EXPECT_EQ(0, ReqInfo.Render.Offset64);
1219 EXPECT_EQ(0, ReqInfo.Render.XOffset);
1220 EXPECT_EQ(0, ReqInfo.Render.YOffset);
1221
1222 // Mip 1 offsets
1223 ReqInfo = {0};
1224 ReqInfo.MipLevel = 1;
1225 ReqInfo.ReqRender = 1;
1226 ResourceInfo->GetOffset(ReqInfo);
1227 uint32_t Mip1Offset = Mip0Size;
1228 switch(bpp)
1229 {
1230 case TEST_BPP_8:
1231 EXPECT_EQ(32, ReqInfo.Render.XOffset);
1232 EXPECT_EQ(0, ReqInfo.Render.YOffset);
1233 break;
1234 case TEST_BPP_16:
1235 EXPECT_EQ(64, ReqInfo.Render.XOffset);
1236 EXPECT_EQ(0, ReqInfo.Render.YOffset);
1237 break;
1238 case TEST_BPP_32:
1239 EXPECT_EQ(0, ReqInfo.Render.XOffset);
1240 EXPECT_EQ(0, ReqInfo.Render.YOffset);
1241 break;
1242 case TEST_BPP_64:
1243 EXPECT_EQ(0, ReqInfo.Render.XOffset);
1244 EXPECT_EQ(0, ReqInfo.Render.YOffset);
1245 break;
1246 case TEST_BPP_128:
1247 EXPECT_EQ(0, ReqInfo.Render.XOffset);
1248 EXPECT_EQ(0, ReqInfo.Render.YOffset);
1249 break;
1250 default:
1251 break;
1252 }
1253 EXPECT_EQ(Mip1Offset, ReqInfo.Render.Offset64);
1254
1255
1256 // Mip 2 offset
1257 ReqInfo = {0};
1258 ReqInfo.MipLevel = 2;
1259 ReqInfo.ReqRender = 1;
1260 ResourceInfo->GetOffset(ReqInfo);
1261 uint32_t Mip2Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
1262 switch(bpp)
1263 {
1264 case TEST_BPP_8:
1265 EXPECT_EQ(16, ReqInfo.Render.XOffset);
1266 EXPECT_EQ(32, ReqInfo.Render.YOffset);
1267 break;
1268 case TEST_BPP_16:
1269 EXPECT_EQ(32, ReqInfo.Render.XOffset);
1270 EXPECT_EQ(16, ReqInfo.Render.YOffset);
1271 break;
1272 case TEST_BPP_32:
1273 EXPECT_EQ(64, ReqInfo.Render.XOffset);
1274 EXPECT_EQ(0, ReqInfo.Render.YOffset);
1275 break;
1276 case TEST_BPP_64:
1277 EXPECT_EQ(128, ReqInfo.Render.XOffset);
1278 EXPECT_EQ(0, ReqInfo.Render.YOffset);
1279 break;
1280 case TEST_BPP_128:
1281 EXPECT_EQ(0, ReqInfo.Render.XOffset);
1282 EXPECT_EQ(0, ReqInfo.Render.YOffset);
1283 break;
1284 default:
1285 break;
1286 }
1287 uint32_t Mip2X = GFX_ALIGN_FLOOR(uint32_t(Mip2Offset % ExpectedPitch), TileSize[i][0]);
1288 uint32_t Mip2Y = GFX_ALIGN_FLOOR(uint32_t(Mip2Offset / ExpectedPitch), TileSize[i][1]);
1289 uint32_t Mip2RenderAlignedOffset = Mip2Y * ExpectedPitch + (Mip2X / TileSize[i][0]) * (TileSize[i][0] * TileSize[i][1]);
1290 EXPECT_EQ(Mip2RenderAlignedOffset, ReqInfo.Render.Offset64);
1291
1292 // Mip 3 offset
1293 ReqInfo = {0};
1294 ReqInfo.MipLevel = 3;
1295 ReqInfo.ReqRender = 1;
1296 ResourceInfo->GetOffset(ReqInfo);
1297 uint32_t Mip3Offset = 0;
1298 switch(bpp)
1299 {
1300 case TEST_BPP_8:
1301 Mip3Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
1302 EXPECT_EQ(0, ReqInfo.Render.XOffset);
1303 EXPECT_EQ(48, ReqInfo.Render.YOffset);
1304 break;
1305 case TEST_BPP_16:
1306 Mip3Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
1307 EXPECT_EQ(0, ReqInfo.Render.XOffset);
1308 EXPECT_EQ(24, ReqInfo.Render.YOffset);
1309 break;
1310 case TEST_BPP_32:
1311 Mip3Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
1312 EXPECT_EQ(32, ReqInfo.Render.XOffset);
1313 EXPECT_EQ(16, ReqInfo.Render.YOffset);
1314 break;
1315 case TEST_BPP_64:
1316 Mip3Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
1317 EXPECT_EQ(64, ReqInfo.Render.XOffset);
1318 EXPECT_EQ(8, ReqInfo.Render.YOffset);
1319 break;
1320 case TEST_BPP_128:
1321 Mip3Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + Mip2Height) * ExpectedPitch;
1322 EXPECT_EQ(128, ReqInfo.Render.XOffset);
1323 EXPECT_EQ(0, ReqInfo.Render.YOffset);
1324 break;
1325 default:
1326 break;
1327 }
1328 uint32_t Mip3X = GFX_ALIGN_FLOOR(uint32_t(Mip3Offset % ExpectedPitch), TileSize[i][0]);
1329 uint32_t Mip3Y = GFX_ALIGN_FLOOR(uint32_t(Mip3Offset / ExpectedPitch), TileSize[i][1]);
1330 uint32_t Mip3RenderAlignedOffset = Mip3Y * ExpectedPitch + (Mip3X / TileSize[i][0]) * (TileSize[i][0] * TileSize[i][1]);
1331 EXPECT_EQ(Mip3RenderAlignedOffset, ReqInfo.Render.Offset64);
1332
1333 // Mip 4 offset
1334 ReqInfo = {0};
1335 ReqInfo.MipLevel = 4;
1336 ReqInfo.ReqRender = 1;
1337 ResourceInfo->GetOffset(ReqInfo);
1338 uint32_t Mip4Offset = 0;
1339 switch(bpp)
1340 {
1341 case TEST_BPP_8:
1342 Mip4Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
1343 EXPECT_EQ(0, ReqInfo.Render.XOffset);
1344 EXPECT_EQ(32, ReqInfo.Render.YOffset);
1345 break;
1346 case TEST_BPP_16:
1347 Mip4Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
1348 EXPECT_EQ(0, ReqInfo.Render.XOffset);
1349 EXPECT_EQ(16, ReqInfo.Render.YOffset);
1350 break;
1351 case TEST_BPP_32:
1352 Mip4Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
1353 EXPECT_EQ(0, ReqInfo.Render.XOffset);
1354 EXPECT_EQ(24, ReqInfo.Render.YOffset);
1355 break;
1356 case TEST_BPP_64:
1357 Mip4Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
1358 EXPECT_EQ(0, ReqInfo.Render.XOffset);
1359 EXPECT_EQ(12, ReqInfo.Render.YOffset);
1360 break;
1361 case TEST_BPP_128:
1362 Mip4Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + Mip2Height) * ExpectedPitch;
1363 EXPECT_EQ(64, ReqInfo.Render.XOffset);
1364 EXPECT_EQ(8, ReqInfo.Render.YOffset);
1365 break;
1366 default:
1367 break;
1368 }
1369 uint32_t Mip4X = GFX_ALIGN_FLOOR(uint32_t(Mip4Offset % ExpectedPitch), TileSize[i][0]);
1370 uint32_t Mip4Y = GFX_ALIGN_FLOOR(uint32_t(Mip4Offset / ExpectedPitch), TileSize[i][1]);
1371 uint32_t Mip4RenderAlignedOffset = Mip4Y * ExpectedPitch + (Mip4X / TileSize[i][0]) * (TileSize[i][0] * TileSize[i][1]);
1372 EXPECT_EQ(Mip4RenderAlignedOffset, ReqInfo.Render.Offset64);
1373
1374 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1375 }
1376 }
1377 /// @brief ULT for 2D Stencil (TileW) Mipped-array Resource
TEST_F(CTestGen9Resource,Test2DStencilMippedArrayedResource)1378 TEST_F(CTestGen9Resource, Test2DStencilMippedArrayedResource)
1379 {
1380 const uint32_t HAlign = {8};
1381 const uint32_t VAlign = {8};
1382
1383 const uint32_t TileSize[2] = {64, 64}; //TileW
1384
1385 GMM_RESCREATE_PARAMS gmmParams = {};
1386 gmmParams.Type = RESOURCE_2D;
1387 gmmParams.NoGfxMemory = 1;
1388 gmmParams.Flags.Info.TiledW = 1;
1389 gmmParams.Flags.Gpu.SeparateStencil = 1;
1390 gmmParams.MaxLod = 4;
1391 gmmParams.ArraySize = 4;
1392
1393 //for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1394 {
1395 uint32_t AlignedWidth = 0;
1396 uint32_t AlignedHeight = 0;
1397 uint32_t ExpectedPitch = 0;
1398 // Valigned Mip Heights
1399 uint32_t Mip0Height = 0;
1400 uint32_t Mip1Height = 0;
1401 uint32_t Mip2Height = 0;
1402
1403 // Haligned Mip Widths
1404 uint32_t Mip0Width = 0;
1405 uint32_t Mip1Width = 0;
1406 uint32_t Mip2Width = 0;
1407
1408 TEST_BPP bpp = TEST_BPP_8;
1409 gmmParams.Format = SetResourceFormat(bpp);
1410 gmmParams.BaseWidth64 = 0x10;
1411 gmmParams.BaseHeight = 0x10;
1412
1413 GMM_RESOURCE_INFO *ResourceInfo;
1414 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1415
1416 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
1417 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
1418
1419 // Mip resource Aligned Width calculation
1420 Mip0Width = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign);
1421 Mip0Height = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign);
1422
1423 for(uint32_t i = 1; i <= gmmParams.MaxLod; i++)
1424 {
1425 uint32_t MipWidth = GMM_ULT_ALIGN(GMM_ULT_MAX(Mip0Width >> i, 1), HAlign);
1426 uint32_t MipHeight = GMM_ULT_ALIGN(GMM_ULT_MAX(Mip0Height >> i, 1), VAlign);
1427 if(i == 1)
1428 {
1429 Mip1Width = AlignedWidth = MipWidth;
1430 Mip1Height = MipHeight;
1431 }
1432 else if(i == 2)
1433 {
1434 AlignedWidth += MipWidth;
1435 Mip2Height = MipHeight;
1436 }
1437 else
1438 {
1439 Mip2Height += MipHeight;
1440 }
1441 }
1442
1443 uint32_t MaxHeight = GMM_ULT_MAX(Mip1Height, Mip2Height);
1444 AlignedHeight = Mip0Height + MaxHeight;
1445
1446 ExpectedPitch = GMM_ULT_MAX(AlignedWidth, Mip0Width) * GetBppValue(bpp);
1447 ExpectedPitch = GMM_ULT_ALIGN(ExpectedPitch, TileSize[0]);
1448 //TileW is programmed as row-interleaved.. ie doubled pitch
1449 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch * 2);
1450
1451 VerifyResourcePitchInTiles<true>(ResourceInfo, static_cast<uint32_t>(ExpectedPitch / TileSize[0]));
1452 VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(ExpectedPitch * AlignedHeight * gmmParams.ArraySize, PAGE_SIZE));
1453 VerifyResourceQPitch<true>(ResourceInfo, AlignedHeight);
1454
1455 for(uint8_t i = 0; i < gmmParams.ArraySize && gmmParams.MaxLod >= 4; i++)
1456 {
1457 uint64_t ArrayOffset = AlignedHeight * ExpectedPitch * i;
1458
1459 // Mip 0 offsets, offset is 0,0
1460 GMM_REQ_OFFSET_INFO ReqInfo = {0};
1461 ReqInfo.MipLevel = 0;
1462 ReqInfo.ReqRender = 1;
1463 ReqInfo.ArrayIndex = i;
1464 ResourceInfo->GetOffset(ReqInfo);
1465
1466 uint32_t Mip0Size = ExpectedPitch * Mip0Height;
1467 uint64_t SliceTileOffset = GFX_ALIGN_FLOOR(AlignedHeight * i, TileSize[1]) * TileSize[0];
1468 uint32_t SliceY = (AlignedHeight * i) % TileSize[1];
1469 EXPECT_EQ(SliceTileOffset, ReqInfo.Render.Offset64);
1470 EXPECT_EQ(0, ReqInfo.Render.XOffset);
1471 EXPECT_EQ(SliceY, ReqInfo.Render.YOffset);
1472
1473 // Mip 1 offsets
1474 ReqInfo = {0};
1475 ReqInfo.MipLevel = 1;
1476 ReqInfo.ReqRender = 1;
1477 ReqInfo.ArrayIndex = i;
1478 ResourceInfo->GetOffset(ReqInfo);
1479 uint32_t Mip1Offset = Mip0Size + ArrayOffset;
1480 uint32_t Mip1X = uint32_t(Mip1Offset % ExpectedPitch);
1481 uint32_t Mip1Y = uint32_t(Mip1Offset / ExpectedPitch);
1482 EXPECT_EQ(0, ReqInfo.Render.XOffset);
1483 EXPECT_EQ(Mip1Y % TileSize[1], ReqInfo.Render.YOffset);
1484 Mip1X = GFX_ALIGN_FLOOR(Mip1X, TileSize[0]);
1485 Mip1Y = GFX_ALIGN_FLOOR(Mip1Y, TileSize[1]);
1486 uint32_t Mip1RenderAlignedOffset = Mip1Y * ExpectedPitch + (Mip1X / TileSize[0]) * (TileSize[0] * TileSize[1]);
1487 EXPECT_EQ(Mip1RenderAlignedOffset, ReqInfo.Render.Offset64);
1488
1489
1490 // Mip 2 offset
1491 ReqInfo = {0};
1492 ReqInfo.MipLevel = 2;
1493 ReqInfo.ReqRender = 1;
1494 ReqInfo.ArrayIndex = i;
1495 ResourceInfo->GetOffset(ReqInfo);
1496 uint32_t Mip2Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch + ArrayOffset;
1497 uint32_t Mip2X = uint32_t(Mip2Offset % ExpectedPitch);
1498 uint32_t Mip2Y = uint32_t(Mip2Offset / ExpectedPitch);
1499 EXPECT_EQ(8, ReqInfo.Render.XOffset);
1500 EXPECT_EQ(Mip2Y % TileSize[1], ReqInfo.Render.YOffset);
1501 Mip2X = GFX_ALIGN_FLOOR(Mip2X, TileSize[0]);
1502 Mip2Y = GFX_ALIGN_FLOOR(Mip2Y, TileSize[1]);
1503 uint32_t Mip2RenderAlignedOffset = Mip2Y * ExpectedPitch + (Mip2X / TileSize[0]) * (TileSize[0] * TileSize[1]);
1504 EXPECT_EQ(Mip2RenderAlignedOffset, ReqInfo.Render.Offset64);
1505
1506 // Mip 3 offset
1507 ReqInfo = {0};
1508 ReqInfo.MipLevel = 3;
1509 ReqInfo.ReqRender = 1;
1510 ReqInfo.ArrayIndex = i;
1511 ResourceInfo->GetOffset(ReqInfo);
1512
1513 uint32_t Mip3Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + GMM_ULT_ALIGN(Mip0Height >> 2, VAlign)) * ExpectedPitch + ArrayOffset;
1514 uint32_t Mip3X = uint32_t(Mip3Offset % ExpectedPitch);
1515 uint32_t Mip3Y = uint32_t(Mip3Offset / ExpectedPitch);
1516 EXPECT_EQ(8, ReqInfo.Render.XOffset);
1517 EXPECT_EQ(Mip3Y % TileSize[1], ReqInfo.Render.YOffset);
1518 Mip3X = GFX_ALIGN_FLOOR(Mip3X, TileSize[0]);
1519 Mip3Y = GFX_ALIGN_FLOOR(Mip3Y, TileSize[1]);
1520 uint32_t Mip3RenderAlignedOffset = Mip3Y * ExpectedPitch + (Mip3X / TileSize[0]) * (TileSize[0] * TileSize[1]);
1521 EXPECT_EQ(Mip3RenderAlignedOffset, ReqInfo.Render.Offset64);
1522
1523 // Mip 4 offset
1524 ReqInfo = {0};
1525 ReqInfo.MipLevel = 4;
1526 ReqInfo.ReqRender = 1;
1527 ReqInfo.ArrayIndex = i;
1528 ResourceInfo->GetOffset(ReqInfo);
1529 uint32_t Mip4Offset = 0;
1530 Mip4Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + GMM_ULT_ALIGN(Mip0Height >> 2, VAlign) + GMM_ULT_ALIGN(Mip0Height >> 3, VAlign)) * ExpectedPitch + ArrayOffset;
1531 uint32_t Mip4X = uint32_t(Mip4Offset % ExpectedPitch);
1532 uint32_t Mip4Y = uint32_t(Mip4Offset / ExpectedPitch);
1533 EXPECT_EQ(8, ReqInfo.Render.XOffset);
1534 EXPECT_EQ(Mip4Y % TileSize[1], ReqInfo.Render.YOffset);
1535 Mip4X = GFX_ALIGN_FLOOR(Mip4X, TileSize[0]);
1536 Mip4Y = GFX_ALIGN_FLOOR(Mip4Y, TileSize[1]);
1537 uint32_t Mip4RenderAlignedOffset = Mip4Y * ExpectedPitch + (Mip4X / TileSize[0]) * (TileSize[0] * TileSize[1]);
1538 EXPECT_EQ(Mip4RenderAlignedOffset, ReqInfo.Render.Offset64);
1539 }
1540
1541 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1542 }
1543 }
1544
1545 /// @brief ULT for 2D Stencil (TileW) Mipped-array Resource, and CpuBlt
TEST_F(CTestGen9Resource,Test2DStencilArrayedCpuBltResource)1546 TEST_F(CTestGen9Resource, Test2DStencilArrayedCpuBltResource)
1547 {
1548 const uint32_t HAlign = {8};
1549 const uint32_t VAlign = {8};
1550
1551 const uint32_t TileSize[2] = {64, 64}; //TileW
1552
1553 GMM_RESCREATE_PARAMS gmmParams = {};
1554 gmmParams.Type = RESOURCE_2D;
1555 gmmParams.NoGfxMemory = 1;
1556 gmmParams.Flags.Info.TiledW = 1;
1557 gmmParams.Flags.Gpu.SeparateStencil = 1;
1558 gmmParams.MaxLod = 0;
1559 gmmParams.ArraySize = 6;
1560
1561 {
1562 uint32_t AlignedWidth = 0;
1563 uint32_t AlignedHeight = 0;
1564 uint32_t ExpectedPitch = 0;
1565 // Valigned Mip Heights
1566 uint32_t Mip0Height = 0;
1567 uint32_t Mip1Height = 0;
1568 uint32_t Mip2Height = 0;
1569
1570 // Haligned Mip Widths
1571 uint32_t Mip0Width = 0;
1572 uint32_t Mip1Width = 0;
1573 uint32_t Mip2Width = 0;
1574
1575 TEST_BPP bpp = TEST_BPP_8;
1576 gmmParams.Format = SetResourceFormat(bpp);
1577 gmmParams.BaseWidth64 = 0x4;
1578 gmmParams.BaseHeight = 0x4;
1579
1580 GMM_RESOURCE_INFO *ResourceInfo;
1581 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1582
1583 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
1584 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
1585
1586 // Mip resource Aligned Width calculation
1587 Mip0Width = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign);
1588 Mip0Height = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign);
1589
1590 for(uint32_t i = 1; i <= gmmParams.MaxLod; i++)
1591 {
1592 uint32_t MipWidth = GMM_ULT_ALIGN(GMM_ULT_MAX(Mip0Width >> i, 1), HAlign);
1593 uint32_t MipHeight = GMM_ULT_ALIGN(GMM_ULT_MAX(Mip0Height >> i, 1), VAlign);
1594 if(i == 1)
1595 {
1596 Mip1Width = AlignedWidth = MipWidth;
1597 Mip1Height = MipHeight;
1598 }
1599 else if(i == 2)
1600 {
1601 AlignedWidth += MipWidth;
1602 Mip2Height = MipHeight;
1603 }
1604 else
1605 {
1606 Mip2Height += MipHeight;
1607 }
1608 }
1609
1610 uint32_t MaxHeight = GMM_ULT_MAX(Mip1Height, Mip2Height);
1611 AlignedHeight = Mip0Height + MaxHeight;
1612
1613 ExpectedPitch = GMM_ULT_MAX(AlignedWidth, Mip0Width) * GetBppValue(bpp);
1614 ExpectedPitch = GMM_ULT_ALIGN(ExpectedPitch, TileSize[0]);
1615 //TileW is programmed as row-interleaved.. ie doubled pitch
1616 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch * 2);
1617
1618 VerifyResourcePitchInTiles<true>(ResourceInfo, static_cast<uint32_t>(ExpectedPitch / TileSize[0]));
1619 VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(ExpectedPitch * AlignedHeight * gmmParams.ArraySize, PAGE_SIZE));
1620 VerifyResourceQPitch<true>(ResourceInfo, AlignedHeight);
1621
1622 for(uint8_t i = 0; i < gmmParams.ArraySize && gmmParams.MaxLod >= 4; i++)
1623 {
1624 uint64_t ArrayOffset = AlignedHeight * ExpectedPitch * i;
1625
1626 // Mip 0 offsets, offset is 0,0
1627 GMM_REQ_OFFSET_INFO ReqInfo = {0};
1628 ReqInfo.MipLevel = 0;
1629 ReqInfo.ReqRender = 1;
1630 ReqInfo.ArrayIndex = i;
1631 ResourceInfo->GetOffset(ReqInfo);
1632
1633 uint32_t Mip0Size = ExpectedPitch * Mip0Height;
1634 uint64_t SliceTileOffset = GFX_ALIGN_FLOOR(AlignedHeight * i, TileSize[1]) * TileSize[0];
1635 uint32_t SliceY = (AlignedHeight * i) % TileSize[1];
1636 EXPECT_EQ(SliceTileOffset, ReqInfo.Render.Offset64);
1637 EXPECT_EQ(0, ReqInfo.Render.XOffset);
1638 EXPECT_EQ(SliceY, ReqInfo.Render.YOffset);
1639
1640 // Mip 1 offsets
1641 ReqInfo = {0};
1642 ReqInfo.MipLevel = 1;
1643 ReqInfo.ReqRender = 1;
1644 ReqInfo.ArrayIndex = i;
1645 ResourceInfo->GetOffset(ReqInfo);
1646 uint32_t Mip1Offset = Mip0Size + ArrayOffset;
1647 uint32_t Mip1X = uint32_t(Mip1Offset % ExpectedPitch);
1648 uint32_t Mip1Y = uint32_t(Mip1Offset / ExpectedPitch);
1649 EXPECT_EQ(0, ReqInfo.Render.XOffset);
1650 EXPECT_EQ(Mip1Y % TileSize[1], ReqInfo.Render.YOffset);
1651 Mip1X = GFX_ALIGN_FLOOR(Mip1X, TileSize[0]);
1652 Mip1Y = GFX_ALIGN_FLOOR(Mip1Y, TileSize[1]);
1653 uint32_t Mip1RenderAlignedOffset = Mip1Y * ExpectedPitch + (Mip1X / TileSize[0]) * (TileSize[0] * TileSize[1]);
1654 EXPECT_EQ(Mip1RenderAlignedOffset, ReqInfo.Render.Offset64);
1655
1656
1657 // Mip 2 offset
1658 ReqInfo = {0};
1659 ReqInfo.MipLevel = 2;
1660 ReqInfo.ReqRender = 1;
1661 ReqInfo.ArrayIndex = i;
1662 ResourceInfo->GetOffset(ReqInfo);
1663 uint32_t Mip2Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch + ArrayOffset;
1664 uint32_t Mip2X = uint32_t(Mip2Offset % ExpectedPitch);
1665 uint32_t Mip2Y = uint32_t(Mip2Offset / ExpectedPitch);
1666 EXPECT_EQ(8, ReqInfo.Render.XOffset);
1667 EXPECT_EQ(Mip2Y % TileSize[1], ReqInfo.Render.YOffset);
1668 Mip2X = GFX_ALIGN_FLOOR(Mip2X, TileSize[0]);
1669 Mip2Y = GFX_ALIGN_FLOOR(Mip2Y, TileSize[1]);
1670 uint32_t Mip2RenderAlignedOffset = Mip2Y * ExpectedPitch + (Mip2X / TileSize[0]) * (TileSize[0] * TileSize[1]);
1671 EXPECT_EQ(Mip2RenderAlignedOffset, ReqInfo.Render.Offset64);
1672
1673 // Mip 3 offset
1674 ReqInfo = {0};
1675 ReqInfo.MipLevel = 3;
1676 ReqInfo.ReqRender = 1;
1677 ReqInfo.ArrayIndex = i;
1678 ResourceInfo->GetOffset(ReqInfo);
1679
1680 uint32_t Mip3Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + GMM_ULT_ALIGN(Mip0Height >> 2, VAlign)) * ExpectedPitch + ArrayOffset;
1681 uint32_t Mip3X = uint32_t(Mip3Offset % ExpectedPitch);
1682 uint32_t Mip3Y = uint32_t(Mip3Offset / ExpectedPitch);
1683 EXPECT_EQ(8, ReqInfo.Render.XOffset);
1684 EXPECT_EQ(Mip3Y % TileSize[1], ReqInfo.Render.YOffset);
1685 Mip3X = GFX_ALIGN_FLOOR(Mip3X, TileSize[0]);
1686 Mip3Y = GFX_ALIGN_FLOOR(Mip3Y, TileSize[1]);
1687 uint32_t Mip3RenderAlignedOffset = Mip3Y * ExpectedPitch + (Mip3X / TileSize[0]) * (TileSize[0] * TileSize[1]);
1688 EXPECT_EQ(Mip3RenderAlignedOffset, ReqInfo.Render.Offset64);
1689
1690 // Mip 4 offset
1691 ReqInfo = {0};
1692 ReqInfo.MipLevel = 4;
1693 ReqInfo.ReqRender = 1;
1694 ReqInfo.ArrayIndex = i;
1695 ResourceInfo->GetOffset(ReqInfo);
1696 uint32_t Mip4Offset = 0;
1697 Mip4Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height + GMM_ULT_ALIGN(Mip0Height >> 2, VAlign) + GMM_ULT_ALIGN(Mip0Height >> 3, VAlign)) * ExpectedPitch + ArrayOffset;
1698 uint32_t Mip4X = uint32_t(Mip4Offset % ExpectedPitch);
1699 uint32_t Mip4Y = uint32_t(Mip4Offset / ExpectedPitch);
1700 EXPECT_EQ(8, ReqInfo.Render.XOffset);
1701 EXPECT_EQ(Mip4Y % TileSize[1], ReqInfo.Render.YOffset);
1702 Mip4X = GFX_ALIGN_FLOOR(Mip4X, TileSize[0]);
1703 Mip4Y = GFX_ALIGN_FLOOR(Mip4Y, TileSize[1]);
1704 uint32_t Mip4RenderAlignedOffset = Mip4Y * ExpectedPitch + (Mip4X / TileSize[0]) * (TileSize[0] * TileSize[1]);
1705 EXPECT_EQ(Mip4RenderAlignedOffset, ReqInfo.Render.Offset64);
1706 }
1707
1708 //Verify CpuBlt path (uses Render offset for upload)
1709 {
1710 #ifdef _WIN32
1711 #define ULT_ALIGNED_MALLOC(Size, alignBytes) _aligned_malloc(Size, alignBytes)
1712 #define ULT_ALIGNED_FREE(ptr) _aligned_free(ptr)
1713 #else
1714 #define ULT_ALIGNED_MALLOC(Size, alignBytes) memalign(alignBytes, Size)
1715 #define ULT_ALIGNED_FREE(ptr) free(ptr)
1716 #endif
1717
1718 #ifdef _WIN32
1719 void *LockVA = ULT_ALIGNED_MALLOC(ResourceInfo->GetSizeSurface(), ResourceInfo->GetBaseAlignment());
1720 memset(LockVA, 0, ResourceInfo->GetSizeSurface());
1721 void *Sysmem = malloc(gmmParams.BaseWidth64 * gmmParams.BaseHeight);
1722 memset(Sysmem, 0xbb, gmmParams.BaseWidth64 * gmmParams.BaseHeight);
1723 //Test Upload
1724 GMM_RES_COPY_BLT Blt = {0};
1725 Blt.Gpu.pData = LockVA;
1726 Blt.Gpu.Slice = 4;
1727 Blt.Gpu.MipLevel = 0;
1728 Blt.Sys.BufferSize = gmmParams.BaseWidth64 * gmmParams.BaseHeight;
1729 Blt.Sys.pData = Sysmem;
1730 Blt.Sys.RowPitch = gmmParams.BaseWidth64;
1731 Blt.Sys.PixelPitch = 1;
1732 Blt.Sys.SlicePitch = Blt.Sys.BufferSize;
1733 Blt.Blt.Upload = 1;
1734 Blt.Blt.BytesPerPixel = 1;
1735 ResourceInfo->CpuBlt(&Blt);
1736
1737 uint64_t Offset = 0x100; /*Blt.Gpu.Slice * ResourceInfo->GetQPitchInBytes();*/ // Need SwizzledOffset
1738 for(uint8_t byte = 0; byte < Blt.Sys.BufferSize; byte++)
1739 {
1740 uint8_t *Byte = ((uint8_t *)LockVA) + Offset + byte;
1741 EXPECT_EQ(Byte[0], 0xbb);
1742 }
1743
1744 free(Sysmem);
1745 ULT_ALIGNED_FREE(LockVA);
1746 #endif
1747 }
1748
1749 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1750 }
1751 }
1752
1753 /// @brief ULT for 3D Stencil (TileW) Mipped-array Resource
TEST_F(CTestGen9Resource,Test3DStencilMippedResource)1754 TEST_F(CTestGen9Resource, Test3DStencilMippedResource)
1755 {
1756 const uint32_t HAlign = {8};
1757 const uint32_t VAlign = {8};
1758
1759 const uint32_t TileSize[2] = {64, 64}; //TileW
1760
1761 GMM_RESCREATE_PARAMS gmmParams = {};
1762 gmmParams.Type = RESOURCE_3D;
1763 gmmParams.NoGfxMemory = 1;
1764 gmmParams.Flags.Info.TiledW = 1;
1765 gmmParams.Flags.Gpu.SeparateStencil = 1;
1766 gmmParams.MaxLod = 4;
1767
1768 {
1769 uint32_t AlignedWidth = 0;
1770 uint32_t AlignedHeight = 0;
1771 uint32_t ExpectedPitch = 0;
1772 // Valigned Mip Heights
1773 uint32_t Mip0Height = 0;
1774 uint32_t Mip1Height = 0;
1775 uint32_t Mip2Height = 0;
1776
1777 // Haligned Mip Widths
1778 uint32_t Mip0Width = 0;
1779 uint32_t Mip1Width = 0;
1780 uint32_t Mip2Width = 0;
1781
1782 TEST_BPP bpp = TEST_BPP_8;
1783 gmmParams.Format = SetResourceFormat(bpp);
1784 gmmParams.BaseWidth64 = 0x10;
1785 gmmParams.BaseHeight = 0x10;
1786 gmmParams.Depth = 0x10;
1787
1788 GMM_RESOURCE_INFO *ResourceInfo;
1789 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1790
1791 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
1792 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
1793
1794 // Mip resource Aligned Width calculation
1795 Mip0Width = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign);
1796 Mip0Height = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign);
1797
1798 for(uint32_t i = 1; i <= gmmParams.MaxLod; i++)
1799 {
1800 uint32_t MipWidth = GMM_ULT_ALIGN(Mip0Width >> i, HAlign);
1801 uint32_t MipHeight = GMM_ULT_ALIGN(Mip0Height >> i, VAlign);
1802 if(i == 1)
1803 {
1804 Mip1Width = AlignedWidth = MipWidth;
1805 Mip1Height = MipHeight;
1806 }
1807 else if(i == 2)
1808 {
1809 AlignedWidth += MipWidth;
1810 Mip2Height = MipHeight;
1811 }
1812 else
1813 {
1814 Mip2Height += MipHeight;
1815 }
1816 }
1817
1818 uint32_t MaxHeight = GMM_ULT_MAX(Mip1Height, Mip2Height);
1819 AlignedHeight = Mip0Height + MaxHeight;
1820
1821 ExpectedPitch = AlignedWidth * GetBppValue(bpp);
1822 ExpectedPitch = GMM_ULT_ALIGN(ExpectedPitch, TileSize[0]);
1823 //TileW is programmed as row-interleaved.. ie doubled pitch
1824 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch * 2);
1825
1826 VerifyResourcePitchInTiles<true>(ResourceInfo, static_cast<uint32_t>(ExpectedPitch / TileSize[0]));
1827 VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(ExpectedPitch * AlignedHeight, PAGE_SIZE) * gmmParams.Depth);
1828
1829 //3D QPitch must be aligned to Tile-height, div by 2 for Pitch is doubled
1830 // i.e. Slice-offset = Qpitch*Pitch is tile-aligned.
1831 AlignedHeight = GMM_ULT_ALIGN(AlignedHeight, TileSize[1]);
1832 VerifyResourceQPitch<true>(ResourceInfo, AlignedHeight / 2);
1833
1834 for(uint8_t i = 0; i < gmmParams.Depth; i++)
1835 {
1836 uint64_t SliceOffset = AlignedHeight * ExpectedPitch;
1837 // Mip 0 offsets, offset is 0,0
1838 GMM_REQ_OFFSET_INFO ReqInfo = {0};
1839 ReqInfo.MipLevel = 0;
1840 ReqInfo.ReqRender = 1;
1841 ReqInfo.Slice = i;
1842 ResourceInfo->GetOffset(ReqInfo);
1843
1844 uint32_t Mip0Size = ExpectedPitch * Mip0Height;
1845 EXPECT_EQ((0 + SliceOffset * i), ReqInfo.Render.Offset64);
1846 EXPECT_EQ(0, ReqInfo.Render.XOffset);
1847 EXPECT_EQ(0, ReqInfo.Render.YOffset);
1848
1849 // Mip 1 offsets -- uses 2d mip layout
1850 ReqInfo = {0};
1851 ReqInfo.MipLevel = 1;
1852 ReqInfo.ReqRender = 1;
1853 ReqInfo.Slice = i;
1854 ResourceInfo->GetOffset(ReqInfo);
1855 uint32_t Mip1Offset = Mip0Size;
1856 uint32_t Mip1X = GFX_ALIGN_FLOOR(uint32_t(Mip1Offset % ExpectedPitch), TileSize[0]);
1857 uint32_t Mip1Y = GFX_ALIGN_FLOOR(uint32_t(Mip1Offset / ExpectedPitch), TileSize[1]);
1858 uint32_t Mip1RenderAlignedOffset = Mip1Y * ExpectedPitch + (Mip1X / TileSize[0]) * (TileSize[0] * TileSize[1]) + SliceOffset * i;
1859 EXPECT_EQ(0, ReqInfo.Render.XOffset);
1860 EXPECT_EQ(16, ReqInfo.Render.YOffset);
1861 EXPECT_EQ(Mip1RenderAlignedOffset, ReqInfo.Render.Offset64);
1862
1863
1864 // Mip 2 offset
1865 ReqInfo = {0};
1866 ReqInfo.MipLevel = 2;
1867 ReqInfo.ReqRender = 1;
1868 ReqInfo.Slice = i;
1869 ResourceInfo->GetOffset(ReqInfo);
1870 uint32_t Mip2Offset = Mip1Width * GetBppValue(bpp) + (Mip0Height * ExpectedPitch) + SliceOffset * i;
1871 EXPECT_EQ(8, ReqInfo.Render.XOffset);
1872 EXPECT_EQ(16, ReqInfo.Render.YOffset);
1873 uint32_t Mip2X = GFX_ALIGN_FLOOR(uint32_t(Mip2Offset % ExpectedPitch), TileSize[0]);
1874 uint32_t Mip2Y = GFX_ALIGN_FLOOR(uint32_t(Mip2Offset / ExpectedPitch), TileSize[1]);
1875 uint32_t Mip2RenderAlignedOffset = Mip2Y * ExpectedPitch + (Mip2X / TileSize[0]) * (TileSize[0] * TileSize[1]);
1876 EXPECT_EQ(Mip2RenderAlignedOffset, ReqInfo.Render.Offset64);
1877
1878 // Mip 3 offset
1879 ReqInfo = {0};
1880 ReqInfo.MipLevel = 3;
1881 ReqInfo.ReqRender = 1;
1882 ReqInfo.Slice = i;
1883 ResourceInfo->GetOffset(ReqInfo);
1884 uint32_t Mip3Offset = 0;
1885 Mip3Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
1886 EXPECT_EQ(8, ReqInfo.Render.XOffset);
1887 EXPECT_EQ(24, ReqInfo.Render.YOffset);
1888 uint32_t Mip3X = GFX_ALIGN_FLOOR(uint32_t(Mip3Offset % ExpectedPitch), TileSize[0]);
1889 uint32_t Mip3Y = GFX_ALIGN_FLOOR(uint32_t(Mip3Offset / ExpectedPitch), TileSize[1]);
1890 uint32_t Mip3RenderAlignedOffset = Mip3Y * ExpectedPitch + (Mip3X / TileSize[0]) * (TileSize[0] * TileSize[1]) + SliceOffset * i;
1891 EXPECT_EQ(Mip3RenderAlignedOffset, ReqInfo.Render.Offset64);
1892
1893 // Mip 4 offset
1894 ReqInfo = {0};
1895 ReqInfo.MipLevel = 4;
1896 ReqInfo.ReqRender = 1;
1897 ReqInfo.Slice = i;
1898 ResourceInfo->GetOffset(ReqInfo);
1899 uint32_t Mip4Offset = 0;
1900 Mip4Offset = Mip1Width * GetBppValue(bpp) + Mip0Height * ExpectedPitch;
1901 EXPECT_EQ(8, ReqInfo.Render.XOffset);
1902 EXPECT_EQ(32, ReqInfo.Render.YOffset);
1903 uint32_t Mip4X = GFX_ALIGN_FLOOR(uint32_t(Mip4Offset % ExpectedPitch), TileSize[0]);
1904 uint32_t Mip4Y = GFX_ALIGN_FLOOR(uint32_t(Mip4Offset / ExpectedPitch), TileSize[1]);
1905 uint32_t Mip4RenderAlignedOffset = Mip4Y * ExpectedPitch + (Mip4X / TileSize[0]) * (TileSize[0] * TileSize[1]) + SliceOffset * i;
1906 EXPECT_EQ(Mip4RenderAlignedOffset, ReqInfo.Render.Offset64);
1907 }
1908
1909 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1910 }
1911 }
1912
1913 // ********************************************************************************//
1914 /// @brief ULT for 3D Linear Resource
TEST_F(CTestGen9Resource,Test3DLinearResource)1915 TEST_F(CTestGen9Resource, Test3DLinearResource)
1916 {
1917 // Horizontal/Vertical pixel alignment
1918 const uint32_t HAlign = 16;
1919 const uint32_t VAlign = 4;
1920
1921 GMM_RESCREATE_PARAMS gmmParams = {};
1922 gmmParams.Type = RESOURCE_3D;
1923 gmmParams.NoGfxMemory = 1;
1924 gmmParams.Flags.Info.Linear = 1;
1925 gmmParams.Flags.Gpu.Texture = 1;
1926
1927 // Allocate 1x1x1 surface
1928 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1929 {
1930 TEST_BPP bpp = static_cast<TEST_BPP>(i);
1931 gmmParams.Format = SetResourceFormat(bpp);
1932 gmmParams.BaseWidth64 = 0x1;
1933 gmmParams.BaseHeight = 0x1;
1934 gmmParams.Depth = 0x1;
1935
1936 const uint32_t MinPitch = 32;
1937 const uint32_t PitchAlignment = 32;
1938
1939 GMM_RESOURCE_INFO *ResourceInfo;
1940 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1941
1942 const uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign);
1943 const uint32_t AlignedHeight = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign);
1944 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
1945 PitchInBytes = GMM_ULT_MAX(PitchInBytes, MinPitch);
1946 PitchInBytes = GMM_ULT_ALIGN(PitchInBytes, PitchAlignment);
1947 const uint32_t AlignedSize = GMM_ULT_ALIGN(PitchInBytes * AlignedHeight, PAGE_SIZE);
1948
1949 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
1950 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
1951 VerifyResourcePitch<true>(ResourceInfo, PitchInBytes);
1952 VerifyResourceSize<true>(ResourceInfo, AlignedSize);
1953 VerifyResourceQPitch<true>(ResourceInfo, AlignedHeight);
1954
1955 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1956 }
1957
1958 // Allocate 256 x 256 x 256
1959 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
1960 {
1961 TEST_BPP bpp = static_cast<TEST_BPP>(i);
1962 gmmParams.Format = SetResourceFormat(bpp);
1963 gmmParams.BaseWidth64 = 256;
1964 gmmParams.BaseHeight = 256;
1965 gmmParams.Depth = 256;
1966
1967 const uint32_t MinPitch = 32;
1968 const uint32_t PitchAlignment = 32;
1969
1970 GMM_RESOURCE_INFO *ResourceInfo;
1971 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
1972
1973 const uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign);
1974 const uint32_t AlignedHeight = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign);
1975 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
1976 PitchInBytes = GFX_MAX(PitchInBytes, MinPitch);
1977 PitchInBytes = GMM_ULT_ALIGN(PitchInBytes, PitchAlignment);
1978 const uint32_t AlignedSize = GMM_ULT_ALIGN(PitchInBytes * AlignedHeight * gmmParams.Depth, PAGE_SIZE);
1979
1980 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
1981 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
1982 VerifyResourcePitch<true>(ResourceInfo, PitchInBytes);
1983 VerifyResourceSize<true>(ResourceInfo, AlignedSize);
1984 VerifyResourceQPitch<true>(ResourceInfo, AlignedHeight);
1985
1986 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
1987 }
1988 }
1989
1990 /// @brief ULT for 3D TileX Resource
TEST_F(CTestGen9Resource,Test3DTileXResource)1991 TEST_F(CTestGen9Resource, Test3DTileXResource)
1992 {
1993 // Horizontal/Vertical pixel alignment
1994 const uint32_t HAlign = 16;
1995 const uint32_t VAlign = 4;
1996 const uint32_t TileSize[TEST_BPP_MAX][3] = {{512, 8, 1},
1997 {512, 8, 1},
1998 {512, 8, 1},
1999 {512, 8, 1},
2000 {512, 8, 1}};
2001
2002 GMM_RESCREATE_PARAMS gmmParams = {};
2003 gmmParams.Type = RESOURCE_3D;
2004 gmmParams.NoGfxMemory = 1;
2005 gmmParams.Flags.Info.TiledX = 1;
2006 gmmParams.Flags.Gpu.Texture = 1;
2007
2008 // Allocate 1x1x1 surface
2009 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2010 {
2011 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2012 gmmParams.Format = SetResourceFormat(bpp);
2013 gmmParams.BaseWidth64 = 0x1;
2014 gmmParams.BaseHeight = 0x1;
2015 gmmParams.Depth = 0x1;
2016
2017 GMM_RESOURCE_INFO *ResourceInfo;
2018 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2019
2020 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2021 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2022 VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0]);
2023 VerifyResourcePitchInTiles<true>(ResourceInfo, 1);
2024 VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4));
2025 VerifyResourceQPitch<true>(ResourceInfo, TileSize[i][1]);
2026
2027 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2028 }
2029
2030 // Allocate 2 tiles in X dimension
2031 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2032 {
2033 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2034 gmmParams.Format = SetResourceFormat(bpp);
2035 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1;
2036 gmmParams.BaseHeight = 0x1;
2037 gmmParams.Depth = 0x1;
2038
2039 GMM_RESOURCE_INFO *ResourceInfo;
2040 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2041
2042 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2043 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2044 VerifyResourcePitch<true>(ResourceInfo, 2 * TileSize[i][0]);
2045 VerifyResourcePitchInTiles<true>(ResourceInfo, 2);
2046 VerifyResourceSize<true>(ResourceInfo, 2 * GMM_KBYTE(4));
2047 VerifyResourceQPitch<true>(ResourceInfo, TileSize[i][1]);
2048
2049 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2050 }
2051
2052 // Allocate 2 tiles in X/Y dimension
2053 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2054 {
2055 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2056 gmmParams.Format = SetResourceFormat(bpp);
2057 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1;
2058 gmmParams.BaseHeight = TileSize[i][1] + 1;
2059 gmmParams.Depth = 0x1;
2060
2061 GMM_RESOURCE_INFO *ResourceInfo;
2062 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2063
2064 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2065 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2066 VerifyResourcePitch<true>(ResourceInfo, 2 * TileSize[i][0]);
2067 VerifyResourcePitchInTiles<true>(ResourceInfo, 2);
2068 VerifyResourceSize<true>(ResourceInfo, 2 * 2 * GMM_KBYTE(4));
2069 VerifyResourceQPitch<true>(ResourceInfo, 2 * TileSize[i][1]);
2070
2071 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2072 }
2073
2074 // Allocate 2 tiles in X/Y/Z dimension
2075 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2076 {
2077 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2078 gmmParams.Format = SetResourceFormat(bpp);
2079 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1;
2080 gmmParams.BaseHeight = TileSize[i][1] + 1;
2081 gmmParams.Depth = TileSize[i][2] + 1;
2082
2083 GMM_RESOURCE_INFO *ResourceInfo;
2084 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2085
2086 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2087 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2088 VerifyResourcePitch<true>(ResourceInfo, 2 * TileSize[i][0]);
2089 VerifyResourcePitchInTiles<true>(ResourceInfo, 2);
2090 VerifyResourceSize<true>(ResourceInfo, 2 * 2 * 2 * GMM_KBYTE(4));
2091 VerifyResourceQPitch<true>(ResourceInfo, 2 * TileSize[i][1]);
2092
2093 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2094 }
2095 }
2096
2097 /// @brief ULT for 3D TileY Resource
TEST_F(CTestGen9Resource,Test3DTileYResource)2098 TEST_F(CTestGen9Resource, Test3DTileYResource)
2099 {
2100 // Horizontal/Vertical pixel alignment
2101 const uint32_t HAlign = 16;
2102 const uint32_t VAlign = 4;
2103 const uint32_t TileSize[TEST_BPP_MAX][3] = {{128, 32, 1},
2104 {128, 32, 1},
2105 {128, 32, 1},
2106 {128, 32, 1},
2107 {128, 32, 1}};
2108
2109 GMM_RESCREATE_PARAMS gmmParams = {};
2110 gmmParams.Type = RESOURCE_3D;
2111 gmmParams.NoGfxMemory = 1;
2112 gmmParams.Flags.Info.TiledY = 1;
2113 gmmParams.Flags.Gpu.Texture = 1;
2114
2115 // Allocate 1x1x1 surface
2116 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2117 {
2118 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2119 gmmParams.Format = SetResourceFormat(bpp);
2120 gmmParams.BaseWidth64 = 0x1;
2121 gmmParams.BaseHeight = 0x1;
2122 gmmParams.Depth = 0x1;
2123
2124 const uint32_t MinPitch = 32;
2125 const uint32_t PitchAlignment = 32;
2126
2127 GMM_RESOURCE_INFO *ResourceInfo;
2128 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2129
2130 const uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign);
2131 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
2132 PitchInBytes = GFX_MAX(PitchInBytes, MinPitch);
2133 PitchInBytes = GMM_ULT_ALIGN(PitchInBytes, PitchAlignment);
2134 PitchInBytes = GMM_ULT_ALIGN(PitchInBytes, TileSize[i][0]);
2135
2136 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2137 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2138 VerifyResourcePitch<true>(ResourceInfo, PitchInBytes);
2139 VerifyResourcePitchInTiles<true>(ResourceInfo, PitchInBytes / TileSize[i][0]);
2140 VerifyResourceSize<true>(ResourceInfo, PitchInBytes / TileSize[i][0] * GMM_KBYTE(4));
2141 VerifyResourceQPitch<true>(ResourceInfo, TileSize[i][1]);
2142
2143 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2144 }
2145
2146 // Allocate 2 tiles in X dimension
2147 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2148 {
2149 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2150 gmmParams.Format = SetResourceFormat(bpp);
2151 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1;
2152 gmmParams.BaseHeight = 0x1;
2153 gmmParams.Depth = 0x1;
2154
2155 const uint32_t MinPitch = 32;
2156 const uint32_t PitchAlignment = 32;
2157
2158 GMM_RESOURCE_INFO *ResourceInfo;
2159 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2160
2161 const uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign);
2162 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
2163 PitchInBytes = GFX_MAX(PitchInBytes, MinPitch);
2164 PitchInBytes = GMM_ULT_ALIGN(PitchInBytes, PitchAlignment);
2165 PitchInBytes = GMM_ULT_ALIGN(PitchInBytes, TileSize[i][0]);
2166
2167 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2168 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2169 VerifyResourcePitch<true>(ResourceInfo, PitchInBytes);
2170 VerifyResourcePitchInTiles<true>(ResourceInfo, PitchInBytes / TileSize[i][0]);
2171 VerifyResourceSize<true>(ResourceInfo, PitchInBytes / TileSize[i][0] * GMM_KBYTE(4));
2172 VerifyResourceQPitch<true>(ResourceInfo, TileSize[i][1]);
2173
2174 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2175 }
2176
2177 // Allocate 2 tiles in X/Y dimension
2178 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2179 {
2180 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2181 gmmParams.Format = SetResourceFormat(bpp);
2182 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1;
2183 gmmParams.BaseHeight = TileSize[i][1] + 1;
2184 gmmParams.Depth = 0x1;
2185
2186 const uint32_t MinPitch = 32;
2187 const uint32_t PitchAlignment = 32;
2188
2189 GMM_RESOURCE_INFO *ResourceInfo;
2190 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2191
2192 const uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign);
2193 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
2194 PitchInBytes = GFX_MAX(PitchInBytes, MinPitch);
2195 PitchInBytes = GMM_ULT_ALIGN(PitchInBytes, PitchAlignment);
2196 PitchInBytes = GMM_ULT_ALIGN(PitchInBytes, TileSize[i][0]);
2197
2198 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2199 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2200 VerifyResourcePitch<true>(ResourceInfo, PitchInBytes);
2201 VerifyResourcePitchInTiles<true>(ResourceInfo, PitchInBytes / TileSize[i][0]);
2202 VerifyResourceSize<true>(ResourceInfo, PitchInBytes / TileSize[i][0] * 2 * GMM_KBYTE(4));
2203 VerifyResourceQPitch<true>(ResourceInfo, TileSize[i][1] * 2);
2204
2205 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2206 }
2207
2208 // Allocate 2 tiles in X/Y/Z dimension
2209 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2210 {
2211 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2212 gmmParams.Format = SetResourceFormat(bpp);
2213 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1;
2214 gmmParams.BaseHeight = TileSize[i][1] + 1;
2215 gmmParams.Depth = TileSize[i][2] + 1;
2216
2217 const uint32_t MinPitch = 32;
2218 const uint32_t PitchAlignment = 32;
2219
2220 GMM_RESOURCE_INFO *ResourceInfo;
2221 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2222
2223 const uint32_t AlignedWidth = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign);
2224 uint32_t PitchInBytes = AlignedWidth * GetBppValue(bpp);
2225 PitchInBytes = GFX_MAX(PitchInBytes, MinPitch);
2226 PitchInBytes = GMM_ULT_ALIGN(PitchInBytes, PitchAlignment);
2227 PitchInBytes = GMM_ULT_ALIGN(PitchInBytes, TileSize[i][0]);
2228
2229 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2230 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2231 VerifyResourcePitch<true>(ResourceInfo, PitchInBytes);
2232 VerifyResourcePitchInTiles<true>(ResourceInfo, PitchInBytes / TileSize[i][0]);
2233 VerifyResourceSize<true>(ResourceInfo, PitchInBytes / TileSize[i][0] * 2 * 2 * GMM_KBYTE(4));
2234 VerifyResourceQPitch<true>(ResourceInfo, TileSize[i][1] * 2);
2235
2236 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2237 }
2238 }
2239
2240 /// @brief ULT for 3D TileYs Resource
TEST_F(CTestGen9Resource,Test3DTileYsResource)2241 TEST_F(CTestGen9Resource, Test3DTileYsResource)
2242 {
2243 // Horizontal/Vertical pixel alignment
2244 const uint32_t HAlign[TEST_BPP_MAX] = {64, 32, 32, 32, 16};
2245 const uint32_t VAlign[TEST_BPP_MAX] = {32, 32, 32, 16, 16};
2246
2247 const uint32_t TileSize[TEST_BPP_MAX][3] = {{64, 32, 32},
2248 {64, 32, 32},
2249 {128, 32, 16},
2250 {256, 16, 16},
2251 {256, 16, 16}};
2252
2253 GMM_RESCREATE_PARAMS gmmParams = {};
2254 gmmParams.Type = RESOURCE_3D;
2255 gmmParams.NoGfxMemory = 1;
2256 gmmParams.Flags.Info.TiledY = 1;
2257 gmmParams.Flags.Info.TiledYs = 1;
2258 gmmParams.Flags.Gpu.Texture = 1;
2259
2260 // Allocate 1x1x1 surface
2261 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2262 {
2263 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2264 gmmParams.Format = SetResourceFormat(bpp);
2265 gmmParams.BaseWidth64 = 0x1;
2266 gmmParams.BaseHeight = 0x1;
2267 gmmParams.Depth = 0x1;
2268
2269 GMM_RESOURCE_INFO *ResourceInfo;
2270 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2271
2272 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
2273 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
2274 VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0]); // As wide as 1 tile
2275 VerifyResourcePitchInTiles<true>(ResourceInfo, 1); // 1 tile wide
2276 VerifyResourceSize<false>(ResourceInfo, GMM_KBYTE(64)); // 1 tile big
2277
2278 VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
2279
2280 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2281 }
2282
2283 // Allocate 2 tiles in X dimension
2284 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2285 {
2286 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2287 gmmParams.Format = SetResourceFormat(bpp);
2288 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
2289 gmmParams.BaseHeight = 0x1;
2290 gmmParams.Depth = 0x1;
2291
2292 GMM_RESOURCE_INFO *ResourceInfo;
2293 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2294
2295 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
2296 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
2297 VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0] * 2); // As wide as 2 tile
2298 VerifyResourcePitchInTiles<true>(ResourceInfo, 2); // 2 tile wide
2299 VerifyResourceSize<false>(ResourceInfo, GMM_KBYTE(64) * 2); // 2 tile big
2300
2301 VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
2302
2303 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2304 }
2305
2306 // Allocate 2 tiles in X/Y dimension
2307 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2308 {
2309 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2310 gmmParams.Format = SetResourceFormat(bpp);
2311 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
2312 gmmParams.BaseHeight = TileSize[i][1] + 1; // 1 row larger than 1 tile height
2313 gmmParams.Depth = 0x1;
2314
2315 GMM_RESOURCE_INFO *ResourceInfo;
2316 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2317
2318 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
2319 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
2320 VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0] * 2); // As wide as 2 tile
2321 VerifyResourcePitchInTiles<true>(ResourceInfo, 2); // 2 tile wide
2322 VerifyResourceSize<false>(ResourceInfo, GMM_KBYTE(64) * 4); // 4 tile big
2323
2324 VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
2325
2326 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2327 }
2328
2329 // Allocate 2 tiles in X/Y/Z dimension
2330 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2331 {
2332 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2333 gmmParams.Format = SetResourceFormat(bpp);
2334 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
2335 gmmParams.BaseHeight = TileSize[i][1] + 1; // 1 row larger than 1 tile height
2336 gmmParams.Depth = TileSize[i][2] + 1; // 1 plane larger than 1 tile depth
2337
2338 GMM_RESOURCE_INFO *ResourceInfo;
2339 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2340
2341 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
2342 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
2343 VerifyResourcePitch<true>(ResourceInfo, TileSize[i][0] * 2); // As wide as 2 tile
2344 VerifyResourcePitchInTiles<true>(ResourceInfo, 2); // 2 tile wide
2345 VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(64) * 8); // 8 tile big
2346
2347 VerifyResourceQPitch<false>(ResourceInfo, 0); // Not tested
2348
2349 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2350 }
2351 }
2352
2353 /// @brief ULT for 3D TileYs Mipped Resource
TEST_F(CTestGen9Resource,Test3DTileYsMippedResource)2354 TEST_F(CTestGen9Resource, Test3DTileYsMippedResource)
2355 {
2356 // Horizontal/Vertical pixel alignment
2357 const uint32_t HAlign[TEST_BPP_MAX] = {64, 32, 32, 32, 16};
2358 const uint32_t VAlign[TEST_BPP_MAX] = {32, 32, 32, 16, 16};
2359
2360 const uint32_t TileSize[TEST_BPP_MAX][3] = {{64, 32, 32},
2361 {64, 32, 32},
2362 {128, 32, 16},
2363 {256, 16, 16},
2364 {256, 16, 16}};
2365 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2366 {
2367 const uint32_t ResourceWidth = 0x100;
2368 const uint32_t ResourceHeight = 0x100;
2369 const uint32_t ResourceDepth = 0x100;
2370 const uint32_t MaxLod = 0x5;
2371
2372 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2373 GMM_RESCREATE_PARAMS gmmParams = {};
2374 gmmParams.Type = RESOURCE_3D;
2375 gmmParams.Flags.Info.TiledY = 1;
2376 gmmParams.Flags.Info.TiledYs = 1;
2377 gmmParams.NoGfxMemory = 1;
2378 gmmParams.Flags.Gpu.Texture = 1;
2379 gmmParams.BaseWidth64 = ResourceWidth;
2380 gmmParams.BaseHeight = ResourceHeight;
2381 gmmParams.Depth = ResourceDepth;
2382 gmmParams.MaxLod = MaxLod;
2383 gmmParams.Format = SetResourceFormat(bpp);
2384
2385 GMM_RESOURCE_INFO *ResourceInfo;
2386 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2387
2388 const uint32_t Pitch = ResourceWidth * GetBppValue(bpp);
2389 const uint32_t Mip0Height = ResourceHeight;
2390
2391 // Mip0
2392 GMM_REQ_OFFSET_INFO OffsetInfo = {};
2393 OffsetInfo.ReqRender = 1;
2394 OffsetInfo.MipLevel = 0;
2395 ResourceInfo->GetOffset(OffsetInfo);
2396
2397 EXPECT_EQ(0, OffsetInfo.Render.Offset64);
2398 EXPECT_EQ(0, OffsetInfo.Render.XOffset);
2399 EXPECT_EQ(0, OffsetInfo.Render.YOffset);
2400 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
2401
2402 // Mip1
2403 OffsetInfo = {};
2404 OffsetInfo.ReqRender = 1;
2405 OffsetInfo.MipLevel = 1;
2406 ResourceInfo->GetOffset(OffsetInfo);
2407
2408 const uint32_t SizeOfMip0 = Pitch * ResourceHeight * TileSize[i][2];
2409 const uint32_t Mip1Offset = SizeOfMip0;
2410 const uint32_t Mip1Width = ResourceWidth >> 1;
2411 const uint32_t Mip1Height = ResourceHeight >> 1;
2412
2413 EXPECT_EQ(Mip1Offset, OffsetInfo.Render.Offset64);
2414 EXPECT_EQ(0, OffsetInfo.Render.XOffset);
2415 EXPECT_EQ(0, OffsetInfo.Render.YOffset);
2416 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
2417
2418 // Mip2
2419 OffsetInfo = {};
2420 OffsetInfo.ReqRender = 1;
2421 OffsetInfo.MipLevel = 2;
2422 ResourceInfo->GetOffset(OffsetInfo);
2423
2424 const uint32_t Mip2Height = ResourceHeight >> 2;
2425 const uint32_t Mip2Offset = Mip1Offset + Mip1Width * GetBppValue(bpp) / TileSize[i][0] * GMM_KBYTE(64);
2426
2427 EXPECT_EQ(Mip2Offset, OffsetInfo.Render.Offset64);
2428 EXPECT_EQ(0, OffsetInfo.Render.XOffset);
2429 EXPECT_EQ(0, OffsetInfo.Render.YOffset);
2430 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
2431
2432 // Mip3
2433 OffsetInfo = {};
2434 OffsetInfo.ReqRender = 1;
2435 OffsetInfo.MipLevel = 3;
2436 ResourceInfo->GetOffset(OffsetInfo);
2437
2438 const uint32_t Mip3Y = (Mip0Height + Mip2Height) * TileSize[i][2];
2439 const uint32_t Mip3X = Mip1Width;
2440 const uint32_t Mip3Offset = Mip3Y * Pitch + Mip3X * GetBppValue(bpp) / TileSize[i][0] * GMM_KBYTE(64);
2441
2442 EXPECT_EQ(Mip3Offset, OffsetInfo.Render.Offset64);
2443 EXPECT_EQ(bpp == TEST_BPP_8 ? 32 : 0, OffsetInfo.Render.XOffset);
2444 EXPECT_EQ(0, OffsetInfo.Render.YOffset);
2445 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
2446
2447 // Mip4
2448 OffsetInfo = {};
2449 OffsetInfo.ReqRender = 1;
2450 OffsetInfo.MipLevel = 4;
2451 ResourceInfo->GetOffset(OffsetInfo);
2452
2453 const uint32_t Mip3Height = ResourceHeight >> 3;
2454 const uint32_t Mip4Y = (Mip0Height + Mip2Height + Mip3Height) * TileSize[i][2];
2455 const uint32_t Mip4X = Mip1Width;
2456 const uint32_t Mip4Offset = Mip4Y * Pitch + Mip4X * GetBppValue(bpp) / TileSize[i][0] * GMM_KBYTE(64);
2457
2458 switch(bpp)
2459 {
2460 case TEST_BPP_8:
2461 EXPECT_EQ(Mip3Offset, OffsetInfo.Render.Offset64);
2462 EXPECT_EQ(0, OffsetInfo.Render.XOffset);
2463 EXPECT_EQ(16, OffsetInfo.Render.YOffset);
2464 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
2465 break;
2466 case TEST_BPP_16:
2467 EXPECT_EQ(Mip4Offset, OffsetInfo.Render.Offset64);
2468 EXPECT_EQ(32, OffsetInfo.Render.XOffset);
2469 EXPECT_EQ(0, OffsetInfo.Render.YOffset);
2470 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
2471 break;
2472 case TEST_BPP_32:
2473 EXPECT_EQ(Mip4Offset, OffsetInfo.Render.Offset64);
2474 EXPECT_EQ(64, OffsetInfo.Render.XOffset);
2475 EXPECT_EQ(0, OffsetInfo.Render.YOffset);
2476 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
2477 break;
2478 case TEST_BPP_64:
2479 EXPECT_EQ(Mip4Offset, OffsetInfo.Render.Offset64);
2480 EXPECT_EQ(128, OffsetInfo.Render.XOffset);
2481 EXPECT_EQ(0, OffsetInfo.Render.YOffset);
2482 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
2483 break;
2484 case TEST_BPP_128:
2485 EXPECT_EQ(Mip4Offset, OffsetInfo.Render.Offset64);
2486 EXPECT_EQ(0, OffsetInfo.Render.XOffset);
2487 EXPECT_EQ(0, OffsetInfo.Render.YOffset);
2488 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
2489 break;
2490 default:
2491 break;
2492 }
2493
2494 // Mip5
2495 OffsetInfo = {};
2496 OffsetInfo.ReqRender = 1;
2497 OffsetInfo.MipLevel = 5;
2498 ResourceInfo->GetOffset(OffsetInfo);
2499
2500 const uint32_t Mip4Height = ResourceHeight >> 4;
2501 const uint32_t Mip5Y = (Mip0Height + Mip2Height + Mip3Height + Mip4Height) * TileSize[i][2];
2502 const uint32_t Mip5X = Mip1Width;
2503 const uint32_t Mip5Offset = Mip5Y * Pitch + Mip4X * GetBppValue(bpp) / TileSize[i][0] * GMM_KBYTE(64);
2504
2505 switch(bpp)
2506 {
2507 case TEST_BPP_8:
2508 EXPECT_EQ(Mip3Offset, OffsetInfo.Render.Offset64);
2509 EXPECT_EQ(0, OffsetInfo.Render.XOffset);
2510 EXPECT_EQ(0, OffsetInfo.Render.YOffset);
2511 EXPECT_EQ(16, OffsetInfo.Render.ZOffset);
2512 break;
2513 case TEST_BPP_16:
2514 EXPECT_EQ(Mip4Offset, OffsetInfo.Render.Offset64);
2515 EXPECT_EQ(0, OffsetInfo.Render.XOffset);
2516 EXPECT_EQ(16, OffsetInfo.Render.YOffset);
2517 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
2518 break;
2519 case TEST_BPP_32:
2520 EXPECT_EQ(Mip4Offset, OffsetInfo.Render.Offset64);
2521 EXPECT_EQ(0, OffsetInfo.Render.XOffset);
2522 EXPECT_EQ(16, OffsetInfo.Render.YOffset);
2523 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
2524 break;
2525 case TEST_BPP_64:
2526 EXPECT_EQ(Mip4Offset, OffsetInfo.Render.Offset64);
2527 EXPECT_EQ(0, OffsetInfo.Render.XOffset);
2528 EXPECT_EQ(8, OffsetInfo.Render.YOffset);
2529 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
2530 break;
2531 case TEST_BPP_128:
2532 EXPECT_EQ(Mip5Offset, OffsetInfo.Render.Offset64);
2533 EXPECT_EQ(128, OffsetInfo.Render.XOffset);
2534 EXPECT_EQ(0, OffsetInfo.Render.YOffset);
2535 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
2536 break;
2537 default:
2538 break;
2539 }
2540
2541 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2542 }
2543 }
2544
2545 /// @brief ULT for 3D TileYf Resource
TEST_F(CTestGen9Resource,Test3DTileYfResource)2546 TEST_F(CTestGen9Resource, Test3DTileYfResource)
2547 {
2548 // Horizontal/Vertical pixel alignment
2549 const uint32_t HAlign[TEST_BPP_MAX] = {16, 8, 8, 8, 4};
2550 const uint32_t VAlign[TEST_BPP_MAX] = {16, 16, 16, 8, 8};
2551 const uint32_t TileSize[TEST_BPP_MAX][3] = {{16, 16, 16},
2552 {16, 16, 16},
2553 {32, 16, 8},
2554 {64, 8, 8},
2555 {64, 8, 8}};
2556
2557 GMM_RESCREATE_PARAMS gmmParams = {};
2558 gmmParams.Type = RESOURCE_3D;
2559 gmmParams.NoGfxMemory = 1;
2560 gmmParams.Flags.Info.TiledYf = 1;
2561 gmmParams.Flags.Gpu.Texture = 1;
2562
2563 // Allocate 1x1x1 surface
2564 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2565 {
2566 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2567 gmmParams.Format = SetResourceFormat(bpp);
2568 gmmParams.BaseWidth64 = 0x1;
2569 gmmParams.BaseHeight = 0x1;
2570 gmmParams.Depth = 0x1;
2571 const uint32_t PitchAlignment = 32;
2572
2573 GMM_RESOURCE_INFO *ResourceInfo;
2574 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2575
2576 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
2577 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
2578 VerifyResourcePitch<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0], PitchAlignment));
2579 VerifyResourcePitchInTiles<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0], PitchAlignment) / TileSize[i][0]);
2580 VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0], PitchAlignment) / TileSize[i][0] * GMM_KBYTE(4));
2581 VerifyResourceQPitch<true>(ResourceInfo, TileSize[i][1]);
2582
2583 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2584 }
2585
2586 // Allocate 2 tiles in X dimension
2587 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2588 {
2589 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2590 gmmParams.Format = SetResourceFormat(bpp);
2591 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1;
2592 gmmParams.BaseHeight = 0x1;
2593 gmmParams.Depth = 0x1;
2594 const uint32_t PitchAlignment = 32;
2595
2596
2597 GMM_RESOURCE_INFO *ResourceInfo;
2598 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2599
2600 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
2601 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
2602 VerifyResourcePitch<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 2, PitchAlignment));
2603 VerifyResourcePitchInTiles<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 2, PitchAlignment) / TileSize[i][0]);
2604 VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 2, PitchAlignment) / TileSize[i][0] * GMM_KBYTE(4));
2605 VerifyResourceQPitch<true>(ResourceInfo, TileSize[i][1]);
2606
2607 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2608 }
2609
2610 // Allocate 2 tiles in X/Y dimension
2611 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2612 {
2613 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2614 gmmParams.Format = SetResourceFormat(bpp);
2615 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1;
2616 gmmParams.BaseHeight = TileSize[i][1] + 1;
2617 gmmParams.Depth = 0x1;
2618 const uint32_t PitchAlignment = 32;
2619
2620 GMM_RESOURCE_INFO *ResourceInfo;
2621 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2622
2623 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
2624 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
2625 VerifyResourcePitch<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 2, PitchAlignment));
2626 VerifyResourcePitchInTiles<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 2, PitchAlignment) / TileSize[i][0]);
2627 VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 2, PitchAlignment) / TileSize[i][0] * 2 * GMM_KBYTE(4));
2628 VerifyResourceQPitch<true>(ResourceInfo, TileSize[i][1] * 2);
2629
2630 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2631 }
2632
2633 // Allocate 2 tiles in X/Y/Z dimension
2634 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2635 {
2636 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2637 gmmParams.Format = SetResourceFormat(bpp);
2638 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1;
2639 gmmParams.BaseHeight = TileSize[i][1] + 1;
2640 gmmParams.Depth = TileSize[i][2] + 1;
2641 const uint32_t PitchAlignment = 32;
2642
2643 GMM_RESOURCE_INFO *ResourceInfo;
2644 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2645
2646 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
2647 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
2648 VerifyResourcePitch<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 2, PitchAlignment));
2649 VerifyResourcePitchInTiles<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 2, PitchAlignment) / TileSize[i][0]);
2650 VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(TileSize[i][0] * 2, PitchAlignment) / TileSize[i][0] * 2 * 2 * GMM_KBYTE(4));
2651 VerifyResourceQPitch<true>(ResourceInfo, TileSize[i][1] * 2);
2652
2653 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2654 }
2655 }
2656
2657
2658 /// @brief ULT for Cube Linear Resource
TEST_F(CTestGen9Resource,TestCubeLinearResource)2659 TEST_F(CTestGen9Resource, TestCubeLinearResource)
2660 {
2661 const uint32_t HAlign = 16;
2662 const uint32_t VAlign = 4;
2663
2664 GMM_RESCREATE_PARAMS gmmParams = {};
2665 gmmParams.Type = RESOURCE_CUBE;
2666 gmmParams.NoGfxMemory = 1;
2667 gmmParams.Flags.Info.Linear = 1;
2668 gmmParams.Flags.Gpu.Texture = 1;
2669
2670 // Allocate 1x1
2671 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2672 {
2673 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2674 gmmParams.Format = SetResourceFormat(bpp);
2675 gmmParams.BaseWidth64 = 0x1;
2676 gmmParams.BaseHeight = 0x1;
2677 gmmParams.Depth = 0x1;
2678
2679 GMM_RESOURCE_INFO *ResourceInfo;
2680 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2681
2682 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2683 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2684
2685 uint32_t ExpectedPitch = GMM_ULT_MAX(GMM_BYTES(32), HAlign * GetBppValue(bpp)); // Min Pitch = 32 bytes
2686 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch); // As wide as 1 tile
2687 VerifyResourcePitchInTiles<false>(ResourceInfo, 1); // not applicable
2688
2689 uint32_t ExpectedQPitch = VAlign;
2690 VerifyResourceQPitch<true>(ResourceInfo, ExpectedQPitch); // Each face should be VAlign rows apart within a tile
2691
2692 VerifyResourceSize<true>(ResourceInfo, // PitchInBytes * Rows where Rows = __GMM_MAX_CUBE_FACE x QPitch, then aligned PAGE_SIZE
2693 GMM_ULT_ALIGN(ExpectedPitch *
2694 __GMM_MAX_CUBE_FACE * ExpectedQPitch,
2695 PAGE_SIZE));
2696
2697 for(uint32_t CubeFaceIndex = 0; CubeFaceIndex < __GMM_MAX_CUBE_FACE; CubeFaceIndex++)
2698 {
2699 GMM_REQ_OFFSET_INFO OffsetInfo = {};
2700 OffsetInfo.ReqRender = 1;
2701 OffsetInfo.CubeFace = static_cast<GMM_CUBE_FACE_ENUM>(CubeFaceIndex);
2702 ResourceInfo->GetOffset(OffsetInfo);
2703
2704 EXPECT_EQ(CubeFaceIndex * ExpectedQPitch * ExpectedPitch,
2705 OffsetInfo.Render.Offset64); // Render offset is tile's base address on which cube face begins.
2706 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // X Offset should be 0
2707 EXPECT_EQ(0, OffsetInfo.Render.YOffset); // Y Offset should be 0
2708 EXPECT_EQ(0, OffsetInfo.Render.ZOffset); // Z offset N/A should be 0
2709 }
2710
2711 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2712 }
2713
2714 // Allocate arbitrary size (X/Y dimension not applicable as linear surface)
2715 // Width and Height must be equal
2716 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2717 {
2718 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2719 gmmParams.Format = SetResourceFormat(bpp);
2720 gmmParams.BaseWidth64 = 0x201; // 512 + 1, help ult HAlign/VAlign/Pitch alignment logic as well.
2721 gmmParams.BaseHeight = gmmParams.BaseWidth64; // Heigth must be equal to width.
2722 gmmParams.Depth = 0x1;
2723
2724 GMM_RESOURCE_INFO *ResourceInfo;
2725 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2726
2727 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2728 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2729
2730 uint32_t ExpectedPitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign) * GetBppValue(bpp); // HAligned-width in bytes.
2731 ExpectedPitch = GMM_ULT_ALIGN(ExpectedPitch, GMM_BYTES(32));
2732 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
2733 VerifyResourcePitchInTiles<false>(ResourceInfo, 2); // not applicable
2734
2735 uint32_t ExpectedQPitch = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign);
2736 VerifyResourceQPitch<true>(ResourceInfo, ExpectedQPitch); // Each face should be Valigned-BaseHeight rows apart
2737
2738 VerifyResourceSize<true>(ResourceInfo, // PitchInBytes * Rows where Rows = __GMM_MAX_CUBE_FACE x QPitch, then aligned PAGE_SIZE
2739 GMM_ULT_ALIGN(ExpectedPitch *
2740 __GMM_MAX_CUBE_FACE * ExpectedQPitch,
2741 PAGE_SIZE));
2742
2743 for(uint32_t CubeFaceIndex = 0; CubeFaceIndex < __GMM_MAX_CUBE_FACE; CubeFaceIndex++)
2744 {
2745 GMM_REQ_OFFSET_INFO OffsetInfo = {};
2746 OffsetInfo.ReqRender = 1;
2747 OffsetInfo.CubeFace = static_cast<GMM_CUBE_FACE_ENUM>(CubeFaceIndex);
2748 ResourceInfo->GetOffset(OffsetInfo);
2749
2750 EXPECT_EQ(CubeFaceIndex * ExpectedQPitch * ExpectedPitch,
2751 OffsetInfo.Render.Offset64); // Render offset is tile's base address on which cube face begins.
2752 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // X Offset should be 0
2753 EXPECT_EQ(0, OffsetInfo.Render.YOffset); // Y Offset should be 0
2754 EXPECT_EQ(0, OffsetInfo.Render.ZOffset); // Z offset N/A should be 0
2755 }
2756
2757 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2758 }
2759 }
2760
2761 /// @brief ULT for Cube Linear Mipped Resource Array
TEST_F(CTestGen9Resource,TestCubeLinearMippedResourceArray)2762 TEST_F(CTestGen9Resource, TestCubeLinearMippedResourceArray)
2763 {
2764 const uint32_t HAlign = 16;
2765 const uint32_t VAlign = 4;
2766 const uint32_t MaxLod = 9;
2767 const uint32_t ResWidth = 0x401;
2768 const uint32_t MaxArraySize = 0x10;
2769
2770
2771 GMM_RESCREATE_PARAMS gmmParams = {};
2772 gmmParams.Type = RESOURCE_CUBE;
2773 gmmParams.NoGfxMemory = 1;
2774 gmmParams.Flags.Info.Linear = 1;
2775 gmmParams.Flags.Gpu.Texture = 1;
2776 gmmParams.MaxLod = MaxLod;
2777 gmmParams.ArraySize = MaxArraySize;
2778
2779 // Allocate arbitrary size (X/Y dimension not applicable as linear surface)
2780 // Width and Height must be equal
2781 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2782 {
2783 struct //Cache the value for verifying array elements/Cube face offset/Mip Offset
2784 {
2785 uint64_t Offset; // Note : absolute mip offset
2786 } RenderOffset[GMM_ULT_MAX_MIPMAP] = {};
2787
2788 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2789 gmmParams.Format = SetResourceFormat(bpp);
2790 gmmParams.BaseWidth64 = ResWidth; // 1024 + 1, help ult HAlign/VAlign/Pitch alignment logic as well.
2791 gmmParams.BaseHeight = gmmParams.BaseWidth64; // Heigth must be equal to width.
2792 gmmParams.Depth = 0x1;
2793
2794 GMM_RESOURCE_INFO *ResourceInfo;
2795 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2796
2797 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2798 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2799
2800 //------------------------------|
2801 // |
2802 // LOD0 |
2803 // |
2804 // |
2805 //------------------------------|
2806 // LOD1 | LOD2 |
2807 // |----------|
2808 // | LOD3 |
2809 //-------------| LOD4 .. so on
2810
2811 // Mip 0
2812 // Mip 0 decides the pitch of the entire surface
2813 const uint32_t AlignedWidthMip0 = GMM_ULT_ALIGN(ResWidth, HAlign); // HAlign width in pixel
2814 const uint32_t AlignedHeightMip0 = GMM_ULT_ALIGN(ResWidth, VAlign);
2815 uint32_t ExpectedPitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign) * GetBppValue(bpp); // HAligned-width in bytes.
2816 ExpectedPitch = GMM_ULT_ALIGN(ExpectedPitch, GMM_BYTES(32));
2817 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
2818 VerifyResourcePitchInTiles<false>(ResourceInfo, 2); // Not applicable
2819
2820 // Mip0 should be at offset 0 and tile aligned
2821 GMM_REQ_OFFSET_INFO OffsetInfo = {};
2822 OffsetInfo.ReqRender = 1;
2823 OffsetInfo.MipLevel = 0; //Mip 0
2824 ResourceInfo->GetOffset(OffsetInfo);
2825 EXPECT_EQ(0, OffsetInfo.Render.Offset64);
2826 EXPECT_EQ(0, OffsetInfo.Render.XOffset);
2827 EXPECT_EQ(0, OffsetInfo.Render.YOffset);
2828 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
2829
2830 //cache Mip 0 offset
2831 RenderOffset[0].Offset = 0;
2832
2833 // Mip 1 should be under mip 0
2834 OffsetInfo = {};
2835 OffsetInfo.ReqRender = 1;
2836 OffsetInfo.MipLevel = 1; //Mip 1
2837 ResourceInfo->GetOffset(OffsetInfo);
2838
2839 EXPECT_EQ(AlignedHeightMip0 * ExpectedPitch, // Render offset is the absolute address at which the mip begins
2840 OffsetInfo.Render.Offset64);
2841 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // Not applicable for linear surface
2842 EXPECT_EQ(0, OffsetInfo.Render.YOffset); // Not applicable for linear surface
2843 EXPECT_EQ(0, OffsetInfo.Render.ZOffset); // n/a
2844
2845 //cache Mip 1 offset
2846 RenderOffset[1].Offset = AlignedHeightMip0 * ExpectedPitch; //Absolute base
2847
2848 const uint32_t AlignedWidthMip1 = GMM_ULT_ALIGN(ResWidth >> 1, HAlign); // Align width in pixel to HAlign
2849 const uint32_t AlignedHeightMip1 = GMM_ULT_ALIGN(ResWidth >> 1, VAlign);
2850
2851 uint32_t HeightOfMip;
2852 uint32_t HeightLinesLevel2 = 0;
2853
2854 // Mips 2-9 should be stacked on the right of Mip1 as shown in figure above.
2855 for(int i = 2; i <= MaxLod; i++)
2856 {
2857 OffsetInfo = {};
2858 OffsetInfo.ReqRender = 1;
2859 OffsetInfo.MipLevel = i;
2860 ResourceInfo->GetOffset(OffsetInfo);
2861
2862 HeightOfMip = GMM_ULT_ALIGN(ResWidth >> i, VAlign);
2863
2864 EXPECT_EQ((AlignedHeightMip0 + HeightLinesLevel2) * ExpectedPitch + // Render offset is tile's base address on which mip begins
2865 (AlignedWidthMip1 * GetBppValue(bpp)),
2866 OffsetInfo.Render.Offset64);
2867
2868 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // Not applicable for linear surface
2869 EXPECT_EQ(0, OffsetInfo.Render.YOffset); // Not applicable for linear surface
2870 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
2871
2872 //cache Mip i'th offset
2873 RenderOffset[i].Offset = (AlignedHeightMip0 + HeightLinesLevel2) * ExpectedPitch +
2874 (AlignedWidthMip1 * GetBppValue(bpp));
2875
2876 HeightLinesLevel2 += HeightOfMip;
2877 }
2878
2879 uint32_t Max2DHeight = GMM_ULT_MAX(AlignedHeightMip1, HeightLinesLevel2);
2880 uint32_t ExpectedQPitch = GFX_ALIGN_NP2(AlignedHeightMip0 + Max2DHeight, VAlign);
2881 VerifyResourceQPitch<true>(ResourceInfo, ExpectedQPitch); // Each face should be Valigned-BaseHeight rows apart
2882
2883 VerifyResourceSize<true>(ResourceInfo, // PitchInBytes * Rows where Rows = __GMM_MAX_CUBE_FACE x QPitch, then aligned to tile boundary
2884 GMM_ULT_ALIGN(ExpectedPitch *
2885 MaxArraySize * __GMM_MAX_CUBE_FACE * ExpectedQPitch,
2886 PAGE_SIZE));
2887
2888 // Verify each array element's Mip offset, Cube face offset etc.
2889 for(uint32_t ArrayIndex = 0; ArrayIndex < __GMM_MAX_CUBE_FACE; ArrayIndex++)
2890 {
2891 for(uint32_t CubeFaceIndex = 0; CubeFaceIndex < __GMM_MAX_CUBE_FACE; CubeFaceIndex++)
2892 {
2893 GMM_REQ_OFFSET_INFO OffsetInfo = {};
2894 OffsetInfo.ReqRender = 1;
2895 OffsetInfo.ArrayIndex = ArrayIndex;
2896 OffsetInfo.CubeFace = static_cast<GMM_CUBE_FACE_ENUM>(CubeFaceIndex);
2897 ResourceInfo->GetOffset(OffsetInfo);
2898
2899 //Verify cube face offsets
2900 EXPECT_EQ(((6 * ArrayIndex) + CubeFaceIndex) * ExpectedQPitch * ExpectedPitch,
2901 OffsetInfo.Render.Offset64); // Render offset is tile's base address on which cube face begins.
2902 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // X Offset should be 0 as linear surf
2903 EXPECT_EQ(0, OffsetInfo.Render.YOffset); // Y Offset should be 0 as linear surf
2904 EXPECT_EQ(0, OffsetInfo.Render.ZOffset); // Z offset N/A should be 0
2905
2906 uint32_t CubeFaceBaseOffset = ((6 * ArrayIndex) + CubeFaceIndex) * (ExpectedQPitch * ExpectedPitch);
2907
2908 //Verify mip offsets in each cube face
2909 for(uint32_t Lod = 0; Lod <= MaxLod; Lod++)
2910 {
2911 OffsetInfo.MipLevel = Lod;
2912 ResourceInfo->GetOffset(OffsetInfo);
2913
2914 uint32_t MipOffset = CubeFaceBaseOffset + RenderOffset[Lod].Offset;
2915
2916 uint32_t OffsetX = MipOffset % ExpectedPitch;
2917 uint32_t OffsetY = MipOffset / ExpectedPitch;
2918
2919 uint32_t RenderAlignOffset = OffsetY * ExpectedPitch + OffsetX;
2920
2921 EXPECT_EQ(RenderAlignOffset, OffsetInfo.Render.Offset64); // Render offset absolute address on which cube face begins.
2922 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // X Offset should be 0 as linear surf
2923 EXPECT_EQ(0, OffsetInfo.Render.YOffset); // Y Offset should be 0 as linear surf
2924 EXPECT_EQ(0, OffsetInfo.Render.ZOffset); // Z offset N/A should be 0
2925 }
2926 }
2927 }
2928
2929 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
2930 }
2931 }
2932
2933 /// @brief ULT for Cube TileX Resource
TEST_F(CTestGen9Resource,TestCubeTileXResource)2934 TEST_F(CTestGen9Resource, TestCubeTileXResource)
2935 {
2936 // Cube is allocated as an array of 6 2D surface representing each cube face below
2937 //===============================
2938 // q coordinate | face |
2939 // 0 | + x |
2940 // 1 | - x |
2941 // 2 | + y |
2942 // 3 | - y |
2943 // 4 | + z |
2944 // 5 | - z |
2945 //===============================
2946
2947 const uint32_t HAlign = 16;
2948 const uint32_t VAlign = 4;
2949
2950 const uint32_t TileSize[1][2] = {512, 8};
2951
2952 GMM_RESCREATE_PARAMS gmmParams = {};
2953 gmmParams.Type = RESOURCE_CUBE;
2954 gmmParams.NoGfxMemory = 1;
2955 gmmParams.Flags.Info.TiledX = 1;
2956 gmmParams.Flags.Gpu.Texture = 1;
2957
2958 // Allocate 1x1 surface so that it occupies 1 Tile in X dimension
2959 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
2960 {
2961 TEST_BPP bpp = static_cast<TEST_BPP>(i);
2962 gmmParams.Format = SetResourceFormat(bpp);
2963 gmmParams.BaseWidth64 = 0x1;
2964 gmmParams.BaseHeight = 0x1;
2965 gmmParams.Depth = 0x1;
2966
2967 GMM_RESOURCE_INFO *ResourceInfo;
2968 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
2969
2970 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
2971 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
2972 uint32_t ExpectedPitch = TileSize[0][0];
2973 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch); // As wide as 1 tile
2974 VerifyResourcePitchInTiles<true>(ResourceInfo, 1); // 1 tile wide
2975
2976 uint32_t ExpectedQPitch = VAlign;
2977 VerifyResourceQPitch<true>(ResourceInfo, ExpectedQPitch); // Each face should be VAlign rows apart within a tile
2978
2979 VerifyResourceSize<true>(ResourceInfo, // PitchInBytes * Rows where Rows = __GMM_MAX_CUBE_FACE x QPitch, then aligned to tile boundary
2980 ExpectedPitch *
2981 GMM_ULT_ALIGN(__GMM_MAX_CUBE_FACE * ExpectedQPitch,
2982 TileSize[0][1]));
2983
2984 for(uint32_t CubeFaceIndex = 0; CubeFaceIndex < __GMM_MAX_CUBE_FACE; CubeFaceIndex++)
2985 {
2986 GMM_REQ_OFFSET_INFO OffsetInfo = {};
2987 OffsetInfo.ReqRender = 1;
2988 OffsetInfo.CubeFace = static_cast<GMM_CUBE_FACE_ENUM>(CubeFaceIndex);
2989 ResourceInfo->GetOffset(OffsetInfo);
2990
2991 EXPECT_EQ(GMM_ULT_ALIGN_FLOOR(CubeFaceIndex * ExpectedQPitch, TileSize[0][1]) * ExpectedPitch,
2992 OffsetInfo.Render.Offset64); // Render offset is tile's base address on which cube face begins.
2993 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // X Offset should be 0
2994 EXPECT_EQ((CubeFaceIndex * ExpectedQPitch) % TileSize[0][1],
2995 OffsetInfo.Render.YOffset); // Y Offset should be (CubeFaceIndex * QPitch) % TileHeight
2996 EXPECT_EQ(0, OffsetInfo.Render.ZOffset); // Z offset N/A should be 0
2997 }
2998
2999 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
3000 }
3001
3002 // Allocate 2 tiles in X dimension.
3003 // Width and Height must be equal
3004 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
3005 {
3006 TEST_BPP bpp = static_cast<TEST_BPP>(i);
3007 gmmParams.Format = SetResourceFormat(bpp);
3008 gmmParams.BaseWidth64 = (TileSize[0][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
3009 gmmParams.BaseHeight = gmmParams.BaseWidth64; // Heigth must be equal to width.
3010 gmmParams.Depth = 0x1;
3011
3012 GMM_RESOURCE_INFO *ResourceInfo;
3013 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
3014
3015 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
3016 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
3017
3018 uint32_t ExpectedPitch = TileSize[0][0] * 2; // As wide as 2 tile
3019 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
3020 VerifyResourcePitchInTiles<true>(ResourceInfo, 2); // 2 tile wide
3021
3022 uint32_t ExpectedQPitch = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign);
3023 VerifyResourceQPitch<true>(ResourceInfo, ExpectedQPitch); // Each face should be Valigned-BaseHeight rows apart
3024
3025 VerifyResourceSize<true>(ResourceInfo, // PitchInBytes * Rows where Rows = __GMM_MAX_CUBE_FACE x QPitch, then aligned to tile boundary
3026 ExpectedPitch *
3027 GMM_ULT_ALIGN(__GMM_MAX_CUBE_FACE * ExpectedQPitch,
3028 TileSize[0][1]));
3029
3030 for(uint32_t CubeFaceIndex = 0; CubeFaceIndex < __GMM_MAX_CUBE_FACE; CubeFaceIndex++)
3031 {
3032 GMM_REQ_OFFSET_INFO OffsetInfo = {};
3033 OffsetInfo.ReqRender = 1;
3034 OffsetInfo.CubeFace = static_cast<GMM_CUBE_FACE_ENUM>(CubeFaceIndex);
3035 ResourceInfo->GetOffset(OffsetInfo);
3036 EXPECT_EQ(GMM_ULT_ALIGN_FLOOR(CubeFaceIndex * ExpectedQPitch, TileSize[0][1]) * ExpectedPitch,
3037 OffsetInfo.Render.Offset64); // Render offset is tile's base address on which cube face begins.
3038 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // X Offset should be 0
3039 EXPECT_EQ((CubeFaceIndex * ExpectedQPitch) % TileSize[0][1],
3040 OffsetInfo.Render.YOffset); // Y Offset should be (CubeFaceIndex * QPitch) % TileHeight
3041 EXPECT_EQ(0, OffsetInfo.Render.ZOffset); // Z offset N/A should be 0
3042 }
3043
3044 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
3045 }
3046 }
3047
3048
3049 /// @brief ULT for Cube TileY Resource
TEST_F(CTestGen9Resource,TestCubeTileYResource)3050 TEST_F(CTestGen9Resource, TestCubeTileYResource)
3051 {
3052 // Cube is allocated as an array of 6 2D surface representing each cube face below
3053 //===============================
3054 // �q� coordinate | face |
3055 // 0 | + x |
3056 // 1 | - x |
3057 // 2 | + y |
3058 // 3 | - y |
3059 // 4 | + z |
3060 // 5 | - z |
3061 //===============================
3062
3063 const uint32_t HAlign = 16;
3064 const uint32_t VAlign = 4;
3065
3066 const uint32_t TileSize[1][2] = {128, 32};
3067
3068 GMM_RESCREATE_PARAMS gmmParams = {};
3069 gmmParams.Type = RESOURCE_CUBE;
3070 gmmParams.NoGfxMemory = 1;
3071 gmmParams.Flags.Info.TiledY = 1;
3072 gmmParams.Flags.Gpu.Texture = 1;
3073
3074 // Allocate 1x1 surface within a tile.
3075 for(uint32_t i = 0; i < TEST_BPP_128; i++) //TEST_BPP_128 cannot fit in a tile as HAlign = 16
3076 {
3077 TEST_BPP bpp = static_cast<TEST_BPP>(i);
3078 gmmParams.Format = SetResourceFormat(bpp);
3079 gmmParams.BaseWidth64 = 0x1;
3080 gmmParams.BaseHeight = 0x1;
3081 gmmParams.Depth = 0x1;
3082
3083 GMM_RESOURCE_INFO *ResourceInfo;
3084 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
3085
3086 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
3087 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
3088 VerifyResourcePitch<true>(ResourceInfo, TileSize[0][0]); // As wide as 1 tile
3089 VerifyResourcePitchInTiles<true>(ResourceInfo, 1); // 1 tile wide
3090 VerifyResourceSize<true>(ResourceInfo, GMM_KBYTE(4)); // All 6 faces should be accomated in a tile.
3091 VerifyResourceQPitch<true>(ResourceInfo, VAlign); // Each face should be VAlign rows apart within a tile
3092
3093 for(uint32_t CubeFaceIndex = 0; CubeFaceIndex < __GMM_MAX_CUBE_FACE; CubeFaceIndex++)
3094 {
3095 GMM_REQ_OFFSET_INFO OffsetInfo = {};
3096 OffsetInfo.ReqRender = 1;
3097 OffsetInfo.CubeFace = static_cast<GMM_CUBE_FACE_ENUM>(CubeFaceIndex);
3098 ResourceInfo->GetOffset(OffsetInfo);
3099 EXPECT_EQ(0, OffsetInfo.Render.Offset64); // Render offset should be 0 as its on single tile.
3100 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // X Offset should be 0
3101 EXPECT_EQ(CubeFaceIndex * VAlign, OffsetInfo.Render.YOffset); // Y Offset should be VALIGN * CubeFace Index
3102 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
3103 }
3104
3105 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
3106 }
3107
3108 // Allocate 2 tiles in X dimension.
3109 // Width and Height of Cube must be equal
3110 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
3111 {
3112 TEST_BPP bpp = static_cast<TEST_BPP>(i);
3113 gmmParams.Format = SetResourceFormat(bpp);
3114 gmmParams.BaseWidth64 = (TileSize[0][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
3115 gmmParams.BaseHeight = gmmParams.BaseWidth64; // Heigth must be equal to width.
3116 gmmParams.Depth = 0x1;
3117
3118 GMM_RESOURCE_INFO *ResourceInfo;
3119 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
3120
3121 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
3122 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
3123
3124 uint32_t ExpectedPitch = TileSize[0][0] * 2; // As wide as 2 tile
3125 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
3126 VerifyResourcePitchInTiles<true>(ResourceInfo, 2); // 2 tile wide
3127
3128 uint32_t ExpectedQPitch = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign);
3129 VerifyResourceQPitch<true>(ResourceInfo, ExpectedQPitch); // Each face should be Valigned-BaseHeight rows apart
3130
3131 VerifyResourceSize<true>(ResourceInfo, // PitchInBytes * Rows where Rows = __GMM_MAX_CUBE_FACE x QPitch, then aligned to tile boundary
3132 ExpectedPitch *
3133 GMM_ULT_ALIGN(__GMM_MAX_CUBE_FACE * ExpectedQPitch,
3134 TileSize[0][1]));
3135
3136
3137 for(uint32_t CubeFaceIndex = 0; CubeFaceIndex < __GMM_MAX_CUBE_FACE; CubeFaceIndex++)
3138 {
3139 GMM_REQ_OFFSET_INFO OffsetInfo = {};
3140 OffsetInfo.ReqRender = 1;
3141 OffsetInfo.CubeFace = static_cast<GMM_CUBE_FACE_ENUM>(CubeFaceIndex);
3142 ResourceInfo->GetOffset(OffsetInfo);
3143 EXPECT_EQ(GMM_ULT_ALIGN_FLOOR(CubeFaceIndex * ExpectedQPitch, TileSize[0][1]) * ExpectedPitch,
3144 OffsetInfo.Render.Offset64); // Render offset is tile's base address on which cube face begins.
3145 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // X Offset should be 0
3146 EXPECT_EQ((CubeFaceIndex * ExpectedQPitch) % TileSize[0][1],
3147 OffsetInfo.Render.YOffset); // Y Offset should be (CubeFaceIndex * QPitch) % TileHeight
3148 EXPECT_EQ(0, OffsetInfo.Render.ZOffset); // Z offset N/A should be 0
3149 }
3150
3151 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
3152 }
3153 }
3154
3155 /// @brief ULT for Cube TileYs Resource
TEST_F(CTestGen9Resource,TestCubeTileYsResource)3156 TEST_F(CTestGen9Resource, TestCubeTileYsResource)
3157 {
3158 // Cube is allocated as an array of 6 2D surface representing each cube face below
3159 //===============================
3160 // �q� coordinate | face |
3161 // 0 | + x |
3162 // 1 | - x |
3163 // 2 | + y |
3164 // 3 | - y |
3165 // 4 | + z |
3166 // 5 | - z |
3167 //===============================
3168
3169 const uint32_t HAlign[TEST_BPP_MAX] = {256, 256, 128, 128, 64};
3170 const uint32_t VAlign[TEST_BPP_MAX] = {256, 128, 128, 64, 64};
3171
3172 const uint32_t TileSize[TEST_BPP_MAX][2] = {{256, 256},
3173 {512, 128},
3174 {512, 128},
3175 {1024, 64},
3176 {1024, 64}};
3177
3178 GMM_RESCREATE_PARAMS gmmParams = {};
3179 gmmParams.Type = RESOURCE_CUBE;
3180 gmmParams.NoGfxMemory = 1;
3181 gmmParams.Flags.Info.TiledY = 1;
3182 gmmParams.Flags.Info.TiledYs = 1;
3183 gmmParams.Flags.Gpu.Texture = 1;
3184
3185 // Allocate 1x1 surface so that it occupies 1 Tile in X dimension
3186 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
3187 {
3188 TEST_BPP bpp = static_cast<TEST_BPP>(i);
3189 gmmParams.Format = SetResourceFormat(bpp);
3190 gmmParams.BaseWidth64 = 0x1;
3191 gmmParams.BaseHeight = 0x1;
3192 gmmParams.Depth = 0x1;
3193
3194 GMM_RESOURCE_INFO *ResourceInfo;
3195 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
3196
3197 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
3198 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
3199
3200 uint32_t ExpectedPitch = TileSize[i][0];
3201 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch); // As wide as 1 tile
3202 VerifyResourcePitchInTiles<true>(ResourceInfo, 1); // 1 tile wide
3203
3204 uint32_t ExpectedQPitch = VAlign[i];
3205 VerifyResourceQPitch<true>(ResourceInfo, ExpectedQPitch); // Each face should be VAlign rows apart within a tile
3206
3207 VerifyResourceSize<true>(ResourceInfo, // PitchInBytes * Rows where Rows = __GMM_MAX_CUBE_FACE x QPitch, then aligned to tile boundary
3208 ExpectedPitch *
3209 __GMM_MAX_CUBE_FACE * ExpectedQPitch);
3210
3211 for(uint32_t CubeFaceIndex = 0; CubeFaceIndex < __GMM_MAX_CUBE_FACE; CubeFaceIndex++)
3212 {
3213 GMM_REQ_OFFSET_INFO OffsetInfo = {};
3214 OffsetInfo.ReqRender = 1;
3215 OffsetInfo.CubeFace = static_cast<GMM_CUBE_FACE_ENUM>(CubeFaceIndex);
3216 ResourceInfo->GetOffset(OffsetInfo);
3217
3218 EXPECT_EQ((CubeFaceIndex * ExpectedQPitch) * ExpectedPitch,
3219 OffsetInfo.Render.Offset64); // Render offset is tile's base address on which cube face begins.
3220 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // X Offset should be 0 as cube face starts on tile boundary
3221 EXPECT_EQ(0, OffsetInfo.Render.YOffset); // Y Offset should be 0 as cube face starts on tile boundary
3222 EXPECT_EQ(0, OffsetInfo.Render.ZOffset); // Z offset N/A should be 0
3223 }
3224
3225 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
3226 }
3227
3228 // Allocate 2 tiles in X dimension.
3229 // Width and Height must be equal
3230 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
3231 {
3232 TEST_BPP bpp = static_cast<TEST_BPP>(i);
3233 gmmParams.Format = SetResourceFormat(bpp);
3234 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
3235 gmmParams.BaseHeight = gmmParams.BaseWidth64; // Heigth must be equal to width.
3236 gmmParams.Depth = 0x1;
3237
3238 GMM_RESOURCE_INFO *ResourceInfo;
3239 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
3240
3241 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
3242 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
3243
3244 uint32_t ExpectedPitch = TileSize[i][0] * 2; // As wide as 2 tile
3245 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
3246 VerifyResourcePitchInTiles<true>(ResourceInfo, 2); // 2 tile wide
3247
3248 uint32_t ExpectedQPitch = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign[i]);
3249 VerifyResourceQPitch<true>(ResourceInfo, ExpectedQPitch); // Each face should be Valigned-BaseHeight rows apart
3250
3251 VerifyResourceSize<true>(ResourceInfo, // PitchInBytes * Rows where Rows = __GMM_MAX_CUBE_FACE x QPitch, then aligned to tile boundary
3252 ExpectedPitch *
3253 __GMM_MAX_CUBE_FACE * ExpectedQPitch);
3254
3255 for(uint32_t CubeFaceIndex = 0; CubeFaceIndex < __GMM_MAX_CUBE_FACE; CubeFaceIndex++)
3256 {
3257 GMM_REQ_OFFSET_INFO OffsetInfo = {};
3258 OffsetInfo.ReqRender = 1;
3259 OffsetInfo.CubeFace = static_cast<GMM_CUBE_FACE_ENUM>(CubeFaceIndex);
3260 ResourceInfo->GetOffset(OffsetInfo);
3261 EXPECT_EQ((CubeFaceIndex * ExpectedQPitch) * ExpectedPitch,
3262 OffsetInfo.Render.Offset64); // Render offset is tile's base address on which cube face begins.
3263 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // X Offset should be 0 as cube face starts on tile boundary
3264 EXPECT_EQ(0, OffsetInfo.Render.YOffset); // Y Offset should be 0 as cube face starts on tile boundary
3265 EXPECT_EQ(0, OffsetInfo.Render.ZOffset); // Z offset N/A should be 0
3266 }
3267
3268 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
3269 }
3270 }
3271
3272 /// @brief ULT for Cube TileYf Resource
TEST_F(CTestGen9Resource,TestCubeTileYfResource)3273 TEST_F(CTestGen9Resource, TestCubeTileYfResource)
3274 {
3275 // Cube is allocated as an array of 6 2D surface representing each cube face below
3276 //===============================
3277 // �q� coordinate | face |
3278 // 0 | + x |
3279 // 1 | - x |
3280 // 2 | + y |
3281 // 3 | - y |
3282 // 4 | + z |
3283 // 5 | - z |
3284 //===============================
3285
3286 const uint32_t HAlign[TEST_BPP_MAX] = {64, 64, 32, 32, 16};
3287 const uint32_t VAlign[TEST_BPP_MAX] = {64, 32, 32, 16, 16};
3288
3289 const uint32_t TileSize[TEST_BPP_MAX][2] = {{64, 64},
3290 {128, 32},
3291 {128, 32},
3292 {256, 16},
3293 {256, 16}};
3294
3295 GMM_RESCREATE_PARAMS gmmParams = {};
3296 gmmParams.Type = RESOURCE_CUBE;
3297 gmmParams.NoGfxMemory = 1;
3298 gmmParams.Flags.Info.TiledY = 1;
3299 gmmParams.Flags.Info.TiledYf = 1;
3300 gmmParams.Flags.Gpu.Texture = 1;
3301
3302 // Allocate 1x1 surface so that it occupies 1 Tile in X dimension
3303 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
3304 {
3305 TEST_BPP bpp = static_cast<TEST_BPP>(i);
3306 gmmParams.Format = SetResourceFormat(bpp);
3307 gmmParams.BaseWidth64 = 0x1;
3308 gmmParams.BaseHeight = 0x1;
3309 gmmParams.Depth = 0x1;
3310
3311 GMM_RESOURCE_INFO *ResourceInfo;
3312 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
3313
3314 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
3315 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
3316
3317 uint32_t ExpectedPitch = TileSize[i][0];
3318 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch); // As wide as 1 tile
3319 VerifyResourcePitchInTiles<true>(ResourceInfo, 1); // 1 tile wide
3320
3321 uint32_t ExpectedQPitch = VAlign[i];
3322 VerifyResourceQPitch<true>(ResourceInfo, ExpectedQPitch); // Each face should be VAlign rows apart within a tile
3323
3324 VerifyResourceSize<true>(ResourceInfo, // PitchInBytes * Rows where Rows = __GMM_MAX_CUBE_FACE x QPitch, then aligned to tile boundary
3325 ExpectedPitch *
3326 __GMM_MAX_CUBE_FACE * ExpectedQPitch);
3327
3328 for(uint32_t CubeFaceIndex = 0; CubeFaceIndex < __GMM_MAX_CUBE_FACE; CubeFaceIndex++)
3329 {
3330 GMM_REQ_OFFSET_INFO OffsetInfo = {};
3331 OffsetInfo.ReqRender = 1;
3332 OffsetInfo.CubeFace = static_cast<GMM_CUBE_FACE_ENUM>(CubeFaceIndex);
3333 ResourceInfo->GetOffset(OffsetInfo);
3334
3335 EXPECT_EQ((CubeFaceIndex * ExpectedQPitch) * ExpectedPitch,
3336 OffsetInfo.Render.Offset64); // Render offset is tile's base address on which cube face begins.
3337 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // X Offset should be 0 as cube face starts on tile boundary
3338 EXPECT_EQ(0, OffsetInfo.Render.YOffset); // Y Offset should be 0 as cube face starts on tile boundary
3339 EXPECT_EQ(0, OffsetInfo.Render.ZOffset); // Z offset N/A should be 0
3340 }
3341
3342 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
3343 }
3344
3345 // Allocate 2 tiles in X dimension.
3346 // Width and Height must be equal
3347 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
3348 {
3349 TEST_BPP bpp = static_cast<TEST_BPP>(i);
3350 gmmParams.Format = SetResourceFormat(bpp);
3351 gmmParams.BaseWidth64 = (TileSize[i][0] / GetBppValue(bpp)) + 1; // 1 pixel larger than 1 tile width
3352 gmmParams.BaseHeight = gmmParams.BaseWidth64; // Heigth must be equal to width.
3353 gmmParams.Depth = 0x1;
3354
3355 GMM_RESOURCE_INFO *ResourceInfo;
3356 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
3357
3358 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
3359 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
3360
3361 uint32_t ExpectedPitch = TileSize[i][0] * 2; // As wide as 2 tile
3362 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
3363 VerifyResourcePitchInTiles<true>(ResourceInfo, 2); // 2 tile wide
3364
3365 uint32_t ExpectedQPitch = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign[i]);
3366 VerifyResourceQPitch<true>(ResourceInfo, ExpectedQPitch); // Each face should be Valigned-BaseHeight rows apart
3367
3368 VerifyResourceSize<true>(ResourceInfo, // PitchInBytes * Rows where Rows = __GMM_MAX_CUBE_FACE x QPitch, then aligned to tile boundary
3369 ExpectedPitch *
3370 __GMM_MAX_CUBE_FACE * ExpectedQPitch);
3371
3372 for(uint32_t CubeFaceIndex = 0; CubeFaceIndex < __GMM_MAX_CUBE_FACE; CubeFaceIndex++)
3373 {
3374 GMM_REQ_OFFSET_INFO OffsetInfo = {};
3375 OffsetInfo.ReqRender = 1;
3376 OffsetInfo.CubeFace = static_cast<GMM_CUBE_FACE_ENUM>(CubeFaceIndex);
3377 ResourceInfo->GetOffset(OffsetInfo);
3378 EXPECT_EQ((CubeFaceIndex * ExpectedQPitch) * ExpectedPitch,
3379 OffsetInfo.Render.Offset64); // Render offset is tile's base address on which cube face begins.
3380 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // X Offset should be 0 as cube face starts on tile boundary
3381 EXPECT_EQ(0, OffsetInfo.Render.YOffset); // Y Offset should be 0 as cube face starts on tile boundary
3382 EXPECT_EQ(0, OffsetInfo.Render.ZOffset); // Z offset N/A should be 0
3383 }
3384
3385 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
3386 }
3387 }
3388
3389
3390 /// @brief ULT for Cube TileY Mipped Resource Array
TEST_F(CTestGen9Resource,TestCubeTileYMippedResourceArray)3391 TEST_F(CTestGen9Resource, TestCubeTileYMippedResourceArray)
3392 {
3393 const uint32_t HAlign = 16;
3394 const uint32_t VAlign = 4;
3395
3396 const uint32_t TileSize[2] = {128, 32};
3397 enum Coords
3398 {
3399 X = 0,
3400 Y = 1
3401 };
3402
3403 GMM_RESCREATE_PARAMS gmmParams = {};
3404 gmmParams.Type = RESOURCE_CUBE;
3405 gmmParams.NoGfxMemory = 1;
3406 gmmParams.Flags.Info.TiledY = 1;
3407 gmmParams.Flags.Gpu.Texture = 1;
3408
3409 // Allocate CUBE surface
3410 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
3411 {
3412 const uint32_t ResWidth = 0x201;
3413 const uint32_t MaxLod = 0x9;
3414 const uint32_t MaxArraySize = 0x10;
3415
3416 struct //Cache the value for verifying array elements/Cube face offset/Mip Offset
3417 {
3418 uint64_t Offset; // Note : absolute mip offset
3419 } RenderOffset[GMM_ULT_MAX_MIPMAP];
3420
3421 TEST_BPP bpp = static_cast<TEST_BPP>(i);
3422 gmmParams.Format = SetResourceFormat(bpp);
3423 gmmParams.BaseWidth64 = ResWidth; // 1 pixel larger than 1 tile width
3424 gmmParams.BaseHeight = gmmParams.BaseWidth64; // Heigth must be equal to width.
3425 gmmParams.Depth = 0x1;
3426 gmmParams.MaxLod = MaxLod;
3427 gmmParams.ArraySize = MaxArraySize;
3428
3429 GMM_RESOURCE_INFO *ResourceInfo;
3430 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
3431
3432 VerifyResourceHAlign<true>(ResourceInfo, HAlign);
3433 VerifyResourceVAlign<true>(ResourceInfo, VAlign);
3434
3435 //------------------------------|
3436 // |
3437 // LOD0 |
3438 // |
3439 // |
3440 //------------------------------|
3441 // LOD1 | LOD2 |
3442 // |----------|
3443 // | LOD3 |
3444 //-------------| LOD4 .. so on
3445
3446 //Mip 0
3447 //Mip 0 decides the pitch of the entire resource.
3448 const uint32_t AlignedWidthMip0 = GMM_ULT_ALIGN(ResWidth, HAlign); // HAlign width in pixel
3449 const uint32_t AlignedHeightMip0 = GMM_ULT_ALIGN(ResWidth, VAlign);
3450 uint32_t ExpectedPitch = GMM_ULT_ALIGN(AlignedWidthMip0 * GetBppValue(bpp), TileSize[X]); // Align AlignedWidthMip0 to 128 bytes
3451 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
3452 VerifyResourcePitchInTiles<true>(ResourceInfo, ExpectedPitch / TileSize[X]); // Pitch/TileY-Width
3453
3454 // Mip0 should be at offset 0 and tile aligned
3455 GMM_REQ_OFFSET_INFO OffsetInfo = {};
3456 OffsetInfo.ReqRender = 1;
3457 OffsetInfo.MipLevel = 0; //Mip 0
3458 ResourceInfo->GetOffset(OffsetInfo);
3459 EXPECT_EQ(0, OffsetInfo.Render.Offset64);
3460 EXPECT_EQ(0, OffsetInfo.Render.XOffset);
3461 EXPECT_EQ(0, OffsetInfo.Render.YOffset);
3462 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
3463
3464 //cache Mip 0 offset
3465 RenderOffset[0].Offset = 0;
3466
3467 // Mip 1 should be under mip 0
3468 OffsetInfo = {};
3469 OffsetInfo.ReqRender = 1;
3470 OffsetInfo.MipLevel = 1; //Mip 1
3471 ResourceInfo->GetOffset(OffsetInfo);
3472
3473 EXPECT_EQ(GMM_ULT_ALIGN_FLOOR(AlignedHeightMip0, TileSize[Y]) * ExpectedPitch, // Render offset is tile's base address on which mip begins
3474 OffsetInfo.Render.Offset64);
3475 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // Aligns with Mip0 at X = 0
3476 EXPECT_EQ((AlignedHeightMip0) % TileSize[Y], OffsetInfo.Render.YOffset); // AlignedHeightMip0 % TileY-Height
3477 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
3478
3479 //cache Mip 1 offset
3480 RenderOffset[1].Offset = AlignedHeightMip0 * ExpectedPitch; //Absolute base
3481
3482 const uint32_t AlignedWidthMip1 = GMM_ULT_ALIGN(ResWidth >> 1, HAlign); // Align width in pixel to HAlign
3483 const uint32_t AlignedHeightMip1 = GMM_ULT_ALIGN(ResWidth >> 1, VAlign);
3484
3485 uint32_t HeightOfMip;
3486 uint32_t HeightLinesLevel2 = 0;
3487
3488 // Mips 2-9 should be stacked on the right of Mip1 as shown in figure above.
3489 for(int i = 2; i <= MaxLod; i++)
3490 {
3491 OffsetInfo = {};
3492 OffsetInfo.ReqRender = 1;
3493 OffsetInfo.MipLevel = i;
3494 ResourceInfo->GetOffset(OffsetInfo);
3495
3496 HeightOfMip = GMM_ULT_ALIGN(ResWidth >> i, VAlign);
3497
3498 EXPECT_EQ(GMM_ULT_ALIGN_FLOOR(AlignedHeightMip0 + HeightLinesLevel2, TileSize[Y]) * ExpectedPitch + // Render offset is tile's base address on which mip begins
3499 (AlignedWidthMip1 * GetBppValue(bpp) / TileSize[X]) * PAGE_SIZE,
3500 OffsetInfo.Render.Offset64);
3501
3502 EXPECT_EQ((AlignedWidthMip1 * GetBppValue(bpp)) % TileSize[X], OffsetInfo.Render.XOffset); // Aligns with Mip0 at X = 0
3503 EXPECT_EQ((AlignedHeightMip0 + HeightLinesLevel2) % TileSize[Y], OffsetInfo.Render.YOffset); // AlignedHeightMip0 % TileY-Height
3504 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
3505
3506 //cache Mip i'th offset
3507 RenderOffset[i].Offset = (AlignedHeightMip0 + HeightLinesLevel2) * ExpectedPitch +
3508 (AlignedWidthMip1 * GetBppValue(bpp));
3509
3510 HeightLinesLevel2 += HeightOfMip;
3511 }
3512
3513 uint32_t Max2DHeight = GMM_ULT_MAX(AlignedHeightMip1, HeightLinesLevel2);
3514 uint32_t ExpectedQPitch = GFX_ALIGN_NP2(AlignedHeightMip0 + Max2DHeight, VAlign);
3515 VerifyResourceQPitch<true>(ResourceInfo, ExpectedQPitch); // Each face should be Valigned-BaseHeight rows apart
3516
3517 VerifyResourceSize<true>(ResourceInfo, // PitchInBytes * Rows where Rows = __GMM_MAX_CUBE_FACE x QPitch, then aligned to tile boundary
3518 ExpectedPitch *
3519 GMM_ULT_ALIGN(MaxArraySize * __GMM_MAX_CUBE_FACE * ExpectedQPitch, TileSize[Y]));
3520
3521 // Verify each array element's Mip offset, Cube face offset etc.
3522 for(uint32_t ArrayIndex = 0; ArrayIndex < __GMM_MAX_CUBE_FACE; ArrayIndex++)
3523 {
3524 for(uint32_t CubeFaceIndex = 0; CubeFaceIndex < __GMM_MAX_CUBE_FACE; CubeFaceIndex++)
3525 {
3526 GMM_REQ_OFFSET_INFO OffsetInfo = {};
3527 OffsetInfo.ReqRender = 1;
3528 OffsetInfo.ArrayIndex = ArrayIndex;
3529 OffsetInfo.CubeFace = static_cast<GMM_CUBE_FACE_ENUM>(CubeFaceIndex);
3530 ResourceInfo->GetOffset(OffsetInfo);
3531
3532 //Verify cube face offsets
3533 EXPECT_EQ(GMM_ULT_ALIGN_FLOOR(((6 * ArrayIndex) + CubeFaceIndex) * ExpectedQPitch, TileSize[Y]) * ExpectedPitch,
3534 OffsetInfo.Render.Offset64); // Render offset is tile's base address on which cube face begins.
3535 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // X Offset should be 0
3536 EXPECT_EQ((((6 * ArrayIndex) + CubeFaceIndex) * ExpectedQPitch) % TileSize[Y],
3537 OffsetInfo.Render.YOffset); // Y Offset should be (CubeFaceIndex * QPitch) % TileHeight
3538 EXPECT_EQ(0, OffsetInfo.Render.ZOffset); // Z offset N/A should be 0
3539
3540 uint32_t CubeFaceBaseOffset = ((6 * ArrayIndex) + CubeFaceIndex) * (ExpectedQPitch * ExpectedPitch);
3541
3542 //Verify mip offsets in each cube face
3543 for(uint32_t Lod = 0; Lod <= MaxLod; Lod++)
3544 {
3545 OffsetInfo.MipLevel = Lod;
3546 ResourceInfo->GetOffset(OffsetInfo);
3547
3548 uint32_t MipOffset = CubeFaceBaseOffset + RenderOffset[Lod].Offset;
3549
3550 uint32_t OffsetX = MipOffset % ExpectedPitch;
3551 uint32_t TileAlignedOffsetX = GMM_ULT_ALIGN_FLOOR(OffsetX, TileSize[X]);
3552 OffsetX -= TileAlignedOffsetX;
3553
3554 uint32_t OffsetY = MipOffset / ExpectedPitch;
3555 uint32_t TileAlignedOffsetY = GMM_ULT_ALIGN_FLOOR(OffsetY, TileSize[Y]);
3556 OffsetY -= TileAlignedOffsetY;
3557
3558 uint32_t RenderAlignOffset =
3559 TileAlignedOffsetY * ExpectedPitch +
3560 (TileAlignedOffsetX / TileSize[X]) * PAGE_SIZE;
3561
3562
3563 EXPECT_EQ(RenderAlignOffset, OffsetInfo.Render.Offset64); // Render offset is tile's base address on which cube face begins.
3564 EXPECT_EQ(OffsetX, OffsetInfo.Render.XOffset);
3565 EXPECT_EQ(OffsetY, OffsetInfo.Render.YOffset); // Y Offset should be (CubeFaceIndex * QPitch) % TileHeight
3566 EXPECT_EQ(0, OffsetInfo.Render.ZOffset); // Z offset N/A should be 0
3567 }
3568 }
3569 }
3570
3571 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
3572 }
3573 }
3574
3575 /// @brief ULT for Cube TileYs Mipped Array Resource
TEST_F(CTestGen9Resource,TestCubeTileYsMippedResourceArray)3576 TEST_F(CTestGen9Resource, TestCubeTileYsMippedResourceArray)
3577 {
3578 enum Coords
3579 {
3580 X = 0,
3581 Y = 1
3582 };
3583
3584 const uint32_t HAlign[TEST_BPP_MAX] = {256, 256, 128, 128, 64};
3585 const uint32_t VAlign[TEST_BPP_MAX] = {256, 128, 128, 64, 64};
3586
3587 const uint32_t TileSize[TEST_BPP_MAX][2] = {{256, 256},
3588 {512, 128},
3589 {512, 128},
3590 {1024, 64},
3591 {1024, 64}};
3592
3593 const uint32_t MaxMipTailSize[TEST_BPP_MAX][2] = {{128, 256},
3594 {128, 128},
3595 {64, 128},
3596 {64, 64},
3597 {32, 64}};
3598
3599 const uint32_t MipTailSlotSize[GMM_ULT_MAX_MIPTAIL_SLOTS] = {
3600 GMM_KBYTE(32),
3601 GMM_KBYTE(16),
3602 GMM_KBYTE(8),
3603 GMM_KBYTE(4),
3604 GMM_KBYTE(2),
3605 GMM_KBYTE(1),
3606 GMM_BYTES(768),
3607 GMM_BYTES(512),
3608 GMM_BYTES(448),
3609 GMM_BYTES(384),
3610 GMM_BYTES(320),
3611 GMM_BYTES(256),
3612 GMM_BYTES(192),
3613 GMM_BYTES(128),
3614 GMM_BYTES(64)};
3615
3616 const TEST_MIPTAIL_SLOT_OFFSET MipTailSlotOffsets[GMM_ULT_MAX_MIPTAIL_SLOTS][TEST_BPP_MAX] =
3617 {
3618 /* | 8 bpe | 16 bpe | 32 bpe | 64 bpe | 128 bpe | */
3619 {{128, 0, 0}, {128, 0, 0}, {64, 0, 0}, {64, 0, 0}, {32, 0, 0}},
3620 {{0, 128, 0}, {0, 64, 0}, {0, 64, 0}, {0, 32, 0}, {0, 32, 0}},
3621 {{64, 0, 0}, {64, 0, 0}, {32, 0, 0}, {32, 0, 0}, {16, 0, 0}},
3622 {{0, 64, 0}, {0, 32, 0}, {0, 32, 0}, {0, 16, 0}, {0, 16, 0}},
3623 {{32, 0, 0}, {32, 0, 0}, {16, 0, 0}, {16, 0, 0}, {8, 0, 0}},
3624 {{16, 32, 0}, {16, 16, 0}, {8, 16, 0}, {8, 8, 0}, {4, 8, 0}},
3625 {{0, 48, 0}, {0, 24, 0}, {0, 24, 0}, {0, 12, 0}, {0, 12, 0}},
3626 {{0, 32, 0}, {0, 16, 0}, {0, 16, 0}, {0, 8, 0}, {0, 8, 0}},
3627 {{16, 16, 0}, {16, 8, 0}, {8, 8, 0}, {8, 4, 0}, {4, 4, 0}},
3628 {{16, 0, 0}, {16, 0, 0}, {8, 0, 0}, {8, 0, 0}, {4, 0, 0}},
3629 {{0, 16, 0}, {0, 8, 0}, {0, 8, 0}, {0, 4, 0}, {0, 4, 0}},
3630 {{0, 12, 0}, {8, 4, 0}, {4, 4, 0}, {6, 0, 0}, {3, 0, 0}},
3631 {{0, 8, 0}, {8, 0, 0}, {4, 0, 0}, {4, 0, 0}, {2, 0, 0}},
3632 {{0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {2, 0, 0}, {1, 0, 0}},
3633 {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}};
3634
3635
3636 GMM_RESCREATE_PARAMS gmmParams = {};
3637 gmmParams.Type = RESOURCE_CUBE;
3638 gmmParams.NoGfxMemory = 1;
3639 gmmParams.Flags.Info.TiledY = 1;
3640 gmmParams.Flags.Info.TiledYs = 1;
3641 gmmParams.Flags.Gpu.Texture = 1;
3642
3643 // Allocate CUBE surface
3644 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
3645 {
3646 const uint32_t ResWidth = 0x1001;
3647 const uint32_t MaxLod = 0x9;
3648 const uint32_t MaxArraySize = 0x10;
3649
3650 struct //Cache the value for verifying array elements/Cube face offset/Mip Offset
3651 {
3652 uint64_t Offset; // Note : absolute mip offset
3653 } RenderOffset[GMM_ULT_MAX_MIPMAP];
3654
3655 TEST_BPP bpp = static_cast<TEST_BPP>(i);
3656 gmmParams.Format = SetResourceFormat(bpp);
3657 gmmParams.BaseWidth64 = ResWidth;
3658 gmmParams.BaseHeight = gmmParams.BaseWidth64; // Heigth must be equal to width.
3659 gmmParams.Depth = 0x1;
3660 gmmParams.MaxLod = MaxLod;
3661 gmmParams.ArraySize = MaxArraySize;
3662
3663 GMM_RESOURCE_INFO *ResourceInfo;
3664 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
3665
3666 VerifyResourceHAlign<true>(ResourceInfo, HAlign[i]);
3667 VerifyResourceVAlign<true>(ResourceInfo, VAlign[i]);
3668
3669 //------------------------------|
3670 // |
3671 // LOD0 |
3672 // |
3673 // |
3674 //------------------------------|
3675 // LOD1 | LOD2 |
3676 // |----------|
3677 // | LOD3 |
3678 //-------------| LOD4 .. so on
3679
3680 //Mip 0
3681 //Mip 0 decides the pitch of the entire resource.
3682 const uint32_t AlignedWidthMip0 = GMM_ULT_ALIGN(ResWidth, HAlign[i]); // HAlign width in pixel
3683 const uint32_t AlignedHeightMip0 = GMM_ULT_ALIGN(ResWidth, VAlign[i]);
3684 uint32_t ExpectedPitch = GMM_ULT_ALIGN(AlignedWidthMip0 * GetBppValue(bpp), TileSize[i][X]); // Align AlignedWidthMip0 to Tile width
3685 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
3686 VerifyResourcePitchInTiles<true>(ResourceInfo, ExpectedPitch / TileSize[i][X]); // Pitch/Tile-Width
3687
3688 // Mip0 should be at offset 0 and tile aligned
3689 GMM_REQ_OFFSET_INFO OffsetInfo = {};
3690 OffsetInfo.ReqRender = 1;
3691 OffsetInfo.MipLevel = 0; //Mip 0
3692 ResourceInfo->GetOffset(OffsetInfo);
3693 EXPECT_EQ(0, OffsetInfo.Render.Offset64);
3694 EXPECT_EQ(0, OffsetInfo.Render.XOffset);
3695 EXPECT_EQ(0, OffsetInfo.Render.YOffset);
3696 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
3697
3698 //cache Mip 0 offset
3699 RenderOffset[0].Offset = 0;
3700
3701 // Mip 1 should be under mip 0
3702 OffsetInfo = {};
3703 OffsetInfo.ReqRender = 1;
3704 OffsetInfo.MipLevel = 1; //Mip 1
3705 ResourceInfo->GetOffset(OffsetInfo);
3706
3707 EXPECT_EQ(AlignedHeightMip0 * ExpectedPitch, // Render offset is tile's base address on which mip begins
3708 OffsetInfo.Render.Offset64);
3709 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // Mips are always tile aligned
3710 EXPECT_EQ(0, OffsetInfo.Render.YOffset); // Mips are always tile aligned
3711 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
3712
3713 //cache Mip 1 offset
3714 RenderOffset[1].Offset = AlignedHeightMip0 * ExpectedPitch; //Absolute base
3715
3716 const uint32_t AlignedWidthMip1 = GMM_ULT_ALIGN(ResWidth >> 1, HAlign[i]); // Align width in pixel to HAlign
3717 const uint32_t AlignedHeightMip1 = GMM_ULT_ALIGN(ResWidth >> 1, VAlign[i]);
3718
3719 // Determine MipTail start LOD
3720 uint32_t ExpectedMipTailStartLod = 0;
3721 {
3722 uint32_t MipWidth, MipHeight;
3723 MipWidth = MipHeight = ResWidth;
3724 while((ExpectedMipTailStartLod < MaxLod) &&
3725 !((MipWidth <= MaxMipTailSize[i][X]) &&
3726 (MipHeight <= MaxMipTailSize[i][Y])))
3727 {
3728 ExpectedMipTailStartLod++;
3729
3730 MipWidth = MipWidth >> 1;
3731 MipHeight = MipHeight >> 1;
3732 }
3733 }
3734
3735 VerifyResourceMipTailStartLod<true>(ResourceInfo, ExpectedMipTailStartLod);
3736
3737 uint32_t HeightOfMip;
3738 uint32_t HeightLinesLevel2 = 0;
3739
3740 // Mips[2,MipTailStartLod - 1] should be stacked on the right of Mip1 as shown in figure above.
3741 for(int Lod = 2; Lod < ExpectedMipTailStartLod; Lod++)
3742 {
3743 OffsetInfo = {};
3744 OffsetInfo.ReqRender = 1;
3745 OffsetInfo.MipLevel = Lod;
3746 ResourceInfo->GetOffset(OffsetInfo);
3747
3748 HeightOfMip = GMM_ULT_ALIGN(ResWidth >> Lod, VAlign[i]);
3749
3750 EXPECT_EQ((AlignedHeightMip0 + HeightLinesLevel2) * ExpectedPitch + // Render offset is tile's base address on which mip begins
3751 (AlignedWidthMip1 * GetBppValue(bpp) / TileSize[i][X]) * GMM_KBYTE(64),
3752 OffsetInfo.Render.Offset64);
3753
3754 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // Mip lies on Tile boundary
3755 EXPECT_EQ(0, OffsetInfo.Render.YOffset); // Mip lies on Tile boundary
3756 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
3757
3758 //cache Mip i'th offset
3759 RenderOffset[Lod].Offset = (AlignedHeightMip0 + HeightLinesLevel2) * ExpectedPitch +
3760 (AlignedWidthMip1 * GetBppValue(bpp));
3761
3762 HeightLinesLevel2 += HeightOfMip;
3763 }
3764
3765 // Mips[MipTailStartLod, MaxLod] will be on the mip tail.
3766 for(int Lod = ExpectedMipTailStartLod; Lod <= MaxLod; Lod++)
3767 {
3768 OffsetInfo = {};
3769 OffsetInfo.ReqRender = 1;
3770 OffsetInfo.MipLevel = Lod;
3771 ResourceInfo->GetOffset(OffsetInfo);
3772
3773 uint64_t ExpectedRenderAlignOffset =
3774 (AlignedHeightMip0 + HeightLinesLevel2) * (uint64_t)ExpectedPitch + // Render offset is tile's base address on which mip begins
3775 (AlignedWidthMip1 * GetBppValue(bpp) / TileSize[i][X]) * GMM_KBYTE(64);
3776
3777 EXPECT_EQ(ExpectedRenderAlignOffset, OffsetInfo.Render.Offset64);
3778 EXPECT_EQ(MipTailSlotOffsets[Lod - ExpectedMipTailStartLod][i].X * GetBppValue(bpp), OffsetInfo.Render.XOffset);
3779 EXPECT_EQ(MipTailSlotOffsets[Lod - ExpectedMipTailStartLod][i].Y, OffsetInfo.Render.YOffset);
3780 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
3781
3782 RenderOffset[Lod].Offset = ExpectedRenderAlignOffset + MipTailSlotSize[Lod - ExpectedMipTailStartLod];
3783 }
3784
3785 if(ExpectedMipTailStartLod) // Include mip tail height in the Level 2 height
3786 {
3787 HeightLinesLevel2 += TileSize[i][Y];
3788 }
3789
3790 uint32_t Max2DHeight = GMM_ULT_MAX(AlignedHeightMip1, HeightLinesLevel2);
3791 uint32_t ExpectedQPitch = GFX_ALIGN_NP2(AlignedHeightMip0 + Max2DHeight, VAlign[i]);
3792 VerifyResourceQPitch<true>(ResourceInfo, ExpectedQPitch); // Each face should be Valigned-BaseHeight rows apart
3793
3794 VerifyResourceSize<true>(ResourceInfo, // PitchInBytes * Rows where Rows = __GMM_MAX_CUBE_FACE x QPitch, then aligned to tile boundary
3795 (uint64_t)ExpectedPitch * MaxArraySize * __GMM_MAX_CUBE_FACE * ExpectedQPitch);
3796
3797 // Verify each array element's Mip offset, Cube face offset etc.
3798 for(uint32_t ArrayIndex = 0; ArrayIndex < MaxArraySize; ArrayIndex++)
3799 {
3800 for(uint32_t CubeFaceIndex = 0; CubeFaceIndex < __GMM_MAX_CUBE_FACE; CubeFaceIndex++)
3801 {
3802 GMM_REQ_OFFSET_INFO OffsetInfo = {};
3803 OffsetInfo.ReqRender = 1;
3804 OffsetInfo.ArrayIndex = ArrayIndex;
3805 OffsetInfo.CubeFace = static_cast<GMM_CUBE_FACE_ENUM>(CubeFaceIndex);
3806 ResourceInfo->GetOffset(OffsetInfo);
3807
3808 //Verify cube face offsets
3809 EXPECT_EQ((((6 * ArrayIndex) + CubeFaceIndex) * ExpectedQPitch) * (uint64_t)ExpectedPitch,
3810 OffsetInfo.Render.Offset64); // Render offset is tile's base address on which cube face begins.
3811 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // X Offset should be 0
3812 EXPECT_EQ(0, OffsetInfo.Render.YOffset); // Y Offset should be 0
3813 EXPECT_EQ(0, OffsetInfo.Render.ZOffset); // Z offset N/A should be 0
3814
3815 uint64_t CubeFaceBaseOffset = ((6 * ArrayIndex) + CubeFaceIndex) * (ExpectedQPitch * (uint64_t)ExpectedPitch);
3816
3817 //Verify mip offsets in each cube face
3818 // Mips[0,MipTailStartLod - 1]
3819 for(int Lod = 0; Lod < ExpectedMipTailStartLod; Lod++)
3820 {
3821 OffsetInfo.MipLevel = Lod;
3822 ResourceInfo->GetOffset(OffsetInfo);
3823
3824 uint64_t MipOffset = CubeFaceBaseOffset + RenderOffset[Lod].Offset;
3825
3826 uint32_t TileAlignedOffsetX = MipOffset % ExpectedPitch;
3827 uint32_t TileAlignedOffsetY = MipOffset / ExpectedPitch;
3828
3829 uint64_t ExpectedRenderAlignOffset =
3830 TileAlignedOffsetY * (uint64_t)ExpectedPitch +
3831 (TileAlignedOffsetX / TileSize[i][X]) * GMM_KBYTE(64);
3832
3833 EXPECT_EQ(ExpectedRenderAlignOffset, OffsetInfo.Render.Offset64); // Render offset is tile's base address on which cube face begins.
3834 EXPECT_EQ(0, OffsetInfo.Render.XOffset); // Mip lies on Tile boundary
3835 EXPECT_EQ(0, OffsetInfo.Render.YOffset); // Mip lies on Tile boundary
3836 EXPECT_EQ(0, OffsetInfo.Render.ZOffset); // Z offset N/A should be 0
3837 }
3838
3839 // Mips[MipTailStartLod, MaxLod] will be on the mip tail.
3840 for(int Lod = ExpectedMipTailStartLod; Lod <= MaxLod; Lod++)
3841 {
3842 OffsetInfo.MipLevel = Lod;
3843 ResourceInfo->GetOffset(OffsetInfo);
3844
3845 uint64_t MipOffset = CubeFaceBaseOffset + RenderOffset[Lod].Offset;
3846
3847 uint64_t ExpectedRenderAlignOffset = GMM_ULT_ALIGN_FLOOR(MipOffset, GMM_KBYTE(64));
3848
3849 EXPECT_EQ(ExpectedRenderAlignOffset, OffsetInfo.Render.Offset64);
3850 EXPECT_EQ(MipTailSlotOffsets[Lod - ExpectedMipTailStartLod][i].X * GetBppValue(bpp), OffsetInfo.Render.XOffset);
3851 EXPECT_EQ(MipTailSlotOffsets[Lod - ExpectedMipTailStartLod][i].Y, OffsetInfo.Render.YOffset);
3852 EXPECT_EQ(0, OffsetInfo.Render.ZOffset);
3853 }
3854 }
3855 }
3856
3857 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
3858 }
3859 }
3860
3861 /// @brief ULT for Plannar 2D Resource - Tiling TileYs
TEST_F(CTestGen9Resource,TestPlanar2DTileYs)3862 TEST_F(CTestGen9Resource, TestPlanar2DTileYs)
3863 {
3864 }
3865
3866 /// @brief ULT for Plannar 2D Resource - Tiling TileYf
TEST_F(CTestGen9Resource,TestPlanar2DTileYf)3867 TEST_F(CTestGen9Resource, TestPlanar2DTileYf)
3868 {
3869 }
3870
BuildInputIterator(std::vector<std::tuple<int,int,int,bool,int,int>> & List,int maxTestDimension,int TestArray,bool XEHPPlus)3871 int BuildInputIterator(std::vector<std::tuple<int, int, int, bool, int, int>> &List, int maxTestDimension, int TestArray, bool XEHPPlus)
3872 {
3873 for(uint32_t i = TEST_LINEAR; i < TEST_TILE_MAX; i++)
3874 {
3875 if(XEHPPlus)
3876 {
3877 if(i >= TEST_TILEX && i <= TEST_TILEY_MAX)
3878 continue;
3879 }
3880 else
3881 {
3882 if(i > TEST_TILEY_MAX)
3883 break;
3884 }
3885
3886 for(uint32_t j = TEST_BPP_8; j < TEST_BPP_MAX; j++)
3887 for(uint32_t k = TEST_RESOURCE_1D; k < TEST_RESOURCE_MAX; k++)
3888 for(uint32_t l = 0; l < maxTestDimension; l++)
3889 for(uint32_t m = 0; m < TestArray; m++)
3890 {
3891 List.emplace_back(std::make_tuple(i, j, k, true, l, m));
3892 List.emplace_back(std::make_tuple(i, j, k, false, l, m));
3893 }
3894 }
3895
3896 return List.size();
3897 }
3898
3899 /// @brief ULT for MSAA Resource
TEST_F(CTestGen9Resource,TestMSAA)3900 TEST_F(CTestGen9Resource, TestMSAA)
3901 {
3902 //Tile dimensions in Bytes
3903 const uint32_t MCSTileSize[1][2] = {128, 32}; //MCS is TileY
3904
3905 //Gen9: MSAA 16x no MCS for width > 8K
3906 //No MSAA for YUV/compressed formats
3907 //Interleaved MSS (IMS) for Depth/Stencil. Arrayed MSS (CMS) for Color RT
3908 //MSS (Arrayed): px_wL, px_hL = pixel width/height of single sample at Lod L
3909 // MSS width = px_wL, MSS height = NumSamples*px_hL
3910 //MSS (Interleaved): px_wL, px_hL = pixel width/height of single sample at Lod L
3911 // Samples MSS width MSS Height
3912 // 2x 4*ceil(px_wL/2) px_hL
3913 // 4x 4*ceil(px_wL/2) 4*ceil(px_hL/2)
3914 // 8x 8*ceil(px_wL/2) 4*ceil(px_hL/2)
3915 // 16x 8*ceil(px_wL/2) 8*ceil(px_hL/2)
3916 //MCS (bpp): 2x/4x - bpp_8, 8x - bpp_32, 16x - bpp_64
3917
3918 const uint32_t TestDimensions[4][2] = {
3919 //Input dimensions in #Tiles
3920 {15, 20}, //16 Tiles x 20 <Max Width: Depth MSS crosses Pitch limit beyond this>
3921 {0, 0}, //1x1x1
3922 {1, 0}, //2 Tilesx1
3923 {1, 1}, //2 Tiles x 2
3924 };
3925
3926 uint32_t TestArraySize[2] = {1, 5};
3927
3928 uint32_t HAlign = 0, VAlign = 0, TileDimX = 0, TileDimY = 0;
3929 uint32_t MCSHAlign = 0, MCSVAlign = 0, TileSize = 0;
3930 uint32_t ExpectedMCSBpp;
3931 std::vector<tuple<int, int, int, bool, int, int>> List; //TEST_TILE_TYPE, TEST_BPP, TEST_RESOURCE_TYPE, Depth or RT, TestDimension index, ArraySize
3932 auto Size = BuildInputIterator(List, 4, 2, false); // Size of arrays TestDimensions, TestArraySize
3933
3934 for(auto element : List)
3935 {
3936 GMM_RESCREATE_PARAMS gmmParams = {};
3937 gmmParams.Flags.Info = {0};
3938
3939 TEST_TILE_TYPE Tiling = (TEST_TILE_TYPE)std::get<0>(element);
3940 TEST_BPP Bpp = (TEST_BPP)std::get<1>(element);
3941 TEST_RESOURCE_TYPE ResType = (TEST_RESOURCE_TYPE)std::get<2>(element);
3942 bool IsRT = std::get<3>(element); // True for RT, False for Depth
3943 int TestDimIdx = std::get<4>(element); //index into TestDimensions array
3944 int ArrayIdx = std::get<5>(element); //index into TestArraySize
3945 TileSize = (Tiling == TEST_TILEYS) ? GMM_KBYTE(64) : GMM_KBYTE(4);
3946
3947 //Discard un-supported Tiling/Res_type/bpp for this test
3948 if(ResType != TEST_RESOURCE_2D || Tiling >= TEST_TILEYF //No 1D/3D/Cube. Supported 2D mip-maps/array
3949 || (!IsRT && (Tiling == TEST_TILEX ||
3950 !(Bpp == TEST_BPP_16 || Bpp == TEST_BPP_32)))) //depth supported on 16bit, 32bit formats only
3951 continue;
3952
3953 SetTileFlag(gmmParams, Tiling);
3954 SetResType(gmmParams, ResType);
3955 SetResGpuFlags(gmmParams, IsRT);
3956 SetResArraySize(gmmParams, TestArraySize[ArrayIdx]);
3957
3958 gmmParams.NoGfxMemory = 1;
3959 gmmParams.Format = SetResourceFormat(Bpp);
3960 for(uint32_t k = MSAA_2x; k <= MSAA_16x; k++)
3961 {
3962 GetAlignmentAndTileDimensionsForMSAA(Bpp, IsRT, Tiling, (TEST_MSAA)k,
3963 TileDimX, TileDimY, HAlign, VAlign,
3964 ExpectedMCSBpp, MCSHAlign, MCSVAlign);
3965
3966 gmmParams.BaseWidth64 = TestDimensions[TestDimIdx][0] * TileDimX + 0x1;
3967 gmmParams.BaseHeight = TestDimensions[TestDimIdx][1] * TileDimY + 0x1;
3968 gmmParams.Depth = 0x1;
3969 gmmParams.MSAA.NumSamples = static_cast<uint32_t>(pow((double)2, k));
3970 gmmParams.Flags.Gpu.MCS = 0;
3971
3972 //MSS surface
3973 GMM_RESOURCE_INFO *MSSResourceInfo;
3974 MSSResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
3975
3976 if(MSSResourceInfo)
3977 {
3978 VerifyResourceHAlign<true>(MSSResourceInfo, HAlign);
3979 VerifyResourceVAlign<true>(MSSResourceInfo, VAlign);
3980 if(IsRT) //Arrayed MSS
3981 {
3982 uint32_t ExpectedPitch = 0, ExpectedQPitch = 0;
3983 ExpectedPitch = GMM_ULT_ALIGN(GMM_ULT_ALIGN(gmmParams.BaseWidth64, HAlign) * (uint32_t)pow(2.0, Bpp), TileDimX); // Aligned width * bpp, aligned to TileWidth
3984 VerifyResourcePitch<true>(MSSResourceInfo, ExpectedPitch);
3985 if(Tiling != TEST_LINEAR)
3986 VerifyResourcePitchInTiles<true>(MSSResourceInfo, ExpectedPitch / TileDimX);
3987
3988 ExpectedQPitch = GMM_ULT_ALIGN(gmmParams.BaseHeight, VAlign);
3989 if(gmmParams.ArraySize > 1) //Gen9: Qpitch is distance between array slices (not sample slices)
3990 {
3991 VerifyResourceQPitch<true>(MSSResourceInfo, ExpectedQPitch);
3992 }
3993
3994 uint32_t ExpectedHeight = GMM_ULT_ALIGN(ExpectedQPitch * gmmParams.MSAA.NumSamples * gmmParams.ArraySize, TileDimY); //Align Height =ExpectedPitch * NumSamples * ExpectedQPitch, to Tile-Height
3995 VerifyResourceSize<true>(MSSResourceInfo, GMM_ULT_ALIGN(ExpectedPitch * ExpectedHeight, TileSize));
3996 }
3997 else // Interleaved MSS
3998 {
3999 uint32_t WidthMultiplier, HeightMultiplier;
4000 GetInterleaveMSSPattern((TEST_MSAA)k, WidthMultiplier, HeightMultiplier, IsRT, Bpp);
4001 gmmParams.BaseWidth64 = WidthMultiplier > 1 ? GMM_ULT_ALIGN(gmmParams.BaseWidth64, 2) : gmmParams.BaseWidth64;
4002 gmmParams.BaseHeight = HeightMultiplier > 1 ? GMM_ULT_ALIGN(gmmParams.BaseHeight, 2) : gmmParams.BaseHeight;
4003
4004 uint32_t ExpectedPitch = GMM_ULT_ALIGN(GMM_ULT_ALIGN(gmmParams.BaseWidth64 * WidthMultiplier, HAlign) * (uint32_t)pow(2.0, Bpp), TileDimX);
4005 VerifyResourcePitch<true>(MSSResourceInfo, ExpectedPitch);
4006 if(Tiling != TEST_LINEAR)
4007 {
4008 VerifyResourcePitchInTiles<true>(MSSResourceInfo, ExpectedPitch / TileDimX);
4009 }
4010
4011 uint64_t ExpectedQPitch = GMM_ULT_ALIGN(gmmParams.BaseHeight * HeightMultiplier, VAlign);
4012 if(gmmParams.ArraySize > 1)
4013 {
4014 VerifyResourceQPitch<true>(MSSResourceInfo, ExpectedQPitch);
4015 }
4016 uint64_t ExpectedHeight = GMM_ULT_ALIGN(ExpectedQPitch * gmmParams.ArraySize, TileDimY); //Align Height = ExpectedQPitch*ArraySize, to Tile-Height
4017 VerifyResourceSize<true>(MSSResourceInfo, GMM_ULT_ALIGN(ExpectedPitch * ExpectedHeight, TileSize)); //ExpectedPitch *ExpectedHeight
4018 }
4019 }
4020
4021 //No MCS surface if MSS creation failed
4022 if(MSSResourceInfo)
4023 {
4024 gmmParams.Flags.Gpu.MCS = 1;
4025 GMM_RESOURCE_INFO *MCSResourceInfo;
4026 MCSResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
4027
4028 VerifyResourceHAlign<true>(MCSResourceInfo, MCSHAlign);
4029 VerifyResourceVAlign<true>(MCSResourceInfo, MCSVAlign);
4030
4031 uint32_t ExpectedPitch = GMM_ULT_ALIGN(GMM_ULT_ALIGN(gmmParams.BaseWidth64, MCSHAlign) * ExpectedMCSBpp, MCSTileSize[0][0]); // Align in texels, tehn multiply w/ Bpt
4032 VerifyResourcePitch<true>(MCSResourceInfo, ExpectedPitch);
4033 VerifyResourcePitchInTiles<true>(MCSResourceInfo, ExpectedPitch / MCSTileSize[0][0]);
4034
4035 uint32_t ExpectedQPitch = GMM_ULT_ALIGN(gmmParams.BaseHeight, MCSVAlign);
4036 if(gmmParams.ArraySize > 1)
4037 {
4038 ExpectedQPitch = GMM_ULT_ALIGN(gmmParams.BaseHeight, MCSVAlign); //QPitch only for array
4039 VerifyResourceQPitch<true>(MCSResourceInfo, ExpectedQPitch);
4040 }
4041
4042 uint32_t ExpectedHeight = GMM_ULT_ALIGN(ExpectedQPitch * gmmParams.ArraySize, MCSTileSize[0][1]);
4043 VerifyResourceSize<true>(MCSResourceInfo, GMM_ULT_ALIGN(ExpectedPitch * ExpectedHeight, GMM_KBYTE(4))); //MCS Tile is TileY
4044
4045 pGmmULTClientContext->DestroyResInfoObject(MCSResourceInfo);
4046 } //MCS
4047
4048 pGmmULTClientContext->DestroyResInfoObject(MSSResourceInfo);
4049 } //NumSamples = k
4050 } //Iterate through all Input types
4051
4052 //Mip-mapped, MSAA case:
4053 }
4054
BuildInputIterator(std::vector<tuple<int,int,int,int,int>> & List,int maxTestDimension,int TestArraySize)4055 int BuildInputIterator(std::vector<tuple<int, int, int, int, int>> &List, int maxTestDimension, int TestArraySize)
4056 {
4057 for(uint32_t i = TEST_LINEAR; i < TEST_TILE_MAX; i++)
4058 for(uint32_t j = TEST_BPP_8; j < TEST_BPP_MAX; j++)
4059 for(uint32_t k = TEST_RESOURCE_1D; k < TEST_RESOURCE_MAX; k++)
4060 for(uint32_t l = 0; l < maxTestDimension; l++)
4061 for(uint32_t m = 0; m < TestArraySize; m++)
4062 {
4063 List.emplace_back(make_tuple(i, j, k, l, m));
4064 }
4065
4066 return List.size();
4067 }
4068
4069 /// @brief ULT for Color control Resource (non-MSAA compression)
TEST_F(CTestGen9Resource,TestCCS)4070 TEST_F(CTestGen9Resource, TestCCS)
4071 {
4072 const uint32_t CCSTileSize[1][2] = {128, 32}; //CCS is TileY
4073
4074 const uint32_t TestDimensions[4][3] = {
4075 //Input dimensions in #Tiles
4076 {0, 0, 0}, //1x1x1
4077 {1, 0, 0}, //2 Tilesx1x1
4078 {1, 1, 0}, //2 Tilesx 2x1
4079 {1, 1, 1}, //2 Tilesx 2x2
4080 };
4081 uint32_t TestArraySize[2] = {1, 9};
4082
4083 uint32_t RTHAlign = 128, RTVAlign = 64; //Gen9 CCS's RT should be aligned to 128x64
4084
4085 uint32_t TileDimX, TileDimY, TileDimZ, WidthDivisor, HeightDivisor, TileSize;
4086 uint32_t ExpectedMCSBpp;
4087 std::vector<tuple<int, int, int, int, int>> List; //TEST_TILE_TYPE, TEST_BPP, TEST_RESOURCE_TYPE, TestDimension index, TestArraySize index
4088 auto Size = BuildInputIterator(List, 4, 2); // Send size of TestDimensions, TestArraySize
4089
4090 for(auto element : List)
4091 {
4092 GMM_RESCREATE_PARAMS gmmParams = {};
4093 gmmParams.Flags.Info = {0};
4094
4095 TEST_TILE_TYPE Tiling = (TEST_TILE_TYPE)std::get<0>(element);
4096 TEST_BPP Bpp = (TEST_BPP)std::get<1>(element);
4097 TEST_RESOURCE_TYPE ResType = (TEST_RESOURCE_TYPE)std::get<2>(element);
4098 int TestDimIdx = std::get<3>(element); //index into TestDimensions array
4099 int ArrayIdx = std::get<4>(element); //index into TestArraySize
4100 TileSize = (Tiling == TEST_TILEYS) ? GMM_KBYTE(64) : GMM_KBYTE(4);
4101
4102 //Discard if un-supported Tiling/Res_type/bpp for this test
4103 if(Tiling < TEST_TILEY || !(Bpp == TEST_BPP_32 || //Gen8: NO TileYs/Yf, CCS not supported for !TileY/Yf/Ys/X - gen8 support tilex
4104 Bpp == TEST_BPP_64 || Bpp == TEST_BPP_128) || //LRTC not supported on <32bpp
4105 ResType == TEST_RESOURCE_1D ||
4106 ResType == TEST_RESOURCE_BUFFER) //non-MSAA CCS, 1D is showing issues CCS becoming linear (Buffer is linear)
4107 continue;
4108
4109 SetTileFlag(gmmParams, Tiling);
4110 SetResType(gmmParams, ResType);
4111 SetResGpuFlags(gmmParams, true); //Depth not Supported w/ CCS. Depth only has HiZ, and IMS
4112 SetResArraySize(gmmParams, TestArraySize[ArrayIdx]);
4113
4114 gmmParams.NoGfxMemory = 1;
4115 gmmParams.Format = SetResourceFormat(Bpp);
4116
4117 GetAlignmentAndTileDimensionsForCCS(Bpp, Tiling, ResType,
4118 TileDimX, TileDimY, TileDimZ, WidthDivisor, HeightDivisor);
4119
4120 gmmParams.BaseWidth64 = TestDimensions[TestDimIdx][0] * TileDimX + 0x1;
4121 gmmParams.BaseHeight = (gmmParams.Type == RESOURCE_CUBE) ? gmmParams.BaseWidth64 :
4122 TestDimensions[TestDimIdx][1] * TileDimY + 0x1;
4123 gmmParams.Depth = (gmmParams.Type == RESOURCE_3D) ? TestDimensions[TestDimIdx][2] * TileDimZ + 0x1 : 0x1;
4124 gmmParams.MSAA.NumSamples = 1;
4125 gmmParams.Flags.Gpu.CCS = 0;
4126
4127 //RT surface
4128 GMM_RESOURCE_INFO *RTResourceInfo;
4129 RTResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
4130
4131 //No CCS surface if RT creation failed
4132 if(RTResourceInfo)
4133 {
4134 gmmParams.Flags.Gpu.CCS = 1;
4135 GMM_RESOURCE_INFO *CCSResourceInfo;
4136 CCSResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
4137
4138 VerifyResourceHAlign<true>(CCSResourceInfo, RTHAlign); //Check if RT for CCS creation was aligned to CCS's RT alignment
4139 VerifyResourceVAlign<true>(CCSResourceInfo, RTVAlign);
4140 uint32_t ExpectedPitch = GMM_ULT_ALIGN((uint32_t)(GMM_ULT_ALIGN(gmmParams.BaseWidth64, RTHAlign) / WidthDivisor), CCSTileSize[0][0]);
4141 VerifyResourcePitch<true>(CCSResourceInfo, ExpectedPitch);
4142 VerifyResourcePitchInTiles<true>(CCSResourceInfo, ExpectedPitch / CCSTileSize[0][0]); // 1 tileY wide
4143
4144 uint32_t ExpectedQPitch = GMM_ULT_ALIGN(gmmParams.BaseHeight, RTVAlign); // / HeightDivisor;
4145 if(gmmParams.ArraySize > 1 || gmmParams.Type == RESOURCE_CUBE || gmmParams.Type == RESOURCE_3D)
4146 {
4147 uint32_t DepthSlice = gmmParams.Depth;
4148 //if (gmmParams.Type == RESOURCE_3D && DepthSlice > 1)
4149 //{
4150 // ExpectedQPitch *= DepthSlice;
4151 //}
4152 //else { // Should 3D surface Aux QPitch be distance between R-slices or not
4153 // If it must be R-slice distance, compute 3D QPitch, remove depthslice from arraysize
4154 VerifyResourceQPitch<true>(CCSResourceInfo, ExpectedQPitch); //verify false, else QPitch given for RT-size not CCS
4155 //}
4156 gmmParams.ArraySize *= (gmmParams.Type == RESOURCE_3D) ? DepthSlice : //3D R-slices
4157 (gmmParams.Type == RESOURCE_CUBE) ? 6 : 1; //cube faces treated as array slices
4158 }
4159
4160 ExpectedQPitch /= HeightDivisor;
4161 uint32_t ExpectedHeight = GMM_ULT_ALIGN(ExpectedQPitch * gmmParams.ArraySize, CCSTileSize[0][1]);
4162 VerifyResourceSize<true>(CCSResourceInfo, GMM_ULT_ALIGN(ExpectedPitch * ExpectedHeight, GMM_KBYTE(4)));
4163
4164 pGmmULTClientContext->DestroyResInfoObject(CCSResourceInfo);
4165 } //CCS
4166
4167 pGmmULTClientContext->DestroyResInfoObject(RTResourceInfo);
4168 } //Iterate through all input tuples
4169
4170 // Mip-mapped case
4171 }
4172
4173 /// @brief ULT for MMC Resource
TEST_F(CTestGen9Resource,TestMMC)4174 TEST_F(CTestGen9Resource, TestMMC)
4175 {
4176 const TEST_TILE_TYPE TileTypeSupported[3] = {TEST_TILEY, TEST_TILEYS, TEST_TILEYF};
4177
4178 const uint32_t TileSize[3][TEST_BPP_MAX][2] = {
4179 {{128, 32}, {128, 32}, {128, 32}, {128, 32}, {128, 32}}, // TileY
4180 {{256, 256}, {512, 128}, {512, 128}, {1024, 64}, {1024, 64}}, // TileYs
4181 {{64, 64}, {128, 32}, {128, 32}, {256, 16}, {256, 16}}}; // TileYf
4182
4183 // Normal 2D surface
4184 for(uint32_t Tile : TileTypeSupported)
4185 {
4186 GMM_RESCREATE_PARAMS gmmParams = {};
4187 gmmParams.Type = RESOURCE_2D;
4188 gmmParams.NoGfxMemory = 1;
4189 gmmParams.Flags.Gpu.Texture = 1;
4190 gmmParams.Flags.Gpu.MMC = 1;
4191 gmmParams.BaseWidth64 = 0x100;
4192 gmmParams.BaseHeight = 0x50;
4193 gmmParams.Depth = 0x1;
4194 SetTileFlag(gmmParams, static_cast<TEST_TILE_TYPE>(Tile));
4195
4196 for(uint32_t i = 0; i < TEST_BPP_MAX; i++)
4197 {
4198 TEST_BPP bpp = static_cast<TEST_BPP>(i);
4199 gmmParams.Format = SetResourceFormat(bpp);
4200
4201 GMM_RESOURCE_INFO *ResourceInfo;
4202 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
4203
4204 uint32_t ExpectedPitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[Tile - TEST_TILEY][i][0] / GetBppValue(bpp));
4205 ExpectedPitch *= GetBppValue(bpp);
4206 ExpectedPitch += TileSize[Tile - TEST_TILEY][i][0]; // MMC will have extra tile on the right
4207 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
4208 VerifyResourcePitchInTiles<true>(ResourceInfo, ExpectedPitch / TileSize[Tile - TEST_TILEY][i][0]);
4209
4210 uint32_t Size = GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[Tile - TEST_TILEY][i][1]) * ExpectedPitch;
4211 VerifyResourceSize<true>(ResourceInfo, GMM_ULT_ALIGN(Size, GMM_KBYTE(4)));
4212
4213 VerifyResourceHAlign<false>(ResourceInfo, 0); // Tested elsewhere
4214 VerifyResourceVAlign<false>(ResourceInfo, 0); // Tested elsewhere
4215 VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-mipped surface
4216
4217 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
4218 }
4219 }
4220
4221 // Planar 2D surface
4222 {
4223 GMM_RESCREATE_PARAMS gmmParams = {};
4224 gmmParams.Type = RESOURCE_2D;
4225 gmmParams.NoGfxMemory = 1;
4226 gmmParams.Flags.Gpu.Texture = 1;
4227 gmmParams.Flags.Gpu.MMC = 1;
4228 gmmParams.BaseWidth64 = 0x100;
4229 gmmParams.BaseHeight = 0x50;
4230 gmmParams.Depth = 0x1;
4231 SetTileFlag(gmmParams, TEST_TILEY); // TileY only
4232 gmmParams.Format = GMM_FORMAT_NV12; // 8bpp
4233
4234 GMM_RESOURCE_INFO *ResourceInfo;
4235 ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
4236
4237 uint32_t ExpectedPitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[0][0][0]);
4238 ExpectedPitch += TileSize[0][0][0]; // MMC will have extra tile on the right
4239 VerifyResourcePitch<true>(ResourceInfo, ExpectedPitch);
4240 VerifyResourcePitchInTiles<true>(ResourceInfo, ExpectedPitch / TileSize[0][0][0]);
4241
4242 VerifyResourceSize<false>(ResourceInfo, 0); // Tested elsewhere
4243 VerifyResourceHAlign<false>(ResourceInfo, 0); // Tested elsewhere
4244 VerifyResourceVAlign<false>(ResourceInfo, 0); // Tested elsewhere
4245 VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for non-mipped surface
4246
4247 pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
4248 }
4249 }
4250
4251 /// @brief ULT for StdSwizzle surfaces
TEST_F(CTestGen9Resource,TestStdSwizzle)4252 TEST_F(CTestGen9Resource, TestStdSwizzle)
4253 {
4254 // TODO: Test RedescribedPlanes, along with other StdSwizzle mappings
4255 }
4256