Don't copy compressed buffer on CPU

Change-Id: I9c36ee8f23284286bb846fd9a0fd196733d0f8f9
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2019-04-03 13:15:07 +02:00
parent 3c8b3e9633
commit f76c0e84fb
6 changed files with 94 additions and 4 deletions

View File

@@ -391,6 +391,48 @@ HWTEST_F(EnqueueWriteBufferTypeTest, givenEnqueueWriteBufferCalledWhenLockedPtrI
EXPECT_EQ(0u, memoryManager.unlockResourceCalled);
}
HWTEST_F(EnqueueWriteBufferTypeTest, givenForcedCpuCopyWhenEnqueueWriteCompressedBufferThenDontCopyOnCpu) {
DebugManagerStateRestore dbgRestore;
DebugManager.flags.DoCpuCopyOnWriteBuffer.set(true);
MockExecutionEnvironment executionEnvironment(*platformDevices);
MockMemoryManager memoryManager(false, true, executionEnvironment);
MockContext ctx;
cl_int retVal;
ctx.setMemoryManager(&memoryManager);
auto mockCmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context, pDevice, nullptr);
std::unique_ptr<Buffer> buffer(Buffer::create(&ctx, 0, 1, nullptr, retVal));
static_cast<MemoryAllocation *>(buffer->getGraphicsAllocation())->overrideMemoryPool(MemoryPool::SystemCpuInaccessible);
void *ptr = srcBuffer->getCpuAddressForMemoryTransfer();
buffer->getGraphicsAllocation()->setAllocationType(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
retVal = mockCmdQ->enqueueWriteBuffer(buffer.get(),
CL_FALSE,
0,
MemoryConstants::cacheLineSize,
ptr,
0,
nullptr,
nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_FALSE(mockCmdQ->cpuDataTransferHandlerCalled);
buffer->getGraphicsAllocation()->setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
retVal = mockCmdQ->enqueueWriteBuffer(buffer.get(),
CL_FALSE,
0,
MemoryConstants::cacheLineSize,
ptr,
0,
nullptr,
nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(mockCmdQ->cpuDataTransferHandlerCalled);
}
HWTEST_F(EnqueueWriteBufferTypeTest, givenEnqueueWriteBufferCalledWhenLockedPtrInTransferPropertisIsNotAvailableThenItIsNotUnlocked) {
DebugManagerStateRestore dbgRestore;
DebugManager.flags.DoCpuCopyOnWriteBuffer.set(true);