@@ -320,6 +320,32 @@ TEST(Buffer, givenZeroFlagsNoSharedContextAndRenderCompressedBuffersDisabledWhen
320
320
EXPECT_EQ (GraphicsAllocation::AllocationType::BUFFER, type);
321
321
}
322
322
323
+ TEST (Buffer, givenClMemCopyHostPointerPassedToBufferCreateWhenAllocationIsNotInSystemMemoryPoolThenAllocationIsWrittenByEnqueueWriteBuffer) {
324
+ std::unique_ptr<MockDevice> device (MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr ));
325
+ ::testing::NiceMock<GMockMemoryManagerFailFirstAllocation> *memoryManager = new ::testing::NiceMock<GMockMemoryManagerFailFirstAllocation>;
326
+
327
+ device->injectMemoryManager (memoryManager);
328
+ MockContext ctx (device.get ());
329
+
330
+ auto allocateNonSystemGraphicsAllocation = [memoryManager](AllocationFlags flags, DevicesBitfield devicesBitfield, const void *hostPtr, size_t size, GraphicsAllocation::AllocationType type) -> GraphicsAllocation * {
331
+ auto allocation = memoryManager->allocateGraphicsMemory (size, MemoryConstants::pageSize, false , false );
332
+ reinterpret_cast <MemoryAllocation *>(allocation)->overrideMemoryPool (MemoryPool::SystemCpuInaccessible);
333
+ return allocation;
334
+ };
335
+
336
+ EXPECT_CALL (*memoryManager, allocateGraphicsMemoryInPreferredPool (::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_))
337
+ .WillOnce (::testing::Invoke (allocateNonSystemGraphicsAllocation));
338
+
339
+ cl_int retVal = 0 ;
340
+ cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR;
341
+ char memory[] = {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 };
342
+ auto taskCount = device->getCommandStreamReceiver ().peekLatestFlushedTaskCount ();
343
+
344
+ std::unique_ptr<Buffer> buffer (Buffer::create (&ctx, flags, sizeof (memory), memory, retVal));
345
+ ASSERT_NE (nullptr , buffer.get ());
346
+ auto taskCountSent = device->getCommandStreamReceiver ().peekLatestFlushedTaskCount ();
347
+ EXPECT_LT (taskCount, taskCountSent);
348
+ }
323
349
struct RenderCompressedBuffersTests : public ::testing::Test {
324
350
void SetUp () override {
325
351
localHwInfo = *platformDevices[0 ];
0 commit comments