diff --git a/opencl/source/command_queue/command_queue.cpp b/opencl/source/command_queue/command_queue.cpp index ff1cb58212..4e25cfbaaf 100644 --- a/opencl/source/command_queue/command_queue.cpp +++ b/opencl/source/command_queue/command_queue.cpp @@ -1606,7 +1606,7 @@ cl_int CommandQueue::enqueueStagingWriteImage(Image *dstImage, cl_bool blockingC size_t inputRowPitch, size_t inputSlicePitch, const void *ptr, cl_event *event) { constexpr cl_command_type cmdType = CL_COMMAND_WRITE_IMAGE; CsrSelectionArgs csrSelectionArgs{cmdType, nullptr, dstImage, this->getDevice().getRootDeviceIndex(), globalRegion, nullptr, globalOrigin}; - auto csr = &selectCsrForBuiltinOperation(csrSelectionArgs); + auto &csr = selectCsrForBuiltinOperation(csrSelectionArgs); Event profilingEvent{this, CL_COMMAND_WRITE_IMAGE, CompletionStamp::notReady, CompletionStamp::notReady}; if (isProfilingEnabled()) { @@ -1625,7 +1625,7 @@ cl_int CommandQueue::enqueueStagingWriteImage(Image *dstImage, cl_bool blockingC } memcpy(stagingBuffer, chunkPtr, bufferSize); if (isSingleTransfer) { - return this->enqueueWriteImage(dstImage, false, origin, region, inputRowPitch, inputSlicePitch, stagingBuffer, nullptr, 0, nullptr, event); + return this->enqueueWriteImageImpl(dstImage, false, origin, region, inputRowPitch, inputSlicePitch, stagingBuffer, nullptr, 0, nullptr, event, csr); } if (isFirstTransfer && isProfilingEnabled()) { @@ -1636,13 +1636,13 @@ cl_int CommandQueue::enqueueStagingWriteImage(Image *dstImage, cl_bool blockingC if (isLastTransfer && !this->isOOQEnabled()) { outEvent = event; } - auto ret = this->enqueueWriteImage(dstImage, false, origin, region, inputRowPitch, inputSlicePitch, stagingBuffer, nullptr, 0, nullptr, outEvent); + auto ret = this->enqueueWriteImageImpl(dstImage, false, origin, region, inputRowPitch, inputSlicePitch, stagingBuffer, nullptr, 0, nullptr, outEvent, csr); return ret; }; auto bytesPerPixel = dstImage->getSurfaceFormatInfo().surfaceFormat.imageElementSizeInBytes; auto dstRowPitch = inputRowPitch ? inputRowPitch : globalRegion[0] * bytesPerPixel; auto stagingBufferManager = this->context->getStagingBufferManager(); - auto ret = stagingBufferManager->performImageWrite(ptr, globalOrigin, globalRegion, dstRowPitch, chunkWrite, csr); + auto ret = stagingBufferManager->performImageWrite(ptr, globalOrigin, globalRegion, dstRowPitch, chunkWrite, &csr); if (ret != CL_SUCCESS) { return ret; } diff --git a/opencl/source/command_queue/command_queue.h b/opencl/source/command_queue/command_queue.h index 131479586a..298e6998e0 100644 --- a/opencl/source/command_queue/command_queue.h +++ b/opencl/source/command_queue/command_queue.h @@ -156,6 +156,11 @@ class CommandQueue : public BaseObject<_cl_command_queue> { const void *ptr, GraphicsAllocation *mapAllocation, cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0; + virtual cl_int enqueueWriteImageImpl(Image *dstImage, cl_bool blockingWrite, const size_t *origin, + const size_t *region, size_t inputRowPitch, size_t inputSlicePitch, + const void *ptr, GraphicsAllocation *mapAllocation, cl_uint numEventsInWaitList, + const cl_event *eventWaitList, cl_event *event, CommandStreamReceiver &csr) = 0; + virtual cl_int enqueueCopyBufferRect(Buffer *srcBuffer, Buffer *dstBuffer, const size_t *srcOrigin, const size_t *dstOrigin, const size_t *region, size_t srcRowPitch, size_t srcSlicePitch, size_t dstRowPitch, size_t dstSlicePitch, cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) = 0; diff --git a/opencl/source/command_queue/command_queue_hw.h b/opencl/source/command_queue/command_queue_hw.h index 700eb09b91..851c9a9df8 100644 --- a/opencl/source/command_queue/command_queue_hw.h +++ b/opencl/source/command_queue/command_queue_hw.h @@ -305,6 +305,11 @@ class CommandQueueHw : public CommandQueue { const cl_event *eventWaitList, cl_event *event) override; + cl_int enqueueWriteImageImpl(Image *dstImage, cl_bool blockingWrite, const size_t *origin, + const size_t *region, size_t inputRowPitch, size_t inputSlicePitch, + const void *ptr, GraphicsAllocation *mapAllocation, cl_uint numEventsInWaitList, + const cl_event *eventWaitList, cl_event *event, CommandStreamReceiver &csr) override; + cl_int enqueueCopyBufferToImage(Buffer *srcBuffer, Image *dstImage, size_t srcOffset, diff --git a/opencl/source/command_queue/enqueue_write_image.h b/opencl/source/command_queue/enqueue_write_image.h index 265e532a57..fed8992596 100644 --- a/opencl/source/command_queue/enqueue_write_image.h +++ b/opencl/source/command_queue/enqueue_write_image.h @@ -39,6 +39,25 @@ cl_int CommandQueueHw::enqueueWriteImage( CsrSelectionArgs csrSelectionArgs{cmdType, nullptr, dstImage, device->getRootDeviceIndex(), region, nullptr, origin}; CommandStreamReceiver &csr = selectCsrForBuiltinOperation(csrSelectionArgs); + return enqueueWriteImageImpl(dstImage, blockingWrite, origin, region, inputRowPitch, inputSlicePitch, ptr, mapAllocation, numEventsInWaitList, eventWaitList, event, csr); +} + +template +cl_int CommandQueueHw::enqueueWriteImageImpl( + Image *dstImage, + cl_bool blockingWrite, + const size_t *origin, + const size_t *region, + size_t inputRowPitch, + size_t inputSlicePitch, + const void *ptr, + GraphicsAllocation *mapAllocation, + cl_uint numEventsInWaitList, + const cl_event *eventWaitList, + cl_event *event, + CommandStreamReceiver &csr) { + constexpr cl_command_type cmdType = CL_COMMAND_WRITE_IMAGE; + CsrSelectionArgs csrSelectionArgs{cmdType, nullptr, dstImage, device->getRootDeviceIndex(), region, nullptr, origin}; auto isMemTransferNeeded = true; diff --git a/opencl/test/unit_test/mocks/mock_command_queue.h b/opencl/test/unit_test/mocks/mock_command_queue.h index d0fe522eae..f9f5c53570 100644 --- a/opencl/test/unit_test/mocks/mock_command_queue.h +++ b/opencl/test/unit_test/mocks/mock_command_queue.h @@ -193,6 +193,11 @@ class MockCommandQueue : public CommandQueue { cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) override { return CL_SUCCESS; } + cl_int enqueueWriteImageImpl(Image *dstImage, cl_bool blockingWrite, const size_t *origin, const size_t *region, + size_t inputRowPitch, size_t inputSlicePitch, const void *ptr, GraphicsAllocation *mapAllocation, + cl_uint numEventsInWaitList, const cl_event *eventWaitList, + cl_event *event, CommandStreamReceiver &csr) override { return CL_SUCCESS; } + cl_int enqueueCopyBufferRect(Buffer *srcBuffer, Buffer *dstBuffer, const size_t *srcOrigin, const size_t *dstOrigin, const size_t *region, size_t srcRowPitch, size_t srcSlicePitch, size_t dstRowPitch, size_t dstSlicePitch, cl_uint numEventsInWaitList, @@ -345,30 +350,32 @@ class MockCommandQueueHw : public CommandQueueHw { return reinterpret_cast &>(BaseClass::getGpgpuCommandStreamReceiver()); } - cl_int enqueueWriteImage(Image *dstImage, - cl_bool blockingWrite, - const size_t *origin, - const size_t *region, - size_t inputRowPitch, - size_t inputSlicePitch, - const void *ptr, - GraphicsAllocation *mapAllocation, - cl_uint numEventsInWaitList, - const cl_event *eventWaitList, - cl_event *event) override { + cl_int enqueueWriteImageImpl(Image *dstImage, + cl_bool blockingWrite, + const size_t *origin, + const size_t *region, + size_t inputRowPitch, + size_t inputSlicePitch, + const void *ptr, + GraphicsAllocation *mapAllocation, + cl_uint numEventsInWaitList, + const cl_event *eventWaitList, + cl_event *event, + CommandStreamReceiver &csr) override { enqueueWriteImageCounter++; if (enqueueWriteImageCallBase) { - return BaseClass::enqueueWriteImage(dstImage, - blockingWrite, - origin, - region, - inputRowPitch, - inputSlicePitch, - ptr, - mapAllocation, - numEventsInWaitList, - eventWaitList, - event); + return BaseClass::enqueueWriteImageImpl(dstImage, + blockingWrite, + origin, + region, + inputRowPitch, + inputSlicePitch, + ptr, + mapAllocation, + numEventsInWaitList, + eventWaitList, + event, + csr); } return CL_INVALID_OPERATION; }