Pass MultiGraphicsAllocation in Buffer 3/3

Related-To: NEO-4672
Change-Id: Ic6b696b1df798fcdadcf17f9e22f1c0999361e47
Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
Krzysztof Gibala
2020-07-15 12:53:15 +02:00
committed by sys_ocldev
parent 6224db771a
commit d957349f76
6 changed files with 19 additions and 10 deletions

View File

@@ -374,14 +374,11 @@ Buffer *Buffer::create(Context *context,
} }
Buffer *Buffer::createSharedBuffer(Context *context, cl_mem_flags flags, SharingHandler *sharingHandler, Buffer *Buffer::createSharedBuffer(Context *context, cl_mem_flags flags, SharingHandler *sharingHandler,
GraphicsAllocation *graphicsAllocation) { MultiGraphicsAllocation multiGraphicsAllocation) {
auto rootDeviceIndex = context->getDevice(0)->getRootDeviceIndex(); auto rootDeviceIndex = context->getDevice(0)->getRootDeviceIndex();
auto multiGraphicsAllocation = MultiGraphicsAllocation(rootDeviceIndex);
multiGraphicsAllocation.addAllocation(graphicsAllocation);
auto sharedBuffer = createBufferHw( auto sharedBuffer = createBufferHw(
context, MemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context->getDevice(0)->getDevice()), context, MemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context->getDevice(0)->getDevice()),
flags, 0, graphicsAllocation->getUnderlyingBufferSize(), nullptr, nullptr, multiGraphicsAllocation, flags, 0, multiGraphicsAllocation.getGraphicsAllocation(rootDeviceIndex)->getUnderlyingBufferSize(), nullptr, nullptr, multiGraphicsAllocation,
false, false, false); false, false, false);
sharedBuffer->setSharingHandler(sharingHandler); sharedBuffer->setSharingHandler(sharingHandler);

View File

@@ -87,7 +87,7 @@ class Buffer : public MemObj {
static Buffer *createSharedBuffer(Context *context, static Buffer *createSharedBuffer(Context *context,
cl_mem_flags flags, cl_mem_flags flags,
SharingHandler *sharingHandler, SharingHandler *sharingHandler,
GraphicsAllocation *graphicsAllocation); MultiGraphicsAllocation multiGraphicsAllocation);
static Buffer *createBufferHw(Context *context, static Buffer *createBufferHw(Context *context,
MemoryProperties memoryProperties, MemoryProperties memoryProperties,

View File

@@ -49,7 +49,11 @@ class D3DBuffer : public D3DSharing<D3D> {
auto d3dBufferObj = new D3DBuffer<D3D>(context, d3dBuffer, bufferStaging, sharedResource); auto d3dBufferObj = new D3DBuffer<D3D>(context, d3dBuffer, bufferStaging, sharedResource);
return Buffer::createSharedBuffer(context, flags, d3dBufferObj, alloc); auto rootDeviceIndex = alloc->getRootDeviceIndex();
auto multiGraphicsAllocation = MultiGraphicsAllocation(rootDeviceIndex);
multiGraphicsAllocation.addAllocation(alloc);
return Buffer::createSharedBuffer(context, flags, d3dBufferObj, multiGraphicsAllocation);
} }
~D3DBuffer() override = default; ~D3DBuffer() override = default;

View File

@@ -38,7 +38,11 @@ Buffer *GlBuffer::createSharedGlBuffer(Context *context, cl_mem_flags flags, uns
} }
auto glHandler = new GlBuffer(sharingFunctions, bufferId); auto glHandler = new GlBuffer(sharingFunctions, bufferId);
return Buffer::createSharedBuffer(context, flags, glHandler, graphicsAllocation); auto rootDeviceIndex = graphicsAllocation->getRootDeviceIndex();
auto multiGraphicsAllocation = MultiGraphicsAllocation(rootDeviceIndex);
multiGraphicsAllocation.addAllocation(graphicsAllocation);
return Buffer::createSharedBuffer(context, flags, glHandler, multiGraphicsAllocation);
} }
void GlBuffer::synchronizeObject(UpdateData &updateData) { void GlBuffer::synchronizeObject(UpdateData &updateData) {

View File

@@ -29,5 +29,9 @@ Buffer *UnifiedBuffer::createSharedUnifiedBuffer(Context *context, cl_mem_flags
UnifiedSharingFunctions *sharingFunctions = context->getSharing<UnifiedSharingFunctions>(); UnifiedSharingFunctions *sharingFunctions = context->getSharing<UnifiedSharingFunctions>();
auto sharingHandler = new UnifiedBuffer(sharingFunctions, extMem.type); auto sharingHandler = new UnifiedBuffer(sharingFunctions, extMem.type);
return Buffer::createSharedBuffer(context, flags, sharingHandler, graphicsAllocation); auto rootDeviceIndex = graphicsAllocation->getRootDeviceIndex();
auto multiGraphicsAllocation = MultiGraphicsAllocation(rootDeviceIndex);
multiGraphicsAllocation.addAllocation(graphicsAllocation);
return Buffer::createSharedBuffer(context, flags, sharingHandler, multiGraphicsAllocation);
} }

View File

@@ -2466,7 +2466,7 @@ TEST(SharedBuffersTest, whenBuffersIsCreatedWithSharingHandlerThenItIsSharedBuff
auto memoryManager = context.getDevice(0)->getMemoryManager(); auto memoryManager = context.getDevice(0)->getMemoryManager();
auto handler = new SharingHandler(); auto handler = new SharingHandler();
auto graphicsAlloaction = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{context.getDevice(0)->getRootDeviceIndex(), MemoryConstants::pageSize}); auto graphicsAlloaction = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{context.getDevice(0)->getRootDeviceIndex(), MemoryConstants::pageSize});
auto buffer = Buffer::createSharedBuffer(&context, CL_MEM_READ_ONLY, handler, graphicsAlloaction); auto buffer = Buffer::createSharedBuffer(&context, CL_MEM_READ_ONLY, handler, GraphicsAllocationHelper::toMultiGraphicsAllocation(graphicsAlloaction));
ASSERT_NE(nullptr, buffer); ASSERT_NE(nullptr, buffer);
EXPECT_EQ(handler, buffer->peekSharingHandler()); EXPECT_EQ(handler, buffer->peekSharingHandler());
buffer->release(); buffer->release();