mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 00:24:58 +08:00
Add blitter support for read/write image OpenCL
Change-Id: I5d8bf0590899751f1f562fd55e44b0ed36ca6110 Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com> Related-To: NEO-4692
This commit is contained in:
@@ -804,6 +804,7 @@ using BlitBlockCopyPlatforms = IsWithinProducts<IGFX_SKYLAKE, IGFX_TIGERLAKE_LP>
|
||||
HWTEST2_F(CommandListCreate, givenCopyCommandListWhenCopyRegionWithinMaxBlitSizeThenOneBlitCommandHasBeenSpown, BlitBlockCopyPlatforms) {
|
||||
using GfxFamily = typename NEO::GfxFamilyMapper<gfxCoreFamily>::GfxFamily;
|
||||
using XY_COPY_BLT = typename GfxFamily::XY_COPY_BLT;
|
||||
using MI_ARB_CHECK = typename GfxFamily::MI_ARB_CHECK;
|
||||
|
||||
auto commandList = std::make_unique<WhiteBox<::L0::CommandListCoreFamily<gfxCoreFamily>>>();
|
||||
commandList->initialize(device, NEO::EngineGroupType::Copy);
|
||||
@@ -829,6 +830,8 @@ HWTEST2_F(CommandListCreate, givenCopyCommandListWhenCopyRegionWithinMaxBlitSize
|
||||
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);
|
||||
itor = find<MI_ARB_CHECK *>(cmdList.begin(), cmdList.end());
|
||||
EXPECT_NE(cmdList.end(), itor);
|
||||
itor++;
|
||||
EXPECT_EQ(cmdList.end(), itor);
|
||||
}
|
||||
|
||||
@@ -637,18 +637,27 @@ bool CommandQueue::queueDependenciesClearRequired() const {
|
||||
}
|
||||
|
||||
bool CommandQueue::blitEnqueueAllowed(cl_command_type cmdType) const {
|
||||
bool blitAllowed = device->getHardwareInfo().capabilityTable.blitterOperationsSupported || this->isCopyOnly;
|
||||
|
||||
auto blitAllowed = device->getHardwareInfo().capabilityTable.blitterOperationsSupported || this->isCopyOnly;
|
||||
if (DebugManager.flags.EnableBlitterOperationsForReadWriteBuffers.get() != -1) {
|
||||
blitAllowed &= !!DebugManager.flags.EnableBlitterOperationsForReadWriteBuffers.get();
|
||||
|
||||
blitAllowed &= static_cast<bool>(DebugManager.flags.EnableBlitterOperationsForReadWriteBuffers.get());
|
||||
}
|
||||
|
||||
bool commandAllowed = (CL_COMMAND_READ_BUFFER == cmdType) || (CL_COMMAND_WRITE_BUFFER == cmdType) ||
|
||||
(CL_COMMAND_COPY_BUFFER == cmdType) || (CL_COMMAND_READ_BUFFER_RECT == cmdType) ||
|
||||
(CL_COMMAND_WRITE_BUFFER_RECT == cmdType) || (CL_COMMAND_COPY_BUFFER_RECT == cmdType) ||
|
||||
(CL_COMMAND_SVM_MEMCPY == cmdType);
|
||||
|
||||
return commandAllowed && blitAllowed;
|
||||
switch (cmdType) {
|
||||
case CL_COMMAND_READ_BUFFER:
|
||||
case CL_COMMAND_WRITE_BUFFER:
|
||||
case CL_COMMAND_COPY_BUFFER:
|
||||
case CL_COMMAND_READ_BUFFER_RECT:
|
||||
case CL_COMMAND_WRITE_BUFFER_RECT:
|
||||
case CL_COMMAND_COPY_BUFFER_RECT:
|
||||
case CL_COMMAND_SVM_MEMCPY:
|
||||
case CL_COMMAND_READ_IMAGE:
|
||||
case CL_COMMAND_WRITE_IMAGE:
|
||||
return blitAllowed;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CommandQueue::isBlockedCommandStreamRequired(uint32_t commandType, const EventsRequest &eventsRequest, bool blockedQueue) const {
|
||||
|
||||
@@ -41,27 +41,23 @@ cl_int CommandQueueHw<GfxFamily>::enqueueReadImage(
|
||||
const cl_event *eventWaitList,
|
||||
cl_event *event) {
|
||||
|
||||
auto &csr = getGpgpuCommandStreamReceiver();
|
||||
auto cmdType = CL_COMMAND_READ_IMAGE;
|
||||
auto &csr = getCommandStreamReceiverByCommandType(cmdType);
|
||||
if (nullptr == mapAllocation) {
|
||||
notifyEnqueueReadImage(srcImage, !!blockingRead, EngineHelpers::isBcs(csr.getOsContext().getEngineType()));
|
||||
notifyEnqueueReadImage(srcImage, static_cast<bool>(blockingRead), EngineHelpers::isBcs(csr.getOsContext().getEngineType()));
|
||||
}
|
||||
|
||||
auto isMemTransferNeeded = true;
|
||||
if (srcImage->isMemObjZeroCopy()) {
|
||||
size_t hostOffset;
|
||||
Image::calculateHostPtrOffset(&hostOffset, origin, region, inputRowPitch, inputSlicePitch, srcImage->getImageDesc().image_type, srcImage->getSurfaceFormatInfo().surfaceFormat.ImageElementSizeInBytes);
|
||||
isMemTransferNeeded = srcImage->checkIfMemoryTransferIsRequired(hostOffset, 0, ptr, CL_COMMAND_READ_IMAGE);
|
||||
isMemTransferNeeded = srcImage->checkIfMemoryTransferIsRequired(hostOffset, 0, ptr, cmdType);
|
||||
}
|
||||
if (!isMemTransferNeeded) {
|
||||
return enqueueMarkerForReadWriteOperation(srcImage, ptr, CL_COMMAND_READ_IMAGE, blockingRead,
|
||||
return enqueueMarkerForReadWriteOperation(srcImage, ptr, cmdType, blockingRead,
|
||||
numEventsInWaitList, eventWaitList, event);
|
||||
}
|
||||
|
||||
auto &builder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(EBuiltInOps::CopyImage3dToBuffer,
|
||||
this->getDevice());
|
||||
|
||||
BuiltInOwnershipWrapper builtInLock(builder, this->context);
|
||||
|
||||
size_t hostPtrSize = calculateHostPtrSizeForImage(region, inputRowPitch, inputSlicePitch, srcImage);
|
||||
void *dstPtr = ptr;
|
||||
|
||||
@@ -103,18 +99,12 @@ cl_int CommandQueueHw<GfxFamily>::enqueueReadImage(
|
||||
if (srcImage->getImageDesc().num_mip_levels > 0) {
|
||||
dc.srcMipLevel = findMipLevel(srcImage->getImageDesc().image_type, origin);
|
||||
}
|
||||
dc.transferAllocation = mapAllocation ? mapAllocation : hostPtrSurf.getAllocation();
|
||||
|
||||
MultiDispatchInfo di(dc);
|
||||
auto eBuiltInOps = EBuiltInOps::CopyImage3dToBuffer;
|
||||
MultiDispatchInfo dispatchInfo(dc);
|
||||
|
||||
builder.buildDispatchInfos(di);
|
||||
|
||||
enqueueHandler<CL_COMMAND_READ_IMAGE>(
|
||||
surfaces,
|
||||
blockingRead == CL_TRUE,
|
||||
di,
|
||||
numEventsInWaitList,
|
||||
eventWaitList,
|
||||
event);
|
||||
dispatchBcsOrGpgpuEnqueue<CL_COMMAND_READ_IMAGE>(dispatchInfo, surfaces, eBuiltInOps, numEventsInWaitList, eventWaitList, event, blockingRead == CL_TRUE);
|
||||
|
||||
if (context->isProvidingPerformanceHints()) {
|
||||
if (!isL3Capable(ptr, hostPtrSize)) {
|
||||
|
||||
@@ -35,20 +35,17 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteImage(
|
||||
const cl_event *eventWaitList,
|
||||
cl_event *event) {
|
||||
|
||||
auto cmdType = CL_COMMAND_WRITE_IMAGE;
|
||||
auto isMemTransferNeeded = true;
|
||||
if (dstImage->isMemObjZeroCopy()) {
|
||||
size_t hostOffset;
|
||||
Image::calculateHostPtrOffset(&hostOffset, origin, region, inputRowPitch, inputSlicePitch, dstImage->getImageDesc().image_type, dstImage->getSurfaceFormatInfo().surfaceFormat.ImageElementSizeInBytes);
|
||||
isMemTransferNeeded = dstImage->checkIfMemoryTransferIsRequired(hostOffset, 0, ptr, CL_COMMAND_WRITE_IMAGE);
|
||||
isMemTransferNeeded = dstImage->checkIfMemoryTransferIsRequired(hostOffset, 0, ptr, cmdType);
|
||||
}
|
||||
if (!isMemTransferNeeded) {
|
||||
return enqueueMarkerForReadWriteOperation(dstImage, const_cast<void *>(ptr), CL_COMMAND_WRITE_IMAGE, blockingWrite,
|
||||
return enqueueMarkerForReadWriteOperation(dstImage, const_cast<void *>(ptr), cmdType, blockingWrite,
|
||||
numEventsInWaitList, eventWaitList, event);
|
||||
}
|
||||
auto &builder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(EBuiltInOps::CopyBufferToImage3d,
|
||||
this->getDevice());
|
||||
|
||||
BuiltInOwnershipWrapper lock(builder, this->context);
|
||||
|
||||
size_t hostPtrSize = calculateHostPtrSizeForImage(region, inputRowPitch, inputSlicePitch, dstImage);
|
||||
void *srcPtr = const_cast<void *>(ptr);
|
||||
@@ -69,7 +66,8 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteImage(
|
||||
if (region[0] != 0 &&
|
||||
region[1] != 0 &&
|
||||
region[2] != 0) {
|
||||
bool status = getGpgpuCommandStreamReceiver().createAllocationForHostSurface(hostPtrSurf, false);
|
||||
auto &csr = getCommandStreamReceiverByCommandType(cmdType);
|
||||
bool status = csr.createAllocationForHostSurface(hostPtrSurf, false);
|
||||
if (!status) {
|
||||
return CL_OUT_OF_RESOURCES;
|
||||
}
|
||||
@@ -91,17 +89,12 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteImage(
|
||||
if (dstImage->getImageDesc().num_mip_levels > 0) {
|
||||
dc.dstMipLevel = findMipLevel(dstImage->getImageDesc().image_type, origin);
|
||||
}
|
||||
dc.transferAllocation = mapAllocation ? mapAllocation : hostPtrSurf.getAllocation();
|
||||
|
||||
MultiDispatchInfo di(dc);
|
||||
builder.buildDispatchInfos(di);
|
||||
auto eBuiltInOps = EBuiltInOps::CopyBufferToImage3d;
|
||||
MultiDispatchInfo dispatchInfo(dc);
|
||||
|
||||
enqueueHandler<CL_COMMAND_WRITE_IMAGE>(
|
||||
surfaces,
|
||||
blockingWrite == CL_TRUE,
|
||||
di,
|
||||
numEventsInWaitList,
|
||||
eventWaitList,
|
||||
event);
|
||||
dispatchBcsOrGpgpuEnqueue<CL_COMMAND_WRITE_IMAGE>(dispatchInfo, surfaces, eBuiltInOps, numEventsInWaitList, eventWaitList, event, blockingWrite == CL_TRUE);
|
||||
|
||||
if (context->isProvidingPerformanceHints()) {
|
||||
context->providePerformanceHint(CL_CONTEXT_DIAGNOSTICS_LEVEL_NEUTRAL_INTEL, CL_ENQUEUE_WRITE_IMAGE_REQUIRES_COPY_DATA, static_cast<cl_mem>(dstImage));
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "shared/source/helpers/blit_commands_helper.h"
|
||||
|
||||
#include "opencl/source/built_ins/builtins_dispatch_builder.h"
|
||||
#include "opencl/source/mem_obj/image.h"
|
||||
|
||||
#include "CL/cl.h"
|
||||
|
||||
@@ -47,6 +48,7 @@ struct ClBlitProperties {
|
||||
builtinOpParams.dstRowPitch, builtinOpParams.dstSlicePitch);
|
||||
}
|
||||
|
||||
BlitProperties blitProperties{};
|
||||
GraphicsAllocation *gpuAllocation = nullptr;
|
||||
Vec3<size_t> copyOffset = 0;
|
||||
|
||||
@@ -64,8 +66,9 @@ struct ClBlitProperties {
|
||||
size_t gpuRowPitch = 0;
|
||||
size_t gpuSlicePitch = 0;
|
||||
|
||||
if (BlitterConstants::BlitDirection::HostPtrToBuffer == blitDirection) {
|
||||
// write buffer
|
||||
if (BlitterConstants::BlitDirection::HostPtrToBuffer == blitDirection ||
|
||||
BlitterConstants::BlitDirection::HostPtrToImage == blitDirection) {
|
||||
// write buffer/image
|
||||
hostPtr = builtinOpParams.srcPtr;
|
||||
hostPtrOffset = builtinOpParams.srcOffset;
|
||||
copyOffset = builtinOpParams.dstOffset;
|
||||
@@ -88,10 +91,10 @@ struct ClBlitProperties {
|
||||
copySize = builtinOpParams.size;
|
||||
}
|
||||
|
||||
if (BlitterConstants::BlitDirection::BufferToHostPtr == blitDirection) {
|
||||
// read buffer
|
||||
if (BlitterConstants::BlitDirection::BufferToHostPtr == blitDirection ||
|
||||
BlitterConstants::BlitDirection::ImageToHostPtr == blitDirection) {
|
||||
// read buffer/image
|
||||
hostPtr = builtinOpParams.dstPtr;
|
||||
|
||||
hostPtrOffset = builtinOpParams.dstOffset;
|
||||
copyOffset = builtinOpParams.srcOffset;
|
||||
|
||||
@@ -114,27 +117,79 @@ struct ClBlitProperties {
|
||||
}
|
||||
|
||||
UNRECOVERABLE_IF(BlitterConstants::BlitDirection::HostPtrToBuffer != blitDirection &&
|
||||
BlitterConstants::BlitDirection::BufferToHostPtr != blitDirection);
|
||||
BlitterConstants::BlitDirection::BufferToHostPtr != blitDirection &&
|
||||
BlitterConstants::BlitDirection::HostPtrToImage != blitDirection &&
|
||||
BlitterConstants::BlitDirection::ImageToHostPtr != blitDirection);
|
||||
|
||||
return BlitProperties::constructPropertiesForReadWriteBuffer(blitDirection, commandStreamReceiver, gpuAllocation,
|
||||
hostAllocation, hostPtr, memObjGpuVa, hostAllocGpuVa,
|
||||
hostPtrOffset, copyOffset, copySize,
|
||||
hostRowPitch, hostSlicePitch,
|
||||
gpuRowPitch, gpuSlicePitch);
|
||||
blitProperties = BlitProperties::constructPropertiesForReadWriteBuffer(blitDirection, commandStreamReceiver, gpuAllocation,
|
||||
hostAllocation, hostPtr, memObjGpuVa, hostAllocGpuVa,
|
||||
hostPtrOffset, copyOffset, copySize,
|
||||
hostRowPitch, hostSlicePitch,
|
||||
gpuRowPitch, gpuSlicePitch);
|
||||
|
||||
if (BlitterConstants::BlitDirection::HostPtrToImage == blitDirection ||
|
||||
BlitterConstants::BlitDirection::ImageToHostPtr == blitDirection) {
|
||||
adjustBlitPropertiesForImage(blitProperties, builtinOpParams);
|
||||
}
|
||||
|
||||
return blitProperties;
|
||||
}
|
||||
|
||||
static BlitterConstants::BlitDirection obtainBlitDirection(uint32_t commandType) {
|
||||
if (CL_COMMAND_WRITE_BUFFER == commandType || CL_COMMAND_WRITE_BUFFER_RECT == commandType) {
|
||||
|
||||
switch (commandType) {
|
||||
case CL_COMMAND_WRITE_BUFFER:
|
||||
case CL_COMMAND_WRITE_BUFFER_RECT:
|
||||
return BlitterConstants::BlitDirection::HostPtrToBuffer;
|
||||
} else if (CL_COMMAND_READ_BUFFER == commandType || CL_COMMAND_READ_BUFFER_RECT == commandType) {
|
||||
case CL_COMMAND_READ_BUFFER:
|
||||
case CL_COMMAND_READ_BUFFER_RECT:
|
||||
return BlitterConstants::BlitDirection::BufferToHostPtr;
|
||||
} else if (CL_COMMAND_COPY_BUFFER_RECT == commandType || CL_COMMAND_SVM_MEMCPY == commandType) {
|
||||
return BlitterConstants::BlitDirection::BufferToBuffer;
|
||||
} else {
|
||||
UNRECOVERABLE_IF(CL_COMMAND_COPY_BUFFER != commandType);
|
||||
case CL_COMMAND_COPY_BUFFER:
|
||||
case CL_COMMAND_COPY_BUFFER_RECT:
|
||||
case CL_COMMAND_SVM_MEMCPY:
|
||||
return BlitterConstants::BlitDirection::BufferToBuffer;
|
||||
case CL_COMMAND_WRITE_IMAGE:
|
||||
return BlitterConstants::BlitDirection::HostPtrToImage;
|
||||
case CL_COMMAND_READ_IMAGE:
|
||||
return BlitterConstants::BlitDirection::ImageToHostPtr;
|
||||
default:
|
||||
UNRECOVERABLE_IF(true);
|
||||
}
|
||||
}
|
||||
|
||||
static void adjustBlitPropertiesForImage(BlitProperties &blitProperties, const BuiltinOpParams &builtinOpParams) {
|
||||
|
||||
Image *srcImage = nullptr;
|
||||
Image *dstImage = nullptr;
|
||||
|
||||
blitProperties.srcSize = {static_cast<uint32_t>(builtinOpParams.size.x),
|
||||
static_cast<uint32_t>(builtinOpParams.size.y),
|
||||
static_cast<uint32_t>(builtinOpParams.size.z)};
|
||||
|
||||
blitProperties.dstSize = {static_cast<uint32_t>(builtinOpParams.size.x),
|
||||
static_cast<uint32_t>(builtinOpParams.size.y),
|
||||
static_cast<uint32_t>(builtinOpParams.size.z)};
|
||||
|
||||
if (blitProperties.blitDirection == BlitterConstants::BlitDirection::ImageToHostPtr) {
|
||||
srcImage = castToObject<Image>(builtinOpParams.srcMemObj);
|
||||
blitProperties.bytesPerPixel = srcImage->getSurfaceFormatInfo().surfaceFormat.ImageElementSizeInBytes;
|
||||
blitProperties.srcSize.x = static_cast<uint32_t>(srcImage->getImageDesc().image_width);
|
||||
blitProperties.srcSize.y = static_cast<uint32_t>(srcImage->getImageDesc().image_height);
|
||||
blitProperties.srcSize.z = static_cast<uint32_t>(srcImage->getImageDesc().image_depth);
|
||||
|
||||
} else {
|
||||
dstImage = castToObject<Image>(builtinOpParams.dstMemObj);
|
||||
blitProperties.bytesPerPixel = dstImage->getSurfaceFormatInfo().surfaceFormat.ImageElementSizeInBytes;
|
||||
blitProperties.dstSize.x = static_cast<uint32_t>(dstImage->getImageDesc().image_width);
|
||||
blitProperties.dstSize.y = static_cast<uint32_t>(dstImage->getImageDesc().image_height);
|
||||
blitProperties.dstSize.z = static_cast<uint32_t>(dstImage->getImageDesc().image_depth);
|
||||
}
|
||||
|
||||
blitProperties.srcRowPitch = builtinOpParams.dstRowPitch ? builtinOpParams.dstRowPitch : blitProperties.srcSize.x * blitProperties.bytesPerPixel;
|
||||
blitProperties.dstRowPitch = builtinOpParams.srcRowPitch ? builtinOpParams.srcRowPitch : blitProperties.dstSize.x * blitProperties.bytesPerPixel;
|
||||
blitProperties.srcSlicePitch = builtinOpParams.dstSlicePitch ? builtinOpParams.dstSlicePitch : blitProperties.srcSize.y * blitProperties.srcRowPitch;
|
||||
blitProperties.dstSlicePitch = builtinOpParams.srcSlicePitch ? builtinOpParams.srcSlicePitch : blitProperties.dstSize.y * blitProperties.dstRowPitch;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -1150,3 +1150,21 @@ TEST(CommandQueue, givenCopyOnlyQueueWhenCallingBlitEnqueueAllowedThenReturnTrue
|
||||
queue.isCopyOnly = true;
|
||||
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_READ_BUFFER));
|
||||
}
|
||||
|
||||
TEST(CommandQueue, giveClCommandWhenCallingBlitEnqueueAllowedThenReturnCorrectValue) {
|
||||
MockContext context{};
|
||||
HardwareInfo *hwInfo = context.getDevice(0)->getRootDeviceEnvironment().getMutableHardwareInfo();
|
||||
MockCommandQueue queue(&context, context.getDevice(0), 0);
|
||||
hwInfo->capabilityTable.blitterOperationsSupported = true;
|
||||
|
||||
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_READ_BUFFER));
|
||||
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_WRITE_BUFFER));
|
||||
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_COPY_BUFFER));
|
||||
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_READ_BUFFER_RECT));
|
||||
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_WRITE_BUFFER_RECT));
|
||||
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_COPY_BUFFER_RECT));
|
||||
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_SVM_MEMCPY));
|
||||
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_READ_IMAGE));
|
||||
EXPECT_TRUE(queue.blitEnqueueAllowed(CL_COMMAND_WRITE_IMAGE));
|
||||
EXPECT_FALSE(queue.blitEnqueueAllowed(CL_COMMAND_COPY_IMAGE));
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "shared/test/unit_test/utilities/base_object_utils.h"
|
||||
|
||||
#include "opencl/source/event/user_event.h"
|
||||
#include "opencl/source/helpers/cl_blit_properties.h"
|
||||
#include "opencl/test/unit_test/command_stream/command_stream_receiver_hw_fixture.h"
|
||||
#include "opencl/test/unit_test/fixtures/ult_command_stream_receiver_fixture.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_command_queue.h"
|
||||
@@ -771,6 +772,33 @@ HWTEST_F(BcsTests, givenBltSizeWithLeftoverWhenDispatchedThenProgramAllRequiredC
|
||||
EXPECT_NE(nullptr, genCmdCast<typename FamilyType::MI_NOOP *>(*(cmdIterator++)));
|
||||
}
|
||||
}
|
||||
HWTEST_F(BcsTests, givenCommandTypeWhenObtainBlitDirectionIsCalledThenReturnCorrectBlitDirection) {
|
||||
|
||||
std::array<std::pair<uint32_t, BlitterConstants::BlitDirection>, 9> testParams{
|
||||
std::make_pair(CL_COMMAND_WRITE_BUFFER, BlitterConstants::BlitDirection::HostPtrToBuffer),
|
||||
std::make_pair(CL_COMMAND_WRITE_BUFFER_RECT, BlitterConstants::BlitDirection::HostPtrToBuffer),
|
||||
std::make_pair(CL_COMMAND_READ_BUFFER, BlitterConstants::BlitDirection::BufferToHostPtr),
|
||||
std::make_pair(CL_COMMAND_READ_BUFFER_RECT, BlitterConstants::BlitDirection::BufferToHostPtr),
|
||||
std::make_pair(CL_COMMAND_COPY_BUFFER_RECT, BlitterConstants::BlitDirection::BufferToBuffer),
|
||||
std::make_pair(CL_COMMAND_SVM_MEMCPY, BlitterConstants::BlitDirection::BufferToBuffer),
|
||||
std::make_pair(CL_COMMAND_WRITE_IMAGE, BlitterConstants::BlitDirection::HostPtrToImage),
|
||||
std::make_pair(CL_COMMAND_READ_IMAGE, BlitterConstants::BlitDirection::ImageToHostPtr),
|
||||
std::make_pair(CL_COMMAND_COPY_BUFFER, BlitterConstants::BlitDirection::BufferToBuffer)};
|
||||
|
||||
for (const auto ¶ms : testParams) {
|
||||
uint32_t commandType;
|
||||
BlitterConstants::BlitDirection expectedBlitDirection;
|
||||
std::tie(commandType, expectedBlitDirection) = params;
|
||||
|
||||
auto blitDirection = ClBlitProperties::obtainBlitDirection(commandType);
|
||||
EXPECT_EQ(expectedBlitDirection, blitDirection);
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(BcsTests, givenWrongCommandTypeWhenObtainBlitDirectionIsCalledThenExpectThrow) {
|
||||
uint32_t wrongCommandType = CL_COMMAND_COPY_IMAGE;
|
||||
EXPECT_THROW(ClBlitProperties::obtainBlitDirection(wrongCommandType), std::exception);
|
||||
}
|
||||
|
||||
struct BcsTestParam {
|
||||
Vec3<size_t> copySize;
|
||||
|
||||
@@ -12,10 +12,12 @@
|
||||
#include "opencl/source/helpers/cl_blit_properties.h"
|
||||
#include "opencl/source/mem_obj/mem_obj_helper.h"
|
||||
#include "opencl/test/unit_test/command_stream/command_stream_receiver_hw_fixture.h"
|
||||
#include "opencl/test/unit_test/fixtures/image_fixture.h"
|
||||
#include "opencl/test/unit_test/fixtures/ult_command_stream_receiver_fixture.h"
|
||||
#include "opencl/test/unit_test/helpers/raii_hw_helper.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_allocation_properties.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_hw_helper.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_image.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_internal_allocation_storage.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_kernel.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
|
||||
@@ -1162,6 +1164,270 @@ HWTEST_F(BcsTests, givenInvalidBlitDirectionWhenConstructPropertiesThenException
|
||||
EXPECT_THROW(ClBlitProperties::constructProperties(static_cast<BlitterConstants::BlitDirection>(7), csr, {}), std::exception);
|
||||
}
|
||||
|
||||
HWTEST_F(BcsTests, givenHostPtrToImageWhenConstructPropertiesIsCalledThenValuesAreSetCorrectly) {
|
||||
void *hostPtr = reinterpret_cast<void *>(0x12340000);
|
||||
cl_image_desc imgDesc = Image2dDefaults::imageDesc;
|
||||
imgDesc.image_width = 10u;
|
||||
imgDesc.image_height = 12u;
|
||||
std::unique_ptr<Image> image(Image2dHelper<>::create(context.get(), &imgDesc));
|
||||
BuiltinOpParams builtinOpParams{};
|
||||
builtinOpParams.srcPtr = hostPtr;
|
||||
builtinOpParams.srcMemObj = nullptr;
|
||||
builtinOpParams.dstMemObj = image.get();
|
||||
builtinOpParams.size = {2, 3, 1};
|
||||
|
||||
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
auto expectedDstPtr = image.get()->getGraphicsAllocation(csr.getRootDeviceIndex())->getGpuAddress();
|
||||
auto expectedBytesPerPixel = image.get()->getSurfaceFormatInfo().surfaceFormat.ImageElementSizeInBytes;
|
||||
auto srcRowPitchExpected = expectedBytesPerPixel * builtinOpParams.size.x;
|
||||
auto dstRowPitchExpected = expectedBytesPerPixel * image.get()->getImageDesc().image_width;
|
||||
auto srcSlicePitchExpected = srcRowPitchExpected * builtinOpParams.size.y;
|
||||
auto dstSlicePitchExpected = dstRowPitchExpected * image.get()->getImageDesc().image_height;
|
||||
|
||||
auto blitProperties = ClBlitProperties::constructProperties(BlitterConstants::BlitDirection::HostPtrToImage,
|
||||
csr,
|
||||
builtinOpParams);
|
||||
|
||||
EXPECT_EQ(builtinOpParams.size, blitProperties.copySize);
|
||||
EXPECT_EQ(expectedDstPtr, blitProperties.dstGpuAddress);
|
||||
EXPECT_EQ(builtinOpParams.srcOffset, blitProperties.srcOffset);
|
||||
EXPECT_EQ(builtinOpParams.dstOffset, blitProperties.dstOffset);
|
||||
EXPECT_EQ(expectedBytesPerPixel, blitProperties.bytesPerPixel);
|
||||
EXPECT_EQ(srcRowPitchExpected, blitProperties.srcRowPitch);
|
||||
EXPECT_EQ(dstRowPitchExpected, blitProperties.dstRowPitch);
|
||||
EXPECT_EQ(srcSlicePitchExpected, blitProperties.srcSlicePitch);
|
||||
EXPECT_EQ(dstSlicePitchExpected, blitProperties.dstSlicePitch);
|
||||
}
|
||||
|
||||
HWTEST_F(BcsTests, givenImageToHostPtrWhenConstructPropertiesIsCalledThenValuesAreSetCorrectly) {
|
||||
void *hostPtr = reinterpret_cast<void *>(0x12340000);
|
||||
cl_image_desc imgDesc = Image2dDefaults::imageDesc;
|
||||
imgDesc.image_width = 10u;
|
||||
imgDesc.image_height = 12u;
|
||||
std::unique_ptr<Image> image(Image2dHelper<>::create(context.get(), &imgDesc));
|
||||
BuiltinOpParams builtinOpParams{};
|
||||
builtinOpParams.dstPtr = hostPtr;
|
||||
builtinOpParams.srcMemObj = image.get();
|
||||
builtinOpParams.dstMemObj = nullptr;
|
||||
builtinOpParams.size = {2, 3, 1};
|
||||
|
||||
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
auto expectedSrcPtr = image.get()->getGraphicsAllocation(csr.getRootDeviceIndex())->getGpuAddress();
|
||||
auto expectedBytesPerPixel = image.get()->getSurfaceFormatInfo().surfaceFormat.ImageElementSizeInBytes;
|
||||
auto srcRowPitchExpected = expectedBytesPerPixel * image.get()->getImageDesc().image_width;
|
||||
auto dstRowPitchExpected = expectedBytesPerPixel * builtinOpParams.size.x;
|
||||
auto srcSlicePitchExpected = srcRowPitchExpected * image.get()->getImageDesc().image_height;
|
||||
auto dstSlicePitchExpected = dstRowPitchExpected * builtinOpParams.size.y;
|
||||
|
||||
auto blitProperties = ClBlitProperties::constructProperties(BlitterConstants::BlitDirection::ImageToHostPtr,
|
||||
csr,
|
||||
builtinOpParams);
|
||||
|
||||
EXPECT_EQ(builtinOpParams.size, blitProperties.copySize);
|
||||
EXPECT_EQ(expectedSrcPtr, blitProperties.srcGpuAddress);
|
||||
EXPECT_EQ(builtinOpParams.srcOffset, blitProperties.srcOffset);
|
||||
EXPECT_EQ(builtinOpParams.dstOffset, blitProperties.dstOffset);
|
||||
EXPECT_EQ(expectedBytesPerPixel, blitProperties.bytesPerPixel);
|
||||
EXPECT_EQ(srcRowPitchExpected, blitProperties.srcRowPitch);
|
||||
EXPECT_EQ(dstRowPitchExpected, blitProperties.dstRowPitch);
|
||||
EXPECT_EQ(srcSlicePitchExpected, blitProperties.srcSlicePitch);
|
||||
EXPECT_EQ(dstSlicePitchExpected, blitProperties.dstSlicePitch);
|
||||
}
|
||||
|
||||
HWTEST_F(BcsTests, givenHostPtrToImageWithInputRowSlicePitchesWhenConstructPropertiesIsCalledThenValuesAreSetCorrectly) {
|
||||
void *hostPtr = reinterpret_cast<void *>(0x12340000);
|
||||
cl_image_desc imgDesc = Image2dDefaults::imageDesc;
|
||||
std::unique_ptr<Image> image(Image2dHelper<>::create(context.get(), &imgDesc));
|
||||
BuiltinOpParams builtinOpParams{};
|
||||
builtinOpParams.srcPtr = hostPtr;
|
||||
builtinOpParams.srcMemObj = nullptr;
|
||||
builtinOpParams.dstMemObj = image.get();
|
||||
builtinOpParams.size = {2, 3, 1};
|
||||
auto inputRowPitch = 0x20u;
|
||||
auto inputSlicePitch = 0x400u;
|
||||
builtinOpParams.dstRowPitch = inputRowPitch;
|
||||
builtinOpParams.dstSlicePitch = inputSlicePitch;
|
||||
|
||||
auto expectedBytesPerPixel = image.get()->getSurfaceFormatInfo().surfaceFormat.ImageElementSizeInBytes;
|
||||
auto dstRowPitchExpected = expectedBytesPerPixel * image.get()->getImageDesc().image_width;
|
||||
auto dstSlicePitchExpected = dstRowPitchExpected * image.get()->getImageDesc().image_height;
|
||||
|
||||
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
auto blitProperties = ClBlitProperties::constructProperties(BlitterConstants::BlitDirection::HostPtrToImage,
|
||||
csr,
|
||||
builtinOpParams);
|
||||
|
||||
EXPECT_EQ(inputRowPitch, blitProperties.srcRowPitch);
|
||||
EXPECT_EQ(dstRowPitchExpected, blitProperties.dstRowPitch);
|
||||
EXPECT_EQ(inputSlicePitch, blitProperties.srcSlicePitch);
|
||||
EXPECT_EQ(dstSlicePitchExpected, blitProperties.dstSlicePitch);
|
||||
}
|
||||
|
||||
HWTEST_F(BcsTests, givenImageToHostPtrWithInputRowSlicePitchesWhenConstructPropertiesIsCalledThenValuesAreSetCorrectly) {
|
||||
void *hostPtr = reinterpret_cast<void *>(0x12340000);
|
||||
cl_image_desc imgDesc = Image2dDefaults::imageDesc;
|
||||
std::unique_ptr<Image> image(Image2dHelper<>::create(context.get(), &imgDesc));
|
||||
BuiltinOpParams builtinOpParams{};
|
||||
builtinOpParams.dstPtr = hostPtr;
|
||||
builtinOpParams.srcMemObj = image.get();
|
||||
builtinOpParams.dstMemObj = nullptr;
|
||||
builtinOpParams.size = {2, 3, 1};
|
||||
auto inputRowPitch = 0x20u;
|
||||
auto inputSlicePitch = 0x400u;
|
||||
builtinOpParams.srcRowPitch = inputRowPitch;
|
||||
builtinOpParams.srcSlicePitch = inputSlicePitch;
|
||||
|
||||
auto expectedBytesPerPixel = image.get()->getSurfaceFormatInfo().surfaceFormat.ImageElementSizeInBytes;
|
||||
auto srcRowPitchExpected = expectedBytesPerPixel * image.get()->getImageDesc().image_width;
|
||||
auto srcSlicePitchExpected = srcRowPitchExpected * image.get()->getImageDesc().image_height;
|
||||
|
||||
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
auto blitProperties = ClBlitProperties::constructProperties(BlitterConstants::BlitDirection::ImageToHostPtr,
|
||||
csr,
|
||||
builtinOpParams);
|
||||
|
||||
EXPECT_EQ(srcRowPitchExpected, blitProperties.srcRowPitch);
|
||||
EXPECT_EQ(inputRowPitch, blitProperties.dstRowPitch);
|
||||
EXPECT_EQ(srcSlicePitchExpected, blitProperties.srcSlicePitch);
|
||||
EXPECT_EQ(inputSlicePitch, blitProperties.dstSlicePitch);
|
||||
}
|
||||
|
||||
HWTEST_F(BcsTests, givenHostPtrToImageWhenBlitBufferIsCalledThenBlitCmdIsFound) {
|
||||
if (!pDevice->getHardwareInfo().capabilityTable.supportsImages) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
void *hostPtr = reinterpret_cast<void *>(0x12340000);
|
||||
std::unique_ptr<Image> image(Image2dHelper<>::create(context.get()));
|
||||
BuiltinOpParams builtinOpParams{};
|
||||
builtinOpParams.srcPtr = hostPtr;
|
||||
builtinOpParams.dstMemObj = image.get();
|
||||
|
||||
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
auto blitProperties = ClBlitProperties::constructProperties(BlitterConstants::BlitDirection::HostPtrToImage,
|
||||
csr,
|
||||
builtinOpParams);
|
||||
blitBuffer(&csr, blitProperties, true);
|
||||
|
||||
HardwareParse hwParser;
|
||||
hwParser.parseCommands<FamilyType>(csr.commandStream, 0);
|
||||
auto cmdIterator = find<typename FamilyType::XY_COPY_BLT *>(hwParser.cmdList.begin(), hwParser.cmdList.end());
|
||||
EXPECT_NE(hwParser.cmdList.end(), cmdIterator);
|
||||
}
|
||||
|
||||
HWTEST_F(BcsTests, given3dImageWhenBlitBufferIsCalledThenBlitCmdIsFoundZtimes) {
|
||||
if (!pDevice->getHardwareInfo().capabilityTable.supportsImages) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
void *hostPtr = reinterpret_cast<void *>(0x12340000);
|
||||
std::unique_ptr<Image> image(Image3dHelper<>::create(context.get()));
|
||||
BuiltinOpParams builtinOpParams{};
|
||||
builtinOpParams.srcPtr = hostPtr;
|
||||
builtinOpParams.dstMemObj = image.get();
|
||||
builtinOpParams.size = {1, 1, 10};
|
||||
|
||||
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
auto blitProperties = ClBlitProperties::constructProperties(BlitterConstants::BlitDirection::HostPtrToImage,
|
||||
csr,
|
||||
builtinOpParams);
|
||||
blitBuffer(&csr, blitProperties, true);
|
||||
HardwareParse hwParser;
|
||||
hwParser.parseCommands<FamilyType>(csr.commandStream, 0);
|
||||
uint32_t xyCopyBltCmdFound = 0;
|
||||
|
||||
for (auto &cmd : hwParser.cmdList) {
|
||||
if (auto bltCmd = genCmdCast<typename FamilyType::XY_COPY_BLT *>(cmd)) {
|
||||
++xyCopyBltCmdFound;
|
||||
}
|
||||
}
|
||||
EXPECT_EQ(static_cast<uint32_t>(builtinOpParams.size.z), xyCopyBltCmdFound);
|
||||
}
|
||||
|
||||
HWTEST_F(BcsTests, givenImageToHostPtrWhenBlitBufferIsCalledThenBlitCmdIsFound) {
|
||||
if (!pDevice->getHardwareInfo().capabilityTable.supportsImages) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
void *hostPtr = reinterpret_cast<void *>(0x12340000);
|
||||
std::unique_ptr<Image> image(Image2dHelper<>::create(context.get()));
|
||||
BuiltinOpParams builtinOpParams{};
|
||||
builtinOpParams.dstPtr = hostPtr;
|
||||
builtinOpParams.srcMemObj = image.get();
|
||||
|
||||
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
auto blitProperties = ClBlitProperties::constructProperties(BlitterConstants::BlitDirection::ImageToHostPtr,
|
||||
csr,
|
||||
builtinOpParams);
|
||||
blitBuffer(&csr, blitProperties, true);
|
||||
|
||||
HardwareParse hwParser;
|
||||
hwParser.parseCommands<FamilyType>(csr.commandStream, 0);
|
||||
auto cmdIterator = find<typename FamilyType::XY_COPY_BLT *>(hwParser.cmdList.begin(), hwParser.cmdList.end());
|
||||
EXPECT_NE(hwParser.cmdList.end(), cmdIterator);
|
||||
}
|
||||
|
||||
HWTEST_F(BcsTests, givenHostPtrToImageWhenBlitBufferIsCalledThenBlitCmdIsCorrectlyProgrammed) {
|
||||
if (!pDevice->getHardwareInfo().capabilityTable.supportsImages) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
void *hostPtr = reinterpret_cast<void *>(0x12340000);
|
||||
cl_image_desc imgDesc = Image2dDefaults::imageDesc;
|
||||
imgDesc.image_width = 10;
|
||||
imgDesc.image_height = 12;
|
||||
std::unique_ptr<Image> image(Image2dHelper<>::create(context.get(), &imgDesc));
|
||||
BuiltinOpParams builtinOpParams{};
|
||||
builtinOpParams.srcPtr = hostPtr;
|
||||
builtinOpParams.srcMemObj = nullptr;
|
||||
builtinOpParams.dstMemObj = image.get();
|
||||
builtinOpParams.size = {6, 8, 1};
|
||||
|
||||
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
auto blitProperties = ClBlitProperties::constructProperties(BlitterConstants::BlitDirection::HostPtrToImage,
|
||||
csr,
|
||||
builtinOpParams);
|
||||
blitBuffer(&csr, blitProperties, true);
|
||||
|
||||
HardwareParse hwParser;
|
||||
hwParser.parseCommands<FamilyType>(csr.commandStream, 0);
|
||||
auto cmdIterator = find<typename FamilyType::XY_COPY_BLT *>(hwParser.cmdList.begin(), hwParser.cmdList.end());
|
||||
ASSERT_NE(hwParser.cmdList.end(), cmdIterator);
|
||||
auto bltCmd = genCmdCast<typename FamilyType::XY_COPY_BLT *>(*cmdIterator);
|
||||
|
||||
auto dstPtr = builtinOpParams.dstMemObj->getGraphicsAllocation(csr.getRootDeviceIndex())->getGpuAddress();
|
||||
EXPECT_EQ(blitProperties.srcGpuAddress, bltCmd->getSourceBaseAddress());
|
||||
EXPECT_EQ(dstPtr, bltCmd->getDestinationBaseAddress());
|
||||
}
|
||||
|
||||
HWTEST_F(BcsTests, givenImageToHostPtrWhenBlitBufferIsCalledThenBlitCmdIsCorrectlyProgrammed) {
|
||||
if (!pDevice->getHardwareInfo().capabilityTable.supportsImages) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
void *hostPtr = reinterpret_cast<void *>(0x12340000);
|
||||
cl_image_desc imgDesc = Image2dDefaults::imageDesc;
|
||||
imgDesc.image_width = 10u;
|
||||
imgDesc.image_height = 12u;
|
||||
std::unique_ptr<Image> image(Image2dHelper<>::create(context.get(), &imgDesc));
|
||||
BuiltinOpParams builtinOpParams{};
|
||||
builtinOpParams.dstPtr = hostPtr;
|
||||
builtinOpParams.srcMemObj = image.get();
|
||||
builtinOpParams.dstMemObj = nullptr;
|
||||
builtinOpParams.size = {2, 3, 1};
|
||||
|
||||
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
auto blitProperties = ClBlitProperties::constructProperties(BlitterConstants::BlitDirection::ImageToHostPtr,
|
||||
csr,
|
||||
builtinOpParams);
|
||||
blitBuffer(&csr, blitProperties, true);
|
||||
|
||||
HardwareParse hwParser;
|
||||
hwParser.parseCommands<FamilyType>(csr.commandStream, 0);
|
||||
auto cmdIterator = find<typename FamilyType::XY_COPY_BLT *>(hwParser.cmdList.begin(), hwParser.cmdList.end());
|
||||
ASSERT_NE(hwParser.cmdList.end(), cmdIterator);
|
||||
auto bltCmd = genCmdCast<typename FamilyType::XY_COPY_BLT *>(*cmdIterator);
|
||||
|
||||
auto srcPtr = builtinOpParams.srcMemObj->getGraphicsAllocation(csr.getRootDeviceIndex())->getGpuAddress();
|
||||
EXPECT_EQ(srcPtr, bltCmd->getSourceBaseAddress());
|
||||
EXPECT_EQ(blitProperties.dstGpuAddress, bltCmd->getDestinationBaseAddress());
|
||||
}
|
||||
|
||||
struct MockScratchSpaceController : ScratchSpaceControllerBase {
|
||||
using ScratchSpaceControllerBase::privateScratchAllocation;
|
||||
using ScratchSpaceControllerBase::ScratchSpaceControllerBase;
|
||||
|
||||
@@ -85,86 +85,44 @@ void BlitCommandsHelper<Family>::appendColorDepth(const BlitProperties &blitProp
|
||||
}
|
||||
|
||||
template <>
|
||||
void BlitCommandsHelper<Family>::appendTilingType(const GMM_TILE_TYPE srcTilingType, const GMM_TILE_TYPE dstTilingType, typename Family::XY_COPY_BLT &blitCmd) {
|
||||
using XY_COPY_BLT = typename Family::XY_COPY_BLT;
|
||||
if (srcTilingType == GMM_TILED_Y) {
|
||||
blitCmd.setSourceTiling(XY_COPY_BLT::SOURCE_TILING::SOURCE_TILING_YMAJOR);
|
||||
}
|
||||
if (dstTilingType == GMM_TILED_Y) {
|
||||
blitCmd.setDestinationTiling(XY_COPY_BLT::DESTINATION_TILING::DESTINATION_TILING_YMAJOR);
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
void BlitCommandsHelper<Family>::appendSurfaceType(const BlitProperties &blitProperties, typename Family::XY_COPY_BLT &blitCmd) {
|
||||
}
|
||||
|
||||
template <>
|
||||
void BlitCommandsHelper<Family>::getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch, GMM_TILE_TYPE &tileType, uint32_t &mipTailLod) {
|
||||
constexpr uint32_t TILED_Y_PITCH_ALIGNMENT = 128;
|
||||
constexpr uint32_t NON_TILED_PITCH_ALIGNMENT = 16;
|
||||
|
||||
void BlitCommandsHelper<Family>::getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch, GMM_TILE_TYPE &tileType, uint32_t &mipTailLod, uint32_t &compressionDetails, const RootDeviceEnvironment &rootDeviceEnvironment) {
|
||||
if (allocation.getDefaultGmm()) {
|
||||
auto gmmResInfo = allocation.getDefaultGmm()->gmmResourceInfo.get();
|
||||
auto resInfo = gmmResInfo->getResourceFlags()->Info;
|
||||
if (resInfo.TiledY) {
|
||||
tileType = GMM_TILED_Y;
|
||||
pitch = static_cast<uint32_t>(gmmResInfo->getRenderPitch());
|
||||
pitch = alignUp<uint32_t>(pitch, TILED_Y_PITCH_ALIGNMENT);
|
||||
qPitch = static_cast<uint32_t>(gmmResInfo->getQPitch());
|
||||
} else {
|
||||
pitch = alignUp<uint32_t>(pitch, NON_TILED_PITCH_ALIGNMENT);
|
||||
}
|
||||
auto gmmResourceInfo = allocation.getDefaultGmm()->gmmResourceInfo.get();
|
||||
qPitch = gmmResourceInfo->getQPitch() ? static_cast<uint32_t>(gmmResourceInfo->getQPitch()) : qPitch;
|
||||
pitch = gmmResourceInfo->getRenderPitch() ? static_cast<uint32_t>(gmmResourceInfo->getRenderPitch()) : pitch;
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
void BlitCommandsHelper<Family>::appendSliceOffsets(const BlitProperties &blitProperties, typename Family::XY_COPY_BLT &blitCmd, uint32_t sliceIndex) {
|
||||
void BlitCommandsHelper<Family>::appendSliceOffsets(const BlitProperties &blitProperties, typename Family::XY_COPY_BLT &blitCmd, uint32_t sliceIndex, const RootDeviceEnvironment &rootDeviceEnvironment, uint32_t srcSlicePitch, uint32_t dstSlicePitch) {
|
||||
using XY_COPY_BLT = typename Family::XY_COPY_BLT;
|
||||
auto srcAllocation = blitProperties.srcAllocation;
|
||||
auto dstAllocation = blitProperties.dstAllocation;
|
||||
auto srcQPitch = blitProperties.srcSize.y;
|
||||
auto dstQPitch = blitProperties.dstSize.y;
|
||||
auto srcPitch = static_cast<uint32_t>(blitProperties.srcRowPitch);
|
||||
auto dstPitch = static_cast<uint32_t>(blitProperties.dstRowPitch);
|
||||
auto tileType = GMM_NOT_TILED;
|
||||
uint32_t mipTailLod = 0;
|
||||
auto srcAddress = blitProperties.srcGpuAddress;
|
||||
auto dstAddress = blitProperties.dstGpuAddress;
|
||||
|
||||
getBlitAllocationProperties(*srcAllocation, srcPitch, srcQPitch, tileType, mipTailLod);
|
||||
getBlitAllocationProperties(*dstAllocation, dstPitch, dstQPitch, tileType, mipTailLod);
|
||||
|
||||
auto srcSlicePitch = srcPitch * srcQPitch;
|
||||
auto dstSlicePitch = dstPitch * dstQPitch;
|
||||
|
||||
size_t srcOffset = srcSlicePitch * (sliceIndex + blitProperties.srcOffset.z);
|
||||
size_t dstOffset = dstSlicePitch * (sliceIndex + blitProperties.dstOffset.z);
|
||||
|
||||
blitCmd.setSourceBaseAddress(ptrOffset(srcAllocation->getGpuAddress(), srcOffset));
|
||||
blitCmd.setDestinationBaseAddress(ptrOffset(dstAllocation->getGpuAddress(), dstOffset));
|
||||
blitCmd.setSourceBaseAddress(ptrOffset(srcAddress, srcSlicePitch * (sliceIndex + blitProperties.srcOffset.z)));
|
||||
blitCmd.setDestinationBaseAddress(ptrOffset(dstAddress, dstSlicePitch * (sliceIndex + blitProperties.dstOffset.z)));
|
||||
}
|
||||
|
||||
template <>
|
||||
void BlitCommandsHelper<Family>::appendBlitCommandsForImages(const BlitProperties &blitProperties, typename Family::XY_COPY_BLT &blitCmd) {
|
||||
auto srcTileType = GMM_NOT_TILED;
|
||||
auto dstTileType = GMM_NOT_TILED;
|
||||
void BlitCommandsHelper<Family>::appendBlitCommandsForImages(const BlitProperties &blitProperties, typename Family::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment, uint32_t &srcSlicePitch, uint32_t &dstSlicePitch) {
|
||||
auto tileType = GMM_NOT_TILED;
|
||||
auto srcAllocation = blitProperties.srcAllocation;
|
||||
auto dstAllocation = blitProperties.dstAllocation;
|
||||
auto srcQPitch = blitProperties.srcSize.y;
|
||||
auto dstQPitch = blitProperties.dstSize.y;
|
||||
auto srcPitch = static_cast<uint32_t>(blitProperties.srcRowPitch);
|
||||
auto dstPitch = static_cast<uint32_t>(blitProperties.dstRowPitch);
|
||||
auto srcRowPitch = static_cast<uint32_t>(blitProperties.srcRowPitch);
|
||||
auto dstRowPitch = static_cast<uint32_t>(blitProperties.dstRowPitch);
|
||||
uint32_t mipTailLod = 0;
|
||||
auto compressionDetails = 0u;
|
||||
|
||||
getBlitAllocationProperties(*srcAllocation, srcPitch, srcQPitch, srcTileType, mipTailLod);
|
||||
getBlitAllocationProperties(*dstAllocation, dstPitch, dstQPitch, dstTileType, mipTailLod);
|
||||
getBlitAllocationProperties(*srcAllocation, srcRowPitch, srcQPitch, tileType, mipTailLod, compressionDetails, rootDeviceEnvironment);
|
||||
getBlitAllocationProperties(*dstAllocation, dstRowPitch, dstQPitch, tileType, mipTailLod, compressionDetails, rootDeviceEnvironment);
|
||||
|
||||
srcPitch = (srcTileType == GMM_NOT_TILED) ? srcPitch : srcPitch / 4;
|
||||
dstPitch = (dstTileType == GMM_NOT_TILED) ? dstPitch : dstPitch / 4;
|
||||
blitCmd.setSourcePitch(srcRowPitch);
|
||||
blitCmd.setDestinationPitch(dstRowPitch);
|
||||
|
||||
blitCmd.setSourcePitch(srcPitch);
|
||||
blitCmd.setDestinationPitch(dstPitch);
|
||||
|
||||
appendTilingType(srcTileType, dstTileType, blitCmd);
|
||||
srcSlicePitch = std::max(srcSlicePitch, srcRowPitch * srcQPitch);
|
||||
dstSlicePitch = std::max(dstSlicePitch, dstRowPitch * dstQPitch);
|
||||
}
|
||||
|
||||
template <>
|
||||
|
||||
@@ -41,7 +41,8 @@ BlitProperties BlitProperties::constructPropertiesForReadWriteBuffer(BlitterCons
|
||||
copySize.y = copySize.y ? copySize.y : 1;
|
||||
copySize.z = copySize.z ? copySize.z : 1;
|
||||
|
||||
if (BlitterConstants::BlitDirection::HostPtrToBuffer == blitDirection) {
|
||||
if (BlitterConstants::BlitDirection::HostPtrToBuffer == blitDirection ||
|
||||
BlitterConstants::BlitDirection::HostPtrToImage == blitDirection) {
|
||||
return {
|
||||
nullptr, // outputTimestampPacket
|
||||
blitDirection, // blitDirection
|
||||
@@ -54,10 +55,10 @@ BlitProperties BlitProperties::constructPropertiesForReadWriteBuffer(BlitterCons
|
||||
copySize, // copySize
|
||||
copyOffset, // dstOffset
|
||||
hostPtrOffset, // srcOffset
|
||||
gpuRowPitch, //dstRowPitch
|
||||
gpuSlicePitch, //dstSlicePitch
|
||||
hostRowPitch, //srcRowPitch
|
||||
hostSlicePitch}; //srcSlicePitch
|
||||
gpuRowPitch, // dstRowPitch
|
||||
gpuSlicePitch, // dstSlicePitch
|
||||
hostRowPitch, // srcRowPitch
|
||||
hostSlicePitch}; // srcSlicePitch
|
||||
|
||||
} else {
|
||||
return {
|
||||
|
||||
@@ -129,14 +129,14 @@ struct BlitCommandsHelper {
|
||||
template <size_t patternSize>
|
||||
static void dispatchBlitMemoryFill(NEO::GraphicsAllocation *dstAlloc, uint32_t *pattern, LinearStream &linearStream, size_t size, const RootDeviceEnvironment &rootDeviceEnvironment, COLOR_DEPTH depth);
|
||||
static void appendBlitCommandsForBuffer(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment);
|
||||
static void appendBlitCommandsForImages(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd);
|
||||
static void appendBlitCommandsForImages(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment, uint32_t &srcSlicePitch, uint32_t &dstSlicePitch);
|
||||
static void appendColorDepth(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd);
|
||||
static void appendBlitCommandsForFillBuffer(NEO::GraphicsAllocation *dstAlloc, typename GfxFamily::XY_COLOR_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment);
|
||||
static void appendSurfaceType(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd);
|
||||
static void appendTilingEnable(typename GfxFamily::XY_COLOR_BLT &blitCmd);
|
||||
static void appendTilingType(const GMM_TILE_TYPE srcTilingType, const GMM_TILE_TYPE dstTilingType, typename GfxFamily::XY_COPY_BLT &blitCmd);
|
||||
static void appendSliceOffsets(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd, uint32_t sliceIndex);
|
||||
static void getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch, GMM_TILE_TYPE &tileType, uint32_t &mipTailLod);
|
||||
static void appendSliceOffsets(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd, uint32_t sliceIndex, const RootDeviceEnvironment &rootDeviceEnvironment, uint32_t srcSlicePitch, uint32_t dstSlicePitch);
|
||||
static void getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch, GMM_TILE_TYPE &tileType, uint32_t &mipTailLod, uint32_t &compressionDetails, const RootDeviceEnvironment &rootDeviceEnvironment);
|
||||
static void dispatchDebugPauseCommands(LinearStream &commandStream, uint64_t debugPauseStateGPUAddress, DebugPauseState confirmationTrigger, DebugPauseState waitCondition);
|
||||
static size_t getSizeForDebugPauseCommands();
|
||||
static bool useOneBlitCopyCommand(Vec3<size_t> copySize, uint32_t bytesPerPixel);
|
||||
|
||||
@@ -217,14 +217,14 @@ void BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryFill(NEO::GraphicsAllocati
|
||||
|
||||
template <typename GfxFamily>
|
||||
void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsRegion(const BlitProperties &blitProperties, LinearStream &linearStream, const RootDeviceEnvironment &rootDeviceEnvironment) {
|
||||
auto dstAllocation = blitProperties.dstAllocation;
|
||||
auto srcAllocation = blitProperties.srcAllocation;
|
||||
auto srcSlicePitch = static_cast<uint32_t>(blitProperties.srcSlicePitch);
|
||||
auto dstSlicePitch = static_cast<uint32_t>(blitProperties.dstSlicePitch);
|
||||
|
||||
UNRECOVERABLE_IF(blitProperties.copySize.x > BlitterConstants::maxBlitWidth || blitProperties.copySize.y > BlitterConstants::maxBlitWidth);
|
||||
auto bltCmd = GfxFamily::cmdInitXyCopyBlt;
|
||||
|
||||
bltCmd.setSourceBaseAddress(srcAllocation->getGpuAddress());
|
||||
bltCmd.setDestinationBaseAddress(dstAllocation->getGpuAddress());
|
||||
bltCmd.setSourceBaseAddress(blitProperties.srcAllocation->getGpuAddress());
|
||||
bltCmd.setDestinationBaseAddress(blitProperties.dstAllocation->getGpuAddress());
|
||||
|
||||
bltCmd.setDestinationX1CoordinateLeft(static_cast<uint32_t>(blitProperties.dstOffset.x));
|
||||
bltCmd.setDestinationY1CoordinateTop(static_cast<uint32_t>(blitProperties.dstOffset.y));
|
||||
@@ -235,13 +235,14 @@ void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsRegion(const BlitPropert
|
||||
bltCmd.setSourceY1CoordinateTop(static_cast<uint32_t>(blitProperties.srcOffset.y));
|
||||
|
||||
appendBlitCommandsForBuffer(blitProperties, bltCmd, rootDeviceEnvironment);
|
||||
appendBlitCommandsForImages(blitProperties, bltCmd);
|
||||
appendBlitCommandsForImages(blitProperties, bltCmd, rootDeviceEnvironment, srcSlicePitch, dstSlicePitch);
|
||||
appendColorDepth(blitProperties, bltCmd);
|
||||
appendSurfaceType(blitProperties, bltCmd);
|
||||
for (uint32_t i = 0; i < blitProperties.copySize.z; i++) {
|
||||
appendSliceOffsets(blitProperties, bltCmd, i);
|
||||
appendSliceOffsets(blitProperties, bltCmd, i, rootDeviceEnvironment, srcSlicePitch, dstSlicePitch);
|
||||
auto cmd = linearStream.getSpaceForCmd<typename GfxFamily::XY_COPY_BLT>();
|
||||
*cmd = bltCmd;
|
||||
dispatchPostBlitCommand(linearStream);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,10 +281,15 @@ uint32_t BlitCommandsHelper<GfxFamily>::getAvailableBytesPerPixel(size_t copySiz
|
||||
|
||||
template <typename GfxFamily>
|
||||
void BlitCommandsHelper<GfxFamily>::dispatchBlitCommands(const BlitProperties &blitProperties, LinearStream &linearStream, const RootDeviceEnvironment &rootDeviceEnvironment) {
|
||||
bool preferCopyRegion = isCopyRegionPreferred(blitProperties.copySize, rootDeviceEnvironment);
|
||||
|
||||
preferCopyRegion ? dispatchBlitCommandsForBufferRegion(blitProperties, linearStream, rootDeviceEnvironment)
|
||||
: dispatchBlitCommandsForBufferPerRow(blitProperties, linearStream, rootDeviceEnvironment);
|
||||
if (blitProperties.blitDirection == BlitterConstants::BlitDirection::HostPtrToImage ||
|
||||
blitProperties.blitDirection == BlitterConstants::BlitDirection::ImageToHostPtr) {
|
||||
return dispatchBlitCommandsRegion(blitProperties, linearStream, rootDeviceEnvironment);
|
||||
}
|
||||
|
||||
bool preferCopyBufferRegion = isCopyRegionPreferred(blitProperties.copySize, rootDeviceEnvironment);
|
||||
preferCopyBufferRegion ? dispatchBlitCommandsForBufferRegion(blitProperties, linearStream, rootDeviceEnvironment)
|
||||
: dispatchBlitCommandsForBufferPerRow(blitProperties, linearStream, rootDeviceEnvironment);
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
|
||||
@@ -23,7 +23,7 @@ template <typename GfxFamily>
|
||||
void BlitCommandsHelper<GfxFamily>::appendBlitCommandsForBuffer(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment) {}
|
||||
|
||||
template <typename GfxFamily>
|
||||
void BlitCommandsHelper<GfxFamily>::appendBlitCommandsForImages(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd) {
|
||||
void BlitCommandsHelper<GfxFamily>::appendBlitCommandsForImages(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment, uint32_t &srcSlicePitch, uint32_t &dstSlicePitch) {
|
||||
appendTilingType(GMM_NOT_TILED, GMM_NOT_TILED, blitCmd);
|
||||
}
|
||||
|
||||
@@ -66,11 +66,11 @@ void BlitCommandsHelper<GfxFamily>::appendColorDepth(const BlitProperties &blitP
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
void BlitCommandsHelper<GfxFamily>::appendSliceOffsets(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd, uint32_t sliceIndex) {
|
||||
void BlitCommandsHelper<GfxFamily>::appendSliceOffsets(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd, uint32_t sliceIndex, const RootDeviceEnvironment &rootDeviceEnvironment, uint32_t srcSlicePitch, uint32_t dstSlicePitch) {
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
void BlitCommandsHelper<GfxFamily>::getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch, GMM_TILE_TYPE &tileType, uint32_t &mipTailLod) {
|
||||
void BlitCommandsHelper<GfxFamily>::getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch, GMM_TILE_TYPE &tileType, uint32_t &mipTailLod, uint32_t &compressionDetails, const RootDeviceEnvironment &rootDeviceEnvironment) {
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -67,7 +67,9 @@ constexpr uint64_t maxBytesPerPixel = 0x10;
|
||||
enum class BlitDirection : uint32_t {
|
||||
BufferToHostPtr,
|
||||
HostPtrToBuffer,
|
||||
BufferToBuffer
|
||||
BufferToBuffer,
|
||||
HostPtrToImage,
|
||||
ImageToHostPtr
|
||||
};
|
||||
} // namespace BlitterConstants
|
||||
|
||||
|
||||
@@ -380,8 +380,9 @@ HWTEST2_F(BlitTests, givenGen9AndGetBlitAllocationPropertiesThenCorrectValuesAre
|
||||
auto expectedQPitch = qPitch;
|
||||
auto expectedtileType = tileType;
|
||||
auto expectedMipTailLod = mipTailLod;
|
||||
auto compressionDetails = 0u;
|
||||
|
||||
NEO::BlitCommandsHelper<FamilyType>::getBlitAllocationProperties(alloc, pitch, qPitch, tileType, mipTailLod);
|
||||
NEO::BlitCommandsHelper<FamilyType>::getBlitAllocationProperties(alloc, pitch, qPitch, tileType, mipTailLod, compressionDetails, pDevice->getRootDeviceEnvironment());
|
||||
|
||||
EXPECT_EQ(expectedPitch, pitch);
|
||||
EXPECT_EQ(expectedQPitch, qPitch);
|
||||
|
||||
@@ -72,72 +72,9 @@ HWTEST2_F(BlitTests, givenIncorrectBytePerPixelWhenAppendColorDepthThenAbortIsTh
|
||||
EXPECT_THROW(BlitCommandsHelper<FamilyType>::appendColorDepth(properties, bltCmd), std::exception);
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenNotTiledSrcAndDestinationWhenAppendTilingTypeThenCorrectTilingIsSet, IsGen12LP) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
BlitCommandsHelper<FamilyType>::appendTilingType(GMM_NOT_TILED, GMM_NOT_TILED, bltCmd);
|
||||
EXPECT_EQ(bltCmd.getSourceTiling(), XY_COPY_BLT::SOURCE_TILING::SOURCE_TILING_LINEAR);
|
||||
EXPECT_EQ(bltCmd.getDestinationTiling(), XY_COPY_BLT::DESTINATION_TILING::DESTINATION_TILING_LINEAR);
|
||||
}
|
||||
HWTEST2_F(BlitTests, givenTiledSrcAndDestinationAppendTilingTypeThenCorrectTilingIsSet, IsGen12LP) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
BlitCommandsHelper<FamilyType>::appendTilingType(GMM_TILED_Y, GMM_TILED_Y, bltCmd);
|
||||
EXPECT_EQ(bltCmd.getSourceTiling(), XY_COPY_BLT::SOURCE_TILING::SOURCE_TILING_YMAJOR);
|
||||
EXPECT_EQ(bltCmd.getDestinationTiling(), XY_COPY_BLT::DESTINATION_TILING::DESTINATION_TILING_YMAJOR);
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenTiledSrcAndDestinationWhenAppendImageCommandsThenCorrectTiledIsSet, IsGen12LP) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto gmm = std::make_unique<MockGmm>();
|
||||
auto flags = gmm->gmmResourceInfo->getResourceFlags();
|
||||
flags->Info.TiledY = true;
|
||||
MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
MockGraphicsAllocation mockAllocationDst(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
mockAllocationSrc.setGmm(gmm.get(), 0);
|
||||
mockAllocationDst.setGmm(gmm.get(), 0);
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.srcAllocation = &mockAllocationSrc;
|
||||
properties.dstAllocation = &mockAllocationDst;
|
||||
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd);
|
||||
EXPECT_EQ(bltCmd.getSourceTiling(), XY_COPY_BLT::SOURCE_TILING::SOURCE_TILING_YMAJOR);
|
||||
EXPECT_EQ(bltCmd.getDestinationTiling(), XY_COPY_BLT::DESTINATION_TILING::DESTINATION_TILING_YMAJOR);
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenNotTiledSrcAndDestinationWhenAppendImageCommandsThenCorrectTiledIsSet, IsGen12LP) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto gmm = std::make_unique<MockGmm>();
|
||||
auto flags = gmm->gmmResourceInfo->getResourceFlags();
|
||||
flags->Info.TiledY = false;
|
||||
MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
MockGraphicsAllocation mockAllocationDst(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
mockAllocationSrc.setGmm(gmm.get(), 0);
|
||||
mockAllocationDst.setGmm(gmm.get(), 0);
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.srcAllocation = &mockAllocationSrc;
|
||||
properties.dstAllocation = &mockAllocationDst;
|
||||
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd);
|
||||
EXPECT_EQ(bltCmd.getSourceTiling(), XY_COPY_BLT::SOURCE_TILING::SOURCE_TILING_LINEAR);
|
||||
EXPECT_EQ(bltCmd.getDestinationTiling(), XY_COPY_BLT::DESTINATION_TILING::DESTINATION_TILING_LINEAR);
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenSrcAndDestinationImagesWhenAppendSliceOffsetsThenAdressAreCorectOffseted, IsGen12LP) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto gmm = std::make_unique<MockGmm>();
|
||||
auto flags = gmm->gmmResourceInfo->getResourceFlags();
|
||||
flags->Info.TiledY = false;
|
||||
MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
@@ -150,19 +87,22 @@ HWTEST2_F(BlitTests, givenSrcAndDestinationImagesWhenAppendSliceOffsetsThenAdres
|
||||
BlitProperties properties = {};
|
||||
properties.srcAllocation = &mockAllocationSrc;
|
||||
properties.dstAllocation = &mockAllocationDst;
|
||||
properties.srcGpuAddress = mockAllocationSrc.getGpuAddress();
|
||||
properties.dstGpuAddress = mockAllocationDst.getGpuAddress();
|
||||
|
||||
properties.srcSize.y = 0x10;
|
||||
properties.srcRowPitch = 0x10;
|
||||
auto srcSlicePitch = properties.srcSize.y * properties.srcRowPitch;
|
||||
auto srcSlicePitch = static_cast<uint32_t>(properties.srcSize.y * properties.srcRowPitch);
|
||||
|
||||
properties.dstSize.y = 0x20;
|
||||
properties.dstRowPitch = 0x20;
|
||||
auto dstSlicePitch = properties.dstSize.y * properties.dstRowPitch;
|
||||
auto dstSlicePitch = static_cast<uint32_t>(properties.dstSize.y * properties.dstRowPitch);
|
||||
|
||||
properties.srcOffset = {0x10, 0x10, 0x10};
|
||||
properties.dstOffset = {0x20, 0x20, 0x20};
|
||||
uint32_t index = 7;
|
||||
BlitCommandsHelper<FamilyType>::appendSliceOffsets(properties, bltCmd, index);
|
||||
|
||||
BlitCommandsHelper<FamilyType>::appendSliceOffsets(properties, bltCmd, index, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch);
|
||||
auto expectesSrcOffset = (index + properties.srcOffset.z) * srcSlicePitch;
|
||||
auto expectesDstOffset = (index + properties.dstOffset.z) * dstSlicePitch;
|
||||
|
||||
@@ -170,11 +110,9 @@ HWTEST2_F(BlitTests, givenSrcAndDestinationImagesWhenAppendSliceOffsetsThenAdres
|
||||
EXPECT_EQ(bltCmd.getDestinationBaseAddress(), ptrOffset(mockAllocationDst.getGpuAddress(), expectesDstOffset));
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenNotTiledSrcAndDestinationWhenAppendImageCommandsThenPitchIsValueFromProperties, IsGen12LP) {
|
||||
HWTEST2_F(BlitTests, givenSrcAndDestinationImagesWhenAppendImageCommandsThenPitchIsValueFromGmm, IsGen12LP) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto gmm = std::make_unique<MockGmm>();
|
||||
auto flags = gmm->gmmResourceInfo->getResourceFlags();
|
||||
flags->Info.TiledY = false;
|
||||
MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
@@ -189,9 +127,50 @@ HWTEST2_F(BlitTests, givenNotTiledSrcAndDestinationWhenAppendImageCommandsThenPi
|
||||
properties.dstAllocation = &mockAllocationDst;
|
||||
properties.srcRowPitch = 0x1000;
|
||||
properties.dstRowPitch = 0x4000;
|
||||
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd);
|
||||
EXPECT_EQ(bltCmd.getDestinationPitch(), properties.dstRowPitch);
|
||||
EXPECT_EQ(bltCmd.getSourcePitch(), properties.srcRowPitch);
|
||||
auto srcSlicePitch = static_cast<uint32_t>(properties.srcSlicePitch);
|
||||
auto dstSlicePitch = static_cast<uint32_t>(properties.dstSlicePitch);
|
||||
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch);
|
||||
EXPECT_EQ(bltCmd.getDestinationPitch(), gmm->gmmResourceInfo->getRenderPitch());
|
||||
EXPECT_EQ(bltCmd.getSourcePitch(), gmm->gmmResourceInfo->getRenderPitch());
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenInputAndDefaultSlicePitchWhenAppendBlitCommandsForImagesThenSlicePitchesAreCorrect, IsGen12LP) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
|
||||
MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
MockGraphicsAllocation mockAllocationDst(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.srcAllocation = &mockAllocationSrc;
|
||||
properties.dstAllocation = &mockAllocationDst;
|
||||
properties.srcSize = {10, 10, 1};
|
||||
properties.dstSize = {8, 12, 1};
|
||||
properties.srcRowPitch = 0x10;
|
||||
properties.dstRowPitch = 0x40;
|
||||
|
||||
{
|
||||
uint32_t inputSlicePitch = 0;
|
||||
auto srcSlicePitch = inputSlicePitch;
|
||||
auto dstSlicePitch = inputSlicePitch;
|
||||
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch);
|
||||
|
||||
EXPECT_EQ(srcSlicePitch, static_cast<uint32_t>(properties.srcRowPitch * properties.srcSize.y));
|
||||
EXPECT_EQ(dstSlicePitch, static_cast<uint32_t>(properties.dstRowPitch * properties.dstSize.y));
|
||||
}
|
||||
|
||||
{
|
||||
uint32_t inputSlicePitch = 0x40000;
|
||||
auto srcSlicePitch = inputSlicePitch;
|
||||
auto dstSlicePitch = inputSlicePitch;
|
||||
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch);
|
||||
|
||||
EXPECT_EQ(srcSlicePitch, inputSlicePitch);
|
||||
EXPECT_EQ(dstSlicePitch, inputSlicePitch);
|
||||
}
|
||||
}
|
||||
struct MyMockResourecInfo : public GmmResourceInfo {
|
||||
using GmmResourceInfo::resourceInfo;
|
||||
@@ -213,133 +192,3 @@ struct MyMockResourecInfo : public GmmResourceInfo {
|
||||
size_t pitch = 0;
|
||||
GMM_RESOURCE_FLAG flags = {};
|
||||
};
|
||||
|
||||
HWTEST2_F(BlitTests, givenTiledSrcAndDestinationWhenAppendImageCommandsThenPitchIsValueFromGmm, IsGen12LP) {
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto gmm = std::make_unique<MockGmm>();
|
||||
GMM_RESCREATE_PARAMS gmmParams = {};
|
||||
auto myResourecInfo = std::make_unique<MyMockResourecInfo>(pDevice->getRootDeviceEnvironment().getGmmClientContext(), &gmmParams);
|
||||
myResourecInfo->pitch = 0x100;
|
||||
gmm->gmmResourceInfo.reset(myResourecInfo.release());
|
||||
auto flags = gmm->gmmResourceInfo->getResourceFlags();
|
||||
flags->Info.TiledY = true;
|
||||
MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
MockGraphicsAllocation mockAllocationDst(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
mockAllocationSrc.setGmm(gmm.get(), 0);
|
||||
mockAllocationDst.setGmm(gmm.get(), 0);
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.dstRowPitch = 0x1000;
|
||||
properties.srcRowPitch = 0x1000;
|
||||
|
||||
properties.srcAllocation = &mockAllocationSrc;
|
||||
properties.dstAllocation = &mockAllocationDst;
|
||||
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd);
|
||||
EXPECT_EQ(bltCmd.getDestinationPitch(), gmm->gmmResourceInfo->getRenderPitch() / sizeof(uint32_t));
|
||||
EXPECT_EQ(bltCmd.getSourcePitch(), gmm->gmmResourceInfo->getRenderPitch() / sizeof(uint32_t));
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenTiledSrcAndDestinationWhenGmmReturnsNotAlignedPitchThenValuesInCommandAreAligned, IsGen12LP) {
|
||||
constexpr uint32_t TILED_Y_PITCH_ALIGNMENT = 128;
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto gmm = std::make_unique<MockGmm>();
|
||||
GMM_RESCREATE_PARAMS gmmParams = {};
|
||||
auto myResourecInfo = std::make_unique<MyMockResourecInfo>(pDevice->getRootDeviceEnvironment().getGmmClientContext(), &gmmParams);
|
||||
myResourecInfo->pitch = 0xFC;
|
||||
gmm->gmmResourceInfo.reset(myResourecInfo.release());
|
||||
auto flags = gmm->gmmResourceInfo->getResourceFlags();
|
||||
flags->Info.TiledY = true;
|
||||
MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
MockGraphicsAllocation mockAllocationDst(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
mockAllocationSrc.setGmm(gmm.get(), 0);
|
||||
mockAllocationDst.setGmm(gmm.get(), 0);
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.dstRowPitch = 0x1000;
|
||||
properties.srcRowPitch = 0x1000;
|
||||
|
||||
properties.srcAllocation = &mockAllocationSrc;
|
||||
properties.dstAllocation = &mockAllocationDst;
|
||||
auto expectedPitch = alignUp<uint32_t>(static_cast<uint32_t>(gmm->gmmResourceInfo->getRenderPitch()), TILED_Y_PITCH_ALIGNMENT);
|
||||
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd);
|
||||
EXPECT_EQ(bltCmd.getDestinationPitch(), expectedPitch / sizeof(uint32_t));
|
||||
EXPECT_EQ(bltCmd.getSourcePitch(), expectedPitch / sizeof(uint32_t));
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenDstTiledImageAndNotTiledSourceWhenAppendBlitCommandsForImagesThenPitchIsValueInDwords, IsGen12LP) {
|
||||
constexpr uint32_t TILED_Y_PITCH_ALIGNMENT = 128;
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto gmmSrc = std::make_unique<MockGmm>();
|
||||
auto gmmDst = std::make_unique<MockGmm>();
|
||||
GMM_RESCREATE_PARAMS gmmParams = {};
|
||||
auto myResourecInfoSrc = std::make_unique<MyMockResourecInfo>(pDevice->getRootDeviceEnvironment().getGmmClientContext(), &gmmParams);
|
||||
auto myResourecInfoDst = std::make_unique<MyMockResourecInfo>(pDevice->getRootDeviceEnvironment().getGmmClientContext(), &gmmParams);
|
||||
myResourecInfoSrc->pitch = 0x100;
|
||||
myResourecInfoDst->pitch = 0x200;
|
||||
gmmSrc->gmmResourceInfo.reset(myResourecInfoSrc.release());
|
||||
gmmDst->gmmResourceInfo.reset(myResourecInfoDst.release());
|
||||
auto flags = gmmDst->gmmResourceInfo->getResourceFlags();
|
||||
flags->Info.TiledY = true;
|
||||
MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
MockGraphicsAllocation mockAllocationDst(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
mockAllocationSrc.setGmm(gmmSrc.get(), 0);
|
||||
mockAllocationDst.setGmm(gmmDst.get(), 0);
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.dstRowPitch = 0x1000;
|
||||
properties.srcRowPitch = 0x1000;
|
||||
|
||||
properties.srcAllocation = &mockAllocationSrc;
|
||||
properties.dstAllocation = &mockAllocationDst;
|
||||
auto expectedPitch = alignUp<uint32_t>(static_cast<uint32_t>(gmmDst->gmmResourceInfo->getRenderPitch()), TILED_Y_PITCH_ALIGNMENT);
|
||||
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd);
|
||||
EXPECT_EQ(bltCmd.getDestinationPitch(), expectedPitch / sizeof(uint32_t));
|
||||
EXPECT_EQ(bltCmd.getSourcePitch(), properties.srcRowPitch);
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenSrcTiledImageAndNotTiledDstWhenAppendBlitCommandsForImagesThenPitchIsValueInDwords, IsGen12LP) {
|
||||
constexpr uint32_t TILED_Y_PITCH_ALIGNMENT = 128;
|
||||
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
|
||||
auto gmmSrc = std::make_unique<MockGmm>();
|
||||
auto gmmDst = std::make_unique<MockGmm>();
|
||||
GMM_RESCREATE_PARAMS gmmParams = {};
|
||||
auto myResourecInfoSrc = std::make_unique<MyMockResourecInfo>(pDevice->getRootDeviceEnvironment().getGmmClientContext(), &gmmParams);
|
||||
auto myResourecInfoDst = std::make_unique<MyMockResourecInfo>(pDevice->getRootDeviceEnvironment().getGmmClientContext(), &gmmParams);
|
||||
myResourecInfoSrc->pitch = 0x100;
|
||||
myResourecInfoDst->pitch = 0x200;
|
||||
gmmSrc->gmmResourceInfo.reset(myResourecInfoSrc.release());
|
||||
gmmDst->gmmResourceInfo.reset(myResourecInfoDst.release());
|
||||
auto flags = gmmSrc->gmmResourceInfo->getResourceFlags();
|
||||
flags->Info.TiledY = true;
|
||||
MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
MockGraphicsAllocation mockAllocationDst(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages);
|
||||
mockAllocationSrc.setGmm(gmmSrc.get(), 0);
|
||||
mockAllocationDst.setGmm(gmmDst.get(), 0);
|
||||
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
|
||||
BlitProperties properties = {};
|
||||
properties.dstRowPitch = 0x1000;
|
||||
properties.srcRowPitch = 0x1000;
|
||||
|
||||
properties.srcAllocation = &mockAllocationSrc;
|
||||
properties.dstAllocation = &mockAllocationDst;
|
||||
auto expectedPitch = alignUp<uint32_t>(static_cast<uint32_t>(gmmSrc->gmmResourceInfo->getRenderPitch()), TILED_Y_PITCH_ALIGNMENT);
|
||||
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd);
|
||||
EXPECT_EQ(bltCmd.getSourcePitch(), expectedPitch / sizeof(uint32_t));
|
||||
EXPECT_EQ(bltCmd.getDestinationPitch(), properties.dstRowPitch);
|
||||
}
|
||||
Reference in New Issue
Block a user