mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-07 20:54:47 +08:00
Revert "Add blitter support for read/write image OpenCL"
This reverts commit cc6d6968dd.
Change-Id: I2696f05c5d1e3959f60239ca49483b00ad1b36ec
Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
This commit is contained in:
@@ -637,27 +637,18 @@ 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 &= static_cast<bool>(DebugManager.flags.EnableBlitterOperationsForReadWriteBuffers.get());
|
||||
blitAllowed &= !!DebugManager.flags.EnableBlitterOperationsForReadWriteBuffers.get();
|
||||
}
|
||||
|
||||
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 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;
|
||||
}
|
||||
|
||||
bool CommandQueue::isBlockedCommandStreamRequired(uint32_t commandType, const EventsRequest &eventsRequest, bool blockedQueue) const {
|
||||
|
||||
@@ -41,23 +41,27 @@ cl_int CommandQueueHw<GfxFamily>::enqueueReadImage(
|
||||
const cl_event *eventWaitList,
|
||||
cl_event *event) {
|
||||
|
||||
auto cmdType = CL_COMMAND_READ_IMAGE;
|
||||
auto &csr = getCommandStreamReceiverByCommandType(cmdType);
|
||||
auto &csr = getGpgpuCommandStreamReceiver();
|
||||
if (nullptr == mapAllocation) {
|
||||
notifyEnqueueReadImage(srcImage, static_cast<bool>(blockingRead), EngineHelpers::isBcs(csr.getOsContext().getEngineType()));
|
||||
notifyEnqueueReadImage(srcImage, !!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, cmdType);
|
||||
isMemTransferNeeded = srcImage->checkIfMemoryTransferIsRequired(hostOffset, 0, ptr, CL_COMMAND_READ_IMAGE);
|
||||
}
|
||||
if (!isMemTransferNeeded) {
|
||||
return enqueueMarkerForReadWriteOperation(srcImage, ptr, cmdType, blockingRead,
|
||||
return enqueueMarkerForReadWriteOperation(srcImage, ptr, CL_COMMAND_READ_IMAGE, 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;
|
||||
|
||||
@@ -99,12 +103,18 @@ 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();
|
||||
|
||||
auto eBuiltInOps = EBuiltInOps::CopyImage3dToBuffer;
|
||||
MultiDispatchInfo dispatchInfo(dc);
|
||||
MultiDispatchInfo di(dc);
|
||||
|
||||
dispatchBcsOrGpgpuEnqueue<CL_COMMAND_READ_IMAGE>(dispatchInfo, surfaces, eBuiltInOps, numEventsInWaitList, eventWaitList, event, blockingRead == CL_TRUE);
|
||||
builder.buildDispatchInfos(di);
|
||||
|
||||
enqueueHandler<CL_COMMAND_READ_IMAGE>(
|
||||
surfaces,
|
||||
blockingRead == CL_TRUE,
|
||||
di,
|
||||
numEventsInWaitList,
|
||||
eventWaitList,
|
||||
event);
|
||||
|
||||
if (context->isProvidingPerformanceHints()) {
|
||||
if (!isL3Capable(ptr, hostPtrSize)) {
|
||||
|
||||
@@ -35,17 +35,20 @@ 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, cmdType);
|
||||
isMemTransferNeeded = dstImage->checkIfMemoryTransferIsRequired(hostOffset, 0, ptr, CL_COMMAND_WRITE_IMAGE);
|
||||
}
|
||||
if (!isMemTransferNeeded) {
|
||||
return enqueueMarkerForReadWriteOperation(dstImage, const_cast<void *>(ptr), cmdType, blockingWrite,
|
||||
return enqueueMarkerForReadWriteOperation(dstImage, const_cast<void *>(ptr), CL_COMMAND_WRITE_IMAGE, 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);
|
||||
@@ -66,8 +69,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteImage(
|
||||
if (region[0] != 0 &&
|
||||
region[1] != 0 &&
|
||||
region[2] != 0) {
|
||||
auto &csr = getCommandStreamReceiverByCommandType(cmdType);
|
||||
bool status = csr.createAllocationForHostSurface(hostPtrSurf, false);
|
||||
bool status = getGpgpuCommandStreamReceiver().createAllocationForHostSurface(hostPtrSurf, false);
|
||||
if (!status) {
|
||||
return CL_OUT_OF_RESOURCES;
|
||||
}
|
||||
@@ -89,12 +91,17 @@ 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();
|
||||
|
||||
auto eBuiltInOps = EBuiltInOps::CopyBufferToImage3d;
|
||||
MultiDispatchInfo dispatchInfo(dc);
|
||||
MultiDispatchInfo di(dc);
|
||||
builder.buildDispatchInfos(di);
|
||||
|
||||
dispatchBcsOrGpgpuEnqueue<CL_COMMAND_WRITE_IMAGE>(dispatchInfo, surfaces, eBuiltInOps, numEventsInWaitList, eventWaitList, event, blockingWrite == CL_TRUE);
|
||||
enqueueHandler<CL_COMMAND_WRITE_IMAGE>(
|
||||
surfaces,
|
||||
blockingWrite == CL_TRUE,
|
||||
di,
|
||||
numEventsInWaitList,
|
||||
eventWaitList,
|
||||
event);
|
||||
|
||||
if (context->isProvidingPerformanceHints()) {
|
||||
context->providePerformanceHint(CL_CONTEXT_DIAGNOSTICS_LEVEL_NEUTRAL_INTEL, CL_ENQUEUE_WRITE_IMAGE_REQUIRES_COPY_DATA, static_cast<cl_mem>(dstImage));
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#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"
|
||||
|
||||
@@ -48,7 +47,6 @@ struct ClBlitProperties {
|
||||
builtinOpParams.dstRowPitch, builtinOpParams.dstSlicePitch);
|
||||
}
|
||||
|
||||
BlitProperties blitProperties{};
|
||||
GraphicsAllocation *gpuAllocation = nullptr;
|
||||
Vec3<size_t> copyOffset = 0;
|
||||
|
||||
@@ -66,9 +64,8 @@ struct ClBlitProperties {
|
||||
size_t gpuRowPitch = 0;
|
||||
size_t gpuSlicePitch = 0;
|
||||
|
||||
if (BlitterConstants::BlitDirection::HostPtrToBuffer == blitDirection ||
|
||||
BlitterConstants::BlitDirection::HostPtrToImage == blitDirection) {
|
||||
// write buffer/image
|
||||
if (BlitterConstants::BlitDirection::HostPtrToBuffer == blitDirection) {
|
||||
// write buffer
|
||||
hostPtr = builtinOpParams.srcPtr;
|
||||
hostPtrOffset = builtinOpParams.srcOffset;
|
||||
copyOffset = builtinOpParams.dstOffset;
|
||||
@@ -91,10 +88,10 @@ struct ClBlitProperties {
|
||||
copySize = builtinOpParams.size;
|
||||
}
|
||||
|
||||
if (BlitterConstants::BlitDirection::BufferToHostPtr == blitDirection ||
|
||||
BlitterConstants::BlitDirection::ImageToHostPtr == blitDirection) {
|
||||
// read buffer/image
|
||||
if (BlitterConstants::BlitDirection::BufferToHostPtr == blitDirection) {
|
||||
// read buffer
|
||||
hostPtr = builtinOpParams.dstPtr;
|
||||
|
||||
hostPtrOffset = builtinOpParams.dstOffset;
|
||||
copyOffset = builtinOpParams.srcOffset;
|
||||
|
||||
@@ -117,78 +114,26 @@ struct ClBlitProperties {
|
||||
}
|
||||
|
||||
UNRECOVERABLE_IF(BlitterConstants::BlitDirection::HostPtrToBuffer != blitDirection &&
|
||||
BlitterConstants::BlitDirection::BufferToHostPtr != blitDirection &&
|
||||
BlitterConstants::BlitDirection::HostPtrToImage != blitDirection &&
|
||||
BlitterConstants::BlitDirection::ImageToHostPtr != blitDirection);
|
||||
BlitterConstants::BlitDirection::BufferToHostPtr != blitDirection);
|
||||
|
||||
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;
|
||||
return BlitProperties::constructPropertiesForReadWriteBuffer(blitDirection, commandStreamReceiver, gpuAllocation,
|
||||
hostAllocation, hostPtr, memObjGpuVa, hostAllocGpuVa,
|
||||
hostPtrOffset, copyOffset, copySize,
|
||||
hostRowPitch, hostSlicePitch,
|
||||
gpuRowPitch, gpuSlicePitch);
|
||||
}
|
||||
|
||||
static BlitterConstants::BlitDirection obtainBlitDirection(uint32_t commandType) {
|
||||
|
||||
switch (commandType) {
|
||||
case CL_COMMAND_WRITE_BUFFER:
|
||||
case CL_COMMAND_WRITE_BUFFER_RECT:
|
||||
if (CL_COMMAND_WRITE_BUFFER == commandType || CL_COMMAND_WRITE_BUFFER_RECT == commandType) {
|
||||
return BlitterConstants::BlitDirection::HostPtrToBuffer;
|
||||
case CL_COMMAND_READ_BUFFER:
|
||||
case CL_COMMAND_READ_BUFFER_RECT:
|
||||
} else if (CL_COMMAND_READ_BUFFER == commandType || CL_COMMAND_READ_BUFFER_RECT == commandType) {
|
||||
return BlitterConstants::BlitDirection::BufferToHostPtr;
|
||||
case CL_COMMAND_COPY_BUFFER:
|
||||
case CL_COMMAND_COPY_BUFFER_RECT:
|
||||
case CL_COMMAND_SVM_MEMCPY:
|
||||
} else if (CL_COMMAND_COPY_BUFFER_RECT == commandType || CL_COMMAND_SVM_MEMCPY == commandType) {
|
||||
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);
|
||||
UNRECOVERABLE_IF(CL_COMMAND_COPY_BUFFER != commandType);
|
||||
return BlitterConstants::BlitDirection::BufferToBuffer;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user