Skip to content

Commit 6ea3f57

Browse files
Don't use bcs for mipmapped images OCL
Signed-off-by: Kamil Kopryk <[email protected]> Related-To: NEO-4692
1 parent 3ed0f07 commit 6ea3f57

File tree

6 files changed

+29
-8
lines changed

6 files changed

+29
-8
lines changed

opencl/source/command_queue/command_queue.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ bool CommandQueue::blitEnqueuePreferred(cl_command_type cmdType, const BuiltinOp
745745
return true;
746746
}
747747

748-
bool CommandQueue::blitEnqueueImageAllowed(const size_t *origin, const size_t *region) {
748+
bool CommandQueue::blitEnqueueImageAllowed(const size_t *origin, const size_t *region, const Image &image) {
749749
const auto &hwInfo = device->getHardwareInfo();
750750
const auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
751751
auto blitEnqueuImageAllowed = hwHelper.isBlitterForImagesSupported(hwInfo);
@@ -755,6 +755,7 @@ bool CommandQueue::blitEnqueueImageAllowed(const size_t *origin, const size_t *r
755755
}
756756

757757
blitEnqueuImageAllowed &= (origin[0] + region[0] <= BlitterConstants::maxBlitWidth) && (origin[1] + region[1] <= BlitterConstants::maxBlitHeight);
758+
blitEnqueuImageAllowed &= !isMipMapped(image.getImageDesc());
758759
return blitEnqueuImageAllowed;
759760
}
760761

opencl/source/command_queue/command_queue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ class CommandQueue : public BaseObject<_cl_command_queue> {
354354
bool queueDependenciesClearRequired() const;
355355
bool blitEnqueueAllowed(cl_command_type cmdType) const;
356356
bool blitEnqueuePreferred(cl_command_type cmdType, const BuiltinOpParams &builtinOpParams) const;
357-
MOCKABLE_VIRTUAL bool blitEnqueueImageAllowed(const size_t *origin, const size_t *region);
357+
MOCKABLE_VIRTUAL bool blitEnqueueImageAllowed(const size_t *origin, const size_t *region, const Image &image);
358358
void aubCaptureHook(bool &blocking, bool &clearAllDependencies, const MultiDispatchInfo &multiDispatchInfo);
359359
virtual bool obtainTimestampPacketForCacheFlush(bool isCacheFlushRequired) const = 0;
360360

opencl/source/command_queue/enqueue_read_image.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueReadImage(
4141
const cl_event *eventWaitList,
4242
cl_event *event) {
4343
cl_command_type cmdType = CL_COMMAND_READ_IMAGE;
44-
auto blitAllowed = blitEnqueueAllowed(cmdType) && blitEnqueueImageAllowed(origin, region);
44+
auto blitAllowed = blitEnqueueAllowed(cmdType) && blitEnqueueImageAllowed(origin, region, *srcImage);
4545
auto &csr = getCommandStreamReceiver(blitAllowed);
4646

4747
if (nullptr == mapAllocation) {

opencl/source/command_queue/enqueue_write_image.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteImage(
5454
HostPtrSurface hostPtrSurf(srcPtr, hostPtrSize, true);
5555
GeneralSurface mapSurface;
5656
Surface *surfaces[] = {&dstImgSurf, nullptr};
57-
auto blitAllowed = blitEnqueueAllowed(cmdType) && blitEnqueueImageAllowed(origin, region);
57+
auto blitAllowed = blitEnqueueAllowed(cmdType) && blitEnqueueImageAllowed(origin, region, *dstImage);
5858
if (mapAllocation) {
5959
surfaces[1] = &mapSurface;
6060
mapSurface.setGraphicsAllocation(mapAllocation);

opencl/test/unit_test/command_queue/command_queue_tests.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "opencl/test/unit_test/mocks/mock_context.h"
3838
#include "opencl/test/unit_test/mocks/mock_csr.h"
3939
#include "opencl/test/unit_test/mocks/mock_event.h"
40+
#include "opencl/test/unit_test/mocks/mock_image.h"
4041
#include "opencl/test/unit_test/mocks/mock_kernel.h"
4142
#include "opencl/test/unit_test/mocks/mock_mdi.h"
4243
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
@@ -1313,6 +1314,8 @@ TEST(CommandQueue, givenCopySizeAndOffsetWhenCallingBlitEnqueueImageAllowedThenR
13131314
DebugManager.flags.EnableBlitterForReadWriteImage.set(1);
13141315
MockContext context{};
13151316
MockCommandQueue queue(&context, context.getDevice(0), 0);
1317+
MockImageBase image;
1318+
image.imageDesc.num_mip_levels = 1;
13161319

13171320
auto maxBlitWidth = static_cast<size_t>(BlitterConstants::maxBlitWidth);
13181321
auto maxBlitHeight = static_cast<size_t>(BlitterConstants::maxBlitHeight);
@@ -1329,10 +1332,27 @@ TEST(CommandQueue, givenCopySizeAndOffsetWhenCallingBlitEnqueueImageAllowedThenR
13291332
for (auto &[regionX, regionY, originX, originY, expectedResult] : testParams) {
13301333
size_t region[3] = {regionX, regionY, 0};
13311334
size_t origin[3] = {originX, originY, 0};
1332-
EXPECT_EQ(expectedResult, queue.blitEnqueueImageAllowed(origin, region));
1335+
EXPECT_EQ(expectedResult, queue.blitEnqueueImageAllowed(origin, region, image));
13331336
}
13341337
}
13351338

1339+
TEST(CommandQueue, givenMipMappedImageWhenCallingBlitEnqueueImageAllowedThenCorrectResultIsReturned) {
1340+
DebugManagerStateRestore restorer;
1341+
DebugManager.flags.EnableBlitterForReadWriteImage.set(1);
1342+
MockContext context{};
1343+
MockCommandQueue queue(&context, context.getDevice(0), 0);
1344+
1345+
size_t correctRegion[3] = {10u, 10u, 0};
1346+
size_t correctOrigin[3] = {1u, 1u, 0};
1347+
MockImageBase image;
1348+
1349+
image.imageDesc.num_mip_levels = 1;
1350+
EXPECT_TRUE(queue.blitEnqueueImageAllowed(correctOrigin, correctRegion, image));
1351+
1352+
image.imageDesc.num_mip_levels = 2;
1353+
EXPECT_FALSE(queue.blitEnqueueImageAllowed(correctOrigin, correctRegion, image));
1354+
}
1355+
13361356
TEST(CommandQueue, givenSupportForOperationWhenValidatingSupportThenReturnSuccess) {
13371357
MockCommandQueue queue{};
13381358

opencl/test/unit_test/mocks/mock_command_queue.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class MockCommandQueue : public CommandQueue {
194194

195195
template <typename GfxFamily>
196196
class MockCommandQueueHw : public CommandQueueHw<GfxFamily> {
197-
typedef CommandQueueHw<GfxFamily> BaseClass;
197+
using BaseClass = CommandQueueHw<GfxFamily>;
198198

199199
public:
200200
using BaseClass::bcsEngine;
@@ -310,8 +310,8 @@ class MockCommandQueueHw : public CommandQueueHw<GfxFamily> {
310310
return BaseClass::isCacheFlushForBcsRequired();
311311
}
312312

313-
bool blitEnqueueImageAllowed(const size_t *origin, const size_t *region) override {
314-
isBlitEnqueueImageAllowed = BaseClass::blitEnqueueImageAllowed(origin, region);
313+
bool blitEnqueueImageAllowed(const size_t *origin, const size_t *region, const Image &image) override {
314+
isBlitEnqueueImageAllowed = BaseClass::blitEnqueueImageAllowed(origin, region, image);
315315
return isBlitEnqueueImageAllowed;
316316
}
317317

0 commit comments

Comments
 (0)