mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
Add support for copy images by bliter
Change-Id: I0082fafb3363c6c6eb6973e5e35fa4d3ba1b6465 Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
7937da71f6
commit
89195ca4a3
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "level_zero/core/source/cmdlist/cmdlist_hw.h"
|
||||
#include "level_zero/core/source/driver/driver_handle_imp.h"
|
||||
#include "level_zero/core/source/image/image_hw.h"
|
||||
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_event.h"
|
||||
#include "level_zero/core/test/unit_tests/mocks/mock_kernel.h"
|
||||
@@ -308,12 +309,23 @@ class MockCommandList : public WhiteBox<::L0::CommandListCoreFamily<gfxCoreFamil
|
||||
appendBlitFillCalledTimes++;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
ze_result_t appendCopyImageBlit(NEO::GraphicsAllocation *src,
|
||||
NEO::GraphicsAllocation *dst,
|
||||
Vec3<size_t> srcOffsets, Vec3<size_t> dstOffsets,
|
||||
size_t srcRowPitch, size_t srcSlicePitch,
|
||||
size_t dstRowPitch, size_t dstSlicePitch,
|
||||
size_t bytesPerPixel, Vec3<size_t> copySize,
|
||||
Vec3<uint32_t> srcSize, Vec3<uint32_t> dstSize) override {
|
||||
appendCopyImageBlitCalledTimes++;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
uint32_t appendMemoryCopyKernelWithGACalledTimes = 0;
|
||||
uint32_t appendMemoryCopyBlitCalledTimes = 0;
|
||||
uint32_t appendMemoryCopyBlitRegionCalledTimes = 0;
|
||||
uint32_t appendMemoryCopyKernel2dCalledTimes = 0;
|
||||
uint32_t appendMemoryCopyKernel3dCalledTimes = 0;
|
||||
uint32_t appendBlitFillCalledTimes = 0;
|
||||
uint32_t appendCopyImageBlitCalledTimes = 0;
|
||||
};
|
||||
|
||||
using Platforms = IsAtLeastProduct<IGFX_SKYLAKE>;
|
||||
@@ -664,5 +676,78 @@ HWTEST2_F(CommandListCreate, givenCopyOnlyCommandListWhenAppenBlitFillThenCopyBl
|
||||
auto itor = find<XY_COLOR_BLT *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
}
|
||||
|
||||
using ImageSupport = IsWithinProducts<IGFX_SKYLAKE, IGFX_TIGERLAKE_LP>;
|
||||
|
||||
HWTEST2_F(CommandListCreate, givenCopyCommandListWhenCopyFromMemoryToImageThenBlitImageCopyCalled, ImageSupport) {
|
||||
MockCommandList<gfxCoreFamily> cmdList;
|
||||
cmdList.initialize(device, true);
|
||||
MockDriverHandle driverHandle;
|
||||
device->setDriverHandle(&driverHandle);
|
||||
|
||||
void *srcPtr = reinterpret_cast<void *>(0x1234);
|
||||
|
||||
ze_image_desc_t zeDesc = {};
|
||||
auto imageHW = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
|
||||
imageHW->initialize(device, &zeDesc);
|
||||
|
||||
ze_image_region_t dstRegion = {4, 4, 4, 2, 2, 2};
|
||||
cmdList.appendImageCopyFromMemory(imageHW->toHandle(), srcPtr, &dstRegion, nullptr, 0, nullptr);
|
||||
EXPECT_GT(cmdList.appendCopyImageBlitCalledTimes, 0u);
|
||||
}
|
||||
|
||||
HWTEST2_F(CommandListCreate, givenCopyCommandListWhenCopyFromImageToMemoryThenBlitImageCopyCalled, ImageSupport) {
|
||||
MockCommandList<gfxCoreFamily> cmdList;
|
||||
cmdList.initialize(device, true);
|
||||
MockDriverHandle driverHandle;
|
||||
device->setDriverHandle(&driverHandle);
|
||||
|
||||
void *dstPtr = reinterpret_cast<void *>(0x1234);
|
||||
|
||||
ze_image_desc_t zeDesc = {};
|
||||
auto imageHW = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
|
||||
imageHW->initialize(device, &zeDesc);
|
||||
|
||||
ze_image_region_t srcRegion = {4, 4, 4, 2, 2, 2};
|
||||
cmdList.appendImageCopyToMemory(dstPtr, imageHW->toHandle(), &srcRegion, nullptr, 0, nullptr);
|
||||
EXPECT_GT(cmdList.appendCopyImageBlitCalledTimes, 0u);
|
||||
}
|
||||
|
||||
HWTEST2_F(CommandListCreate, givenCopyCommandListWhenCopyFromImageToImageThenBlitImageCopyCalled, ImageSupport) {
|
||||
MockCommandList<gfxCoreFamily> cmdList;
|
||||
cmdList.initialize(device, true);
|
||||
MockDriverHandle driverHandle;
|
||||
device->setDriverHandle(&driverHandle);
|
||||
|
||||
ze_image_desc_t zeDesc = {};
|
||||
auto imageHWSrc = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
|
||||
auto imageHWDst = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
|
||||
imageHWSrc->initialize(device, &zeDesc);
|
||||
imageHWDst->initialize(device, &zeDesc);
|
||||
|
||||
ze_image_region_t srcRegion = {4, 4, 4, 2, 2, 2};
|
||||
ze_image_region_t dstRegion = {4, 4, 4, 2, 2, 2};
|
||||
cmdList.appendImageCopyRegion(imageHWDst->toHandle(), imageHWSrc->toHandle(), &dstRegion, &srcRegion, nullptr, 0, nullptr);
|
||||
EXPECT_GT(cmdList.appendCopyImageBlitCalledTimes, 0u);
|
||||
}
|
||||
|
||||
HWTEST2_F(CommandListCreate, givenCopyCommandListWhenCopyFromImagBlitThenCommandAddedToStream, ImageSupport) {
|
||||
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
|
||||
using XY_COPY_BLT = typename GfxFamily::XY_COPY_BLT;
|
||||
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, true));
|
||||
ze_image_desc_t zeDesc = {};
|
||||
auto imageHWSrc = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
|
||||
auto imageHWDst = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
|
||||
imageHWSrc->initialize(device, &zeDesc);
|
||||
imageHWDst->initialize(device, &zeDesc);
|
||||
|
||||
commandList->appendImageCopyRegion(imageHWDst->toHandle(), imageHWSrc->toHandle(), nullptr, nullptr, nullptr, 0, nullptr);
|
||||
GenCmdList cmdList;
|
||||
ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer(
|
||||
cmdList, ptrOffset(commandList->commandContainer.getCommandStream()->getCpuBase(), 0), commandList->commandContainer.getCommandStream()->getUsed()));
|
||||
auto itor = find<XY_COPY_BLT *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
||||
Reference in New Issue
Block a user