Return a unique pointer for multiple calls to openIpcHandle

This to follow specification, which says:

zeMemOpenIpcHandle:

- Multiple calls to this function with the same IPC handle will return
unique pointers.

Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
Jaime Arteaga
2022-11-30 15:42:33 +00:00
committed by Compute-Runtime-Automation
parent af82557e55
commit 99655d34f9
42 changed files with 164 additions and 105 deletions

View File

@@ -45,7 +45,7 @@ class D3DBuffer : public D3DSharing<D3D> {
AllocationType::SHARED_BUFFER,
false, // isMultiStorageAllocation
context->getDeviceBitfieldForAllocation(context->getDevice(0)->getRootDeviceIndex())};
auto alloc = context->getMemoryManager()->createGraphicsAllocationFromSharedHandle(toOsHandle(sharedHandle), properties, true, false);
auto alloc = context->getMemoryManager()->createGraphicsAllocationFromSharedHandle(toOsHandle(sharedHandle), properties, true, false, true);
auto d3dBufferObj = new D3DBuffer<D3D>(context, d3dBuffer, bufferStaging, sharedResource);

View File

@@ -88,7 +88,7 @@ Image *D3DSurface::create(Context *context, cl_dx9_surface_info_khr *surfaceInfo
false, // isMultiStorageAllocation
context->getDeviceBitfieldForAllocation(rootDeviceIndex));
alloc = context->getMemoryManager()->createGraphicsAllocationFromSharedHandle(toOsHandle(surfaceInfo->shared_handle), allocProperties,
false, false);
false, false, true);
updateImgInfoAndDesc(alloc->getDefaultGmm(), imgInfo, imagePlane, 0u);
} else {
lockable = !(surfaceDesc.Usage & D3DResourceFlags::USAGE_RENDERTARGET) || imagePlane != ImagePlane::NO_PLANE;

View File

@@ -91,7 +91,7 @@ Image *D3DTexture<D3D>::create2d(Context *context, D3DTexture2d *d3dTexture, cl_
false, // isMultiStorageAllocation
context->getDeviceBitfieldForAllocation(rootDeviceIndex));
if (memoryManager->verifyHandle(toOsHandle(sharedHandle), rootDeviceIndex, false)) {
alloc = memoryManager->createGraphicsAllocationFromSharedHandle(toOsHandle(sharedHandle), allocProperties, false, false);
alloc = memoryManager->createGraphicsAllocationFromSharedHandle(toOsHandle(sharedHandle), allocProperties, false, false, true);
} else {
err.set(CL_INVALID_D3D11_RESOURCE_KHR);
return nullptr;
@@ -183,7 +183,7 @@ Image *D3DTexture<D3D>::create3d(Context *context, D3DTexture3d *d3dTexture, cl_
false, // isMultiStorageAllocation
context->getDeviceBitfieldForAllocation(rootDeviceIndex));
if (memoryManager->verifyHandle(toOsHandle(sharedHandle), rootDeviceIndex, false)) {
alloc = memoryManager->createGraphicsAllocationFromSharedHandle(toOsHandle(sharedHandle), allocProperties, false, false);
alloc = memoryManager->createGraphicsAllocationFromSharedHandle(toOsHandle(sharedHandle), allocProperties, false, false, true);
} else {
err.set(CL_INVALID_D3D11_RESOURCE_KHR);
return nullptr;

View File

@@ -151,7 +151,7 @@ GraphicsAllocation *GlBuffer::createGraphicsAllocation(Context *context, unsigne
context->getDeviceBitfieldForAllocation(context->getDevice(0)->getRootDeviceIndex())};
// couldn't find allocation for reuse - create new
graphicsAllocation =
context->getMemoryManager()->createGraphicsAllocationFromSharedHandle(bufferInfo.globalShareHandle, properties, true, false);
context->getMemoryManager()->createGraphicsAllocationFromSharedHandle(bufferInfo.globalShareHandle, properties, true, false, true);
}
if (!graphicsAllocation) {

View File

@@ -57,7 +57,7 @@ Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl
AllocationType::SHARED_IMAGE,
false, // isMultiStorageAllocation
context->getDeviceBitfieldForAllocation(context->getDevice(0)->getRootDeviceIndex()));
auto alloc = memoryManager->createGraphicsAllocationFromSharedHandle(texInfo.globalShareHandle, allocProperties, false, false);
auto alloc = memoryManager->createGraphicsAllocationFromSharedHandle(texInfo.globalShareHandle, allocProperties, false, false, true);
if (alloc == nullptr) {
errorCode.set(CL_INVALID_GL_OBJECT);
@@ -126,7 +126,7 @@ Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl
GraphicsAllocation *mcsAlloc = nullptr;
if (texInfo.globalShareHandleMCS) {
AllocationProperties allocProperties(context->getDevice(0)->getRootDeviceIndex(), 0, AllocationType::MCS, context->getDeviceBitfieldForAllocation(context->getDevice(0)->getRootDeviceIndex()));
mcsAlloc = memoryManager->createGraphicsAllocationFromSharedHandle(texInfo.globalShareHandleMCS, allocProperties, false, false);
mcsAlloc = memoryManager->createGraphicsAllocationFromSharedHandle(texInfo.globalShareHandleMCS, allocProperties, false, false, true);
if (texInfo.pGmmResInfoMCS) {
DEBUG_BREAK_IF(mcsAlloc->getDefaultGmm() != nullptr);
mcsAlloc->setDefaultGmm(new Gmm(gmmHelper, texInfo.pGmmResInfoMCS));

View File

@@ -46,7 +46,7 @@ GraphicsAllocation *UnifiedSharing::createGraphicsAllocation(Context *context, U
allocationType,
false, // isMultiStorageAllocation
context->getDeviceBitfieldForAllocation(context->getDevice(0)->getRootDeviceIndex())};
return memoryManager->createGraphicsAllocationFromSharedHandle(toOsHandle(description.handle), properties, false, false);
return memoryManager->createGraphicsAllocationFromSharedHandle(toOsHandle(description.handle), properties, false, false, true);
}
default:
return nullptr;

View File

@@ -191,7 +191,7 @@ Image *VASurface::createSharedVaSurface(Context *context, VASharingFunctions *sh
sharedSurfaceInfo.imgInfo, AllocationType::SHARED_IMAGE,
context->getDeviceBitfieldForAllocation(context->getDevice(0)->getRootDeviceIndex()));
auto alloc = memoryManager->createGraphicsAllocationFromSharedHandle(sharedSurfaceInfo.sharedHandle, properties, false, false);
auto alloc = memoryManager->createGraphicsAllocationFromSharedHandle(sharedSurfaceInfo.sharedHandle, properties, false, false, true);
memoryManager->closeSharedHandle(alloc);