Don't use bcs for mipmapped images OCL

Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
Related-To: NEO-4692
This commit is contained in:
Kamil Kopryk 2021-06-10 11:54:07 +00:00 committed by Compute-Runtime-Automation
parent 3ed0f074af
commit 6ea3f57849
6 changed files with 29 additions and 8 deletions

View File

@ -745,7 +745,7 @@ bool CommandQueue::blitEnqueuePreferred(cl_command_type cmdType, const BuiltinOp
return true;
}
bool CommandQueue::blitEnqueueImageAllowed(const size_t *origin, const size_t *region) {
bool CommandQueue::blitEnqueueImageAllowed(const size_t *origin, const size_t *region, const Image &image) {
const auto &hwInfo = device->getHardwareInfo();
const auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
auto blitEnqueuImageAllowed = hwHelper.isBlitterForImagesSupported(hwInfo);
@ -755,6 +755,7 @@ bool CommandQueue::blitEnqueueImageAllowed(const size_t *origin, const size_t *r
}
blitEnqueuImageAllowed &= (origin[0] + region[0] <= BlitterConstants::maxBlitWidth) && (origin[1] + region[1] <= BlitterConstants::maxBlitHeight);
blitEnqueuImageAllowed &= !isMipMapped(image.getImageDesc());
return blitEnqueuImageAllowed;
}

View File

@ -354,7 +354,7 @@ class CommandQueue : public BaseObject<_cl_command_queue> {
bool queueDependenciesClearRequired() const;
bool blitEnqueueAllowed(cl_command_type cmdType) const;
bool blitEnqueuePreferred(cl_command_type cmdType, const BuiltinOpParams &builtinOpParams) const;
MOCKABLE_VIRTUAL bool blitEnqueueImageAllowed(const size_t *origin, const size_t *region);
MOCKABLE_VIRTUAL bool blitEnqueueImageAllowed(const size_t *origin, const size_t *region, const Image &image);
void aubCaptureHook(bool &blocking, bool &clearAllDependencies, const MultiDispatchInfo &multiDispatchInfo);
virtual bool obtainTimestampPacketForCacheFlush(bool isCacheFlushRequired) const = 0;

View File

@ -41,7 +41,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueReadImage(
const cl_event *eventWaitList,
cl_event *event) {
cl_command_type cmdType = CL_COMMAND_READ_IMAGE;
auto blitAllowed = blitEnqueueAllowed(cmdType) && blitEnqueueImageAllowed(origin, region);
auto blitAllowed = blitEnqueueAllowed(cmdType) && blitEnqueueImageAllowed(origin, region, *srcImage);
auto &csr = getCommandStreamReceiver(blitAllowed);
if (nullptr == mapAllocation) {

View File

@ -54,7 +54,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteImage(
HostPtrSurface hostPtrSurf(srcPtr, hostPtrSize, true);
GeneralSurface mapSurface;
Surface *surfaces[] = {&dstImgSurf, nullptr};
auto blitAllowed = blitEnqueueAllowed(cmdType) && blitEnqueueImageAllowed(origin, region);
auto blitAllowed = blitEnqueueAllowed(cmdType) && blitEnqueueImageAllowed(origin, region, *dstImage);
if (mapAllocation) {
surfaces[1] = &mapSurface;
mapSurface.setGraphicsAllocation(mapAllocation);

View File

@ -37,6 +37,7 @@
#include "opencl/test/unit_test/mocks/mock_context.h"
#include "opencl/test/unit_test/mocks/mock_csr.h"
#include "opencl/test/unit_test/mocks/mock_event.h"
#include "opencl/test/unit_test/mocks/mock_image.h"
#include "opencl/test/unit_test/mocks/mock_kernel.h"
#include "opencl/test/unit_test/mocks/mock_mdi.h"
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
@ -1313,6 +1314,8 @@ TEST(CommandQueue, givenCopySizeAndOffsetWhenCallingBlitEnqueueImageAllowedThenR
DebugManager.flags.EnableBlitterForReadWriteImage.set(1);
MockContext context{};
MockCommandQueue queue(&context, context.getDevice(0), 0);
MockImageBase image;
image.imageDesc.num_mip_levels = 1;
auto maxBlitWidth = static_cast<size_t>(BlitterConstants::maxBlitWidth);
auto maxBlitHeight = static_cast<size_t>(BlitterConstants::maxBlitHeight);
@ -1329,10 +1332,27 @@ TEST(CommandQueue, givenCopySizeAndOffsetWhenCallingBlitEnqueueImageAllowedThenR
for (auto &[regionX, regionY, originX, originY, expectedResult] : testParams) {
size_t region[3] = {regionX, regionY, 0};
size_t origin[3] = {originX, originY, 0};
EXPECT_EQ(expectedResult, queue.blitEnqueueImageAllowed(origin, region));
EXPECT_EQ(expectedResult, queue.blitEnqueueImageAllowed(origin, region, image));
}
}
TEST(CommandQueue, givenMipMappedImageWhenCallingBlitEnqueueImageAllowedThenCorrectResultIsReturned) {
DebugManagerStateRestore restorer;
DebugManager.flags.EnableBlitterForReadWriteImage.set(1);
MockContext context{};
MockCommandQueue queue(&context, context.getDevice(0), 0);
size_t correctRegion[3] = {10u, 10u, 0};
size_t correctOrigin[3] = {1u, 1u, 0};
MockImageBase image;
image.imageDesc.num_mip_levels = 1;
EXPECT_TRUE(queue.blitEnqueueImageAllowed(correctOrigin, correctRegion, image));
image.imageDesc.num_mip_levels = 2;
EXPECT_FALSE(queue.blitEnqueueImageAllowed(correctOrigin, correctRegion, image));
}
TEST(CommandQueue, givenSupportForOperationWhenValidatingSupportThenReturnSuccess) {
MockCommandQueue queue{};

View File

@ -194,7 +194,7 @@ class MockCommandQueue : public CommandQueue {
template <typename GfxFamily>
class MockCommandQueueHw : public CommandQueueHw<GfxFamily> {
typedef CommandQueueHw<GfxFamily> BaseClass;
using BaseClass = CommandQueueHw<GfxFamily>;
public:
using BaseClass::bcsEngine;
@ -310,8 +310,8 @@ class MockCommandQueueHw : public CommandQueueHw<GfxFamily> {
return BaseClass::isCacheFlushForBcsRequired();
}
bool blitEnqueueImageAllowed(const size_t *origin, const size_t *region) override {
isBlitEnqueueImageAllowed = BaseClass::blitEnqueueImageAllowed(origin, region);
bool blitEnqueueImageAllowed(const size_t *origin, const size_t *region, const Image &image) override {
isBlitEnqueueImageAllowed = BaseClass::blitEnqueueImageAllowed(origin, region, image);
return isBlitEnqueueImageAllowed;
}