fix: correct memory copy region

Resolves:  NEO-11103

Signed-off-by: John Falkowski <john.falkowski@intel.com>
This commit is contained in:
John Falkowski 2024-04-09 18:53:16 +00:00 committed by Compute-Runtime-Automation
parent 15b59b145e
commit 10c7a9552d
2 changed files with 51 additions and 1 deletions

View File

@ -1714,7 +1714,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMemoryCopyRegion(void *d
{srcRegion->width, srcRegion->height, srcRegion->depth},
srcPitch, srcSlicePitch, dstPitch, dstSlicePitch, srcSize3, dstSize3,
signalEvent, numWaitEvents, phWaitEvents, relaxedOrderingDispatch);
} else if (srcRegion->depth > 1) {
} else if ((srcRegion->depth > 1) || (srcRegion->originZ != 0) || (dstRegion->originZ != 0)) {
result = this->appendMemoryCopyKernel3d(&dstAllocationStruct, &srcAllocationStruct, Builtin::copyBufferRectBytes3d,
dstRegion, dstPitch, dstSlicePitch, dstAllocationStruct.offset,
srcRegion, srcPitch, srcSlicePitch, srcAllocationStruct.offset,

View File

@ -582,6 +582,56 @@ HWTEST2_F(CommandListTest,
context->freeMem(dstBuffer);
}
HWTEST2_F(CommandListTest,
givenComputeCommandListAndRegionMemoryCopyFrom2dSourceImageto3dDestImageThenBuiltinFlagIsSetAndDestinationAllocSystemFlagNotSet, IsAtLeastSkl) {
auto commandList = std::make_unique<WhiteBox<::L0::CommandListCoreFamily<gfxCoreFamily>>>();
commandList->initialize(device, NEO::EngineGroupType::renderCompute, 0u);
constexpr size_t size = 4096u;
constexpr size_t alignment = 4096u;
void *dstBuffer = nullptr;
ze_device_mem_alloc_desc_t deviceDesc = {};
auto result = context->allocDeviceMem(device->toHandle(),
&deviceDesc,
size, alignment, &dstBuffer);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
void *srcPtr = reinterpret_cast<void *>(0x1234);
ze_copy_region_t dstRegion = {4, 4, 1, 2, 2, 1};
ze_copy_region_t srcRegion = {4, 4, 0, 2, 2, 1};
commandList->appendMemoryCopyRegion(dstBuffer, &dstRegion, 0, 0, srcPtr, &srcRegion, 0, 0, nullptr, 0, nullptr, false, false);
EXPECT_TRUE(commandList->usedKernelLaunchParams.isBuiltInKernel);
EXPECT_FALSE(commandList->usedKernelLaunchParams.isDestinationAllocationInSystemMemory);
context->freeMem(dstBuffer);
}
HWTEST2_F(CommandListTest,
givenComputeCommandListAndRegionMemoryCopyFrom3dSourceImageto2dDestImageThenBuiltinFlagIsSetAndDestinationAllocSystemFlagNotSet, IsAtLeastSkl) {
auto commandList = std::make_unique<WhiteBox<::L0::CommandListCoreFamily<gfxCoreFamily>>>();
commandList->initialize(device, NEO::EngineGroupType::renderCompute, 0u);
constexpr size_t size = 4096u;
constexpr size_t alignment = 4096u;
void *dstBuffer = nullptr;
ze_device_mem_alloc_desc_t deviceDesc = {};
auto result = context->allocDeviceMem(device->toHandle(),
&deviceDesc,
size, alignment, &dstBuffer);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
void *srcPtr = reinterpret_cast<void *>(0x1234);
ze_copy_region_t dstRegion = {4, 4, 0, 2, 2, 1};
ze_copy_region_t srcRegion = {4, 4, 1, 2, 2, 1};
commandList->appendMemoryCopyRegion(dstBuffer, &dstRegion, 0, 0, srcPtr, &srcRegion, 0, 0, nullptr, 0, nullptr, false, false);
EXPECT_TRUE(commandList->usedKernelLaunchParams.isBuiltInKernel);
EXPECT_FALSE(commandList->usedKernelLaunchParams.isDestinationAllocationInSystemMemory);
context->freeMem(dstBuffer);
}
HWTEST2_F(CommandListTest,
givenComputeCommandListAnd3dRegionWhenMemoryCopyRegionInExternalHostAllocationCalledThenBuiltinAndDestinationAllocSystemFlagIsSet, IsAtLeastSkl) {
auto commandList = std::make_unique<WhiteBox<::L0::CommandListCoreFamily<gfxCoreFamily>>>();