diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index e6964ce131..fa125bd345 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -1375,6 +1375,10 @@ ze_result_t CommandListCoreFamily::appendCopyImageBlit(NEO::Graph size_t bytesPerPixel, const Vec3 ©Size, const Vec3 &srcSize, const Vec3 &dstSize, Event *signalEvent) { + if (!handleCounterBasedEventOperations(signalEvent)) { + return ZE_RESULT_ERROR_INVALID_ARGUMENT; + } + auto clearColorAllocation = device->getNEODevice()->getDefaultEngine().commandStreamReceiver->getClearColorAllocation(); auto blitProperties = NEO::BlitProperties::constructPropertiesForCopy(dst, src, @@ -1392,6 +1396,12 @@ ze_result_t CommandListCoreFamily::appendCopyImageBlit(NEO::Graph dummyBlitWa.isWaRequired = true; appendSignalEventPostWalker(signalEvent, nullptr, nullptr, false, false, true); + + if (this->isInOrderExecutionEnabled()) { + appendSignalInOrderDependencyCounter(signalEvent, false); + } + handleInOrderDependencyCounter(signalEvent, false, false); + return ZE_RESULT_SUCCESS; } diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_in_order_cmdlist_1.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_in_order_cmdlist_1.cpp index fce863628b..b5484dc003 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_in_order_cmdlist_1.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_in_order_cmdlist_1.cpp @@ -24,6 +24,7 @@ #include "level_zero/core/source/gfx_core_helpers/l0_gfx_core_helper.h" #include "level_zero/core/test/unit_tests/fixtures/in_order_cmd_list_fixture.h" #include "level_zero/core/test/unit_tests/mocks/mock_event.h" +#include "level_zero/core/test/unit_tests/mocks/mock_image.h" #include #include @@ -1652,6 +1653,25 @@ HWTEST2_F(InOrderCmdListTests, givenNonInOrderCmdListWhenPassingCounterBasedEven immCmdList->copyThroughLockedPtrEnabled = true; EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, immCmdList->appendMemoryCopy(alloc, ©Data, 1, eventHandle, 0, nullptr, false, false)); + { + auto image = std::make_unique>>(); + ze_image_region_t imgRegion = {1, 1, 1, 1, 1, 1}; + ze_image_desc_t zeDesc = {}; + zeDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC; + zeDesc.type = ZE_IMAGE_TYPE_3D; + zeDesc.format.layout = ZE_IMAGE_FORMAT_LAYOUT_8_8_8_8; + zeDesc.format.type = ZE_IMAGE_FORMAT_TYPE_UINT; + zeDesc.width = 11; + zeDesc.height = 13; + zeDesc.depth = 17; + zeDesc.format.x = ZE_IMAGE_FORMAT_SWIZZLE_A; + zeDesc.format.y = ZE_IMAGE_FORMAT_SWIZZLE_0; + zeDesc.format.z = ZE_IMAGE_FORMAT_SWIZZLE_1; + zeDesc.format.w = ZE_IMAGE_FORMAT_SWIZZLE_X; + image->initialize(device, &zeDesc); + EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, copyOnlyCmdList->appendImageCopyFromMemoryExt(image->toHandle(), ©Data, &imgRegion, 0, 0, eventHandle, 0, nullptr, false)); + } + context->freeMem(alloc); } @@ -3628,6 +3648,58 @@ HWTEST2_F(InOrderCmdListTests, givenCopyOnlyInOrderModeWhenProgrammingCopyRegion EXPECT_EQ(0u, sdiCmd->getDataDword1()); } +HWTEST2_F(InOrderCmdListTests, givenCopyOnlyInOrderModeWhenProgrammingImageCopyFromMemoryExtThenSignalInOrderAllocation, IsAtLeastXeHpCore) { + using XY_COPY_BLT = typename std::remove_const::type; + using MI_STORE_DATA_IMM = typename FamilyType::MI_STORE_DATA_IMM; + + auto immCmdList = createCopyOnlyImmCmdList(); + + auto cmdStream = immCmdList->getCmdContainer().getCommandStream(); + + void *srcPtr = reinterpret_cast(0x1234); + + auto image = std::make_unique>>(); + ze_image_desc_t desc = {}; + desc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC; + desc.type = ZE_IMAGE_TYPE_3D; + desc.format.layout = ZE_IMAGE_FORMAT_LAYOUT_8_8_8_8; + desc.format.type = ZE_IMAGE_FORMAT_TYPE_UINT; + desc.width = 11; + desc.height = 13; + desc.depth = 17; + + desc.format.x = ZE_IMAGE_FORMAT_SWIZZLE_A; + desc.format.y = ZE_IMAGE_FORMAT_SWIZZLE_0; + desc.format.z = ZE_IMAGE_FORMAT_SWIZZLE_1; + desc.format.w = ZE_IMAGE_FORMAT_SWIZZLE_X; + image->initialize(device, &desc); + + immCmdList->appendImageCopyFromMemoryExt(image->toHandle(), srcPtr, nullptr, 0, 0, nullptr, 0, nullptr, false); + auto offset = cmdStream->getUsed(); + immCmdList->appendImageCopyFromMemoryExt(image->toHandle(), srcPtr, nullptr, 0, 0, nullptr, 0, nullptr, false); + + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer(cmdList, + ptrOffset(cmdStream->getCpuBase(), offset), + (cmdStream->getUsed() - offset))); + + auto copyItor = find(cmdList.begin(), cmdList.end()); + ASSERT_NE(cmdList.end(), copyItor); + + auto sdiItor = find(copyItor, cmdList.end()); + ASSERT_NE(cmdList.end(), sdiItor); + + auto sdiCmd = genCmdCast(*sdiItor); + + auto inOrderExecInfo = immCmdList->inOrderExecInfo; + uint64_t syncVa = inOrderExecInfo->isHostStorageDuplicated() ? reinterpret_cast(inOrderExecInfo->getBaseHostAddress()) : inOrderExecInfo->getBaseDeviceAddress(); + + EXPECT_EQ(syncVa, sdiCmd->getAddress()); + EXPECT_EQ(immCmdList->isQwordInOrderCounter(), sdiCmd->getStoreQword()); + EXPECT_EQ(2u, sdiCmd->getDataDword0()); + EXPECT_EQ(0u, sdiCmd->getDataDword1()); +} + HWTEST2_F(InOrderCmdListTests, givenInOrderModeWhenProgrammingAppendWaitOnEventsThenSignalSyncAllocation, IsAtLeastXeHpCore) { using MI_STORE_DATA_IMM = typename FamilyType::MI_STORE_DATA_IMM; using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;