From 61524596e0983086e00d282ae81b50eac22ff25a Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Tue, 19 Oct 2021 20:45:59 +0000 Subject: [PATCH] Fail on blitMemoryToAllocation when blitter support is disabled Related-To: NEO-6325 Signed-off-by: Mateusz Jablonski --- .../memory_manager/memory_manager_tests.cpp | 20 +++++++++++++++++++ .../source/helpers/blit_commands_helper.cpp | 3 +++ 2 files changed, 23 insertions(+) diff --git a/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp b/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp index 35be2f5d1b..84230b3687 100644 --- a/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp +++ b/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp @@ -3017,6 +3017,26 @@ TEST(MemoryTransferHelperTest, givenBlitOperationSupportedWhenBcsEngineNotAvaila EXPECT_EQ(BlitOperationResult::Unsupported, BlitHelperFunctions::blitMemoryToAllocation(*device, &graphicsAllocation, 0, srcData, {dataSize, 1, 1})); } +TEST(MemoryTransferHelperTest, givenBlitOperationSupportedDisabledWhenBlitMemoryToAllocationThenReturnUnsupported) { + DebugManagerStateRestore restorer; + constexpr uint32_t dataSize = 16; + uint8_t destData[dataSize] = {}; + uint8_t srcData[dataSize] = {}; + + MockGraphicsAllocation graphicsAllocation{destData, sizeof(destData)}; + graphicsAllocation.storageInfo.memoryBanks = 1; + graphicsAllocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER); + + auto hwInfo = *defaultHwInfo; + hwInfo.capabilityTable.blitterOperationsSupported = true; + hwInfo.featureTable.ftrBcsInfo = 1; + DebugManager.flags.EnableBlitterOperationsSupport.set(false); + + auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(&hwInfo)); + + EXPECT_EQ(BlitOperationResult::Unsupported, BlitHelperFunctions::blitMemoryToAllocation(*device, &graphicsAllocation, 0, srcData, {dataSize, 1, 1})); +} + TEST(MemoryManagerTest, givenMemoryManagerWithLocalMemoryWhenCreatingMultiGraphicsAllocationInSystemMemoryThenForceSystemMemoryPlacement) { MockExecutionEnvironment executionEnvironment(defaultHwInfo.get()); executionEnvironment.initGmm(); diff --git a/shared/source/helpers/blit_commands_helper.cpp b/shared/source/helpers/blit_commands_helper.cpp index d924795002..ec4b9f1968 100644 --- a/shared/source/helpers/blit_commands_helper.cpp +++ b/shared/source/helpers/blit_commands_helper.cpp @@ -178,6 +178,9 @@ BlitOperationResult BlitHelper::blitMemoryToAllocationBanks(const Device &device if (!hwInfo.capabilityTable.blitterOperationsSupported && !isBlitterRequired) { return BlitOperationResult::Unsupported; } + if (0 == DebugManager.flags.EnableBlitterOperationsSupport.get()) { + return BlitOperationResult::Unsupported; + } UNRECOVERABLE_IF(memoryBanks.none());