Revert "Revert "Fix Read/WriteBuffer for unaligned offsets""

This reverts commit 71f6524197.

Change-Id: I4f31fb6fa14fb5e3b8d8bf0a1745429bcdacd5af
This commit is contained in:
Venevtsev, Igor
2018-12-20 03:03:42 -07:00
committed by sys_ocldev
parent 541ab5af50
commit f6757c02a4
6 changed files with 150 additions and 9 deletions

View File

@@ -89,8 +89,15 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteBuffer(
BuiltInOwnershipWrapper builtInLock(builder, this->context);
void *srcPtr = const_cast<void *>(ptr);
void *alignedSrcPtr = srcPtr;
size_t srcPtrOffset = 0;
HostPtrSurface hostPtrSurf(srcPtr, size, true);
if (!isAligned<4>(srcPtr)) {
alignedSrcPtr = alignDown(srcPtr, 4);
srcPtrOffset = ptrDiff(srcPtr, alignedSrcPtr);
}
HostPtrSurface hostPtrSurf(alignedSrcPtr, size + srcPtrOffset, true);
MemObjSurface bufferSurf(buffer);
Surface *surfaces[] = {&bufferSurf, &hostPtrSurf};
@@ -99,11 +106,13 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteBuffer(
if (!status) {
return CL_OUT_OF_RESOURCES;
}
srcPtr = reinterpret_cast<void *>(hostPtrSurf.getAllocation()->getGpuAddressToPatch());
hostPtrSurf.getAllocation()->allocationOffset = srcPtrOffset;
}
BuiltinDispatchInfoBuilder::BuiltinOpParams dc;
dc.srcPtr = srcPtr;
dc.srcPtr = alignedSrcPtr;
dc.srcOffset = {srcPtrOffset, 0, 0};
dc.dstMemObj = buffer;
dc.dstOffset = {offset, 0, 0};
dc.size = {size, 0, 0};