Add dedicated map allocation

Related-To: NEO-2917

Change-Id: Ieeca40f5faf29433a5c464d2c3ca3b8910695a9b
Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2019-04-08 14:49:35 +02:00
committed by sys_ocldev
parent 91a64c8518
commit e201725dd5
45 changed files with 287 additions and 77 deletions

View File

@@ -27,6 +27,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteBuffer(
size_t offset,
size_t size,
const void *ptr,
GraphicsAllocation *mapAllocation,
cl_uint numEventsInWaitList,
const cl_event *eventWaitList,
cl_event *event) {
@@ -89,16 +90,25 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteBuffer(
HostPtrSurface hostPtrSurf(srcPtr, size, true);
MemObjSurface bufferSurf(buffer);
Surface *surfaces[] = {&bufferSurf, &hostPtrSurf};
GeneralSurface mapSurface;
Surface *surfaces[] = {&bufferSurf, nullptr};
if (size != 0) {
bool status = getCommandStreamReceiver().createAllocationForHostSurface(hostPtrSurf, false);
if (!status) {
return CL_OUT_OF_RESOURCES;
if (mapAllocation) {
surfaces[1] = &mapSurface;
mapSurface.setGraphicsAllocation(mapAllocation);
//get offset between base cpu ptr of map allocation and dst ptr
size_t srcOffset = ptrDiff(srcPtr, mapAllocation->getUnderlyingBuffer());
srcPtr = reinterpret_cast<void *>(mapAllocation->getGpuAddress() + srcOffset);
} else {
surfaces[1] = &hostPtrSurf;
if (size != 0) {
bool status = getCommandStreamReceiver().createAllocationForHostSurface(hostPtrSurf, false);
if (!status) {
return CL_OUT_OF_RESOURCES;
}
srcPtr = reinterpret_cast<void *>(hostPtrSurf.getAllocation()->getGpuAddress());
}
srcPtr = reinterpret_cast<void *>(hostPtrSurf.getAllocation()->getGpuAddress());
}
void *alignedSrcPtr = alignDown(srcPtr, 4);
size_t srcPtrOffset = ptrDiff(srcPtr, alignedSrcPtr);