feature: system allocator support for image APIs

Related-To: NEO-15461

Signed-off-by: Young Jin Yoon <young.jin.yoon@intel.com>
Signed-off-by: Narendra Bagria <narendra.bagria@intel.com>
This commit is contained in:
Narendra Bagria
2025-08-21 17:20:14 +00:00
committed by Compute-Runtime-Automation
parent 1197ec47bc
commit 001f3a3816
15 changed files with 736 additions and 93 deletions

View File

@@ -286,8 +286,8 @@ struct CommandListCoreFamily : public CommandListImp {
uint32_t numWaitEvents, uint32_t numWaitEvents,
ze_event_handle_t *phWaitEvents, CmdListMemoryCopyParams &memoryCopyParams); ze_event_handle_t *phWaitEvents, CmdListMemoryCopyParams &memoryCopyParams);
MOCKABLE_VIRTUAL ze_result_t appendCopyImageBlit(NEO::GraphicsAllocation *src, MOCKABLE_VIRTUAL ze_result_t appendCopyImageBlit(uintptr_t srcPtr, NEO::GraphicsAllocation *src,
NEO::GraphicsAllocation *dst, uintptr_t dstPtr, NEO::GraphicsAllocation *dst,
const Vec3<size_t> &srcOffsets, const Vec3<size_t> &dstOffsets, const Vec3<size_t> &srcOffsets, const Vec3<size_t> &dstOffsets,
size_t srcRowPitch, size_t srcSlicePitch, size_t srcRowPitch, size_t srcSlicePitch,
size_t dstRowPitch, size_t dstSlicePitch, size_t dstRowPitch, size_t dstSlicePitch,
@@ -416,7 +416,8 @@ struct CommandListCoreFamily : public CommandListImp {
bool singleEventPacketRequired(bool inputSinglePacketEventRequest) const; bool singleEventPacketRequired(bool inputSinglePacketEventRequest) const;
void programEventL3Flush(Event *event); void programEventL3Flush(Event *event);
virtual ze_result_t flushInOrderCounterSignal(bool waitOnInOrderCounterRequired) { return ZE_RESULT_SUCCESS; }; virtual ze_result_t flushInOrderCounterSignal(bool waitOnInOrderCounterRequired) { return ZE_RESULT_SUCCESS; };
bool isCopyOffloadAllowed(const NEO::GraphicsAllocation &srcAllocation, const NEO::GraphicsAllocation &dstAllocation) const; bool isCopyOffloadAllowed(const NEO::GraphicsAllocation *srcAllocation, const NEO::GraphicsAllocation *dstAllocation) const;
bool isSharedSystemEnabled() const;
void setAdditionalKernelLaunchParams(CmdListKernelLaunchParams &launchParams, Kernel &kernel) const; void setAdditionalKernelLaunchParams(CmdListKernelLaunchParams &launchParams, Kernel &kernel) const;
void dispatchInOrderPostOperationBarrier(Event *signalOperation, bool dcFlushRequired, bool copyOperation); void dispatchInOrderPostOperationBarrier(Event *signalOperation, bool dcFlushRequired, bool copyOperation);
NEO::GraphicsAllocation *getDeviceCounterAllocForResidency(NEO::GraphicsAllocation *counterDeviceAlloc); NEO::GraphicsAllocation *getDeviceCounterAllocForResidency(NEO::GraphicsAllocation *counterDeviceAlloc);

View File

@@ -814,6 +814,8 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendImageCopyFromMemoryExt(z
return ZE_RESULT_ERROR_INVALID_NULL_POINTER; return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
} }
bool sharedSystemEnabled = isSharedSystemEnabled();
auto image = Image::fromHandle(hDstImage); auto image = Image::fromHandle(hDstImage);
auto bytesPerPixel = static_cast<uint32_t>(image->getImageInfo().surfaceFormat->imageElementSizeInBytes); auto bytesPerPixel = static_cast<uint32_t>(image->getImageInfo().surfaceFormat->imageElementSizeInBytes);
Vec3<size_t> imgSize = {image->getImageDesc().width, Vec3<size_t> imgSize = {image->getImageDesc().width,
@@ -857,13 +859,17 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendImageCopyFromMemoryExt(z
uint64_t bufferSize = getInputBufferSize(image->getImageInfo().imgDesc.imageType, srcRowPitch, srcSlicePitch, pDstRegion); uint64_t bufferSize = getInputBufferSize(image->getImageInfo().imgDesc.imageType, srcRowPitch, srcSlicePitch, pDstRegion);
auto allocationStruct = getAlignedAllocationData(this->device, false, srcPtr, bufferSize, true, false); auto allocationStruct = getAlignedAllocationData(this->device, sharedSystemEnabled, srcPtr, bufferSize, true, false);
if (allocationStruct.alloc == nullptr) { if (allocationStruct.alloc == nullptr && sharedSystemEnabled == false) {
return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY; return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY;
} }
memoryCopyParams.taskCountUpdateRequired |= CommandList::isExternalHostPtrAlloc(allocationStruct.alloc); memoryCopyParams.taskCountUpdateRequired |= CommandList::isExternalHostPtrAlloc(allocationStruct.alloc);
if ((allocationStruct.alloc == nullptr) && (NEO::debugManager.flags.EmitMemAdvisePriorToCopyForNonUsm.get() == 1)) {
appendMemAdvise(device, reinterpret_cast<void *>(allocationStruct.alignedAllocationPtr), bufferSize, static_cast<ze_memory_advice_t>(ZE_MEMORY_ADVICE_SET_SYSTEM_MEMORY_PREFERRED_LOCATION));
}
DriverHandleImp *driverHandle = static_cast<DriverHandleImp *>(device->getDriverHandle()); DriverHandleImp *driverHandle = static_cast<DriverHandleImp *>(device->getDriverHandle());
if (driverHandle->isRemoteImageNeeded(image, device)) { if (driverHandle->isRemoteImageNeeded(image, device)) {
L0::Image *peerImage = nullptr; L0::Image *peerImage = nullptr;
@@ -875,7 +881,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendImageCopyFromMemoryExt(z
image = peerImage; image = peerImage;
} }
memoryCopyParams.copyOffloadAllowed = isCopyOffloadAllowed(*allocationStruct.alloc, *image->getAllocation()); memoryCopyParams.copyOffloadAllowed = isCopyOffloadAllowed(allocationStruct.alloc, image->getAllocation());
if (isCopyOnly(memoryCopyParams.copyOffloadAllowed)) { if (isCopyOnly(memoryCopyParams.copyOffloadAllowed)) {
if ((bytesPerPixel == 3) || (bytesPerPixel == 6) || image->isMimickedImage()) { if ((bytesPerPixel == 3) || (bytesPerPixel == 6) || image->isMimickedImage()) {
@@ -883,7 +889,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendImageCopyFromMemoryExt(z
} }
size_t imgRowPitch = image->getImageInfo().rowPitch; size_t imgRowPitch = image->getImageInfo().rowPitch;
size_t imgSlicePitch = image->getImageInfo().slicePitch; size_t imgSlicePitch = image->getImageInfo().slicePitch;
auto status = appendCopyImageBlit(allocationStruct.alloc, image->getAllocation(), auto status = appendCopyImageBlit(allocationStruct.alignedAllocationPtr, allocationStruct.alloc, image->getAllocation()->getGpuAddress(), image->getAllocation(),
{0, 0, 0}, {pDstRegion->originX, pDstRegion->originY, pDstRegion->originZ}, srcRowPitch, srcSlicePitch, {0, 0, 0}, {pDstRegion->originX, pDstRegion->originY, pDstRegion->originZ}, srcRowPitch, srcSlicePitch,
imgRowPitch, imgSlicePitch, bytesPerPixel, {pDstRegion->width, pDstRegion->height, pDstRegion->depth}, {pDstRegion->width, pDstRegion->height, pDstRegion->depth}, imgSize, imgRowPitch, imgSlicePitch, bytesPerPixel, {pDstRegion->width, pDstRegion->height, pDstRegion->depth}, {pDstRegion->width, pDstRegion->height, pDstRegion->depth}, imgSize,
event, numWaitEvents, phWaitEvents, memoryCopyParams); event, numWaitEvents, phWaitEvents, memoryCopyParams);
@@ -926,9 +932,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendImageCopyFromMemoryExt(z
auto lock = device->getBuiltinFunctionsLib()->obtainUniqueOwnership(); auto lock = device->getBuiltinFunctionsLib()->obtainUniqueOwnership();
Kernel *builtinKernel = device->getBuiltinFunctionsLib()->getImageFunction(builtInType); Kernel *builtinKernel = device->getBuiltinFunctionsLib()->getImageFunction(builtInType);
builtinKernel->setArgBufferWithAlloc(0u, allocationStruct.alignedAllocationPtr, builtinSetArgCopy(builtinKernel, 0, reinterpret_cast<void *>(&allocationStruct.alignedAllocationPtr), allocationStruct.alloc);
allocationStruct.alloc,
nullptr);
builtinKernel->setArgRedescribedImage(1u, image->toHandle(), false); builtinKernel->setArgRedescribedImage(1u, image->toHandle(), false);
builtinKernel->setArgumentValue(2u, sizeof(size_t), &allocationStruct.offset); builtinKernel->setArgumentValue(2u, sizeof(size_t), &allocationStruct.offset);
@@ -1014,6 +1018,8 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendImageCopyToMemoryExt(voi
return ZE_RESULT_ERROR_INVALID_NULL_HANDLE; return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
} }
bool sharedSystemEnabled = isSharedSystemEnabled();
auto image = Image::fromHandle(hSrcImage); auto image = Image::fromHandle(hSrcImage);
auto bytesPerPixel = static_cast<uint32_t>(image->getImageInfo().surfaceFormat->imageElementSizeInBytes); auto bytesPerPixel = static_cast<uint32_t>(image->getImageInfo().surfaceFormat->imageElementSizeInBytes);
Vec3<size_t> imgSize = {image->getImageDesc().width, Vec3<size_t> imgSize = {image->getImageDesc().width,
@@ -1057,13 +1063,17 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendImageCopyToMemoryExt(voi
uint64_t bufferSize = getInputBufferSize(image->getImageInfo().imgDesc.imageType, destRowPitch, destSlicePitch, pSrcRegion); uint64_t bufferSize = getInputBufferSize(image->getImageInfo().imgDesc.imageType, destRowPitch, destSlicePitch, pSrcRegion);
auto allocationStruct = getAlignedAllocationData(this->device, false, dstPtr, bufferSize, false, false); auto allocationStruct = getAlignedAllocationData(this->device, sharedSystemEnabled, dstPtr, bufferSize, false, false);
if (allocationStruct.alloc == nullptr) { if (allocationStruct.alloc == nullptr && sharedSystemEnabled == false) {
return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY; return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY;
} }
memoryCopyParams.taskCountUpdateRequired |= CommandList::isExternalHostPtrAlloc(allocationStruct.alloc); memoryCopyParams.taskCountUpdateRequired |= CommandList::isExternalHostPtrAlloc(allocationStruct.alloc);
if ((allocationStruct.alloc == nullptr) && (NEO::debugManager.flags.EmitMemAdvisePriorToCopyForNonUsm.get() == 1)) {
appendMemAdvise(device, reinterpret_cast<void *>(allocationStruct.alignedAllocationPtr), bufferSize, static_cast<ze_memory_advice_t>(ZE_MEMORY_ADVICE_SET_SYSTEM_MEMORY_PREFERRED_LOCATION));
}
DriverHandleImp *driverHandle = static_cast<DriverHandleImp *>(device->getDriverHandle()); DriverHandleImp *driverHandle = static_cast<DriverHandleImp *>(device->getDriverHandle());
if (driverHandle->isRemoteImageNeeded(image, device)) { if (driverHandle->isRemoteImageNeeded(image, device)) {
L0::Image *peerImage = nullptr; L0::Image *peerImage = nullptr;
@@ -1075,7 +1085,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendImageCopyToMemoryExt(voi
image = peerImage; image = peerImage;
} }
memoryCopyParams.copyOffloadAllowed = isCopyOffloadAllowed(*image->getAllocation(), *allocationStruct.alloc); memoryCopyParams.copyOffloadAllowed = isCopyOffloadAllowed(image->getAllocation(), allocationStruct.alloc);
if (isCopyOnly(memoryCopyParams.copyOffloadAllowed)) { if (isCopyOnly(memoryCopyParams.copyOffloadAllowed)) {
if ((bytesPerPixel == 3) || (bytesPerPixel == 6) || image->isMimickedImage()) { if ((bytesPerPixel == 3) || (bytesPerPixel == 6) || image->isMimickedImage()) {
@@ -1083,7 +1093,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendImageCopyToMemoryExt(voi
} }
size_t imgRowPitch = image->getImageInfo().rowPitch; size_t imgRowPitch = image->getImageInfo().rowPitch;
size_t imgSlicePitch = image->getImageInfo().slicePitch; size_t imgSlicePitch = image->getImageInfo().slicePitch;
auto status = appendCopyImageBlit(image->getAllocation(), allocationStruct.alloc, auto status = appendCopyImageBlit(image->getAllocation()->getGpuAddress(), image->getAllocation(), allocationStruct.alignedAllocationPtr, allocationStruct.alloc,
{pSrcRegion->originX, pSrcRegion->originY, pSrcRegion->originZ}, {0, 0, 0}, imgRowPitch, imgSlicePitch, {pSrcRegion->originX, pSrcRegion->originY, pSrcRegion->originZ}, {0, 0, 0}, imgRowPitch, imgSlicePitch,
destRowPitch, destSlicePitch, bytesPerPixel, {pSrcRegion->width, pSrcRegion->height, pSrcRegion->depth}, destRowPitch, destSlicePitch, bytesPerPixel, {pSrcRegion->width, pSrcRegion->height, pSrcRegion->depth},
imgSize, {pSrcRegion->width, pSrcRegion->height, pSrcRegion->depth}, event, numWaitEvents, phWaitEvents, memoryCopyParams); imgSize, {pSrcRegion->width, pSrcRegion->height, pSrcRegion->depth}, event, numWaitEvents, phWaitEvents, memoryCopyParams);
@@ -1137,9 +1147,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendImageCopyToMemoryExt(voi
Kernel *builtinKernel = device->getBuiltinFunctionsLib()->getImageFunction(builtInType); Kernel *builtinKernel = device->getBuiltinFunctionsLib()->getImageFunction(builtInType);
builtinKernel->setArgRedescribedImage(0u, image->toHandle(), false); builtinKernel->setArgRedescribedImage(0u, image->toHandle(), false);
builtinKernel->setArgBufferWithAlloc(1u, allocationStruct.alignedAllocationPtr, builtinSetArgCopy(builtinKernel, 1, reinterpret_cast<void *>(&allocationStruct.alignedAllocationPtr), allocationStruct.alloc);
allocationStruct.alloc,
nullptr);
uint32_t origin[] = {pSrcRegion->originX, uint32_t origin[] = {pSrcRegion->originX,
pSrcRegion->originY, pSrcRegion->originY,
pSrcRegion->originZ, pSrcRegion->originZ,
@@ -1190,15 +1198,20 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendImageCopyToMemoryExt(voi
ze_group_count_t kernelArgs{pSrcRegion->width / groupSizeX, pSrcRegion->height / groupSizeY, ze_group_count_t kernelArgs{pSrcRegion->width / groupSizeX, pSrcRegion->height / groupSizeY,
pSrcRegion->depth / groupSizeZ}; pSrcRegion->depth / groupSizeZ};
auto dstAllocationType = allocationStruct.alloc->getAllocationType();
CmdListKernelLaunchParams launchParams = {}; CmdListKernelLaunchParams launchParams = {};
launchParams.isBuiltInKernel = true; launchParams.isBuiltInKernel = true;
launchParams.isDestinationAllocationInSystemMemory = if (allocationStruct.alloc == nullptr) {
(dstAllocationType == NEO::AllocationType::bufferHostMemory) || launchParams.isDestinationAllocationInSystemMemory = true;
(dstAllocationType == NEO::AllocationType::externalHostPtr); launchParams.isDestinationAllocationImported = false;
} else {
auto dstAllocationType = allocationStruct.alloc->getAllocationType();
launchParams.isDestinationAllocationInSystemMemory =
(dstAllocationType == NEO::AllocationType::bufferHostMemory) ||
(dstAllocationType == NEO::AllocationType::externalHostPtr);
if constexpr (checkIfAllocationImportedRequired()) { if constexpr (checkIfAllocationImportedRequired()) {
launchParams.isDestinationAllocationImported = this->isAllocationImported(allocationStruct.alloc, device->getDriverHandle()->getSvmAllocsManager()); launchParams.isDestinationAllocationImported = this->isAllocationImported(allocationStruct.alloc, device->getDriverHandle()->getSvmAllocsManager());
}
} }
launchParams.relaxedOrderingDispatch = memoryCopyParams.relaxedOrderingDispatch; launchParams.relaxedOrderingDispatch = memoryCopyParams.relaxedOrderingDispatch;
ret = CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernel(builtinKernel->toHandle(), kernelArgs, ret = CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernel(builtinKernel->toHandle(), kernelArgs,
@@ -1281,7 +1294,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendImageCopyRegion(ze_image
srcImage = peerImage; srcImage = peerImage;
} }
memoryCopyParams.copyOffloadAllowed = isCopyOffloadAllowed(*srcImage->getAllocation(), *dstImage->getAllocation()); memoryCopyParams.copyOffloadAllowed = isCopyOffloadAllowed(srcImage->getAllocation(), dstImage->getAllocation());
if (isCopyOnly(memoryCopyParams.copyOffloadAllowed)) { if (isCopyOnly(memoryCopyParams.copyOffloadAllowed)) {
auto bytesPerPixel = static_cast<uint32_t>(srcImage->getImageInfo().surfaceFormat->imageElementSizeInBytes); auto bytesPerPixel = static_cast<uint32_t>(srcImage->getImageInfo().surfaceFormat->imageElementSizeInBytes);
@@ -1300,7 +1313,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendImageCopyRegion(ze_image
auto dstSlicePitch = auto dstSlicePitch =
(dstImage->getImageInfo().imgDesc.imageType == NEO::ImageType::image1DArray ? 1 : dstRegion.height) * dstRowPitch; (dstImage->getImageInfo().imgDesc.imageType == NEO::ImageType::image1DArray ? 1 : dstRegion.height) * dstRowPitch;
auto status = appendCopyImageBlit(srcImage->getAllocation(), dstImage->getAllocation(), auto status = appendCopyImageBlit(srcImage->getAllocation()->getGpuAddress(), srcImage->getAllocation(), dstImage->getAllocation()->getGpuAddress(), dstImage->getAllocation(),
{srcRegion.originX, srcRegion.originY, srcRegion.originZ}, {dstRegion.originX, dstRegion.originY, dstRegion.originZ}, srcRowPitch, srcSlicePitch, {srcRegion.originX, srcRegion.originY, srcRegion.originZ}, {dstRegion.originX, dstRegion.originY, dstRegion.originZ}, srcRowPitch, srcSlicePitch,
dstRowPitch, dstSlicePitch, bytesPerPixel, {srcRegion.width, srcRegion.height, srcRegion.depth}, srcImgSize, dstImgSize, dstRowPitch, dstSlicePitch, bytesPerPixel, {srcRegion.width, srcRegion.height, srcRegion.depth}, srcImgSize, dstImgSize,
event, numWaitEvents, phWaitEvents, memoryCopyParams); event, numWaitEvents, phWaitEvents, memoryCopyParams);
@@ -1676,7 +1689,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMemoryCopyBlitRegion(Ali
} }
template <GFXCORE_FAMILY gfxCoreFamily> template <GFXCORE_FAMILY gfxCoreFamily>
ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendCopyImageBlit(NEO::GraphicsAllocation *src, ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendCopyImageBlit(uintptr_t srcPtr,
NEO::GraphicsAllocation *src,
uintptr_t dstPtr,
NEO::GraphicsAllocation *dst, NEO::GraphicsAllocation *dst,
const Vec3<size_t> &srcOffsets, const Vec3<size_t> &dstOffsets, const Vec3<size_t> &srcOffsets, const Vec3<size_t> &dstOffsets,
size_t srcRowPitch, size_t srcSlicePitch, size_t srcRowPitch, size_t srcSlicePitch,
@@ -1698,9 +1713,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendCopyImageBlit(NEO::Graph
auto clearColorAllocation = device->getNEODevice()->getDefaultEngine().commandStreamReceiver->getClearColorAllocation(); auto clearColorAllocation = device->getNEODevice()->getDefaultEngine().commandStreamReceiver->getClearColorAllocation();
auto blitProperties = NEO::BlitProperties::constructPropertiesForCopy(dst, src, auto blitProperties = NEO::BlitProperties::constructPropertiesForSystemCopy(dst, src, dstPtr, srcPtr,
dstOffsets, srcOffsets, copySize, srcRowPitch, srcSlicePitch, dstOffsets, srcOffsets, copySize, srcRowPitch, srcSlicePitch,
dstRowPitch, dstSlicePitch, clearColorAllocation); dstRowPitch, dstSlicePitch, clearColorAllocation);
blitProperties.computeStreamPartitionCount = this->partitionCount; blitProperties.computeStreamPartitionCount = this->partitionCount;
blitProperties.highPriority = isHighPriorityImmediateCmdList(); blitProperties.highPriority = isHighPriorityImmediateCmdList();
blitProperties.bytesPerPixel = bytesPerPixel; blitProperties.bytesPerPixel = bytesPerPixel;
@@ -1796,8 +1811,17 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendPageFaultCopy(NEO::Graph
} }
template <GFXCORE_FAMILY gfxCoreFamily> template <GFXCORE_FAMILY gfxCoreFamily>
bool CommandListCoreFamily<gfxCoreFamily>::isCopyOffloadAllowed(const NEO::GraphicsAllocation &srcAllocation, const NEO::GraphicsAllocation &dstAllocation) const { bool CommandListCoreFamily<gfxCoreFamily>::isCopyOffloadAllowed(const NEO::GraphicsAllocation *srcAllocation, const NEO::GraphicsAllocation *dstAllocation) const {
return !(srcAllocation.isAllocatedInLocalMemoryPool() && dstAllocation.isAllocatedInLocalMemoryPool()) && isCopyOffloadEnabled(); if (srcAllocation == nullptr || dstAllocation == nullptr) {
return isCopyOffloadEnabled();
}
return !(srcAllocation->isAllocatedInLocalMemoryPool() && dstAllocation->isAllocatedInLocalMemoryPool()) && isCopyOffloadEnabled();
}
template <GFXCORE_FAMILY gfxCoreFamily>
bool CommandListCoreFamily<gfxCoreFamily>::isSharedSystemEnabled() const {
NEO::Device *neoDevice = device->getNEODevice();
return neoDevice->areSharedSystemAllocationsAllowed() && (NEO::debugManager.flags.TreatNonUsmForTransfersAsSharedSystem.get() == 1);
} }
template <GFXCORE_FAMILY gfxCoreFamily> template <GFXCORE_FAMILY gfxCoreFamily>
@@ -1810,7 +1834,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMemoryCopy(void *dstptr,
CmdListMemoryCopyParams &memoryCopyParams) { CmdListMemoryCopyParams &memoryCopyParams) {
NEO::Device *neoDevice = device->getNEODevice(); NEO::Device *neoDevice = device->getNEODevice();
bool sharedSystemEnabled = ((neoDevice->areSharedSystemAllocationsAllowed()) && (NEO::debugManager.flags.TreatNonUsmForTransfersAsSharedSystem.get() == 1)); bool sharedSystemEnabled = isSharedSystemEnabled();
uint32_t callId = 0; uint32_t callId = 0;
if (NEO::debugManager.flags.EnableSWTags.get()) { if (NEO::debugManager.flags.EnableSWTags.get()) {
@@ -1842,11 +1866,8 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMemoryCopy(void *dstptr,
appendMemAdvise(device, reinterpret_cast<void *>(srcAllocationStruct.alignedAllocationPtr), size, static_cast<ze_memory_advice_t>(ZE_MEMORY_ADVICE_SET_SYSTEM_MEMORY_PREFERRED_LOCATION)); appendMemAdvise(device, reinterpret_cast<void *>(srcAllocationStruct.alignedAllocationPtr), size, static_cast<ze_memory_advice_t>(ZE_MEMORY_ADVICE_SET_SYSTEM_MEMORY_PREFERRED_LOCATION));
} }
if (dstAllocationStruct.alloc == nullptr || srcAllocationStruct.alloc == nullptr) { memoryCopyParams.copyOffloadAllowed = isCopyOffloadAllowed(srcAllocationStruct.alloc, dstAllocationStruct.alloc);
memoryCopyParams.copyOffloadAllowed = true;
} else {
memoryCopyParams.copyOffloadAllowed = isCopyOffloadAllowed(*srcAllocationStruct.alloc, *dstAllocationStruct.alloc);
}
const bool isCopyOnlyEnabled = isCopyOnly(memoryCopyParams.copyOffloadAllowed); const bool isCopyOnlyEnabled = isCopyOnly(memoryCopyParams.copyOffloadAllowed);
const bool inOrderCopyOnlySignalingAllowed = this->isInOrderExecutionEnabled() && !memoryCopyParams.forceDisableCopyOnlyInOrderSignaling && isCopyOnlyEnabled; const bool inOrderCopyOnlySignalingAllowed = this->isInOrderExecutionEnabled() && !memoryCopyParams.forceDisableCopyOnlyInOrderSignaling && isCopyOnlyEnabled;
@@ -2092,7 +2113,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMemoryCopyRegion(void *d
CommandList::isExternalHostPtrAlloc(srcAllocationStruct.alloc); CommandList::isExternalHostPtrAlloc(srcAllocationStruct.alloc);
} }
memoryCopyParams.copyOffloadAllowed = isCopyOffloadAllowed(*srcAllocationStruct.alloc, *dstAllocationStruct.alloc); memoryCopyParams.copyOffloadAllowed = isCopyOffloadAllowed(srcAllocationStruct.alloc, dstAllocationStruct.alloc);
const bool isCopyOnlyEnabled = isCopyOnly(memoryCopyParams.copyOffloadAllowed); const bool isCopyOnlyEnabled = isCopyOnly(memoryCopyParams.copyOffloadAllowed);
const bool inOrderCopyOnlySignalingAllowed = this->isInOrderExecutionEnabled() && !memoryCopyParams.forceDisableCopyOnlyInOrderSignaling && isCopyOnlyEnabled; const bool inOrderCopyOnlySignalingAllowed = this->isInOrderExecutionEnabled() && !memoryCopyParams.forceDisableCopyOnlyInOrderSignaling && isCopyOnlyEnabled;
@@ -2383,7 +2404,7 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMemoryFill(void *ptr,
memoryCopyParams.copyOffloadAllowed = isCopyOffloadEnabled() && (patternSize <= this->maxFillPatternSizeForCopyEngine); memoryCopyParams.copyOffloadAllowed = isCopyOffloadEnabled() && (patternSize <= this->maxFillPatternSizeForCopyEngine);
NEO::Device *neoDevice = device->getNEODevice(); NEO::Device *neoDevice = device->getNEODevice();
bool sharedSystemEnabled = ((neoDevice->areSharedSystemAllocationsAllowed()) && (NEO::debugManager.flags.TreatNonUsmForTransfersAsSharedSystem.get() == 1)); bool sharedSystemEnabled = isSharedSystemEnabled();
uint32_t callId = 0; uint32_t callId = 0;
if (NEO::debugManager.flags.EnableSWTags.get()) { if (NEO::debugManager.flags.EnableSWTags.get()) {
callId = neoDevice->getRootDeviceEnvironment().tagsManager->incrementAndGetCurrentCallCount(); callId = neoDevice->getRootDeviceEnvironment().tagsManager->incrementAndGetCurrentCallCount();

View File

@@ -141,8 +141,8 @@ class MockCommandListHw : public WhiteBox<::L0::CommandListCoreFamily<gfxCoreFam
} }
return ZE_RESULT_SUCCESS; return ZE_RESULT_SUCCESS;
} }
ze_result_t appendCopyImageBlit(NEO::GraphicsAllocation *src, ze_result_t appendCopyImageBlit(uintptr_t srcPtr, NEO::GraphicsAllocation *src,
NEO::GraphicsAllocation *dst, uintptr_t dstPtr, NEO::GraphicsAllocation *dst,
const Vec3<size_t> &srcOffsets, const Vec3<size_t> &dstOffsets, const Vec3<size_t> &srcOffsets, const Vec3<size_t> &dstOffsets,
size_t srcRowPitch, size_t srcSlicePitch, size_t srcRowPitch, size_t srcSlicePitch,
size_t dstRowPitch, size_t dstSlicePitch, size_t dstRowPitch, size_t dstSlicePitch,
@@ -1682,6 +1682,328 @@ HWTEST_F(CommandListAppendMemoryCopyBlit, whenAppendMemoryCopyBlitIsAppendedAndN
EXPECT_NE(firstBatchBufferAllocation, secondBatchBufferAllocation); EXPECT_NE(firstBatchBufferAllocation, secondBatchBufferAllocation);
} }
struct CommandListAppendImage : Test<CommandListFixture> {
CmdListMemoryCopyParams copyParams = {};
};
HWTEST2_F(CommandListAppendImage, givenCommandListWhenAppendImageCopyFromMemoryIsCalledWithNullGraphicsAllocationAndSharedSystemNotEnabledThenErrorIsReturned, IsAtLeastXe2HpgCore) {
DebugManagerStateRestore restore;
debugManager.flags.EmitMemAdvisePriorToCopyForNonUsm.set(1);
auto commandList = std::make_unique<MockCommandListHw<FamilyType::gfxCoreFamily>>();
commandList->failAlignedAlloc = true;
commandList->initialize(device, NEO::EngineGroupType::copy, 0u);
ASSERT_EQ(ZE_RESULT_SUCCESS, commandList->initialize(device, NEO::EngineGroupType::copy, 0u));
void *srcPtr = reinterpret_cast<void *>(0x1234);
ze_image_desc_t zeDesc = {};
zeDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
auto image = std::make_unique<WhiteBox<::L0::ImageCoreFamily<FamilyType::gfxCoreFamily>>>();
image->initialize(device, &zeDesc);
EXPECT_EQ(ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY, commandList->appendImageCopyFromMemory(image->toHandle(), srcPtr, nullptr, nullptr, 0, nullptr, copyParams));
}
HWTEST2_F(CommandListAppendImage, givenCommandListWhenAppendImageCopyFromMemoryIsCalledWithNullGraphicsAllocationAndSharedSystemEnabledThenSuccessIsReturned, IsAtLeastXe2HpgCore) {
DebugManagerStateRestore restore;
debugManager.flags.EnableSharedSystemUsmSupport.set(1);
debugManager.flags.TreatNonUsmForTransfersAsSharedSystem.set(1);
debugManager.flags.EmitMemAdvisePriorToCopyForNonUsm.set(1);
auto commandList = std::make_unique<MockCommandListHw<FamilyType::gfxCoreFamily>>();
commandList->failAlignedAlloc = true;
commandList->initialize(device, NEO::EngineGroupType::copy, 0u);
ASSERT_EQ(ZE_RESULT_SUCCESS, commandList->initialize(device, NEO::EngineGroupType::copy, 0u));
auto &hwInfo = *device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo();
VariableBackup<uint64_t> sharedSystemMemCapabilities{&hwInfo.capabilityTable.sharedSystemMemCapabilities};
sharedSystemMemCapabilities = 0xf;
void *srcPtr = reinterpret_cast<void *>(0x1234);
ze_image_desc_t zeDesc = {};
zeDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
auto image = std::make_unique<WhiteBox<::L0::ImageCoreFamily<FamilyType::gfxCoreFamily>>>();
image->initialize(device, &zeDesc);
EXPECT_EQ(ZE_RESULT_SUCCESS, commandList->appendImageCopyFromMemory(image->toHandle(), srcPtr, nullptr, nullptr, 0, nullptr, copyParams));
}
HWTEST2_F(CommandListAppendImage, givenCommandListWhenAppendImageCopyFromMemoryIsCalledWithValidGraphicsAllocationThenSuccessIsReturned, IsAtLeastXe2HpgCore) {
DebugManagerStateRestore restore;
debugManager.flags.EmitMemAdvisePriorToCopyForNonUsm.set(1);
auto commandList = std::make_unique<MockCommandListHw<FamilyType::gfxCoreFamily>>();
commandList->failAlignedAlloc = false;
commandList->initialize(device, NEO::EngineGroupType::copy, 0u);
ASSERT_EQ(ZE_RESULT_SUCCESS, commandList->initialize(device, NEO::EngineGroupType::copy, 0u));
void *srcPtr = reinterpret_cast<void *>(0x1234);
ze_image_desc_t zeDesc = {};
zeDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
auto image = std::make_unique<WhiteBox<::L0::ImageCoreFamily<FamilyType::gfxCoreFamily>>>();
image->initialize(device, &zeDesc);
EXPECT_EQ(ZE_RESULT_SUCCESS, commandList->appendImageCopyFromMemory(image->toHandle(), srcPtr, nullptr, nullptr, 0, nullptr, copyParams));
}
HWTEST2_F(CommandListAppendImage, givenCommandListWhenAppendImageCopyToMemoryIsCalledWithNullGraphicsAllocationAndSharedSystemNotEnabledThenErrorIsReturned, IsAtLeastXe2HpgCore) {
DebugManagerStateRestore restore;
debugManager.flags.EmitMemAdvisePriorToCopyForNonUsm.set(1);
auto commandList = std::make_unique<MockCommandListHw<FamilyType::gfxCoreFamily>>();
commandList->failAlignedAlloc = true;
commandList->initialize(device, NEO::EngineGroupType::copy, 0u);
ASSERT_EQ(ZE_RESULT_SUCCESS, commandList->initialize(device, NEO::EngineGroupType::copy, 0u));
ze_image_desc_t zeDesc = {};
zeDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
auto image = std::make_unique<WhiteBox<::L0::ImageCoreFamily<FamilyType::gfxCoreFamily>>>();
image->initialize(device, &zeDesc);
void *dstPtr = reinterpret_cast<void *>(0x1234);
EXPECT_EQ(ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY, commandList->appendImageCopyToMemory(dstPtr, image->toHandle(), nullptr, nullptr, 0, nullptr, copyParams));
}
HWTEST2_F(CommandListAppendImage, givenCommandListWhenAppendImageCopyToMemoryIsCalledWithNullGraphicsAllocationAndSharedSystemEnabledThenSuccessIsReturned, IsAtLeastXe2HpgCore) {
DebugManagerStateRestore restore;
debugManager.flags.EnableSharedSystemUsmSupport.set(1);
debugManager.flags.TreatNonUsmForTransfersAsSharedSystem.set(1);
debugManager.flags.EmitMemAdvisePriorToCopyForNonUsm.set(1);
auto commandList = std::make_unique<MockCommandListHw<FamilyType::gfxCoreFamily>>();
commandList->failAlignedAlloc = true;
commandList->initialize(device, NEO::EngineGroupType::copy, 0u);
ASSERT_EQ(ZE_RESULT_SUCCESS, commandList->initialize(device, NEO::EngineGroupType::copy, 0u));
auto &hwInfo = *device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo();
VariableBackup<uint64_t> sharedSystemMemCapabilities{&hwInfo.capabilityTable.sharedSystemMemCapabilities};
sharedSystemMemCapabilities = 0xf;
ze_image_desc_t zeDesc = {};
zeDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
auto image = std::make_unique<WhiteBox<::L0::ImageCoreFamily<FamilyType::gfxCoreFamily>>>();
image->initialize(device, &zeDesc);
void *dstPtr = reinterpret_cast<void *>(0x1234);
EXPECT_EQ(ZE_RESULT_SUCCESS, commandList->appendImageCopyToMemory(dstPtr, image->toHandle(), nullptr, nullptr, 0, nullptr, copyParams));
}
HWTEST2_F(CommandListAppendImage, givenCommandListWhenAppendImageCopyToMemoryIsCalledWithValidGraphicsAllocationThenSuccessIsReturned, IsAtLeastXe2HpgCore) {
DebugManagerStateRestore restore;
debugManager.flags.EmitMemAdvisePriorToCopyForNonUsm.set(1);
auto commandList = std::make_unique<MockCommandListHw<FamilyType::gfxCoreFamily>>();
commandList->failAlignedAlloc = false;
commandList->initialize(device, NEO::EngineGroupType::copy, 0u);
ASSERT_EQ(ZE_RESULT_SUCCESS, commandList->initialize(device, NEO::EngineGroupType::copy, 0u));
ze_image_desc_t zeDesc = {};
zeDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
auto image = std::make_unique<WhiteBox<::L0::ImageCoreFamily<FamilyType::gfxCoreFamily>>>();
image->initialize(device, &zeDesc);
void *dstPtr = reinterpret_cast<void *>(0x1234);
EXPECT_EQ(ZE_RESULT_SUCCESS, commandList->appendImageCopyToMemory(dstPtr, image->toHandle(), nullptr, nullptr, 0, nullptr, copyParams));
}
HWTEST2_F(CommandListAppendImage, givenCopyCommandListWhenAppendImageCopyFromMemoryIsCalledWithSharedSystemAndEmitMemAdviseEnabledThenSuccessIsReturned, IsAtLeastXe2HpgCore) {
DebugManagerStateRestore restore;
debugManager.flags.EnableSharedSystemUsmSupport.set(1);
debugManager.flags.TreatNonUsmForTransfersAsSharedSystem.set(1);
debugManager.flags.EmitMemAdvisePriorToCopyForNonUsm.set(1);
auto commandList = std::make_unique<WhiteBox<::L0::CommandListCoreFamily<FamilyType::gfxCoreFamily>>>();
ASSERT_EQ(ZE_RESULT_SUCCESS, commandList->initialize(device, NEO::EngineGroupType::copy, 0u));
auto &hwInfo = *device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo();
VariableBackup<uint64_t> sharedSystemMemCapabilities{&hwInfo.capabilityTable.sharedSystemMemCapabilities};
sharedSystemMemCapabilities = 0xf;
void *srcPtr = reinterpret_cast<void *>(0x1234);
ze_image_desc_t zeDesc = {};
zeDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
zeDesc.type = ZE_IMAGE_TYPE_3D;
zeDesc.width = 4;
zeDesc.height = 2;
zeDesc.depth = 2;
L0::Image *imagePtr = nullptr;
ASSERT_EQ(ZE_RESULT_SUCCESS, L0::Image::create(device->getNEODevice()->getHardwareInfo().platform.eProductFamily, device, &zeDesc, &imagePtr));
std::unique_ptr<L0::Image> image(imagePtr);
ze_image_region_t dstImgRegion = {2, 1, 1, 4, 2, 2};
EXPECT_EQ(ZE_RESULT_SUCCESS, commandList->appendImageCopyFromMemory(image->toHandle(), srcPtr, &dstImgRegion, nullptr, 0, nullptr, copyParams));
}
HWTEST2_F(CommandListAppendImage, givenCopyCommandListWhenAppendImageCopyFromMemoryIsCalledWithSharedSystemEnabledAndEmitMemAdviseNotEnabledThenSuccessIsReturned, IsAtLeastXe2HpgCore) {
DebugManagerStateRestore restore;
debugManager.flags.EnableSharedSystemUsmSupport.set(1);
debugManager.flags.TreatNonUsmForTransfersAsSharedSystem.set(1);
debugManager.flags.EmitMemAdvisePriorToCopyForNonUsm.set(-1);
auto commandList = std::make_unique<WhiteBox<::L0::CommandListCoreFamily<FamilyType::gfxCoreFamily>>>();
ASSERT_EQ(ZE_RESULT_SUCCESS, commandList->initialize(device, NEO::EngineGroupType::copy, 0u));
auto &hwInfo = *device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo();
VariableBackup<uint64_t> sharedSystemMemCapabilities{&hwInfo.capabilityTable.sharedSystemMemCapabilities};
sharedSystemMemCapabilities = 0xf;
void *srcPtr = reinterpret_cast<void *>(0x1234);
ze_image_desc_t zeDesc = {};
zeDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
zeDesc.type = ZE_IMAGE_TYPE_3D;
zeDesc.width = 4;
zeDesc.height = 2;
zeDesc.depth = 2;
L0::Image *imagePtr = nullptr;
ASSERT_EQ(ZE_RESULT_SUCCESS, L0::Image::create(device->getNEODevice()->getHardwareInfo().platform.eProductFamily, device, &zeDesc, &imagePtr));
std::unique_ptr<L0::Image> image(imagePtr);
ze_image_region_t dstImgRegion = {2, 1, 1, 4, 2, 2};
EXPECT_EQ(ZE_RESULT_SUCCESS, commandList->appendImageCopyFromMemory(image->toHandle(), srcPtr, &dstImgRegion, nullptr, 0, nullptr, copyParams));
}
HWTEST2_F(CommandListAppendImage, givenComputeCommandListWhenAppendImageCopyFromMemoryIsCalledWithSharedSystemEnabledThenSuccessIsReturned, IsAtLeastXe2HpgCore) {
DebugManagerStateRestore restore;
debugManager.flags.EnableSharedSystemUsmSupport.set(1);
debugManager.flags.TreatNonUsmForTransfersAsSharedSystem.set(1);
debugManager.flags.EmitMemAdvisePriorToCopyForNonUsm.set(1);
auto kernel = device->getBuiltinFunctionsLib()->getImageFunction(ImageBuiltin::copyBufferToImage3dBytes);
auto mockBuiltinKernel = static_cast<Mock<::L0::KernelImp> *>(kernel);
mockBuiltinKernel->setArgRedescribedImageCallBase = false;
auto commandList = std::make_unique<WhiteBox<::L0::CommandListCoreFamily<FamilyType::gfxCoreFamily>>>();
ASSERT_EQ(ZE_RESULT_SUCCESS, commandList->initialize(device, NEO::EngineGroupType::renderCompute, 0u));
auto &hwInfo = *device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo();
VariableBackup<uint64_t> sharedSystemMemCapabilities{&hwInfo.capabilityTable.sharedSystemMemCapabilities};
sharedSystemMemCapabilities = 0xf;
void *srcPtr = reinterpret_cast<void *>(0x1234);
ze_image_desc_t zeDesc = {};
zeDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
zeDesc.type = ZE_IMAGE_TYPE_3D;
zeDesc.width = 4;
zeDesc.height = 2;
zeDesc.depth = 2;
L0::Image *imagePtr = nullptr;
ASSERT_EQ(ZE_RESULT_SUCCESS, L0::Image::create(device->getNEODevice()->getHardwareInfo().platform.eProductFamily, device, &zeDesc, &imagePtr));
std::unique_ptr<L0::Image> image(imagePtr);
ze_image_region_t dstImgRegion = {2, 1, 1, 4, 2, 2};
EXPECT_EQ(ZE_RESULT_SUCCESS, commandList->appendImageCopyFromMemory(image->toHandle(), srcPtr, &dstImgRegion, nullptr, 0, nullptr, copyParams));
}
HWTEST2_F(CommandListAppendImage, givenCopyCommandListWhenAppendImageCopyToMemoryIsCalledWithSharedSystemAndEmitMemAdviseEnabledThenSuccessIsReturned, IsAtLeastXe2HpgCore) {
DebugManagerStateRestore restore;
debugManager.flags.EnableSharedSystemUsmSupport.set(1);
debugManager.flags.TreatNonUsmForTransfersAsSharedSystem.set(1);
debugManager.flags.EmitMemAdvisePriorToCopyForNonUsm.set(1);
auto commandList = std::make_unique<WhiteBox<::L0::CommandListCoreFamily<FamilyType::gfxCoreFamily>>>();
ASSERT_EQ(ZE_RESULT_SUCCESS, commandList->initialize(device, NEO::EngineGroupType::copy, 0u));
auto &hwInfo = *device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo();
VariableBackup<uint64_t> sharedSystemMemCapabilities{&hwInfo.capabilityTable.sharedSystemMemCapabilities};
sharedSystemMemCapabilities = 0xf;
ze_image_desc_t zeDesc = {};
zeDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
zeDesc.type = ZE_IMAGE_TYPE_3D;
zeDesc.width = 4;
zeDesc.height = 2;
zeDesc.depth = 2;
L0::Image *imagePtr = nullptr;
auto result = L0::Image::create(device->getNEODevice()->getHardwareInfo().platform.eProductFamily, device, &zeDesc, &imagePtr);
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
std::unique_ptr<L0::Image> image(imagePtr);
ze_image_region_t srcImgRegion = {2, 1, 1, 4, 2, 2};
void *dstPtr = reinterpret_cast<void *>(0x1234);
EXPECT_EQ(ZE_RESULT_SUCCESS, commandList->appendImageCopyToMemory(dstPtr, image->toHandle(), &srcImgRegion, nullptr, 0, nullptr, copyParams));
}
HWTEST2_F(CommandListAppendImage, givenCopyCommandListWhenAppendImageCopyToMemoryIsCalledWithSharedSystemEnabledAndEmitMemAdviseNotEnabledThenSuccessIsReturned, IsAtLeastXe2HpgCore) {
DebugManagerStateRestore restore;
debugManager.flags.EnableSharedSystemUsmSupport.set(1);
debugManager.flags.TreatNonUsmForTransfersAsSharedSystem.set(1);
debugManager.flags.EmitMemAdvisePriorToCopyForNonUsm.set(-1);
auto commandList = std::make_unique<WhiteBox<::L0::CommandListCoreFamily<FamilyType::gfxCoreFamily>>>();
ASSERT_EQ(ZE_RESULT_SUCCESS, commandList->initialize(device, NEO::EngineGroupType::copy, 0u));
auto &hwInfo = *device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo();
VariableBackup<uint64_t> sharedSystemMemCapabilities{&hwInfo.capabilityTable.sharedSystemMemCapabilities};
sharedSystemMemCapabilities = 0xf;
ze_image_desc_t zeDesc = {};
zeDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
zeDesc.type = ZE_IMAGE_TYPE_3D;
zeDesc.width = 4;
zeDesc.height = 2;
zeDesc.depth = 2;
L0::Image *imagePtr = nullptr;
auto result = L0::Image::create(device->getNEODevice()->getHardwareInfo().platform.eProductFamily, device, &zeDesc, &imagePtr);
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
std::unique_ptr<L0::Image> image(imagePtr);
ze_image_region_t srcImgRegion = {2, 1, 1, 4, 2, 2};
void *dstPtr = reinterpret_cast<void *>(0x1234);
EXPECT_EQ(ZE_RESULT_SUCCESS, commandList->appendImageCopyToMemory(dstPtr, image->toHandle(), &srcImgRegion, nullptr, 0, nullptr, copyParams));
}
HWTEST2_F(CommandListAppendImage, givenComputeCommandListWhenAppendImageCopyToMemoryIsCalledWithSharedSystemEnabledThenSuccessIsReturned, IsAtLeastXe2HpgCore) {
DebugManagerStateRestore restore;
debugManager.flags.EnableSharedSystemUsmSupport.set(1);
debugManager.flags.TreatNonUsmForTransfersAsSharedSystem.set(1);
debugManager.flags.EmitMemAdvisePriorToCopyForNonUsm.set(1);
auto kernel = device->getBuiltinFunctionsLib()->getImageFunction(ImageBuiltin::copyImage3dToBufferBytes);
auto mockBuiltinKernel = static_cast<Mock<::L0::KernelImp> *>(kernel);
mockBuiltinKernel->setArgRedescribedImageCallBase = false;
auto commandList = std::make_unique<WhiteBox<::L0::CommandListCoreFamily<FamilyType::gfxCoreFamily>>>();
ASSERT_EQ(ZE_RESULT_SUCCESS, commandList->initialize(device, NEO::EngineGroupType::renderCompute, 0u));
auto &hwInfo = *device->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo();
VariableBackup<uint64_t> sharedSystemMemCapabilities{&hwInfo.capabilityTable.sharedSystemMemCapabilities};
sharedSystemMemCapabilities = 0xf;
ze_image_desc_t zeDesc = {};
zeDesc.stype = ZE_STRUCTURE_TYPE_IMAGE_DESC;
zeDesc.type = ZE_IMAGE_TYPE_3D;
zeDesc.width = 4;
zeDesc.height = 2;
zeDesc.depth = 2;
L0::Image *imagePtr = nullptr;
auto result = L0::Image::create(device->getNEODevice()->getHardwareInfo().platform.eProductFamily, device, &zeDesc, &imagePtr);
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
std::unique_ptr<L0::Image> image(imagePtr);
ze_image_region_t srcImgRegion = {2, 1, 1, 4, 2, 2};
void *dstPtr = reinterpret_cast<void *>(0x1234);
EXPECT_EQ(ZE_RESULT_SUCCESS, commandList->appendImageCopyToMemory(dstPtr, image->toHandle(), &srcImgRegion, nullptr, 0, nullptr, copyParams));
}
template <typename GfxFamily> template <typename GfxFamily>
struct MockL0GfxCoreHelperSupportsCmdListHeapSharingHw : L0::L0GfxCoreHelperHw<GfxFamily> { struct MockL0GfxCoreHelperSupportsCmdListHeapSharingHw : L0::L0GfxCoreHelperHw<GfxFamily> {
bool platformSupportsCmdListHeapSharing() const override { return true; } bool platformSupportsCmdListHeapSharing() const override { return true; }

View File

@@ -334,7 +334,7 @@ HWTEST_F(AppendMemoryCopyTests, givenCopyCommandListWhenTimestampPassedToImageCo
MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); MemoryPool::system4KBPages, MemoryManager::maxOsContextCount);
CmdListMemoryCopyParams copyParams = {}; CmdListMemoryCopyParams copyParams = {};
commandList->appendCopyImageBlit(&mockAllocationDst, &mockAllocationSrc, {0, 0, 0}, {0, 0, 0}, 1, 1, 1, 1, 1, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, event.get(), 0, nullptr, copyParams); commandList->appendCopyImageBlit(mockAllocationSrc.getGpuAddress(), &mockAllocationSrc, mockAllocationDst.getGpuAddress(), &mockAllocationDst, {0, 0, 0}, {0, 0, 0}, 1, 1, 1, 1, 1, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, event.get(), 0, nullptr, copyParams);
GenCmdList cmdList; GenCmdList cmdList;
ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer(
cmdList, ptrOffset(commandList->getCmdContainer().getCommandStream()->getCpuBase(), 0), commandList->getCmdContainer().getCommandStream()->getUsed())); cmdList, ptrOffset(commandList->getCmdContainer().getCommandStream()->getCpuBase(), 0), commandList->getCmdContainer().getCommandStream()->getUsed()));
@@ -372,7 +372,7 @@ HWTEST2_F(AppendMemoryCopyTests, givenWaitWhenWhenAppendBlitCalledThenProgramSem
CmdListMemoryCopyParams copyParams = {}; CmdListMemoryCopyParams copyParams = {};
{ {
commandList->appendCopyImageBlit(&mockAllocationDst, &mockAllocationSrc, {0, 0, 0}, {0, 0, 0}, 1, 1, 1, 1, 1, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, event.get(), 0, nullptr, copyParams); commandList->appendCopyImageBlit(mockAllocationSrc.getGpuAddress(), &mockAllocationSrc, mockAllocationDst.getGpuAddress(), &mockAllocationDst, {0, 0, 0}, {0, 0, 0}, 1, 1, 1, 1, 1, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, event.get(), 0, nullptr, copyParams);
GenCmdList cmdList; GenCmdList cmdList;
ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer(cmdList, ptrOffset(cmdStream->getCpuBase(), offset), cmdStream->getUsed() - offset)); ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer(cmdList, ptrOffset(cmdStream->getCpuBase(), offset), cmdStream->getUsed() - offset));
@@ -384,7 +384,7 @@ HWTEST2_F(AppendMemoryCopyTests, givenWaitWhenWhenAppendBlitCalledThenProgramSem
offset = cmdStream->getUsed(); offset = cmdStream->getUsed();
auto eventHandle = event->toHandle(); auto eventHandle = event->toHandle();
commandList->appendCopyImageBlit(&mockAllocationDst, &mockAllocationSrc, {0, 0, 0}, {0, 0, 0}, 1, 1, 1, 1, 1, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, nullptr, 1, &eventHandle, copyParams); commandList->appendCopyImageBlit(mockAllocationSrc.getGpuAddress(), &mockAllocationSrc, mockAllocationDst.getGpuAddress(), &mockAllocationDst, {0, 0, 0}, {0, 0, 0}, 1, 1, 1, 1, 1, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, nullptr, 1, &eventHandle, copyParams);
GenCmdList cmdList; GenCmdList cmdList;
ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer(cmdList, ptrOffset(cmdStream->getCpuBase(), offset), cmdStream->getUsed() - offset)); ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer(cmdList, ptrOffset(cmdStream->getCpuBase(), offset), cmdStream->getUsed() - offset));
auto itor = find<MI_SEMAPHORE_WAIT *>(cmdList.begin(), cmdList.end()); auto itor = find<MI_SEMAPHORE_WAIT *>(cmdList.begin(), cmdList.end());
@@ -455,7 +455,7 @@ HWTEST2_F(AppendMemoryCopyTests, givenCopyCommandListWhenTiled1DArrayImagePassed
size_t arrayLevels = 8; size_t arrayLevels = 8;
size_t depth = 1; size_t depth = 1;
CmdListMemoryCopyParams copyParams = {}; CmdListMemoryCopyParams copyParams = {};
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, 0, nullptr, copyParams); commandList->appendCopyImageBlit(mockAllocationSrc.getGpuAddress(), &mockAllocationSrc, mockAllocationDst.getGpuAddress(), &mockAllocationDst, {0, 0, 0}, {0, 0, 0}, 4, 4, 4, 4, 1, {1, arrayLevels, depth}, {1, arrayLevels, depth}, {1, arrayLevels, depth}, nullptr, 0, nullptr, copyParams);
GenCmdList cmdList; GenCmdList cmdList;
ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer(
cmdList, ptrOffset(commandList->getCmdContainer().getCommandStream()->getCpuBase(), 0), commandList->getCmdContainer().getCommandStream()->getUsed())); cmdList, ptrOffset(commandList->getCmdContainer().getCommandStream()->getCpuBase(), 0), commandList->getCmdContainer().getCommandStream()->getUsed()));
@@ -490,7 +490,7 @@ HWTEST2_F(AppendMemoryCopyTests, givenCopyCommandListWhenNotTiled1DArrayImagePas
size_t arrayLevels = 8; size_t arrayLevels = 8;
size_t depth = 1; size_t depth = 1;
CmdListMemoryCopyParams copyParams = {}; CmdListMemoryCopyParams copyParams = {};
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, 0, nullptr, copyParams); commandList->appendCopyImageBlit(mockAllocationSrc.getGpuAddress(), &mockAllocationSrc, mockAllocationDst.getGpuAddress(), &mockAllocationDst, {0, 0, 0}, {0, 0, 0}, 1, 1, 1, 1, 1, {1, arrayLevels, depth}, {1, arrayLevels, depth}, {1, arrayLevels, depth}, nullptr, 0, nullptr, copyParams);
GenCmdList cmdList; GenCmdList cmdList;
ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer(
cmdList, ptrOffset(commandList->getCmdContainer().getCommandStream()->getCpuBase(), 0), commandList->getCmdContainer().getCommandStream()->getUsed())); cmdList, ptrOffset(commandList->getCmdContainer().getCommandStream()->getCpuBase(), 0), commandList->getCmdContainer().getCommandStream()->getUsed()));
@@ -637,7 +637,7 @@ HWTEST_F(AppendMemoryCopyTests, givenCopyOnlyCommandListWithUseAdditionalBlitPro
EXPECT_EQ(0u, commandList->additionalBlitPropertiesCalled); EXPECT_EQ(0u, commandList->additionalBlitPropertiesCalled);
EXPECT_EQ(0u, commandList->inOrderPatchCmds.size()); EXPECT_EQ(0u, commandList->inOrderPatchCmds.size());
CmdListMemoryCopyParams copyParams = {}; CmdListMemoryCopyParams copyParams = {};
commandList->appendCopyImageBlit(&mockAllocationDst, &mockAllocationSrc, {0, 0, 0}, {0, 0, 0}, 1, 1, 1, 1, 1, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, nullptr, 0, nullptr, copyParams); commandList->appendCopyImageBlit(mockAllocationSrc.getGpuAddress(), &mockAllocationSrc, mockAllocationDst.getGpuAddress(), &mockAllocationDst, {0, 0, 0}, {0, 0, 0}, 1, 1, 1, 1, 1, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, nullptr, 0, nullptr, copyParams);
EXPECT_EQ(0u, commandList->additionalBlitPropertiesCalled); EXPECT_EQ(0u, commandList->additionalBlitPropertiesCalled);
EXPECT_EQ(1u, commandList->appendSignalInOrderDependencyCounterCalled); EXPECT_EQ(1u, commandList->appendSignalInOrderDependencyCounterCalled);
@@ -649,7 +649,7 @@ HWTEST_F(AppendMemoryCopyTests, givenCopyOnlyCommandListWithUseAdditionalBlitPro
commandList->useAdditionalBlitProperties = true; commandList->useAdditionalBlitProperties = true;
commandList->appendCopyImageBlit(&mockAllocationDst, &mockAllocationSrc, {0, 0, 0}, {0, 0, 0}, 1, 1, 1, 1, 1, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, nullptr, 0, nullptr, copyParams); commandList->appendCopyImageBlit(mockAllocationSrc.getGpuAddress(), &mockAllocationSrc, mockAllocationDst.getGpuAddress(), &mockAllocationDst, {0, 0, 0}, {0, 0, 0}, 1, 1, 1, 1, 1, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, nullptr, 0, nullptr, copyParams);
EXPECT_EQ(1u, commandList->additionalBlitPropertiesCalled); EXPECT_EQ(1u, commandList->additionalBlitPropertiesCalled);
EXPECT_EQ(1u, commandList->appendSignalInOrderDependencyCounterCalled); EXPECT_EQ(1u, commandList->appendSignalInOrderDependencyCounterCalled);
if (commandList->inOrderCmdsPatchingEnabled()) { if (commandList->inOrderCmdsPatchingEnabled()) {
@@ -674,7 +674,7 @@ HWTEST_F(AppendMemoryCopyTests, givenCopyOnlyCommandListWithUseAdditionalBlitPro
EXPECT_EQ(0u, commandList->additionalBlitPropertiesCalled); EXPECT_EQ(0u, commandList->additionalBlitPropertiesCalled);
EXPECT_EQ(0u, commandList->inOrderPatchCmds.size()); EXPECT_EQ(0u, commandList->inOrderPatchCmds.size());
CmdListMemoryCopyParams copyParams = {}; CmdListMemoryCopyParams copyParams = {};
commandList->appendCopyImageBlit(&mockAllocationDst, &mockAllocationSrc, {0, 0, 0}, {0, 0, 0}, 1, 1, 1, 1, 1, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, nullptr, 0, nullptr, copyParams); commandList->appendCopyImageBlit(mockAllocationSrc.getGpuAddress(), &mockAllocationSrc, mockAllocationDst.getGpuAddress(), &mockAllocationDst, {0, 0, 0}, {0, 0, 0}, 1, 1, 1, 1, 1, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, nullptr, 0, nullptr, copyParams);
EXPECT_EQ(1u, commandList->additionalBlitPropertiesCalled); EXPECT_EQ(1u, commandList->additionalBlitPropertiesCalled);
EXPECT_EQ(0u, commandList->inOrderPatchCmds.size()); EXPECT_EQ(0u, commandList->inOrderPatchCmds.size());
} }
@@ -885,7 +885,7 @@ HWTEST_F(AppendMemoryCopyTests, givenCopyOnlyCommandListWithUseAdditionalBlitPro
EXPECT_EQ(0u, commandList->appendSignalInOrderDependencyCounterCalled); EXPECT_EQ(0u, commandList->appendSignalInOrderDependencyCounterCalled);
EXPECT_EQ(0u, commandList->inOrderPatchCmds.size()); EXPECT_EQ(0u, commandList->inOrderPatchCmds.size());
CmdListMemoryCopyParams copyParams = {}; CmdListMemoryCopyParams copyParams = {};
commandList->appendCopyImageBlit(&mockAllocationDst, &mockAllocationSrc, {0, 0, 0}, {0, 0, 0}, 1, 1, 1, 1, 1, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, nullptr, 0, nullptr, copyParams); commandList->appendCopyImageBlit(mockAllocationSrc.getGpuAddress(), &mockAllocationSrc, mockAllocationDst.getGpuAddress(), &mockAllocationDst, {0, 0, 0}, {0, 0, 0}, 1, 1, 1, 1, 1, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, nullptr, 0, nullptr, copyParams);
EXPECT_EQ(1u, commandList->additionalBlitPropertiesCalled); EXPECT_EQ(1u, commandList->additionalBlitPropertiesCalled);
EXPECT_EQ(0u, commandList->appendSignalInOrderDependencyCounterCalled); EXPECT_EQ(0u, commandList->appendSignalInOrderDependencyCounterCalled);
if (commandList->inOrderCmdsPatchingEnabled()) { if (commandList->inOrderCmdsPatchingEnabled()) {
@@ -907,6 +907,18 @@ HWTEST_F(AppendMemoryCopyTests, givenCopyOnlyCommandListWithUseAdditionalBlitPro
} }
} }
HWTEST_F(AppendMemoryCopyTests, givenCopyOnlyCommandListWithNonZeroNumWaitEventsAndNullEventHandlesWhenCallingAppendCopyImageBlitThenErrorIsReturned) {
auto commandList = std::make_unique<WhiteBox<::L0::CommandListCoreFamily<FamilyType::gfxCoreFamily>>>();
commandList->initialize(device, NEO::EngineGroupType::copy, 0u);
NEO::MockGraphicsAllocation mockAllocationSrc(0, 1u /*num gmms*/, NEO::AllocationType::buffer, reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t), MemoryPool::system4KBPages, MemoryManager::maxOsContextCount);
NEO::MockGraphicsAllocation mockAllocationDst(0, 1u /*num gmms*/, NEO::AllocationType::image, reinterpret_cast<void *>(0x2345), 0x1000, 0, sizeof(uint32_t), MemoryPool::system4KBPages, MemoryManager::maxOsContextCount);
CmdListMemoryCopyParams copyParams = {};
auto result = commandList->appendCopyImageBlit(mockAllocationSrc.getGpuAddress(), &mockAllocationSrc, mockAllocationDst.getGpuAddress(), &mockAllocationDst, {0, 0, 0}, {0, 0, 0}, 1, 1, 1, 1, 1, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, nullptr, 1, nullptr, copyParams);
EXPECT_EQ(result, ZE_RESULT_ERROR_INVALID_ARGUMENT);
}
HWTEST_F(AppendMemoryCopyTests, givenCopyOnlyCommandListWithUseAdditionalBlitPropertiesWhenPatchingCommandsAfterCallingMemoryFillWithTwoBytesPatternThenCommandsRemainsTheSame) { HWTEST_F(AppendMemoryCopyTests, givenCopyOnlyCommandListWithUseAdditionalBlitPropertiesWhenPatchingCommandsAfterCallingMemoryFillWithTwoBytesPatternThenCommandsRemainsTheSame) {
auto commandList = std::make_unique<MockCommandListForAdditionalBlitProperties2<FamilyType::gfxCoreFamily>>(); auto commandList = std::make_unique<MockCommandListForAdditionalBlitProperties2<FamilyType::gfxCoreFamily>>();
commandList->initialize(device, NEO::EngineGroupType::copy, ZE_COMMAND_LIST_FLAG_IN_ORDER); commandList->initialize(device, NEO::EngineGroupType::copy, ZE_COMMAND_LIST_FLAG_IN_ORDER);

View File

@@ -183,8 +183,8 @@ class MockCommandListExtensionHw : public WhiteBox<::L0::CommandListCoreFamily<g
} }
return ZE_RESULT_SUCCESS; return ZE_RESULT_SUCCESS;
} }
ze_result_t appendCopyImageBlit(NEO::GraphicsAllocation *src, ze_result_t appendCopyImageBlit(uintptr_t srcPtr, NEO::GraphicsAllocation *src,
NEO::GraphicsAllocation *dst, uintptr_t dstPtr, NEO::GraphicsAllocation *dst,
const Vec3<size_t> &srcOffsets, const Vec3<size_t> &dstOffsets, const Vec3<size_t> &srcOffsets, const Vec3<size_t> &dstOffsets,
size_t srcRowPitch, size_t srcSlicePitch, size_t srcRowPitch, size_t srcSlicePitch,
size_t dstRowPitch, size_t dstSlicePitch, size_t dstRowPitch, size_t dstSlicePitch,

View File

@@ -1086,8 +1086,8 @@ TaskCountType CommandStreamReceiverHw<GfxFamily>::flushBcsTask(const BlitPropert
if (blitProperties.blitSyncProperties.outputTimestampPacket) { if (blitProperties.blitSyncProperties.outputTimestampPacket) {
bool deviceToHostPostSyncFenceRequired = getProductHelper().isDeviceToHostCopySignalingFenceRequired() && bool deviceToHostPostSyncFenceRequired = getProductHelper().isDeviceToHostCopySignalingFenceRequired() &&
!blitProperties.dstAllocation->isAllocatedInLocalMemoryPool() && (blitProperties.dstAllocation && !blitProperties.dstAllocation->isAllocatedInLocalMemoryPool()) &&
blitProperties.srcAllocation->isAllocatedInLocalMemoryPool(); (blitProperties.srcAllocation && blitProperties.srcAllocation->isAllocatedInLocalMemoryPool());
if (deviceToHostPostSyncFenceRequired) { if (deviceToHostPostSyncFenceRequired) {
MemorySynchronizationCommands<GfxFamily>::addAdditionalSynchronization(commandStream, tagAllocation->getGpuAddress(), NEO::FenceType::release, peekRootDeviceEnvironment()); MemorySynchronizationCommands<GfxFamily>::addAdditionalSynchronization(commandStream, tagAllocation->getGpuAddress(), NEO::FenceType::release, peekRootDeviceEnvironment());
@@ -1106,8 +1106,12 @@ TaskCountType CommandStreamReceiverHw<GfxFamily>::flushBcsTask(const BlitPropert
} }
blitProperties.csrDependencies.makeResident(*this); blitProperties.csrDependencies.makeResident(*this);
blitProperties.srcAllocation->prepareHostPtrForResidency(this); if (blitProperties.srcAllocation) {
blitProperties.dstAllocation->prepareHostPtrForResidency(this); blitProperties.srcAllocation->prepareHostPtrForResidency(this);
}
if (blitProperties.dstAllocation) {
blitProperties.dstAllocation->prepareHostPtrForResidency(this);
}
makeResident(*blitProperties.srcAllocation); makeResident(*blitProperties.srcAllocation);
makeResident(*blitProperties.dstAllocation); makeResident(*blitProperties.dstAllocation);
if (blitProperties.clearColorAllocation) { if (blitProperties.clearColorAllocation) {

View File

@@ -291,12 +291,14 @@ void BlitCommandsHelper<Family>::appendBlitCommandsForImages(const BlitPropertie
auto dstRowPitch = static_cast<uint32_t>(blitProperties.dstRowPitch); auto dstRowPitch = static_cast<uint32_t>(blitProperties.dstRowPitch);
uint32_t mipTailLod = 0; uint32_t mipTailLod = 0;
auto compressionDetails = 0u; auto compressionDetails = 0u;
if (srcAllocation) {
getBlitAllocationProperties(*srcAllocation, srcRowPitch, srcQPitch, tileType, mipTailLod, compressionDetails, getBlitAllocationProperties(*srcAllocation, srcRowPitch, srcQPitch, tileType, mipTailLod, compressionDetails,
rootDeviceEnvironment, blitProperties.srcPlane); rootDeviceEnvironment, blitProperties.srcPlane);
getBlitAllocationProperties(*dstAllocation, dstRowPitch, dstQPitch, tileType, mipTailLod, compressionDetails, }
rootDeviceEnvironment, blitProperties.dstPlane); if (dstAllocation) {
getBlitAllocationProperties(*dstAllocation, dstRowPitch, dstQPitch, tileType, mipTailLod, compressionDetails,
rootDeviceEnvironment, blitProperties.dstPlane);
}
blitCmd.setSourcePitch(srcRowPitch); blitCmd.setSourcePitch(srcRowPitch);
blitCmd.setDestinationPitch(dstRowPitch); blitCmd.setDestinationPitch(dstRowPitch);

View File

@@ -80,7 +80,7 @@ template <typename GfxFamily>
void BlitCommandsHelper<GfxFamily>::appendSurfaceType(const BlitProperties &blitProperties, typename GfxFamily::XY_BLOCK_COPY_BLT &blitCmd) { void BlitCommandsHelper<GfxFamily>::appendSurfaceType(const BlitProperties &blitProperties, typename GfxFamily::XY_BLOCK_COPY_BLT &blitCmd) {
using XY_BLOCK_COPY_BLT = typename GfxFamily::XY_BLOCK_COPY_BLT; using XY_BLOCK_COPY_BLT = typename GfxFamily::XY_BLOCK_COPY_BLT;
if (blitProperties.srcAllocation->getDefaultGmm()) { if (blitProperties.srcAllocation && blitProperties.srcAllocation->getDefaultGmm()) {
auto resInfo = blitProperties.srcAllocation->getDefaultGmm()->gmmResourceInfo.get(); auto resInfo = blitProperties.srcAllocation->getDefaultGmm()->gmmResourceInfo.get();
auto resourceType = resInfo->getResourceType(); auto resourceType = resInfo->getResourceType();
auto isArray = resInfo->getArraySize() > 1; auto isArray = resInfo->getArraySize() > 1;
@@ -100,7 +100,7 @@ void BlitCommandsHelper<GfxFamily>::appendSurfaceType(const BlitProperties &blit
} }
} }
if (blitProperties.dstAllocation->getDefaultGmm()) { if (blitProperties.dstAllocation && blitProperties.dstAllocation->getDefaultGmm()) {
auto resInfo = blitProperties.dstAllocation->getDefaultGmm()->gmmResourceInfo.get(); auto resInfo = blitProperties.dstAllocation->getDefaultGmm()->gmmResourceInfo.get();
auto resourceType = resInfo->getResourceType(); auto resourceType = resInfo->getResourceType();
auto isArray = resInfo->getArraySize() > 1; auto isArray = resInfo->getArraySize() > 1;
@@ -212,10 +212,14 @@ void BlitCommandsHelper<GfxFamily>::appendBlitCommandsForImages(const BlitProper
auto srcCompressionFormat = blitCmd.getSourceCompressionFormat(); auto srcCompressionFormat = blitCmd.getSourceCompressionFormat();
auto dstCompressionFormat = blitCmd.getDestinationCompressionFormat(); auto dstCompressionFormat = blitCmd.getDestinationCompressionFormat();
getBlitAllocationProperties(*srcAllocation, srcRowPitch, srcQPitch, srcTileType, srcMipTailLod, srcCompressionFormat, if (srcAllocation) {
rootDeviceEnvironment, blitProperties.srcPlane); getBlitAllocationProperties(*srcAllocation, srcRowPitch, srcQPitch, srcTileType, srcMipTailLod, srcCompressionFormat,
getBlitAllocationProperties(*dstAllocation, dstRowPitch, dstQPitch, dstTileType, dstMipTailLod, dstCompressionFormat, rootDeviceEnvironment, blitProperties.srcPlane);
rootDeviceEnvironment, blitProperties.dstPlane); }
if (dstAllocation) {
getBlitAllocationProperties(*dstAllocation, dstRowPitch, dstQPitch, dstTileType, dstMipTailLod, dstCompressionFormat,
rootDeviceEnvironment, blitProperties.dstPlane);
}
srcSlicePitch = std::max(srcSlicePitch, srcRowPitch * srcQPitch); srcSlicePitch = std::max(srcSlicePitch, srcRowPitch * srcQPitch);
dstSlicePitch = std::max(dstSlicePitch, dstRowPitch * dstQPitch); dstSlicePitch = std::max(dstSlicePitch, dstRowPitch * dstQPitch);

View File

@@ -244,13 +244,13 @@ bool BlitProperties::isImageOperation() const {
blitDirection == BlitterConstants::BlitDirection::imageToImage; blitDirection == BlitterConstants::BlitDirection::imageToImage;
} }
bool BlitProperties::isSrc1DTiledArray() const { bool BlitProperties::isSrc1DTiledArray() const {
if (srcAllocation->getDefaultGmm()) { if (srcAllocation && srcAllocation->getDefaultGmm()) {
return is1DTiledArray(srcAllocation->getDefaultGmm()->gmmResourceInfo.get()); return is1DTiledArray(srcAllocation->getDefaultGmm()->gmmResourceInfo.get());
} }
return false; return false;
} }
bool BlitProperties::isDst1DTiledArray() const { bool BlitProperties::isDst1DTiledArray() const {
if (dstAllocation->getDefaultGmm()) { if (dstAllocation && dstAllocation->getDefaultGmm()) {
return is1DTiledArray(dstAllocation->getDefaultGmm()->gmmResourceInfo.get()); return is1DTiledArray(dstAllocation->getDefaultGmm()->gmmResourceInfo.get());
} }
return false; return false;

View File

@@ -68,35 +68,35 @@ void BlitCommandsHelper<Family>::appendBlitCommandsBlockCopy(const BlitPropertie
auto dstAllocation = blitProperties.dstAllocation; auto dstAllocation = blitProperties.dstAllocation;
auto srcAllocation = blitProperties.srcAllocation; auto srcAllocation = blitProperties.srcAllocation;
if (srcAllocation->isCompressionEnabled()) { if (srcAllocation && srcAllocation->isCompressionEnabled()) {
auto resourceFormat = srcAllocation->getDefaultGmm()->gmmResourceInfo->getResourceFormat(); auto resourceFormat = srcAllocation->getDefaultGmm()->gmmResourceInfo->getResourceFormat();
srcCompressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat); srcCompressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat);
} }
if (dstAllocation->isCompressionEnabled()) { if (dstAllocation && dstAllocation->isCompressionEnabled()) {
auto resourceFormat = dstAllocation->getDefaultGmm()->gmmResourceInfo->getResourceFormat(); auto resourceFormat = dstAllocation->getDefaultGmm()->gmmResourceInfo->getResourceFormat();
dstCompressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat); dstCompressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat);
} }
if (debugManager.flags.ForceBufferCompressionFormat.get() != -1) { if (debugManager.flags.ForceBufferCompressionFormat.get() != -1) {
if (srcAllocation->isCompressionEnabled()) { if (srcAllocation && srcAllocation->isCompressionEnabled()) {
srcCompressionFormat = static_cast<uint8_t>(debugManager.flags.ForceBufferCompressionFormat.get()); srcCompressionFormat = static_cast<uint8_t>(debugManager.flags.ForceBufferCompressionFormat.get());
} }
if (dstAllocation->isCompressionEnabled()) { if (dstAllocation && dstAllocation->isCompressionEnabled()) {
dstCompressionFormat = static_cast<uint8_t>(debugManager.flags.ForceBufferCompressionFormat.get()); dstCompressionFormat = static_cast<uint8_t>(debugManager.flags.ForceBufferCompressionFormat.get());
} }
} }
DEBUG_BREAK_IF((AuxTranslationDirection::none != blitProperties.auxTranslationDirection) && DEBUG_BREAK_IF((AuxTranslationDirection::none != blitProperties.auxTranslationDirection) &&
(blitProperties.dstAllocation != blitProperties.srcAllocation || !blitProperties.dstAllocation->isCompressionEnabled())); (blitProperties.dstAllocation != blitProperties.srcAllocation || (blitProperties.dstAllocation && !blitProperties.dstAllocation->isCompressionEnabled())));
blitCmd.setSourceCompressionFormat(static_cast<XY_BLOCK_COPY_BLT::SOURCE_COMPRESSION_FORMAT>(srcCompressionFormat)); blitCmd.setSourceCompressionFormat(static_cast<XY_BLOCK_COPY_BLT::SOURCE_COMPRESSION_FORMAT>(srcCompressionFormat));
blitCmd.setDestinationCompressionFormat(static_cast<XY_BLOCK_COPY_BLT::DESTINATION_COMPRESSION_FORMAT>(dstCompressionFormat)); blitCmd.setDestinationCompressionFormat(static_cast<XY_BLOCK_COPY_BLT::DESTINATION_COMPRESSION_FORMAT>(dstCompressionFormat));
if (MemoryPoolHelper::isSystemMemoryPool(blitProperties.dstAllocation->getMemoryPool())) { if (!dstAllocation || MemoryPoolHelper::isSystemMemoryPool(dstAllocation->getMemoryPool())) {
blitCmd.setDestinationTargetMemory(XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM); blitCmd.setDestinationTargetMemory(XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
} }
if (MemoryPoolHelper::isSystemMemoryPool(blitProperties.srcAllocation->getMemoryPool())) { if (!srcAllocation || MemoryPoolHelper::isSystemMemoryPool(srcAllocation->getMemoryPool())) {
blitCmd.setSourceTargetMemory(XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM); blitCmd.setSourceTargetMemory(XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
} }

View File

@@ -67,35 +67,35 @@ void BlitCommandsHelper<Family>::appendBlitCommandsBlockCopy(const BlitPropertie
auto dstAllocation = blitProperties.dstAllocation; auto dstAllocation = blitProperties.dstAllocation;
auto srcAllocation = blitProperties.srcAllocation; auto srcAllocation = blitProperties.srcAllocation;
if (srcAllocation->isCompressionEnabled()) { if (srcAllocation && srcAllocation->isCompressionEnabled()) {
auto resourceFormat = srcAllocation->getDefaultGmm()->gmmResourceInfo->getResourceFormat(); auto resourceFormat = srcAllocation->getDefaultGmm()->gmmResourceInfo->getResourceFormat();
srcCompressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat); srcCompressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat);
} }
if (dstAllocation->isCompressionEnabled()) { if (dstAllocation && dstAllocation->isCompressionEnabled()) {
auto resourceFormat = dstAllocation->getDefaultGmm()->gmmResourceInfo->getResourceFormat(); auto resourceFormat = dstAllocation->getDefaultGmm()->gmmResourceInfo->getResourceFormat();
dstCompressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat); dstCompressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat);
} }
if (debugManager.flags.ForceBufferCompressionFormat.get() != -1) { if (debugManager.flags.ForceBufferCompressionFormat.get() != -1) {
if (srcAllocation->isCompressionEnabled()) { if (srcAllocation && srcAllocation->isCompressionEnabled()) {
srcCompressionFormat = static_cast<uint8_t>(debugManager.flags.ForceBufferCompressionFormat.get()); srcCompressionFormat = static_cast<uint8_t>(debugManager.flags.ForceBufferCompressionFormat.get());
} }
if (dstAllocation->isCompressionEnabled()) { if (dstAllocation && dstAllocation->isCompressionEnabled()) {
dstCompressionFormat = static_cast<uint8_t>(debugManager.flags.ForceBufferCompressionFormat.get()); dstCompressionFormat = static_cast<uint8_t>(debugManager.flags.ForceBufferCompressionFormat.get());
} }
} }
DEBUG_BREAK_IF((AuxTranslationDirection::none != blitProperties.auxTranslationDirection) && DEBUG_BREAK_IF((AuxTranslationDirection::none != blitProperties.auxTranslationDirection) &&
(blitProperties.dstAllocation != blitProperties.srcAllocation || !blitProperties.dstAllocation->isCompressionEnabled())); (blitProperties.dstAllocation != blitProperties.srcAllocation || (blitProperties.dstAllocation && !blitProperties.dstAllocation->isCompressionEnabled())));
blitCmd.setSourceCompressionFormat(static_cast<XY_BLOCK_COPY_BLT::SOURCE_COMPRESSION_FORMAT>(srcCompressionFormat)); blitCmd.setSourceCompressionFormat(static_cast<XY_BLOCK_COPY_BLT::SOURCE_COMPRESSION_FORMAT>(srcCompressionFormat));
blitCmd.setDestinationCompressionFormat(static_cast<XY_BLOCK_COPY_BLT::DESTINATION_COMPRESSION_FORMAT>(dstCompressionFormat)); blitCmd.setDestinationCompressionFormat(static_cast<XY_BLOCK_COPY_BLT::DESTINATION_COMPRESSION_FORMAT>(dstCompressionFormat));
if (MemoryPoolHelper::isSystemMemoryPool(blitProperties.dstAllocation->getMemoryPool())) { if (!dstAllocation || MemoryPoolHelper::isSystemMemoryPool(dstAllocation->getMemoryPool())) {
blitCmd.setDestinationTargetMemory(XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM); blitCmd.setDestinationTargetMemory(XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
} }
if (MemoryPoolHelper::isSystemMemoryPool(blitProperties.srcAllocation->getMemoryPool())) { if (!srcAllocation || MemoryPoolHelper::isSystemMemoryPool(srcAllocation->getMemoryPool())) {
blitCmd.setSourceTargetMemory(XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM); blitCmd.setSourceTargetMemory(XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
} }

View File

@@ -142,7 +142,7 @@ void BlitCommandsHelper<Family>::appendBlitCommandsMemCopy(const BlitProperties
} }
DEBUG_BREAK_IF((AuxTranslationDirection::none != blitProperties.auxTranslationDirection) && DEBUG_BREAK_IF((AuxTranslationDirection::none != blitProperties.auxTranslationDirection) &&
(dstAllocation != srcAllocation || !dstAllocation->isCompressionEnabled())); (dstAllocation != srcAllocation || (dstAllocation && !dstAllocation->isCompressionEnabled())));
} }
template <> template <>
@@ -209,8 +209,8 @@ void BlitCommandsHelper<Family>::encodeWa(LinearStream &cmdStream, const BlitPro
const bool applyForDst = (debugManager.flags.EnableBcsSwControlWa.get() & dstInSystemMemOnly); const bool applyForDst = (debugManager.flags.EnableBcsSwControlWa.get() & dstInSystemMemOnly);
const bool applyAlways = (debugManager.flags.EnableBcsSwControlWa.get() == enableAlways); const bool applyAlways = (debugManager.flags.EnableBcsSwControlWa.get() == enableAlways);
const bool enableWa = (!blitProperties.srcAllocation->isAllocatedInLocalMemoryPool() && applyForSrc) || const bool enableWa = ((blitProperties.srcAllocation && !blitProperties.srcAllocation->isAllocatedInLocalMemoryPool()) && applyForSrc) ||
(!blitProperties.dstAllocation->isAllocatedInLocalMemoryPool() && applyForDst) || ((blitProperties.dstAllocation && !blitProperties.dstAllocation->isAllocatedInLocalMemoryPool()) && applyForDst) ||
applyAlways; applyAlways;
uint32_t newValue = enableWa ? waEnabledMMioValue : waDisabledMMioValue; uint32_t newValue = enableWa ? waEnabledMMioValue : waDisabledMMioValue;

View File

@@ -49,9 +49,9 @@ template <>
void BlitCommandsHelper<Family>::adjustControlSurfaceType(const BlitProperties &blitProperties, typename Family::XY_BLOCK_COPY_BLT &blitCmd) { void BlitCommandsHelper<Family>::adjustControlSurfaceType(const BlitProperties &blitProperties, typename Family::XY_BLOCK_COPY_BLT &blitCmd) {
using CONTROL_SURFACE_TYPE = typename Family::XY_BLOCK_COPY_BLT::CONTROL_SURFACE_TYPE; using CONTROL_SURFACE_TYPE = typename Family::XY_BLOCK_COPY_BLT::CONTROL_SURFACE_TYPE;
using COMPRESSION_ENABLE = typename Family::XY_BLOCK_COPY_BLT::COMPRESSION_ENABLE; using COMPRESSION_ENABLE = typename Family::XY_BLOCK_COPY_BLT::COMPRESSION_ENABLE;
auto srcAllocation = blitProperties.srcAllocation;
if (srcAllocation->getDefaultGmm()) { auto srcAllocation = blitProperties.srcAllocation;
if (srcAllocation && srcAllocation->getDefaultGmm()) {
auto gmmResourceInfo = srcAllocation->getDefaultGmm()->gmmResourceInfo.get(); auto gmmResourceInfo = srcAllocation->getDefaultGmm()->gmmResourceInfo.get();
auto resInfo = gmmResourceInfo->getResourceFlags()->Info; auto resInfo = gmmResourceInfo->getResourceFlags()->Info;
if (resInfo.MediaCompressed) { if (resInfo.MediaCompressed) {
@@ -62,7 +62,7 @@ void BlitCommandsHelper<Family>::adjustControlSurfaceType(const BlitProperties &
} }
auto dstAllocation = blitProperties.dstAllocation; auto dstAllocation = blitProperties.dstAllocation;
if (dstAllocation->getDefaultGmm()) { if (dstAllocation && dstAllocation->getDefaultGmm()) {
auto gmmResourceInfo = dstAllocation->getDefaultGmm()->gmmResourceInfo.get(); auto gmmResourceInfo = dstAllocation->getDefaultGmm()->gmmResourceInfo.get();
auto resInfo = gmmResourceInfo->getResourceFlags()->Info; auto resInfo = gmmResourceInfo->getResourceFlags()->Info;
if (resInfo.MediaCompressed) { if (resInfo.MediaCompressed) {
@@ -90,12 +90,13 @@ void BlitCommandsHelper<Family>::appendBlitCommandsBlockCopy(const BlitPropertie
compressionEnabledField = static_cast<typename XY_BLOCK_COPY_BLT::COMPRESSION_ENABLE>(debugManager.flags.ForceCompressionDisabledForCompressedBlitCopies.get()); compressionEnabledField = static_cast<typename XY_BLOCK_COPY_BLT::COMPRESSION_ENABLE>(debugManager.flags.ForceCompressionDisabledForCompressedBlitCopies.get());
} }
if (blitProperties.dstAllocation->isCompressionEnabled()) { if (blitProperties.dstAllocation && blitProperties.dstAllocation->isCompressionEnabled()) {
blitCmd.setDestinationCompressionEnable(compressionEnabledField); blitCmd.setDestinationCompressionEnable(compressionEnabledField);
blitCmd.setDestinationAuxiliarysurfacemode(XY_BLOCK_COPY_BLT::AUXILIARY_SURFACE_MODE_AUX_CCS_E); blitCmd.setDestinationAuxiliarysurfacemode(XY_BLOCK_COPY_BLT::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
blitCmd.setDestinationCompressionFormat(compressionFormat); blitCmd.setDestinationCompressionFormat(compressionFormat);
} }
if (blitProperties.srcAllocation->isCompressionEnabled()) {
if (blitProperties.srcAllocation && blitProperties.srcAllocation->isCompressionEnabled()) {
blitCmd.setSourceCompressionEnable(compressionEnabledField); blitCmd.setSourceCompressionEnable(compressionEnabledField);
blitCmd.setSourceAuxiliarysurfacemode(XY_BLOCK_COPY_BLT::AUXILIARY_SURFACE_MODE_AUX_CCS_E); blitCmd.setSourceAuxiliarysurfacemode(XY_BLOCK_COPY_BLT::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
blitCmd.setSourceCompressionFormat(compressionFormat); blitCmd.setSourceCompressionFormat(compressionFormat);
@@ -128,7 +129,7 @@ void BlitCommandsHelper<Family>::appendBlitCommandsBlockCopy(const BlitPropertie
} }
DEBUG_BREAK_IF((AuxTranslationDirection::none != blitProperties.auxTranslationDirection) && DEBUG_BREAK_IF((AuxTranslationDirection::none != blitProperties.auxTranslationDirection) &&
(blitProperties.dstAllocation != blitProperties.srcAllocation || !blitProperties.dstAllocation->isCompressionEnabled())); (blitProperties.dstAllocation != blitProperties.srcAllocation || (blitProperties.dstAllocation && !blitProperties.dstAllocation->isCompressionEnabled())));
auto mocs = rootDeviceEnvironment.getGmmHelper()->getUncachedMOCS(); auto mocs = rootDeviceEnvironment.getGmmHelper()->getUncachedMOCS();

View File

@@ -99,6 +99,7 @@ TEST_F(BlitPropertiesTests, givenBlitPropertiesWhenDstIs1DTiledArrayThenTransfor
EXPECT_EQ(blitProperties.dstOffset.y, 0u); EXPECT_EQ(blitProperties.dstOffset.y, 0u);
EXPECT_EQ(blitProperties.dstOffset.z, size.y); EXPECT_EQ(blitProperties.dstOffset.z, size.y);
} }
TEST_F(BlitPropertiesTests, givenBlitPropertiesWhenDstAndSrcIsNot1DTiledArrayThenSizeAndOffsetNotchanged) { TEST_F(BlitPropertiesTests, givenBlitPropertiesWhenDstAndSrcIsNot1DTiledArrayThenSizeAndOffsetNotchanged) {
blitProperties.transform1DArrayTo2DArrayIfNeeded(); blitProperties.transform1DArrayTo2DArrayIfNeeded();
@@ -143,4 +144,24 @@ TEST_F(BlitPropertiesTests, givenGmmResInfoForTiled1DWhenIs1DTiledArrayCalledThe
resourceInfoSrc->mockResourceCreateParams.ArraySize = 1; resourceInfoSrc->mockResourceCreateParams.ArraySize = 1;
EXPECT_FALSE(blitProperties.is1DTiledArray(resourceInfoSrc)); EXPECT_FALSE(blitProperties.is1DTiledArray(resourceInfoSrc));
} }
TEST_F(BlitPropertiesTests, givenNullSrcAllocationWhenCallingIsSrc1DTiledArrayThenFalseIsReturned) {
blitProperties.srcAllocation = nullptr;
EXPECT_FALSE(blitProperties.isSrc1DTiledArray());
}
TEST_F(BlitPropertiesTests, givenNullDstAllocationWhenCallingIsDst1DTiledArrayThenFalseIsReturned) {
blitProperties.dstAllocation = nullptr;
EXPECT_FALSE(blitProperties.isDst1DTiledArray());
}
TEST_F(BlitPropertiesTests, givenSrcAllocationWithNullGmmWhenCallingIsSrc1DTiledArrayThenFalseIsReturned) {
blitProperties.srcAllocation->setGmm(nullptr, 0);
EXPECT_FALSE(blitProperties.isSrc1DTiledArray());
}
TEST_F(BlitPropertiesTests, givenDstAllocationWithNullGmmWhenCallingIsDst1DTiledArrayThenFalseIsReturned) {
blitProperties.dstAllocation->setGmm(nullptr, 0);
EXPECT_FALSE(blitProperties.isDst1DTiledArray());
}
} // namespace NEO } // namespace NEO

View File

@@ -1422,3 +1422,258 @@ HWTEST2_F(BlitTests, givenXyCopyBltCommandWhenApplyBlitPropertiesIsCalledThenNot
NEO::BlitCommandsHelper<FamilyType>::applyAdditionalBlitProperties(properties, bltCmd, pDevice->getRootDeviceEnvironment(), true); NEO::BlitCommandsHelper<FamilyType>::applyAdditionalBlitProperties(properties, bltCmd, pDevice->getRootDeviceEnvironment(), true);
EXPECT_EQ(memcmp(&bltCmd, &bltCmdBefore, sizeof(XY_COPY_BLT)), 0); EXPECT_EQ(memcmp(&bltCmd, &bltCmdBefore, sizeof(XY_COPY_BLT)), 0);
} }
HWTEST2_F(BlitTests, givenSrcAndDstAllocationWithCompressionEnabledWhenAppendBlitCommandsBlockCopyThenSetSrcAndDstTargetMemToLocalMemAndCompressionHandled, IsXeHpgCore) {
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
XY_BLOCK_COPY_BLT blitCmd = FamilyType::cmdInitXyBlockCopyBlt;
blitCmd.setSourceX1CoordinateLeft(0);
blitCmd.setSourceY1CoordinateTop(0);
blitCmd.setDestinationX2CoordinateRight(1);
blitCmd.setDestinationY2CoordinateBottom(1);
BlitProperties properties{};
auto gmm = std::make_unique<MockGmm>(pDevice->getGmmHelper());
gmm->setCompressionEnabled(true);
MockGraphicsAllocation mockDstAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast<void *>(0x1234),
0x2000, 0, sizeof(uint32_t), MemoryPool::system4KBPages, MemoryManager::maxOsContextCount);
MockGraphicsAllocation mockSrcAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast<void *>(0x2345),
0x2000, 0, sizeof(uint32_t), MemoryPool::system4KBPages, MemoryManager::maxOsContextCount);
mockDstAllocation.setGmm(gmm.get(), 0);
mockSrcAllocation.setGmm(gmm.get(), 0);
properties.dstAllocation = &mockDstAllocation;
properties.srcAllocation = &mockSrcAllocation;
BlitCommandsHelper<FamilyType>::appendBlitCommandsBlockCopy(properties, blitCmd, pDevice->getRootDeviceEnvironment());
EXPECT_EQ(blitCmd.getDestinationTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_LOCAL_MEM);
EXPECT_EQ(blitCmd.getSourceTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_LOCAL_MEM);
EXPECT_EQ(blitCmd.getDestinationCompressionEnable(), XY_BLOCK_COPY_BLT::COMPRESSION_ENABLE::COMPRESSION_ENABLE_COMPRESSION_ENABLE);
EXPECT_EQ(blitCmd.getSourceCompressionEnable(), XY_BLOCK_COPY_BLT::COMPRESSION_ENABLE::COMPRESSION_ENABLE_COMPRESSION_ENABLE);
EXPECT_EQ(blitCmd.getDestinationAuxiliarysurfacemode(), XY_BLOCK_COPY_BLT::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
EXPECT_EQ(blitCmd.getSourceAuxiliarysurfacemode(), XY_BLOCK_COPY_BLT::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
}
HWTEST2_F(BlitTests, givenSrcAndDstAllocationWithoutCompressionEnabledWhenAppendBlitCommandsBlockCopyThenSetSrcAndDstTargetMemToLocalMemAndCompressionHandled, IsXeHpgCore) {
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
XY_BLOCK_COPY_BLT blitCmd = FamilyType::cmdInitXyBlockCopyBlt;
blitCmd.setSourceX1CoordinateLeft(0);
blitCmd.setSourceY1CoordinateTop(0);
blitCmd.setDestinationX2CoordinateRight(1);
blitCmd.setDestinationY2CoordinateBottom(1);
BlitProperties properties{};
auto gmm = std::make_unique<MockGmm>(pDevice->getGmmHelper());
gmm->setCompressionEnabled(false);
MockGraphicsAllocation mockDstAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast<void *>(0x1234),
0x2000, 0, sizeof(uint32_t), MemoryPool::system4KBPages, MemoryManager::maxOsContextCount);
MockGraphicsAllocation mockSrcAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast<void *>(0x2345),
0x2000, 0, sizeof(uint32_t), MemoryPool::system4KBPages, MemoryManager::maxOsContextCount);
mockDstAllocation.setGmm(gmm.get(), 0);
mockSrcAllocation.setGmm(gmm.get(), 0);
properties.dstAllocation = &mockDstAllocation;
properties.srcAllocation = &mockSrcAllocation;
BlitCommandsHelper<FamilyType>::appendBlitCommandsBlockCopy(properties, blitCmd, pDevice->getRootDeviceEnvironment());
EXPECT_EQ(blitCmd.getDestinationTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_LOCAL_MEM);
EXPECT_EQ(blitCmd.getSourceTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_LOCAL_MEM);
EXPECT_EQ(blitCmd.getDestinationCompressionEnable(), 0u);
EXPECT_EQ(blitCmd.getSourceCompressionEnable(), 0u);
EXPECT_EQ(blitCmd.getDestinationAuxiliarysurfacemode(), 0u);
EXPECT_EQ(blitCmd.getSourceAuxiliarysurfacemode(), 0u);
}
HWTEST2_F(BlitTests, givenNullAllocationsWhenAppendBlitCommandsBlockCopyThenSetSrcAndDstTargetMemToLocalMemAndCompressionHandled, IsXeHpgCore) {
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
XY_BLOCK_COPY_BLT blitCmd = FamilyType::cmdInitXyBlockCopyBlt;
blitCmd.setSourceX1CoordinateLeft(0);
blitCmd.setSourceY1CoordinateTop(0);
blitCmd.setDestinationX2CoordinateRight(1);
blitCmd.setDestinationY2CoordinateBottom(1);
BlitProperties properties{};
properties.dstAllocation = nullptr;
properties.srcAllocation = nullptr;
BlitCommandsHelper<FamilyType>::appendBlitCommandsBlockCopy(properties, blitCmd, pDevice->getRootDeviceEnvironment());
EXPECT_EQ(blitCmd.getDestinationTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_LOCAL_MEM);
EXPECT_EQ(blitCmd.getSourceTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_LOCAL_MEM);
EXPECT_EQ(blitCmd.getDestinationCompressionEnable(), 0u);
EXPECT_EQ(blitCmd.getSourceCompressionEnable(), 0u);
EXPECT_EQ(blitCmd.getDestinationAuxiliarysurfacemode(), 0u);
EXPECT_EQ(blitCmd.getSourceAuxiliarysurfacemode(), 0u);
}
HWTEST2_F(BlitTests, givenNullAllocationsWhenAdjustControlSurfaceTypeThenSurfaceTypeWillNotChange, IsXeHpgCore) {
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
XY_BLOCK_COPY_BLT blitCmd = FamilyType::cmdInitXyBlockCopyBlt;
BlitProperties properties{};
properties.srcAllocation = nullptr;
properties.dstAllocation = nullptr;
constexpr auto initialSrcSurface = 0; // CONTROL_SURFACE_TYPE_3D
constexpr auto initialDstSurface = 0; // CONTROL_SURFACE_TYPE_3D
BlitCommandsHelper<FamilyType>::adjustControlSurfaceType(properties, blitCmd);
EXPECT_EQ(blitCmd.getSourceControlSurfaceType(), initialSrcSurface);
EXPECT_EQ(blitCmd.getDestinationControlSurfaceType(), initialDstSurface);
}
HWTEST2_F(BlitTests, givenSrcAndDstAllocationWithCompressionEnabledAndForceBufferCompressionFormatSetWhenAppendBlitCommandsBlockCopyIsCalledThenSetSrcAndDstTargetMemToSystemMemAndCompressionHandled, IsAtLeastXe2HpgCore) {
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
XY_BLOCK_COPY_BLT blitCmd = FamilyType::cmdInitXyBlockCopyBlt;
blitCmd.setSourceX1CoordinateLeft(0);
blitCmd.setSourceY1CoordinateTop(0);
blitCmd.setDestinationX2CoordinateRight(1);
blitCmd.setDestinationY2CoordinateBottom(1);
BlitProperties properties = {};
DebugManagerStateRestore dbgRestore;
uint32_t compressionFormat = 1;
debugManager.flags.ForceBufferCompressionFormat.set(static_cast<int32_t>(compressionFormat));
auto gmm = std::make_unique<MockGmm>(pDevice->getGmmHelper());
gmm->setCompressionEnabled(true);
MockGraphicsAllocation mockDstAllocation(0, 1u /*num gmms*/, AllocationType::buffer, reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t), MemoryPool::system4KBPages, MemoryManager::maxOsContextCount);
MockGraphicsAllocation mockSrcAllocation(0, 1u /*num gmms*/, AllocationType::buffer, reinterpret_cast<void *>(0x2345), 0x2000, 0, sizeof(uint32_t), MemoryPool::system4KBPages, MemoryManager::maxOsContextCount);
mockDstAllocation.setGmm(gmm.get(), 0);
mockSrcAllocation.setGmm(gmm.get(), 0);
properties.dstAllocation = &mockDstAllocation;
properties.srcAllocation = &mockSrcAllocation;
BlitCommandsHelper<FamilyType>::appendBlitCommandsBlockCopy(properties, blitCmd, pDevice->getRootDeviceEnvironment());
EXPECT_EQ(blitCmd.getDestinationCompressionFormat(), compressionFormat);
EXPECT_EQ(blitCmd.getSourceCompressionFormat(), compressionFormat);
EXPECT_EQ(blitCmd.getDestinationTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
EXPECT_EQ(blitCmd.getSourceTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
}
HWTEST2_F(BlitTests, givenSrcAllocationWithoutCompressionEnabledAndForceBufferCompressionFormatSetWhenAppendBlitCommandsBlockCopyIsCalledThenSetSrcTargetMemToSystemMemAndCompressionHandled, IsAtLeastXe2HpgCore) {
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
XY_BLOCK_COPY_BLT blitCmd = FamilyType::cmdInitXyBlockCopyBlt;
blitCmd.setSourceX1CoordinateLeft(0);
blitCmd.setSourceY1CoordinateTop(0);
blitCmd.setDestinationX2CoordinateRight(1);
blitCmd.setDestinationY2CoordinateBottom(1);
BlitProperties properties = {};
DebugManagerStateRestore dbgRestore;
MockGraphicsAllocation mockSrcAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast<void *>(0x1234),
0x2000, 0, sizeof(uint32_t), MemoryPool::system4KBPages, MemoryManager::maxOsContextCount);
auto gmm = std::make_unique<MockGmm>(pDevice->getGmmHelper());
gmm->setCompressionEnabled(false);
mockSrcAllocation.setGmm(gmm.get(), 0);
properties.srcAllocation = &mockSrcAllocation;
properties.dstAllocation = nullptr;
debugManager.flags.ForceBufferCompressionFormat.set(1);
auto initialDstCompressionFormat = blitCmd.getDestinationCompressionFormat();
auto initialSrcCompressionFormat = blitCmd.getSourceCompressionFormat();
BlitCommandsHelper<FamilyType>::appendBlitCommandsBlockCopy(properties, blitCmd, pDevice->getRootDeviceEnvironment());
EXPECT_EQ(blitCmd.getDestinationCompressionFormat(), initialDstCompressionFormat);
EXPECT_EQ(blitCmd.getSourceCompressionFormat(), initialSrcCompressionFormat);
EXPECT_EQ(blitCmd.getDestinationTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
EXPECT_EQ(blitCmd.getSourceTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
}
HWTEST2_F(BlitTests, givenDstAllocationWithoutCompressionEnabledAndForceBufferCompressionFormatSetWhenAppendBlitCommandsBlockCopyIsCalledThenSetDstTargetMemToSystemMemAndCompressionHandled, IsAtLeastXe2HpgCore) {
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
XY_BLOCK_COPY_BLT blitCmd = FamilyType::cmdInitXyBlockCopyBlt;
blitCmd.setSourceX1CoordinateLeft(0);
blitCmd.setSourceY1CoordinateTop(0);
blitCmd.setDestinationX2CoordinateRight(1);
blitCmd.setDestinationY2CoordinateBottom(1);
BlitProperties properties = {};
DebugManagerStateRestore dbgRestore;
MockGraphicsAllocation mockDstAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast<void *>(0x1234),
0x2000, 0, sizeof(uint32_t), MemoryPool::system4KBPages, MemoryManager::maxOsContextCount);
auto gmm = std::make_unique<MockGmm>(pDevice->getGmmHelper());
gmm->setCompressionEnabled(false);
mockDstAllocation.setGmm(gmm.get(), 0);
properties.dstAllocation = &mockDstAllocation;
properties.srcAllocation = nullptr;
debugManager.flags.ForceBufferCompressionFormat.set(1);
auto initialDstCompressionFormat = blitCmd.getDestinationCompressionFormat();
auto initialSrcCompressionFormat = blitCmd.getSourceCompressionFormat();
BlitCommandsHelper<FamilyType>::appendBlitCommandsBlockCopy(properties, blitCmd, pDevice->getRootDeviceEnvironment());
EXPECT_EQ(blitCmd.getDestinationCompressionFormat(), initialDstCompressionFormat);
EXPECT_EQ(blitCmd.getSourceCompressionFormat(), initialSrcCompressionFormat);
EXPECT_EQ(blitCmd.getDestinationTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
EXPECT_EQ(blitCmd.getSourceTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
}
HWTEST2_F(BlitTests, givenNullAllocationsAndForceBufferCompressionFormatSetWhenAppendBlitCommandsBlockCopyIsCalledThenSetSrcAndDstTargetMemToSystemMemAndCompressionHandled, IsAtLeastXe2HpgCore) {
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
XY_BLOCK_COPY_BLT blitCmd = FamilyType::cmdInitXyBlockCopyBlt;
blitCmd.setSourceX1CoordinateLeft(0);
blitCmd.setSourceY1CoordinateTop(0);
blitCmd.setDestinationX2CoordinateRight(1);
blitCmd.setDestinationY2CoordinateBottom(1);
BlitProperties properties = {};
DebugManagerStateRestore dbgRestore;
properties.dstAllocation = nullptr;
properties.srcAllocation = nullptr;
debugManager.flags.ForceBufferCompressionFormat.set(1);
auto initialDstCompressionFormat = blitCmd.getDestinationCompressionFormat();
auto initialSrcCompressionFormat = blitCmd.getSourceCompressionFormat();
BlitCommandsHelper<FamilyType>::appendBlitCommandsBlockCopy(properties, blitCmd, pDevice->getRootDeviceEnvironment());
EXPECT_EQ(blitCmd.getDestinationCompressionFormat(), initialDstCompressionFormat);
EXPECT_EQ(blitCmd.getSourceCompressionFormat(), initialSrcCompressionFormat);
EXPECT_EQ(blitCmd.getDestinationTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
EXPECT_EQ(blitCmd.getSourceTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
}
HWTEST2_F(BlitTests, givenNullAllocationsWhenAppendBlitCommandsForImagesThenSlicePitchesWillBeUpdated, IsNotPVC) {
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
XY_BLOCK_COPY_BLT blitCmd = FamilyType::cmdInitXyBlockCopyBlt;
BlitProperties properties{};
properties.dstAllocation = nullptr;
properties.srcAllocation = nullptr;
properties.dstSize = {8, 12, 1};
properties.srcSize = {10, 10, 1};
properties.dstRowPitch = 0x40;
properties.srcRowPitch = 0x10;
uint32_t dstSlicePitch = 0;
uint32_t srcSlicePitch = 0;
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, blitCmd, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch);
EXPECT_NE(dstSlicePitch, 0u);
EXPECT_NE(srcSlicePitch, 0u);
}