@@ -391,6 +391,48 @@ HWTEST_F(EnqueueWriteBufferTypeTest, givenEnqueueWriteBufferCalledWhenLockedPtrI
391
391
EXPECT_EQ (0u , memoryManager.unlockResourceCalled );
392
392
}
393
393
394
+ HWTEST_F (EnqueueWriteBufferTypeTest, givenForcedCpuCopyWhenEnqueueWriteCompressedBufferThenDontCopyOnCpu) {
395
+ DebugManagerStateRestore dbgRestore;
396
+ DebugManager.flags .DoCpuCopyOnWriteBuffer .set (true );
397
+
398
+ MockExecutionEnvironment executionEnvironment (*platformDevices);
399
+ MockMemoryManager memoryManager (false , true , executionEnvironment);
400
+ MockContext ctx;
401
+ cl_int retVal;
402
+ ctx.setMemoryManager (&memoryManager);
403
+ auto mockCmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context, pDevice, nullptr );
404
+ std::unique_ptr<Buffer> buffer (Buffer::create (&ctx, 0 , 1 , nullptr , retVal));
405
+ static_cast <MemoryAllocation *>(buffer->getGraphicsAllocation ())->overrideMemoryPool (MemoryPool::SystemCpuInaccessible);
406
+ void *ptr = srcBuffer->getCpuAddressForMemoryTransfer ();
407
+ buffer->getGraphicsAllocation ()->setAllocationType (GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
408
+
409
+ retVal = mockCmdQ->enqueueWriteBuffer (buffer.get (),
410
+ CL_FALSE,
411
+ 0 ,
412
+ MemoryConstants::cacheLineSize,
413
+ ptr,
414
+ 0 ,
415
+ nullptr ,
416
+ nullptr );
417
+
418
+ EXPECT_EQ (CL_SUCCESS, retVal);
419
+ EXPECT_FALSE (mockCmdQ->cpuDataTransferHandlerCalled );
420
+
421
+ buffer->getGraphicsAllocation ()->setAllocationType (GraphicsAllocation::AllocationType::BUFFER);
422
+
423
+ retVal = mockCmdQ->enqueueWriteBuffer (buffer.get (),
424
+ CL_FALSE,
425
+ 0 ,
426
+ MemoryConstants::cacheLineSize,
427
+ ptr,
428
+ 0 ,
429
+ nullptr ,
430
+ nullptr );
431
+
432
+ EXPECT_EQ (CL_SUCCESS, retVal);
433
+ EXPECT_TRUE (mockCmdQ->cpuDataTransferHandlerCalled );
434
+ }
435
+
394
436
HWTEST_F (EnqueueWriteBufferTypeTest, givenEnqueueWriteBufferCalledWhenLockedPtrInTransferPropertisIsNotAvailableThenItIsNotUnlocked) {
395
437
DebugManagerStateRestore dbgRestore;
396
438
DebugManager.flags .DoCpuCopyOnWriteBuffer .set (true );
0 commit comments