mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
Copy user buffers when not accepted by Kernel
When performing copy operations to or from buffers allocated by the user, it could happen that the buffer address is not accepted by kernel, even though the buffer is valid. In those ocassions, then allocate a new graphics allocation and copy the user buffer. Change-Id: I6b1b6f2ef5fea0acf32c868bc87eafe8746f9a79 Signed-off: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
38dc396336
commit
9f9bf38d64
@@ -483,12 +483,10 @@ bool CommandStreamReceiver::createAllocationForHostSurface(HostPtrSurface &surfa
|
||||
allocation.reset(memoryManager->allocateGraphicsMemoryWithProperties(properties, surface.getMemoryPointer()));
|
||||
if (allocation == nullptr && surface.peekIsPtrCopyAllowed()) {
|
||||
// Try with no host pointer allocation and copy
|
||||
AllocationProperties copyProperties{rootDeviceIndex, surface.getSurfaceSize(), GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, internalAllocationStorage->getDeviceBitfield()};
|
||||
copyProperties.alignment = MemoryConstants::pageSize;
|
||||
allocation.reset(memoryManager->allocateGraphicsMemoryWithProperties(copyProperties));
|
||||
if (allocation) {
|
||||
memcpy_s(allocation->getUnderlyingBuffer(), allocation->getUnderlyingBufferSize(), surface.getMemoryPointer(), surface.getSurfaceSize());
|
||||
}
|
||||
allocation.reset(memoryManager->allocateInternalGraphicsMemoryWithHostCopy(rootDeviceIndex,
|
||||
internalAllocationStorage->getDeviceBitfield(),
|
||||
surface.getMemoryPointer(),
|
||||
surface.getSurfaceSize()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user