mirror of
https://github.com/intel/compute-runtime.git
synced 2025-11-10 05:49:51 +08:00
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:
committed by
sys_ocldev
parent
6224db771a
commit
d957349f76
@@ -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);
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user