|
1 | 1 | /* |
2 | | - * Copyright (C) 2020-2024 Intel Corporation |
| 2 | + * Copyright (C) 2020-2025 Intel Corporation |
3 | 3 | * |
4 | 4 | * SPDX-License-Identifier: MIT |
5 | 5 | * |
|
8 | 8 | #include "shared/source/helpers/register_offsets.h" |
9 | 9 | #include "shared/test/common/cmd_parse/gen_cmd_parse.h" |
10 | 10 | #include "shared/test/common/mocks/mock_device.h" |
| 11 | +#include "shared/test/common/mocks/mock_gmm.h" |
| 12 | +#include "shared/test/common/mocks/mock_gmm_client_context.h" |
| 13 | +#include "shared/test/common/mocks/mock_gmm_resource_info.h" |
11 | 14 | #include "shared/test/common/mocks/mock_graphics_allocation.h" |
12 | 15 | #include "shared/test/common/test_macros/hw_test.h" |
13 | 16 |
|
@@ -352,5 +355,79 @@ HWTEST2_F(AppendMemoryCopyFromContext, givenCommandListThenUpOnPerformingAppendM |
352 | 355 | EXPECT_EQ(ZE_RESULT_SUCCESS, result); |
353 | 356 | } |
354 | 357 |
|
| 358 | +struct IsAtLeastXeHpCoreAndNotXe2HpgCoreWith2DArrayImageSupport { |
| 359 | + template <PRODUCT_FAMILY productFamily> |
| 360 | + static constexpr bool isMatched() { |
| 361 | + return IsAtLeastGfxCore<IGFX_XE_HP_CORE>::isMatched<productFamily>() && !IsXe2HpgCore::isMatched<productFamily>() && NEO::HwMapper<productFamily>::GfxProduct::supportsSampler; |
| 362 | + } |
| 363 | +}; |
| 364 | +HWTEST2_F(AppendMemoryCopyTests, givenCopyCommandListWhenTiled1DArrayImagePassedToImageCopyBlitThenTransformedTo2DArrayCopy, IsAtLeastXeHpCoreAndNotXe2HpgCoreWith2DArrayImageSupport) { |
| 365 | + using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT; |
| 366 | + auto commandList = std::make_unique<WhiteBox<::L0::CommandListCoreFamily<gfxCoreFamily>>>(); |
| 367 | + commandList->initialize(device, NEO::EngineGroupType::copy, 0u); |
| 368 | + |
| 369 | + auto gmmSrc = std::make_unique<MockGmm>(device->getNEODevice()->getGmmHelper()); |
| 370 | + auto resourceInfoSrc = static_cast<MockGmmResourceInfo *>(gmmSrc->gmmResourceInfo.get()); |
| 371 | + resourceInfoSrc->getResourceFlags()->Info.Tile64 = 1; |
| 372 | + resourceInfoSrc->mockResourceCreateParams.Type = GMM_RESOURCE_TYPE::RESOURCE_1D; |
| 373 | + resourceInfoSrc->mockResourceCreateParams.ArraySize = 8; |
| 374 | + |
| 375 | + NEO::MockGraphicsAllocation mockAllocationSrc(0, 1u /*num gmms*/, NEO::AllocationType::internalHostMemory, |
| 376 | + reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t), |
| 377 | + MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); |
| 378 | + NEO::MockGraphicsAllocation mockAllocationDst(0, 1u /*num gmms*/, NEO::AllocationType::internalHostMemory, |
| 379 | + reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t), |
| 380 | + MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); |
| 381 | + |
| 382 | + mockAllocationSrc.setGmm(gmmSrc.get(), 0); |
| 383 | + mockAllocationDst.setGmm(gmmSrc.get(), 0); |
| 384 | + |
| 385 | + size_t arrayLevels = 8; |
| 386 | + size_t depth = 1; |
| 387 | + commandList->appendCopyImageBlit(&mockAllocationDst, &mockAllocationSrc, {0, 0, 0}, {0, 0, 0}, 4, 4, 4, 4, 1, {1, arrayLevels, depth}, {1, arrayLevels, depth}, {1, arrayLevels, depth}, nullptr); |
| 388 | + GenCmdList cmdList; |
| 389 | + ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( |
| 390 | + cmdList, ptrOffset(commandList->getCmdContainer().getCommandStream()->getCpuBase(), 0), commandList->getCmdContainer().getCommandStream()->getUsed())); |
| 391 | + auto itor = find<XY_BLOCK_COPY_BLT *>(cmdList.begin(), cmdList.end()); |
| 392 | + EXPECT_NE(cmdList.end(), itor); |
| 393 | + auto cmd = genCmdCast<XY_BLOCK_COPY_BLT *>(*itor); |
| 394 | + EXPECT_EQ(cmd->getSourceSurfaceDepth(), arrayLevels); |
| 395 | + EXPECT_EQ(cmd->getSourceSurfaceHeight(), depth); |
| 396 | +} |
| 397 | + |
| 398 | +HWTEST2_F(AppendMemoryCopyTests, givenCopyCommandListWhenNotTiled1DArrayImagePassedToImageCopyBlitThenNotTransformedTo2DArrayCopy, IsAtLeastXeHpCoreAndNotXe2HpgCoreWith2DArrayImageSupport) { |
| 399 | + using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT; |
| 400 | + auto commandList = std::make_unique<WhiteBox<::L0::CommandListCoreFamily<gfxCoreFamily>>>(); |
| 401 | + commandList->initialize(device, NEO::EngineGroupType::copy, 0u); |
| 402 | + |
| 403 | + auto gmmSrc = std::make_unique<MockGmm>(device->getNEODevice()->getGmmHelper()); |
| 404 | + auto resourceInfoSrc = static_cast<MockGmmResourceInfo *>(gmmSrc->gmmResourceInfo.get()); |
| 405 | + resourceInfoSrc->getResourceFlags()->Info.Tile64 = 0; |
| 406 | + resourceInfoSrc->mockResourceCreateParams.Type = GMM_RESOURCE_TYPE::RESOURCE_1D; |
| 407 | + resourceInfoSrc->mockResourceCreateParams.ArraySize = 8; |
| 408 | + |
| 409 | + NEO::MockGraphicsAllocation mockAllocationSrc(0, 1u /*num gmms*/, NEO::AllocationType::internalHostMemory, |
| 410 | + reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t), |
| 411 | + MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); |
| 412 | + NEO::MockGraphicsAllocation mockAllocationDst(0, 1u /*num gmms*/, NEO::AllocationType::internalHostMemory, |
| 413 | + reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t), |
| 414 | + MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); |
| 415 | + |
| 416 | + mockAllocationSrc.setGmm(gmmSrc.get(), 0); |
| 417 | + mockAllocationDst.setGmm(gmmSrc.get(), 0); |
| 418 | + |
| 419 | + size_t arrayLevels = 8; |
| 420 | + size_t depth = 1; |
| 421 | + commandList->appendCopyImageBlit(&mockAllocationDst, &mockAllocationSrc, {0, 0, 0}, {0, 0, 0}, 1, 1, 1, 1, 1, {1, arrayLevels, depth}, {1, arrayLevels, depth}, {1, arrayLevels, depth}, nullptr); |
| 422 | + GenCmdList cmdList; |
| 423 | + ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( |
| 424 | + cmdList, ptrOffset(commandList->getCmdContainer().getCommandStream()->getCpuBase(), 0), commandList->getCmdContainer().getCommandStream()->getUsed())); |
| 425 | + auto itor = find<XY_BLOCK_COPY_BLT *>(cmdList.begin(), cmdList.end()); |
| 426 | + EXPECT_NE(cmdList.end(), itor); |
| 427 | + auto cmd = genCmdCast<XY_BLOCK_COPY_BLT *>(*itor); |
| 428 | + EXPECT_EQ(cmd->getSourceSurfaceDepth(), depth); |
| 429 | + EXPECT_EQ(cmd->getSourceSurfaceHeight(), arrayLevels); |
| 430 | +} |
| 431 | + |
355 | 432 | } // namespace ult |
356 | 433 | } // namespace L0 |
0 commit comments