Add map allocation for images

Related-To: NEO-3097

Change-Id: I5bfd89fd597a8d55597ff7a2aa05b2abd278d5bd
Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2019-04-15 18:17:28 +02:00
committed by sys_ocldev
parent 18a9e164e1
commit 0c6823afd6
27 changed files with 149 additions and 63 deletions

View File

@@ -350,7 +350,7 @@ Image *Image::create(Context *context,
} else {
errcodeRet = cmdQ->enqueueWriteImage(image, CL_TRUE, &copyOrigin[0], &copyRegion[0],
hostPtrRowPitch, hostPtrSlicePitch,
hostPtr, 0, nullptr, nullptr);
hostPtr, nullptr, 0, nullptr, nullptr);
}
} else {
image->transferData(memory->getUnderlyingBuffer(), imgInfo.rowPitch, imgInfo.slicePitch,
@@ -945,7 +945,7 @@ cl_int Image::writeNV12Planes(const void *hostPtr, size_t hostPtrRowPitch) {
nullptr,
retVal));
retVal = cmdQ->enqueueWriteImage(imageYPlane.get(), CL_TRUE, origin, region, hostPtrRowPitch, 0, hostPtr, 0, nullptr, nullptr);
retVal = cmdQ->enqueueWriteImage(imageYPlane.get(), CL_TRUE, origin, region, hostPtrRowPitch, 0, hostPtr, nullptr, 0, nullptr, nullptr);
// UV Plane is two times smaller than Plane Y
region[0] = region[0] / 2;
@@ -967,7 +967,7 @@ cl_int Image::writeNV12Planes(const void *hostPtr, size_t hostPtrRowPitch) {
nullptr,
retVal));
retVal = cmdQ->enqueueWriteImage(imageUVPlane.get(), CL_TRUE, origin, region, hostPtrRowPitch, 0, hostPtr, 0, nullptr, nullptr);
retVal = cmdQ->enqueueWriteImage(imageUVPlane.get(), CL_TRUE, origin, region, hostPtrRowPitch, 0, hostPtr, nullptr, 0, nullptr, nullptr);
return retVal;
}

View File

@@ -314,19 +314,20 @@ void *MemObj::getBasePtrForMap() {
if (associatedMemObject) {
return associatedMemObject->getBasePtrForMap();
}
if (getMapAllocation()) {
return getMapAllocation()->getUnderlyingBuffer();
}
if (getFlags() & CL_MEM_USE_HOST_PTR) {
return getHostPtr();
} else {
TakeOwnershipWrapper<MemObj> memObjOwnership(*this);
auto memory = memoryManager->allocateSystemMemory(getSize(), MemoryConstants::pageSize);
setAllocatedMapPtr(memory);
AllocationProperties properties{false, getSize(), GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR};
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(properties, memory);
setMapAllocation(allocation);
return getAllocatedMapPtr();
if (getMapAllocation()) {
return getMapAllocation()->getUnderlyingBuffer();
} else {
auto memory = memoryManager->allocateSystemMemory(getSize(), MemoryConstants::pageSize);
setAllocatedMapPtr(memory);
AllocationProperties properties{false, getSize(), GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR};
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(properties, memory);
setMapAllocation(allocation);
return getAllocatedMapPtr();
}
}
}