1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720
|
/*==============================================================================
Copyright(c) 2016 Intel Corporation
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files(the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and / or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
============================================================================*/
#include "GmmGen11ResourceULT.h"
using namespace std;
/////////////////////////////////////////////////////////////////////////////////////
/// Sets up common environment for Resource fixture tests. this is called once per
/// test case before executing all tests under resource fixture test case.
// It also calls SetupTestCase from CommonULT to initialize global context and others.
///
/// @see CTestGen9Resource::SetUpTestCase()
///
/////////////////////////////////////////////////////////////////////////////////////
void CTestGen11Resource::SetUpTestCase()
{
printf("%s\n", __FUNCTION__);
GfxPlatform.eProductFamily = IGFX_LAKEFIELD;
GfxPlatform.eRenderCoreFamily = IGFX_GEN11_CORE;
CommonULT::SetUpTestCase();
}
/////////////////////////////////////////////////////////////////////////////////////
/// cleans up once all the tests finish execution. It also calls TearDownTestCase
/// from CommonULT to destroy global context and others.
///
/// @see CTestGen10Resource::TearDownTestCase()
/////////////////////////////////////////////////////////////////////////////////////
void CTestGen11Resource::TearDownTestCase()
{
printf("%s\n", __FUNCTION__);
CommonULT::TearDownTestCase();
}
/// @brief ULT for 2D TileYs Resource
TEST_F(CTestGen11Resource, TestPlanar2D_NV12_MediaCompressed)
{
/* Test planar surface with hybrid UV planes where UV plane is half the size
of Y and U/V data is packed together */
// YYYYYYYY
// YYYYYYYY
// YYYYYYYY
// YYYYYYYY
// [UV-Packing]
// YccsYccsYccs
// YccsYccsYccs
// UVccsUVccsUVccs
// UVccsUVccsUVccs
const uint32_t TileSize[2] = {128, 32}; // TileY
GMM_RESCREATE_PARAMS gmmParams = {};
gmmParams.Type = RESOURCE_2D;
gmmParams.NoGfxMemory = 1;
gmmParams.Flags.Gpu.MMC = 1;
gmmParams.Flags.Gpu.Texture = 1;
gmmParams.Flags.Gpu.UnifiedAuxSurface = 1;
gmmParams.Flags.Info.TiledY = 1;
gmmParams.BaseWidth64 = 0x2048; //8264
gmmParams.BaseHeight = 0x274; // 628
gmmParams.Depth = 0x1;
SetTileFlag(gmmParams, static_cast<TEST_TILE_TYPE>(TEST_TILEY));
gmmParams.Format = GMM_FORMAT_NV12;
GMM_RESOURCE_INFO *ResourceInfo;
//__debugbreak();
ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
uint32_t Pitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[0]);
uint32_t Height = GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[1]) +
GMM_ULT_ALIGN(gmmParams.BaseHeight / 2, TileSize[1]);
uint32_t Size = GMM_ULT_ALIGN(Pitch * Height, GMM_KBYTE(4));
VerifyResourcePitch<true>(ResourceInfo, Pitch);
VerifyResourcePitchInTiles<true>(ResourceInfo, Pitch / TileSize[0]);
VerifyResourceSize<true>(ResourceInfo, Size);
VerifyResourceHAlign<false>(ResourceInfo, 0); // Same as any other 2D surface -- tested elsewhere
VerifyResourceVAlign<false>(ResourceInfo, 0); // Same as any other 2D surface -- tested elsewhere
VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for planar
// Y plane should be at 0,0
EXPECT_EQ(0, ResourceInfo->GetPlanarXOffset(GMM_PLANE_Y));
EXPECT_EQ(0, ResourceInfo->GetPlanarYOffset(GMM_PLANE_Y));
// U/V plane should be at end of Y plane
EXPECT_EQ(0, ResourceInfo->GetPlanarXOffset(GMM_PLANE_U));
EXPECT_EQ(GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[1]), ResourceInfo->GetPlanarYOffset(GMM_PLANE_U));
EXPECT_EQ(0, ResourceInfo->GetPlanarXOffset(GMM_PLANE_V));
EXPECT_EQ(GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[1]), ResourceInfo->GetPlanarYOffset(GMM_PLANE_U));
EXPECT_EQ(GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[1]), ResourceInfo->GetPlanarYOffset(GMM_PLANE_V));
// Y Plane CCS should be at the end of NV12 surface.
EXPECT_EQ(Size, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS));
EXPECT_EQ(Size, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_Y_CCS));
// UV Plane CCS offset
uint32_t YCcsSize = GMM_ULT_ALIGN(((GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[1]) * Pitch) / 1024), PAGE_SIZE);
EXPECT_EQ(Size + YCcsSize, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_UV_CCS));
uint32_t UVCcsSize = GMM_ULT_ALIGN((Height - GFX_ALIGN(gmmParams.BaseHeight, TileSize[1])) * Pitch / 1024, PAGE_SIZE);
uint32_t MediaStateOffset = Size + YCcsSize + UVCcsSize;
EXPECT_EQ(MediaStateOffset, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_COMP_STATE));
pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
}
TEST_F(CTestGen11Resource, TestPlanar2D_NV12_MediaCompressedArray)
{
/* Test planar surface with hybrid UV planes where UV plane is half the size
of Y and U/V data is packed together */
// YYYYYYYY
// YYYYYYYY
// YYYYYYYY
// YYYYYYYY
// [UV-Packing]
// YccsYccsYccs
// YccsYccsYccs
// UVccsUVccsUVccs
// UVccsUVccsUVccs
// ...
const uint32_t TileSize[2] = {128, 32}; // TileY
GMM_RESCREATE_PARAMS gmmParams = {};
gmmParams.Type = RESOURCE_2D;
gmmParams.NoGfxMemory = 1;
gmmParams.Flags.Gpu.MMC = 1;
gmmParams.Flags.Gpu.Texture = 1;
gmmParams.Flags.Gpu.UnifiedAuxSurface = 1;
gmmParams.Flags.Info.TiledY = 1;
gmmParams.BaseWidth64 = 0x2048;
gmmParams.BaseHeight = 0x274;
gmmParams.Depth = 0x1;
gmmParams.ArraySize = 20;
SetTileFlag(gmmParams, static_cast<TEST_TILE_TYPE>(TEST_TILEY));
gmmParams.Format = GMM_FORMAT_NV12;
GMM_RESOURCE_INFO *ResourceInfo;
//__debugbreak();
ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
uint32_t Pitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[0]);
uint32_t Height = GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[1]) +
GMM_ULT_ALIGN(gmmParams.BaseHeight / 2, TileSize[1]);
uint32_t Size = GMM_ULT_ALIGN(Pitch * Height, GMM_KBYTE(4)) * gmmParams.ArraySize;
VerifyResourcePitch<true>(ResourceInfo, Pitch);
VerifyResourcePitchInTiles<true>(ResourceInfo, Pitch / TileSize[0]);
VerifyResourceSize<true>(ResourceInfo, Size);
VerifyResourceHAlign<false>(ResourceInfo, 0); // Same as any other 2D surface -- tested elsewhere
VerifyResourceVAlign<false>(ResourceInfo, 0); // Same as any other 2D surface -- tested elsewhere
VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for planar
// Y plane should be at 0,0
EXPECT_EQ(0, ResourceInfo->GetPlanarXOffset(GMM_PLANE_Y));
EXPECT_EQ(0, ResourceInfo->GetPlanarYOffset(GMM_PLANE_Y));
// U/V plane should be at end of Y plane
EXPECT_EQ(0, ResourceInfo->GetPlanarXOffset(GMM_PLANE_U));
EXPECT_EQ(GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[1]), ResourceInfo->GetPlanarYOffset(GMM_PLANE_U));
EXPECT_EQ(0, ResourceInfo->GetPlanarXOffset(GMM_PLANE_V));
EXPECT_EQ(GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[1]), ResourceInfo->GetPlanarYOffset(GMM_PLANE_U));
EXPECT_EQ(GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[1]), ResourceInfo->GetPlanarYOffset(GMM_PLANE_V));
// Y Plane CCS should be at the end of NV12 surface.
EXPECT_EQ(Size, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_CCS));
EXPECT_EQ(Size, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_Y_CCS));
// UV Plane CCS offset
uint32_t YCcsSize = GMM_ULT_ALIGN(((GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[1]) * Pitch) / 1024), PAGE_SIZE);
EXPECT_EQ(Size + YCcsSize, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_UV_CCS));
uint32_t UVCcsSize = GMM_ULT_ALIGN((Height - GFX_ALIGN(gmmParams.BaseHeight, TileSize[1])) * Pitch / 1024, PAGE_SIZE);
uint32_t MediaStateOffset = Size + YCcsSize + UVCcsSize;
EXPECT_EQ(MediaStateOffset, ResourceInfo->GetUnifiedAuxSurfaceOffset(GMM_AUX_COMP_STATE));
uint32_t AuxSize = YCcsSize + UVCcsSize + PAGE_SIZE;
EXPECT_EQ(AuxSize * gmmParams.ArraySize, ResourceInfo->GetSizeAuxSurface(GMM_AUX_CCS));
for(int i = 0; i < gmmParams.ArraySize; i++)
{
EXPECT_EQ(Size + AuxSize * i, ResourceInfo->GetPlanarAuxOffset(i, GMM_AUX_Y_CCS));
EXPECT_EQ(Size + (AuxSize * i) + YCcsSize, ResourceInfo->GetPlanarAuxOffset(i, GMM_AUX_UV_CCS));
EXPECT_EQ(Size + (AuxSize * i) + (YCcsSize + UVCcsSize), ResourceInfo->GetPlanarAuxOffset(i, GMM_AUX_COMP_STATE));
}
pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
}
/// @brief ULT for 2D TileYf Resource
TEST_F(CTestGen11Resource, Test2DTileYfResource)
{
printf("%s\n", __FUNCTION__);
}
/// @brief ULT for Plannar 2D Resource - RGBP
TEST_F(CTestGen11Resource, TestPlanar2D_RGBP)
{
/* Test planar surfaces where all planes are full-sized */
// YYYYYYYY
// YYYYYYYY
// YYYYYYYY
// YYYYYYYY
// UUUUUUUU
// UUUUUUUU
// UUUUUUUU
// UUUUUUUU
// VVVVVVVV
// VVVVVVVV
// VVVVVVVV
// VVVVVVVV
const TEST_TILE_TYPE TileTypes[] = {TEST_LINEAR, TEST_TILEX, TEST_TILEY};
const uint32_t PlaneRowAlignment = 16;
const uint32_t TileSize[3][2] = {{1, 1}, //Linear
{512, 8}, // TileX
{128, 32}}; // TileY
for(uint32_t TileIndex = 0; TileIndex < sizeof(TileTypes) / sizeof(TileTypes[0]); TileIndex++)
{
TEST_TILE_TYPE Tile = TileTypes[TileIndex];
GMM_RESCREATE_PARAMS gmmParams = {};
gmmParams.Type = RESOURCE_2D;
gmmParams.NoGfxMemory = 1;
gmmParams.Flags.Gpu.Texture = 1;
gmmParams.BaseWidth64 = 0x101;
gmmParams.BaseHeight = 0x101;
gmmParams.Depth = 0x1;
SetTileFlag(gmmParams, static_cast<TEST_TILE_TYPE>(Tile));
gmmParams.Format = GMM_FORMAT_RGBP;
GMM_RESOURCE_INFO *ResourceInfo;
ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
uint32_t Pitch, Height;
if(Tile != TEST_LINEAR)
{
Pitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[TileIndex][0]);
//Since Tile alignment factor is greater than GMM_IMCx_PLANE_ROW_ALIGNMENT=16
Height = GMM_ULT_ALIGN(gmmParams.BaseHeight, PlaneRowAlignment);
Height = GMM_ULT_ALIGN(Height, TileSize[TileIndex][1]) * 3 /*Y, U, V*/;
}
else
{
Pitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64, GMM_BYTES(64));
Height = gmmParams.BaseHeight * 3 /*Y, U, V*/;
}
uint32_t Size = GMM_ULT_ALIGN(Pitch * Height, GMM_KBYTE(4));
VerifyResourcePitch<true>(ResourceInfo, Pitch);
if(Tile != TEST_LINEAR)
{
VerifyResourcePitchInTiles<true>(ResourceInfo, Pitch / TileSize[TileIndex][0]);
}
VerifyResourceSize<true>(ResourceInfo, Size);
VerifyResourceHAlign<false>(ResourceInfo, 0); // Same as any other 2D surface -- tested elsewhere
VerifyResourceVAlign<false>(ResourceInfo, 0); // Same as any other 2D surface -- tested elsewhere
VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for planar
// Y plane should be at 0,0
EXPECT_EQ(0, ResourceInfo->GetPlanarXOffset(GMM_PLANE_Y));
EXPECT_EQ(0, ResourceInfo->GetPlanarYOffset(GMM_PLANE_Y));
// U plane should be at end of Y plane
EXPECT_EQ(0, ResourceInfo->GetPlanarXOffset(GMM_PLANE_U));
EXPECT_EQ(Height / 3, ResourceInfo->GetPlanarYOffset(GMM_PLANE_U));
// V plane should be at end of U plane
EXPECT_EQ(0, ResourceInfo->GetPlanarXOffset(GMM_PLANE_V));
EXPECT_EQ(2 * (Height / 3), ResourceInfo->GetPlanarYOffset(GMM_PLANE_V));
pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
}
}
/// @brief ULT for Plannar 2D Resource - RGBP
TEST_F(CTestGen11Resource, TestPlanar2DCustom_RGBP)
{
/* Test planar surfaces where all planes are full-sized */
// YYYYYYYY
// YYYYYYYY
// YYYYYYYY
// YYYYYYYY
// UUUUUUUU
// UUUUUUUU
// UUUUUUUU
// UUUUUUUU
// VVVVVVVV
// VVVVVVVV
// VVVVVVVV
// VVVVVVVV
const TEST_TILE_TYPE TileTypes[] = {TEST_LINEAR, TEST_TILEX, TEST_TILEY};
const uint32_t PlaneRowAlignment = 16;
const uint32_t TileSize[3][2] = {{1, 1}, //Linear
{512, 8}, // TileX
{128, 32}}; // TileY
for(uint32_t TileIndex = 0; TileIndex < sizeof(TileTypes) / sizeof(TileTypes[0]); TileIndex++)
{
TEST_TILE_TYPE Tile = TileTypes[TileIndex];
GMM_RESCREATE_CUSTOM_PARAMS gmmParams = {};
gmmParams.Type = RESOURCE_2D;
gmmParams.Flags.Gpu.Texture = 1;
gmmParams.BaseWidth64 = 0x101;
gmmParams.BaseHeight = GMM_ULT_ALIGN(0x101, PlaneRowAlignment);
SetTileFlag_Custom(gmmParams, static_cast<TEST_TILE_TYPE>(Tile));
gmmParams.Format = GMM_FORMAT_RGBP;
uint32_t Pitch, Height;
Pitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64, GMM_BYTES(64));
Height = GMM_ULT_ALIGN(gmmParams.BaseHeight, PlaneRowAlignment /* min16 rows*/) * 3 /*Y, U, V*/;
uint32_t Size = Pitch * Height;
gmmParams.Pitch = Pitch;
gmmParams.Size = Size;
gmmParams.PlaneOffset.X[GMM_PLANE_Y] = 0;
gmmParams.PlaneOffset.Y[GMM_PLANE_Y] = 0;
gmmParams.PlaneOffset.X[GMM_PLANE_U] = 0;
gmmParams.PlaneOffset.Y[GMM_PLANE_U] = Height / 3;
gmmParams.PlaneOffset.X[GMM_PLANE_V] = 0;
gmmParams.PlaneOffset.Y[GMM_PLANE_V] = 2 * (Height / 3);
gmmParams.NoOfPlanes = 3;
GMM_RESOURCE_INFO *ResourceInfo;
ResourceInfo = pGmmULTClientContext->CreateCustomResInfoObject(&gmmParams);
VerifyResourcePitch<true>(ResourceInfo, Pitch);
if(Tile != TEST_LINEAR)
{
VerifyResourcePitchInTiles<true>(ResourceInfo, Pitch / TileSize[TileIndex][0]);
}
VerifyResourceSize<true>(ResourceInfo, Size);
VerifyResourceHAlign<false>(ResourceInfo, 0); // Same as any other 2D surface -- tested elsewhere
VerifyResourceVAlign<false>(ResourceInfo, 0); // Same as any other 2D surface -- tested elsewhere
VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for planar
// Y plane should be at 0,0
EXPECT_EQ(0, ResourceInfo->GetPlanarXOffset(GMM_PLANE_Y));
EXPECT_EQ(0, ResourceInfo->GetPlanarYOffset(GMM_PLANE_Y));
// U plane should be at end of Y plane
EXPECT_EQ(0, ResourceInfo->GetPlanarXOffset(GMM_PLANE_U));
EXPECT_EQ(Height / 3, ResourceInfo->GetPlanarYOffset(GMM_PLANE_U));
// V plane should be at end of U plane
EXPECT_EQ(0, ResourceInfo->GetPlanarXOffset(GMM_PLANE_V));
EXPECT_EQ(2 * (Height / 3), ResourceInfo->GetPlanarYOffset(GMM_PLANE_V));
pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
}
}
/// @brief ULT for Plannar 2D Resource - MFX_JPEG_YUV422V , IMC1, IMC3
TEST_F(CTestGen11Resource, TestPlanar2D_MFX_JPEG_YUV422V)
{
/* Test planar surfaces where both U and V are half the size of Y */
// YYYYYYYY
// YYYYYYYY
// YYYYYYYY
// YYYYYYYY
// UUUUUUUU
// UUUUUUUU
// VVVVVVVV
// VVVVVVVV
const TEST_TILE_TYPE TileTypes[] = {TEST_LINEAR, TEST_TILEX, TEST_TILEY};
const uint32_t PlaneRowAlignment = 16;
const uint32_t TileSize[3][2] = {{1, 1}, //Linear
{512, 8}, // TileX
{128, 32}}; // TileY
for(uint32_t TileIndex = 0; TileIndex < sizeof(TileTypes) / sizeof(TileTypes[0]); TileIndex++)
{
TEST_TILE_TYPE Tile = TileTypes[TileIndex];
GMM_RESCREATE_PARAMS gmmParams = {};
gmmParams.Type = RESOURCE_2D;
gmmParams.NoGfxMemory = 1;
gmmParams.Flags.Gpu.Texture = 1;
gmmParams.BaseWidth64 = 0x101;
gmmParams.BaseHeight = 0x101;
gmmParams.Depth = 0x1;
SetTileFlag(gmmParams, static_cast<TEST_TILE_TYPE>(Tile));
gmmParams.Format = GMM_FORMAT_MFX_JPEG_YUV422V;
GMM_RESOURCE_INFO *ResourceInfo;
ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
uint32_t Pitch, Height;
uint32_t YHeight, VHeight;
if(Tile != TEST_LINEAR)
{
Pitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[TileIndex][0]);
YHeight = GMM_ULT_ALIGN(gmmParams.BaseHeight, PlaneRowAlignment);
YHeight = GMM_ULT_ALIGN(YHeight, TileSize[TileIndex][1]);
VHeight = GMM_ULT_ALIGN(GMM_ULT_ALIGN(gmmParams.BaseHeight, 2) / 2, PlaneRowAlignment);
VHeight = GMM_ULT_ALIGN(VHeight, TileSize[TileIndex][1]);
}
else
{
Pitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64, GMM_BYTES(64));
YHeight = GMM_ULT_ALIGN(gmmParams.BaseHeight, PlaneRowAlignment);
VHeight = GMM_ULT_ALIGN(GMM_ULT_ALIGN(gmmParams.BaseHeight, 2) / 2, PlaneRowAlignment);
}
Height = YHeight + 2 * VHeight;
uint32_t Size = GMM_ULT_ALIGN(Pitch * Height, GMM_KBYTE(4));
VerifyResourcePitch<true>(ResourceInfo, Pitch);
if(Tile != TEST_LINEAR)
{
VerifyResourcePitchInTiles<true>(ResourceInfo, Pitch / TileSize[TileIndex][0]);
}
VerifyResourceSize<true>(ResourceInfo, Size);
VerifyResourceHAlign<false>(ResourceInfo, 0); // Same as any other 2D surface -- tested elsewhere
VerifyResourceVAlign<false>(ResourceInfo, 0); // Same as any other 2D surface -- tested elsewhere
VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for planar
// Y plane should be at 0,0
EXPECT_EQ(0, ResourceInfo->GetPlanarXOffset(GMM_PLANE_Y));
EXPECT_EQ(0, ResourceInfo->GetPlanarYOffset(GMM_PLANE_Y));
// U plane should be at end of Y plane
EXPECT_EQ(0, ResourceInfo->GetPlanarXOffset(GMM_PLANE_U));
EXPECT_EQ(YHeight, ResourceInfo->GetPlanarYOffset(GMM_PLANE_U));
// V plane should be at end of U plane
EXPECT_EQ(0, ResourceInfo->GetPlanarXOffset(GMM_PLANE_V));
EXPECT_EQ(YHeight + VHeight, ResourceInfo->GetPlanarYOffset(GMM_PLANE_V));
pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
}
}
/// @brief ULT for Plannar 2D Resource - MFX_JPEG_YUV411R
TEST_F(CTestGen11Resource, TestPlanar2D_MFX_JPEG_YUV411R)
{
/* Test planar surfaces where both U and V are quarter the size of Y */
//YYYYYYYY
//YYYYYYYY
//YYYYYYYY
//YYYYYYYY
//UUUUUUUU
//VVVVVVVV
const TEST_TILE_TYPE TileTypes[] = {TEST_LINEAR, TEST_TILEX, TEST_TILEY};
const uint32_t PlaneRowAlignment = 16;
const uint32_t TileSize[3][2] = {{1, 1}, //Linear
{512, 8}, // TileX
{128, 32}}; // TileY
for(uint32_t TileIndex = 0; TileIndex < sizeof(TileTypes) / sizeof(TileTypes[0]); TileIndex++)
{
TEST_TILE_TYPE Tile = TileTypes[TileIndex];
GMM_RESCREATE_PARAMS gmmParams = {};
gmmParams.Type = RESOURCE_2D;
gmmParams.NoGfxMemory = 1;
gmmParams.Flags.Gpu.Texture = 1;
gmmParams.BaseWidth64 = 0x101;
gmmParams.BaseHeight = 0x101;
gmmParams.Depth = 0x1;
SetTileFlag(gmmParams, static_cast<TEST_TILE_TYPE>(Tile));
gmmParams.Format = GMM_FORMAT_MFX_JPEG_YUV411R_TYPE;
GMM_RESOURCE_INFO *ResourceInfo;
ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
uint32_t Pitch, Height;
uint32_t YHeight, VHeight;
if(Tile != TEST_LINEAR)
{
Pitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[TileIndex][0]);
YHeight = GMM_ULT_ALIGN(gmmParams.BaseHeight, PlaneRowAlignment);
YHeight = GMM_ULT_ALIGN(YHeight, TileSize[TileIndex][1]);
VHeight = GMM_ULT_ALIGN(GMM_ULT_ALIGN(gmmParams.BaseHeight, 4) / 4, PlaneRowAlignment);
VHeight = GMM_ULT_ALIGN(VHeight, TileSize[TileIndex][1]);
}
else
{
Pitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64, GMM_BYTES(64));
YHeight = GMM_ULT_ALIGN(gmmParams.BaseHeight, PlaneRowAlignment);
VHeight = GMM_ULT_ALIGN(GMM_ULT_ALIGN(gmmParams.BaseHeight, 4) / 4, PlaneRowAlignment);
}
Height = YHeight + 2 * VHeight;
uint32_t Size = GMM_ULT_ALIGN(Pitch * Height, GMM_KBYTE(4));
VerifyResourcePitch<true>(ResourceInfo, Pitch);
if(Tile != TEST_LINEAR)
{
VerifyResourcePitchInTiles<true>(ResourceInfo, Pitch / TileSize[TileIndex][0]);
}
VerifyResourceSize<true>(ResourceInfo, Size);
VerifyResourceHAlign<false>(ResourceInfo, 0); // Same as any other 2D surface -- tested elsewhere
VerifyResourceVAlign<false>(ResourceInfo, 0); // Same as any other 2D surface -- tested elsewhere
VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for planar
// Y plane should be at 0,0
EXPECT_EQ(0, ResourceInfo->GetPlanarXOffset(GMM_PLANE_Y));
EXPECT_EQ(0, ResourceInfo->GetPlanarYOffset(GMM_PLANE_Y));
// U plane should be at end of Y plane
EXPECT_EQ(0, ResourceInfo->GetPlanarXOffset(GMM_PLANE_U));
EXPECT_EQ(YHeight, ResourceInfo->GetPlanarYOffset(GMM_PLANE_U));
// V plane should be at end of U plane
EXPECT_EQ(0, ResourceInfo->GetPlanarXOffset(GMM_PLANE_V));
EXPECT_EQ(YHeight + VHeight, ResourceInfo->GetPlanarYOffset(GMM_PLANE_V));
pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
}
}
/// @brief ULT for Plannar 2D Resource - NV12
TEST_F(CTestGen11Resource, TestPlanar2D_NV12)
{
/* Test planar surface with hybrid UV planes where UV plane is half the size
of Y and U/V data is packed together */
// YYYYYYYY
// YYYYYYYY
// YYYYYYYY
// YYYYYYYY
// [UV-Packing]
const TEST_TILE_TYPE TileTypes[] = {TEST_LINEAR, TEST_TILEX, TEST_TILEY};
const uint32_t TileSize[3][2] = {{1, 1}, //Linear
{512, 8}, // TileX
{128, 32}}; // TileY
for(uint32_t TileIndex = 0; TileIndex < sizeof(TileTypes) / sizeof(TileTypes[0]); TileIndex++)
{
TEST_TILE_TYPE Tile = TileTypes[TileIndex];
GMM_RESCREATE_PARAMS gmmParams = {};
gmmParams.Type = RESOURCE_2D;
gmmParams.NoGfxMemory = 1;
gmmParams.Flags.Gpu.Texture = 1;
gmmParams.BaseWidth64 = 0x100;
gmmParams.BaseHeight = 0x100;
gmmParams.Depth = 0x1;
SetTileFlag(gmmParams, static_cast<TEST_TILE_TYPE>(Tile));
gmmParams.Format = GMM_FORMAT_NV12;
GMM_RESOURCE_INFO *ResourceInfo;
ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
uint32_t Pitch, Height;
if(Tile != TEST_LINEAR)
{
Pitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[TileIndex][0]);
Height = GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[TileIndex][1]) +
GMM_ULT_ALIGN(gmmParams.BaseHeight / 2, TileSize[TileIndex][1]);
}
else
{
Pitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[TileIndex][0]);
Height = GMM_ULT_ALIGN(gmmParams.BaseHeight /*Y*/ + gmmParams.BaseHeight / 2 /*UV*/, TileSize[TileIndex][1]);
}
uint32_t Size = GMM_ULT_ALIGN(Pitch * Height, GMM_KBYTE(4));
VerifyResourcePitch<true>(ResourceInfo, Pitch);
if(Tile != TEST_LINEAR)
{
VerifyResourcePitchInTiles<true>(ResourceInfo, Pitch / TileSize[TileIndex][0]);
}
VerifyResourceSize<true>(ResourceInfo, Size);
VerifyResourceHAlign<false>(ResourceInfo, 0); // Same as any other 2D surface -- tested elsewhere
VerifyResourceVAlign<false>(ResourceInfo, 0); // Same as any other 2D surface -- tested elsewhere
VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for planar
// Y plane should be at 0,0
EXPECT_EQ(0, ResourceInfo->GetPlanarXOffset(GMM_PLANE_Y));
EXPECT_EQ(0, ResourceInfo->GetPlanarYOffset(GMM_PLANE_Y));
// U/V plane should be at end of Y plane
EXPECT_EQ(0, ResourceInfo->GetPlanarXOffset(GMM_PLANE_U));
EXPECT_EQ(0, ResourceInfo->GetPlanarXOffset(GMM_PLANE_V));
if(Tile != TEST_LINEAR)
{
EXPECT_EQ(GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[TileIndex][1]), ResourceInfo->GetPlanarYOffset(GMM_PLANE_U));
EXPECT_EQ(GMM_ULT_ALIGN(gmmParams.BaseHeight, TileSize[TileIndex][1]), ResourceInfo->GetPlanarYOffset(GMM_PLANE_V));
}
else
{
EXPECT_EQ(gmmParams.BaseHeight, ResourceInfo->GetPlanarYOffset(GMM_PLANE_U));
EXPECT_EQ(gmmParams.BaseHeight, ResourceInfo->GetPlanarYOffset(GMM_PLANE_V));
}
pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
}
}
/// @brief ULT for Planar 2D Resource - IMC4
TEST_F(CTestGen11Resource, TestPlanar2D_IMC4)
{
/* Test planar surface V surface is on the right of U */
// YYYYYYYY
// YYYYYYYY
// YYYYYYYY
// YYYYYYYY
// UUUUVVVV
// UUUUVVVV
const TEST_TILE_TYPE TileTypes[] = {TEST_LINEAR, TEST_TILEX, TEST_TILEY};
const uint32_t PlaneRowAlignment = 16;
const uint32_t TileSize[3][2] = {{1, 1}, //Linear
{512, 8}, // TileX
{128, 32}}; // TileY
for(uint32_t TileIndex = 0; TileIndex < sizeof(TileTypes) / sizeof(TileTypes[0]); TileIndex++)
{
TEST_TILE_TYPE Tile = TileTypes[TileIndex];
GMM_RESCREATE_PARAMS gmmParams = {};
gmmParams.Type = RESOURCE_2D;
gmmParams.NoGfxMemory = 1;
gmmParams.Flags.Gpu.Texture = 1;
gmmParams.BaseWidth64 = 0x101;
gmmParams.BaseHeight = 0x101;
gmmParams.Depth = 0x1;
SetTileFlag(gmmParams, static_cast<TEST_TILE_TYPE>(Tile));
gmmParams.Format = GMM_FORMAT_IMC4;
GMM_RESOURCE_INFO *ResourceInfo;
ResourceInfo = pGmmULTClientContext->CreateResInfoObject(&gmmParams);
uint32_t Pitch, Height;
uint32_t YHeight, VHeight;
if(Tile != TEST_LINEAR)
{
Pitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64, TileSize[TileIndex][0]);
if(Pitch / TileSize[TileIndex][0] % 2)
{
Pitch += TileSize[TileIndex][0];
}
YHeight = GMM_ULT_ALIGN(gmmParams.BaseHeight, PlaneRowAlignment);
VHeight = YHeight / 2;
YHeight = GMM_ULT_ALIGN(YHeight, TileSize[TileIndex][1]);
VHeight = GMM_ULT_ALIGN(VHeight, TileSize[TileIndex][1]); // No need of PlaneRowAlignment since last plane
}
else
{
Pitch = GMM_ULT_ALIGN(gmmParams.BaseWidth64, GMM_BYTES(64));
YHeight = GMM_ULT_ALIGN(gmmParams.BaseHeight, PlaneRowAlignment);
VHeight = YHeight / 2;
}
Height = YHeight + VHeight;
uint32_t Size = GMM_ULT_ALIGN(Pitch * Height, GMM_KBYTE(4));
VerifyResourcePitch<true>(ResourceInfo, Pitch);
if(Tile != TEST_LINEAR)
{
VerifyResourcePitchInTiles<true>(ResourceInfo, Pitch / TileSize[TileIndex][0]);
}
VerifyResourceSize<true>(ResourceInfo, Size);
VerifyResourceHAlign<false>(ResourceInfo, 0); // Same as any other 2D surface -- tested elsewhere
VerifyResourceVAlign<false>(ResourceInfo, 0); // Same as any other 2D surface -- tested elsewhere
VerifyResourceQPitch<false>(ResourceInfo, 0); // N/A for planar
// Y plane should be at 0,0
EXPECT_EQ(0, ResourceInfo->GetPlanarXOffset(GMM_PLANE_Y));
EXPECT_EQ(0, ResourceInfo->GetPlanarYOffset(GMM_PLANE_Y));
// U plane should be at end of Y plane
// V plane should be at end of U plane
EXPECT_EQ(0, ResourceInfo->GetPlanarXOffset(GMM_PLANE_U));
EXPECT_EQ(Pitch / 2, ResourceInfo->GetPlanarXOffset(GMM_PLANE_V));
if(Tile != TEST_LINEAR)
{
EXPECT_EQ(YHeight, ResourceInfo->GetPlanarYOffset(GMM_PLANE_U));
EXPECT_EQ(YHeight, ResourceInfo->GetPlanarYOffset(GMM_PLANE_V));
}
else
{
EXPECT_EQ(YHeight, ResourceInfo->GetPlanarYOffset(GMM_PLANE_U));
EXPECT_EQ(YHeight, ResourceInfo->GetPlanarYOffset(GMM_PLANE_V));
}
pGmmULTClientContext->DestroyResInfoObject(ResourceInfo);
}
}
|