Remove OCL object from MemoryProperties 10/n

Add cl_mem_flags, cl_mem_flags_intel and wire it in mem_obj.
Refactor:
- validateMemoryPropertiesForImage
- validateExtraMemoryProperties

Related-To: NEO-3132
Change-Id: I90fac5fc00e24fc67346109a1fe6f269ef51e1e0
Signed-off-by: Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
Gibala
2019-09-24 16:05:17 +02:00
committed by sys_ocldev
parent fc652b2822
commit 2f9bfc7748
38 changed files with 233 additions and 158 deletions

View File

@@ -659,7 +659,7 @@ cl_mem CL_API_CALL clCreateSubBuffer(cl_mem buffer,
break; break;
} }
cl_mem_flags parentFlags = parentBuffer->getFlags(); cl_mem_flags parentFlags = parentBuffer->getMemoryPropertiesFlags();
if (parentBuffer->isSubBuffer() == true) { if (parentBuffer->isSubBuffer() == true) {
retVal = CL_INVALID_MEM_OBJECT; retVal = CL_INVALID_MEM_OBJECT;
@@ -765,7 +765,7 @@ cl_mem CL_API_CALL clCreateImage(cl_context context,
if (retVal == CL_SUCCESS) { if (retVal == CL_SUCCESS) {
MemoryProperties propertiesStruct(flags); MemoryProperties propertiesStruct(flags);
if (isFieldValid(propertiesStruct.flags, MemObjHelper::validFlagsForImage)) { if (isFieldValid(propertiesStruct.flags, MemObjHelper::validFlagsForImage)) {
image = Image::validateAndCreateImage(pContext, propertiesStruct, imageFormat, imageDesc, hostPtr, retVal); image = Image::validateAndCreateImage(pContext, propertiesStruct, flags, 0, imageFormat, imageDesc, hostPtr, retVal);
} else { } else {
retVal = CL_INVALID_VALUE; retVal = CL_INVALID_VALUE;
} }
@@ -804,7 +804,7 @@ cl_mem CL_API_CALL clCreateImageWithPropertiesINTEL(cl_context context,
if (retVal == CL_SUCCESS) { if (retVal == CL_SUCCESS) {
if (MemoryPropertiesParser::parseMemoryProperties(properties, propertiesStruct, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::IMAGE)) { if (MemoryPropertiesParser::parseMemoryProperties(properties, propertiesStruct, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::IMAGE)) {
image = Image::validateAndCreateImage(pContext, propertiesStruct, imageFormat, imageDesc, hostPtr, retVal); image = Image::validateAndCreateImage(pContext, propertiesStruct, propertiesStruct.flags, propertiesStruct.flags_intel, imageFormat, imageDesc, hostPtr, retVal);
} else { } else {
retVal = CL_INVALID_VALUE; retVal = CL_INVALID_VALUE;
} }
@@ -851,7 +851,7 @@ cl_mem CL_API_CALL clCreateImage2D(cl_context context,
if (retVal == CL_SUCCESS) { if (retVal == CL_SUCCESS) {
MemoryProperties propertiesStruct(flags); MemoryProperties propertiesStruct(flags);
image2D = Image::validateAndCreateImage(pContext, propertiesStruct, imageFormat, &imageDesc, hostPtr, retVal); image2D = Image::validateAndCreateImage(pContext, propertiesStruct, flags, 0, imageFormat, &imageDesc, hostPtr, retVal);
} }
ErrorCodeHelper err(errcodeRet, retVal); ErrorCodeHelper err(errcodeRet, retVal);
@@ -902,7 +902,7 @@ cl_mem CL_API_CALL clCreateImage3D(cl_context context,
if (retVal == CL_SUCCESS) { if (retVal == CL_SUCCESS) {
MemoryProperties propertiesStruct(flags); MemoryProperties propertiesStruct(flags);
image3D = Image::validateAndCreateImage(pContext, propertiesStruct, imageFormat, &imageDesc, hostPtr, retVal); image3D = Image::validateAndCreateImage(pContext, propertiesStruct, flags, 0, imageFormat, &imageDesc, hostPtr, retVal);
} }
ErrorCodeHelper err(errcodeRet, retVal); ErrorCodeHelper err(errcodeRet, retVal);

View File

@@ -341,7 +341,7 @@ cl_int CommandQueue::enqueueWriteMemObjForUnmap(MemObj *memObj, void *mappedPtr,
image->getHostPtrRowPitch(), image->getHostPtrSlicePitch(), mappedPtr, memObj->getMapAllocation(), image->getHostPtrRowPitch(), image->getHostPtrSlicePitch(), mappedPtr, memObj->getMapAllocation(),
eventsRequest.numEventsInWaitList, eventsRequest.eventWaitList, eventsRequest.outEvent); eventsRequest.numEventsInWaitList, eventsRequest.eventWaitList, eventsRequest.outEvent);
bool mustCallFinish = true; bool mustCallFinish = true;
if (!(image->getFlags() & CL_MEM_USE_HOST_PTR)) { if (!(image->getMemoryPropertiesFlags() & CL_MEM_USE_HOST_PTR)) {
mustCallFinish = true; mustCallFinish = true;
} else { } else {
mustCallFinish = (CommandQueue::getTaskLevelFromWaitList(this->taskLevel, eventsRequest.numEventsInWaitList, eventsRequest.eventWaitList) != Event::eventNotReady); mustCallFinish = (CommandQueue::getTaskLevelFromWaitList(this->taskLevel, eventsRequest.numEventsInWaitList, eventsRequest.eventWaitList) != Event::eventNotReady);

View File

@@ -54,7 +54,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueFillBuffer(
BuiltInOwnershipWrapper builtInLock(builder, this->context); BuiltInOwnershipWrapper builtInLock(builder, this->context);
BuiltinOpParams dc; BuiltinOpParams dc;
MemObj patternMemObj(this->context, 0, 0, alignUp(patternSize, 4), patternAllocation->getUnderlyingBuffer(), MemObj patternMemObj(this->context, 0, 0, 0, 0, alignUp(patternSize, 4), patternAllocation->getUnderlyingBuffer(),
patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true); patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true);
dc.srcMemObj = &patternMemObj; dc.srcMemObj = &patternMemObj;
dc.dstMemObj = buffer; dc.dstMemObj = buffer;

View File

@@ -469,7 +469,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueSVMMemFill(void *svmPtr,
BuiltInOwnershipWrapper builtInLock(builder, this->context); BuiltInOwnershipWrapper builtInLock(builder, this->context);
BuiltinOpParams operationParams; BuiltinOpParams operationParams;
MemObj patternMemObj(this->context, 0, 0, alignUp(patternSize, 4), patternAllocation->getUnderlyingBuffer(), MemObj patternMemObj(this->context, 0, 0, 0, 0, alignUp(patternSize, 4), patternAllocation->getUnderlyingBuffer(),
patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true); patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true);
void *alignedDstPtr = alignDown(svmPtr, 4); void *alignedDstPtr = alignDown(svmPtr, 4);

View File

@@ -2190,7 +2190,7 @@ cl_int Kernel::checkCorrectImageAccessQualifier(cl_uint argIndex,
WithCastToInternal(mem, &pMemObj); WithCastToInternal(mem, &pMemObj);
if (pMemObj) { if (pMemObj) {
cl_kernel_arg_access_qualifier accessQualifier = getKernelInfo().kernelArgInfo[argIndex].accessQualifier; cl_kernel_arg_access_qualifier accessQualifier = getKernelInfo().kernelArgInfo[argIndex].accessQualifier;
cl_mem_flags flags = pMemObj->getFlags(); cl_mem_flags flags = pMemObj->getMemoryPropertiesFlags();
if ((accessQualifier == CL_KERNEL_ARG_ACCESS_READ_ONLY && ((flags | CL_MEM_WRITE_ONLY) == flags)) || if ((accessQualifier == CL_KERNEL_ARG_ACCESS_READ_ONLY && ((flags | CL_MEM_WRITE_ONLY) == flags)) ||
(accessQualifier == CL_KERNEL_ARG_ACCESS_WRITE_ONLY && ((flags | CL_MEM_READ_ONLY) == flags))) { (accessQualifier == CL_KERNEL_ARG_ACCESS_WRITE_ONLY && ((flags | CL_MEM_READ_ONLY) == flags))) {
return CL_INVALID_ARG_VALUE; return CL_INVALID_ARG_VALUE;

View File

@@ -33,6 +33,8 @@ BufferFuncs bufferFactory[IGFX_MAX_CORE] = {};
Buffer::Buffer(Context *context, Buffer::Buffer(Context *context,
MemoryProperties properties, MemoryProperties properties,
cl_mem_flags flags,
cl_mem_flags_intel flagsIntel,
size_t size, size_t size,
void *memoryStorage, void *memoryStorage,
void *hostPtr, void *hostPtr,
@@ -43,6 +45,8 @@ Buffer::Buffer(Context *context,
: MemObj(context, : MemObj(context,
CL_MEM_OBJECT_BUFFER, CL_MEM_OBJECT_BUFFER,
properties, properties,
flags,
flagsIntel,
size, size,
memoryStorage, memoryStorage,
hostPtr, hostPtr,
@@ -54,7 +58,7 @@ Buffer::Buffer(Context *context,
setHostPtrMinSize(size); setHostPtrMinSize(size);
} }
Buffer::Buffer() : MemObj(nullptr, CL_MEM_OBJECT_BUFFER, 0, 0, nullptr, nullptr, nullptr, false, false, false) { Buffer::Buffer() : MemObj(nullptr, CL_MEM_OBJECT_BUFFER, 0, 0, 0, 0, nullptr, nullptr, nullptr, false, false, false) {
} }
Buffer::~Buffer() = default; Buffer::~Buffer() = default;
@@ -92,7 +96,7 @@ void Buffer::validateInputAndCreateBuffer(cl_context &context,
return; return;
} }
if (!MemObjHelper::validateMemoryPropertiesForBuffer(properties, flags, flagsIntel)) { if (!MemObjHelper::validateMemoryPropertiesForBuffer(MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties), flags, flagsIntel)) {
retVal = CL_INVALID_VALUE; retVal = CL_INVALID_VALUE;
return; return;
} }
@@ -401,7 +405,7 @@ Buffer *Buffer::createSubBuffer(cl_mem_flags flags,
const cl_buffer_region *region, const cl_buffer_region *region,
cl_int &errcodeRet) { cl_int &errcodeRet) {
DEBUG_BREAK_IF(nullptr == createFunction); DEBUG_BREAK_IF(nullptr == createFunction);
auto buffer = createFunction(this->context, flags, region->size, auto buffer = createFunction(this->context, flags, flags, 0, region->size,
ptrOffset(this->memoryStorage, region->origin), ptrOffset(this->memoryStorage, region->origin),
this->hostPtr ? ptrOffset(this->hostPtr, region->origin) : nullptr, this->hostPtr ? ptrOffset(this->hostPtr, region->origin) : nullptr,
this->graphicsAllocation, this->graphicsAllocation,
@@ -506,7 +510,7 @@ Buffer *Buffer::createBufferHw(Context *context,
auto funcCreate = bufferFactory[hwInfo.platform.eRenderCoreFamily].createBufferFunction; auto funcCreate = bufferFactory[hwInfo.platform.eRenderCoreFamily].createBufferFunction;
DEBUG_BREAK_IF(nullptr == funcCreate); DEBUG_BREAK_IF(nullptr == funcCreate);
auto pBuffer = funcCreate(context, properties, size, memoryStorage, hostPtr, gfxAllocation, auto pBuffer = funcCreate(context, properties, properties.flags, properties.flags_intel, size, memoryStorage, hostPtr, gfxAllocation,
zeroCopy, isHostPtrSVM, isImageRedescribed); zeroCopy, isHostPtrSVM, isImageRedescribed);
DEBUG_BREAK_IF(nullptr == pBuffer); DEBUG_BREAK_IF(nullptr == pBuffer);
if (pBuffer) { if (pBuffer) {
@@ -517,6 +521,7 @@ Buffer *Buffer::createBufferHw(Context *context,
Buffer *Buffer::createBufferHwFromDevice(const Device *device, Buffer *Buffer::createBufferHwFromDevice(const Device *device,
cl_mem_flags flags, cl_mem_flags flags,
cl_mem_flags_intel flagsIntel,
size_t size, size_t size,
void *memoryStorage, void *memoryStorage,
void *hostPtr, void *hostPtr,
@@ -529,7 +534,7 @@ Buffer *Buffer::createBufferHwFromDevice(const Device *device,
auto funcCreate = bufferFactory[hwInfo.platform.eRenderCoreFamily].createBufferFunction; auto funcCreate = bufferFactory[hwInfo.platform.eRenderCoreFamily].createBufferFunction;
DEBUG_BREAK_IF(nullptr == funcCreate); DEBUG_BREAK_IF(nullptr == funcCreate);
auto pBuffer = funcCreate(nullptr, flags, size, memoryStorage, hostPtr, gfxAllocation, auto pBuffer = funcCreate(nullptr, flags, flags, flagsIntel, size, memoryStorage, hostPtr, gfxAllocation,
zeroCopy, isHostPtrSVM, isImageRedescribed); zeroCopy, isHostPtrSVM, isImageRedescribed);
pBuffer->executionEnvironment = device->getExecutionEnvironment(); pBuffer->executionEnvironment = device->getExecutionEnvironment();
return pBuffer; return pBuffer;
@@ -547,7 +552,7 @@ uint32_t Buffer::getMocsValue(bool disableL3Cache, bool isReadOnlyArgument) cons
} }
bufferAddress += this->offset; bufferAddress += this->offset;
bool readOnlyMemObj = isValueSet(getFlags(), CL_MEM_READ_ONLY) || isReadOnlyArgument; bool readOnlyMemObj = isValueSet(getMemoryPropertiesFlags(), CL_MEM_READ_ONLY) || isReadOnlyArgument;
bool alignedMemObj = isAligned<MemoryConstants::cacheLineSize>(bufferAddress) && bool alignedMemObj = isAligned<MemoryConstants::cacheLineSize>(bufferAddress) &&
isAligned<MemoryConstants::cacheLineSize>(bufferSize); isAligned<MemoryConstants::cacheLineSize>(bufferSize);
@@ -564,8 +569,9 @@ void Buffer::setSurfaceState(const Device *device,
size_t svmSize, size_t svmSize,
void *svmPtr, void *svmPtr,
GraphicsAllocation *gfxAlloc, GraphicsAllocation *gfxAlloc,
cl_mem_flags flags) { cl_mem_flags flags,
auto buffer = Buffer::createBufferHwFromDevice(device, flags, svmSize, svmPtr, svmPtr, gfxAlloc, true, false, false); cl_mem_flags_intel flagsIntel) {
auto buffer = Buffer::createBufferHwFromDevice(device, flags, flagsIntel, svmSize, svmPtr, svmPtr, gfxAlloc, true, false, false);
buffer->setArgStateful(surfaceState, false, false, false, false); buffer->setArgStateful(surfaceState, false, false, false, false);
buffer->graphicsAllocation = nullptr; buffer->graphicsAllocation = nullptr;
delete buffer; delete buffer;

View File

@@ -23,6 +23,8 @@ struct MemoryProperties;
typedef Buffer *(*BufferCreatFunc)(Context *context, typedef Buffer *(*BufferCreatFunc)(Context *context,
MemoryProperties properties, MemoryProperties properties,
cl_mem_flags flags,
cl_mem_flags_intel flagsIntel,
size_t size, size_t size,
void *memoryStorage, void *memoryStorage,
void *hostPtr, void *hostPtr,
@@ -84,6 +86,7 @@ class Buffer : public MemObj {
static Buffer *createBufferHwFromDevice(const Device *device, static Buffer *createBufferHwFromDevice(const Device *device,
cl_mem_flags flags, cl_mem_flags flags,
cl_mem_flags_intel flagsIntel,
size_t size, size_t size,
void *memoryStorage, void *memoryStorage,
void *hostPtr, void *hostPtr,
@@ -101,7 +104,8 @@ class Buffer : public MemObj {
size_t svmSize, size_t svmSize,
void *svmPtr, void *svmPtr,
GraphicsAllocation *gfxAlloc = nullptr, GraphicsAllocation *gfxAlloc = nullptr,
cl_mem_flags flags = 0); cl_mem_flags flags = 0,
cl_mem_flags_intel flagsIntel = 0);
static void provideCompressionHint(GraphicsAllocation::AllocationType allocationType, static void provideCompressionHint(GraphicsAllocation::AllocationType allocationType,
Context *context, Context *context,
@@ -132,6 +136,8 @@ class Buffer : public MemObj {
protected: protected:
Buffer(Context *context, Buffer(Context *context,
MemoryProperties properties, MemoryProperties properties,
cl_mem_flags flags,
cl_mem_flags_intel flagsIntel,
size_t size, size_t size,
void *memoryStorage, void *memoryStorage,
void *hostPtr, void *hostPtr,
@@ -162,6 +168,8 @@ class BufferHw : public Buffer {
public: public:
BufferHw(Context *context, BufferHw(Context *context,
MemoryProperties properties, MemoryProperties properties,
cl_mem_flags flags,
cl_mem_flags_intel flagsIntel,
size_t size, size_t size,
void *memoryStorage, void *memoryStorage,
void *hostPtr, void *hostPtr,
@@ -169,7 +177,7 @@ class BufferHw : public Buffer {
bool zeroCopy, bool zeroCopy,
bool isHostPtrSVM, bool isHostPtrSVM,
bool isObjectRedescribed) bool isObjectRedescribed)
: Buffer(context, properties, size, memoryStorage, hostPtr, gfxAllocation, : Buffer(context, properties, flags, flagsIntel, size, memoryStorage, hostPtr, gfxAllocation,
zeroCopy, isHostPtrSVM, isObjectRedescribed) {} zeroCopy, isHostPtrSVM, isObjectRedescribed) {}
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnlyArgument) override; void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnlyArgument) override;
@@ -177,6 +185,8 @@ class BufferHw : public Buffer {
static Buffer *create(Context *context, static Buffer *create(Context *context,
MemoryProperties properties, MemoryProperties properties,
cl_mem_flags flags,
cl_mem_flags_intel flagsIntel,
size_t size, size_t size,
void *memoryStorage, void *memoryStorage,
void *hostPtr, void *hostPtr,
@@ -186,6 +196,8 @@ class BufferHw : public Buffer {
bool isObjectRedescribed) { bool isObjectRedescribed) {
auto buffer = new BufferHw<GfxFamily>(context, auto buffer = new BufferHw<GfxFamily>(context,
properties, properties,
flags,
flagsIntel,
size, size,
memoryStorage, memoryStorage,
hostPtr, hostPtr,

View File

@@ -39,6 +39,8 @@ ImageFuncs imageFactory[IGFX_MAX_CORE] = {};
Image::Image(Context *context, Image::Image(Context *context,
const MemoryProperties &properties, const MemoryProperties &properties,
cl_mem_flags flags,
cl_mem_flags_intel flagsIntel,
size_t size, size_t size,
void *hostPtr, void *hostPtr,
cl_image_format imageFormat, cl_image_format imageFormat,
@@ -53,6 +55,8 @@ Image::Image(Context *context,
: MemObj(context, : MemObj(context,
imageDesc.image_type, imageDesc.image_type,
properties, properties,
flags,
flagsIntel,
size, size,
graphicsAllocation->getUnderlyingBuffer(), graphicsAllocation->getUnderlyingBuffer(),
hostPtr, hostPtr,
@@ -408,7 +412,7 @@ Image *Image::createImageHw(Context *context, const MemoryProperties &properties
auto funcCreate = imageFactory[hwInfo.platform.eRenderCoreFamily].createImageFunction; auto funcCreate = imageFactory[hwInfo.platform.eRenderCoreFamily].createImageFunction;
DEBUG_BREAK_IF(nullptr == funcCreate); DEBUG_BREAK_IF(nullptr == funcCreate);
auto image = funcCreate(context, properties, size, hostPtr, imageFormat, imageDesc, auto image = funcCreate(context, properties, properties.flags, properties.flags_intel, size, hostPtr, imageFormat, imageDesc,
zeroCopy, graphicsAllocation, isObjectRedescribed, baseMipLevel, mipCount, surfaceFormatInfo, nullptr); zeroCopy, graphicsAllocation, isObjectRedescribed, baseMipLevel, mipCount, surfaceFormatInfo, nullptr);
DEBUG_BREAK_IF(nullptr == image); DEBUG_BREAK_IF(nullptr == image);
image->createFunction = funcCreate; image->createFunction = funcCreate;
@@ -464,7 +468,7 @@ cl_int Image::validate(Context *context,
const auto minimumBufferSize = imageDesc->image_height * rowSize; const auto minimumBufferSize = imageDesc->image_height * rowSize;
if ((imageDesc->image_row_pitch % (*pitchAlignment)) || if ((imageDesc->image_row_pitch % (*pitchAlignment)) ||
((parentBuffer->getFlags() & CL_MEM_USE_HOST_PTR) && (reinterpret_cast<uint64_t>(parentBuffer->getHostPtr()) % (*baseAddressAlignment))) || ((parentBuffer->getMemoryPropertiesFlags() & CL_MEM_USE_HOST_PTR) && (reinterpret_cast<uint64_t>(parentBuffer->getHostPtr()) % (*baseAddressAlignment))) ||
(minimumBufferSize > parentBuffer->getSize())) { (minimumBufferSize > parentBuffer->getSize())) {
return CL_INVALID_IMAGE_FORMAT_DESCRIPTOR; return CL_INVALID_IMAGE_FORMAT_DESCRIPTOR;
} else if (memoryProperties.flags.useHostPtr || memoryProperties.flags.copyHostPtr) { } else if (memoryProperties.flags.useHostPtr || memoryProperties.flags.copyHostPtr) {
@@ -858,6 +862,8 @@ Image *Image::redescribeFillImage() {
DEBUG_BREAK_IF(nullptr == createFunction); DEBUG_BREAK_IF(nullptr == createFunction);
auto image = createFunction(context, auto image = createFunction(context,
properties.flags | CL_MEM_USE_HOST_PTR, properties.flags | CL_MEM_USE_HOST_PTR,
properties.flags | CL_MEM_USE_HOST_PTR,
properties.flags_intel,
this->getSize(), this->getSize(),
this->getCpuAddress(), this->getCpuAddress(),
imageFormatNew, imageFormatNew,
@@ -905,6 +911,8 @@ Image *Image::redescribe() {
DEBUG_BREAK_IF(nullptr == createFunction); DEBUG_BREAK_IF(nullptr == createFunction);
auto image = createFunction(context, auto image = createFunction(context,
properties.flags | CL_MEM_USE_HOST_PTR, properties.flags | CL_MEM_USE_HOST_PTR,
properties.flags | CL_MEM_USE_HOST_PTR,
properties.flags_intel,
this->getSize(), this->getSize(),
this->getCpuAddress(), this->getCpuAddress(),
imageFormatNew, imageFormatNew,
@@ -1027,12 +1035,14 @@ bool Image::isDepthFormat(const cl_image_format &imageFormat) {
Image *Image::validateAndCreateImage(Context *context, Image *Image::validateAndCreateImage(Context *context,
const MemoryProperties &properties, const MemoryProperties &properties,
cl_mem_flags flags,
cl_mem_flags_intel flagsIntel,
const cl_image_format *imageFormat, const cl_image_format *imageFormat,
const cl_image_desc *imageDesc, const cl_image_desc *imageDesc,
const void *hostPtr, const void *hostPtr,
cl_int &errcodeRet) { cl_int &errcodeRet) {
if (!MemObjHelper::validateMemoryPropertiesForImage(properties, imageDesc->mem_object)) { if (!MemObjHelper::validateMemoryPropertiesForImage(MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties), flags, flagsIntel, imageDesc->mem_object)) {
errcodeRet = CL_INVALID_VALUE; errcodeRet = CL_INVALID_VALUE;
return nullptr; return nullptr;
} }

View File

@@ -26,6 +26,8 @@ struct SurfaceOffsets {
typedef Image *(*ImageCreatFunc)(Context *context, typedef Image *(*ImageCreatFunc)(Context *context,
const MemoryProperties &properties, const MemoryProperties &properties,
uint64_t flags,
uint64_t flagsIntel,
size_t size, size_t size,
void *hostPtr, void *hostPtr,
const cl_image_format &imageFormat, const cl_image_format &imageFormat,
@@ -58,6 +60,8 @@ class Image : public MemObj {
static Image *validateAndCreateImage(Context *context, static Image *validateAndCreateImage(Context *context,
const MemoryProperties &properties, const MemoryProperties &properties,
cl_mem_flags flags,
cl_mem_flags_intel flagsIntel,
const cl_image_format *imageFormat, const cl_image_format *imageFormat,
const cl_image_desc *imageDesc, const cl_image_desc *imageDesc,
const void *hostPtr, const void *hostPtr,
@@ -180,6 +184,8 @@ class Image : public MemObj {
protected: protected:
Image(Context *context, Image(Context *context,
const MemoryProperties &properties, const MemoryProperties &properties,
cl_mem_flags flags,
cl_mem_flags_intel flags_intel,
size_t size, size_t size,
void *hostPtr, void *hostPtr,
cl_image_format imageFormat, cl_image_format imageFormat,
@@ -234,6 +240,8 @@ class ImageHw : public Image {
public: public:
ImageHw(Context *context, ImageHw(Context *context,
const MemoryProperties &properties, const MemoryProperties &properties,
cl_mem_flags flags,
cl_mem_flags_intel flagsIntel,
size_t size, size_t size,
void *hostPtr, void *hostPtr,
const cl_image_format &imageFormat, const cl_image_format &imageFormat,
@@ -245,7 +253,7 @@ class ImageHw : public Image {
uint32_t mipCount, uint32_t mipCount,
const SurfaceFormatInfo &surfaceFormatInfo, const SurfaceFormatInfo &surfaceFormatInfo,
const SurfaceOffsets *surfaceOffsets = nullptr) const SurfaceOffsets *surfaceOffsets = nullptr)
: Image(context, properties, size, hostPtr, imageFormat, imageDesc, : Image(context, properties, flags, flagsIntel, size, hostPtr, imageFormat, imageDesc,
zeroCopy, graphicsAllocation, isObjectRedescribed, baseMipLevel, mipCount, surfaceFormatInfo, surfaceOffsets) { zeroCopy, graphicsAllocation, isObjectRedescribed, baseMipLevel, mipCount, surfaceFormatInfo, surfaceOffsets) {
if (getImageDesc().image_type == CL_MEM_OBJECT_IMAGE1D || if (getImageDesc().image_type == CL_MEM_OBJECT_IMAGE1D ||
getImageDesc().image_type == CL_MEM_OBJECT_IMAGE1D_BUFFER || getImageDesc().image_type == CL_MEM_OBJECT_IMAGE1D_BUFFER ||
@@ -287,6 +295,8 @@ class ImageHw : public Image {
void transformImage3dTo2dArray(void *memory) override; void transformImage3dTo2dArray(void *memory) override;
static Image *create(Context *context, static Image *create(Context *context,
const MemoryProperties &properties, const MemoryProperties &properties,
cl_mem_flags flags,
cl_mem_flags_intel flagsIntel,
size_t size, size_t size,
void *hostPtr, void *hostPtr,
const cl_image_format &imageFormat, const cl_image_format &imageFormat,
@@ -301,6 +311,8 @@ class ImageHw : public Image {
UNRECOVERABLE_IF(surfaceFormatInfo == nullptr); UNRECOVERABLE_IF(surfaceFormatInfo == nullptr);
return new ImageHw<GfxFamily>(context, return new ImageHw<GfxFamily>(context,
properties, properties,
flags,
flagsIntel,
size, size,
hostPtr, hostPtr,
imageFormat, imageFormat,

View File

@@ -28,6 +28,8 @@ namespace NEO {
MemObj::MemObj(Context *context, MemObj::MemObj(Context *context,
cl_mem_object_type memObjectType, cl_mem_object_type memObjectType,
const MemoryProperties &properties, const MemoryProperties &properties,
cl_mem_flags flags,
cl_mem_flags_intel flagsIntel,
size_t size, size_t size,
void *memoryStorage, void *memoryStorage,
void *hostPtr, void *hostPtr,
@@ -35,7 +37,7 @@ MemObj::MemObj(Context *context,
bool zeroCopy, bool zeroCopy,
bool isHostPtrSVM, bool isHostPtrSVM,
bool isObjectRedescribed) bool isObjectRedescribed)
: context(context), memObjectType(memObjectType), properties(properties), size(size), : context(context), memObjectType(memObjectType), properties(properties), flags(flags), flags_intel(flagsIntel), size(size),
memoryStorage(memoryStorage), hostPtr(hostPtr), memoryStorage(memoryStorage), hostPtr(hostPtr),
isZeroCopy(zeroCopy), isHostPtrSVM(isHostPtrSVM), isObjectRedescribed(isObjectRedescribed), isZeroCopy(zeroCopy), isHostPtrSVM(isHostPtrSVM), isObjectRedescribed(isObjectRedescribed),
graphicsAllocation(gfxAllocation) { graphicsAllocation(gfxAllocation) {
@@ -220,10 +222,6 @@ void MemObj::setAllocatedMapPtr(void *allocatedMapPtr) {
this->allocatedMapPtr = allocatedMapPtr; this->allocatedMapPtr = allocatedMapPtr;
} }
cl_mem_flags MemObj::getFlags() const {
return getProperties().flags;
}
bool MemObj::isMemObjZeroCopy() const { bool MemObj::isMemObjZeroCopy() const {
return isZeroCopy; return isZeroCopy;
} }
@@ -325,7 +323,7 @@ void *MemObj::getBasePtrForMap() {
if (associatedMemObject) { if (associatedMemObject) {
return associatedMemObject->getBasePtrForMap(); return associatedMemObject->getBasePtrForMap();
} }
if (getFlags() & CL_MEM_USE_HOST_PTR) { if (getMemoryPropertiesFlags() & CL_MEM_USE_HOST_PTR) {
return getHostPtr(); return getHostPtr();
} else { } else {
TakeOwnershipWrapper<MemObj> memObjOwnership(*this); TakeOwnershipWrapper<MemObj> memObjOwnership(*this);

View File

@@ -14,6 +14,7 @@
#include "runtime/sharings/sharing.h" #include "runtime/sharings/sharing.h"
#include "mem_obj_types.h" #include "mem_obj_types.h"
#include "memory_properties_flags.h"
#include <atomic> #include <atomic>
#include <cstdint> #include <cstdint>
@@ -39,6 +40,8 @@ class MemObj : public BaseObject<_cl_mem> {
MemObj(Context *context, MemObj(Context *context,
cl_mem_object_type memObjectType, cl_mem_object_type memObjectType,
const MemoryProperties &properties, const MemoryProperties &properties,
cl_mem_flags flags,
cl_mem_flags_intel flagsIntel,
size_t size, size_t size,
void *memoryStorage, void *memoryStorage,
void *hostPtr, void *hostPtr,
@@ -59,7 +62,6 @@ class MemObj : public BaseObject<_cl_mem> {
void *getHostPtr() const; void *getHostPtr() const;
bool getIsObjectRedescribed() const { return isObjectRedescribed; }; bool getIsObjectRedescribed() const { return isObjectRedescribed; };
size_t getSize() const; size_t getSize() const;
cl_mem_flags getFlags() const;
bool addMappedPtr(void *ptr, size_t ptrLength, cl_map_flags &mapFlags, MemObjSizeArray &size, MemObjOffsetArray &offset, uint32_t mipLevel); bool addMappedPtr(void *ptr, size_t ptrLength, cl_map_flags &mapFlags, MemObjSizeArray &size, MemObjOffsetArray &offset, uint32_t mipLevel);
bool findMappedPtr(void *mappedPtr, MapInfo &outMapInfo) { return mapOperationsHandler.find(mappedPtr, outMapInfo); } bool findMappedPtr(void *mappedPtr, MapInfo &outMapInfo) { return mapOperationsHandler.find(mappedPtr, outMapInfo); }
@@ -121,7 +123,7 @@ class MemObj : public BaseObject<_cl_mem> {
return mapAllocation; return mapAllocation;
} }
const MemoryProperties &getProperties() const { return properties; } const cl_mem_flags &getMemoryPropertiesFlags() const { return flags; }
protected: protected:
void getOsSpecificMemObjectInfo(const cl_mem_info &paramName, size_t *srcParamSize, void **srcParam); void getOsSpecificMemObjectInfo(const cl_mem_info &paramName, size_t *srcParamSize, void **srcParam);
@@ -129,6 +131,9 @@ class MemObj : public BaseObject<_cl_mem> {
Context *context; Context *context;
cl_mem_object_type memObjectType; cl_mem_object_type memObjectType;
MemoryProperties properties; MemoryProperties properties;
MemoryPropertiesFlags memoryProperties;
cl_mem_flags flags = 0;
cl_mem_flags_intel flags_intel = 0;
size_t size; size_t size;
size_t hostPtrMinSize = 0; size_t hostPtrMinSize = 0;
void *memoryStorage; void *memoryStorage;

View File

@@ -15,7 +15,7 @@ bool MemObjHelper::isSuitableForRenderCompression(bool renderCompressed, const M
return renderCompressed && preferCompression; return renderCompressed && preferCompression;
} }
bool MemObjHelper::validateExtraMemoryProperties(const MemoryProperties &properties) { bool MemObjHelper::validateExtraMemoryProperties(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel) {
return true; return true;
} }

View File

@@ -30,15 +30,15 @@ class MemObjHelper {
static const uint64_t validFlagsForImage; static const uint64_t validFlagsForImage;
static const uint64_t validFlagsForImageIntel; static const uint64_t validFlagsForImageIntel;
static bool validateMemoryPropertiesForBuffer(const MemoryProperties &properties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel);
static bool validateMemoryPropertiesForImage(const MemoryProperties &properties, cl_mem parent);
static bool parseUnifiedMemoryProperties(cl_mem_properties_intel *properties, SVMAllocsManager::UnifiedMemoryProperties &unifiedMemoryProperties); static bool parseUnifiedMemoryProperties(cl_mem_properties_intel *properties, SVMAllocsManager::UnifiedMemoryProperties &unifiedMemoryProperties);
static bool validateMemoryPropertiesForBuffer(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel);
static bool validateMemoryPropertiesForImage(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, cl_mem parent);
static AllocationProperties getAllocationPropertiesWithImageInfo(ImageInfo &imgInfo, bool allocateMemory, const MemoryPropertiesFlags &memoryProperties); static AllocationProperties getAllocationPropertiesWithImageInfo(ImageInfo &imgInfo, bool allocateMemory, const MemoryPropertiesFlags &memoryProperties);
static bool checkMemFlagsForSubBuffer(cl_mem_flags flags); static bool checkMemFlagsForSubBuffer(cl_mem_flags flags);
static SVMAllocsManager::SvmAllocationProperties getSvmAllocationProperties(cl_mem_flags flags); static SVMAllocsManager::SvmAllocationProperties getSvmAllocationProperties(cl_mem_flags flags);
static bool isSuitableForRenderCompression(bool renderCompressed, const MemoryPropertiesFlags &properties, Context &context, bool preferCompression); static bool isSuitableForRenderCompression(bool renderCompressed, const MemoryPropertiesFlags &properties, Context &context, bool preferCompression);
protected: protected:
static bool validateExtraMemoryProperties(const MemoryProperties &properties); static bool validateExtraMemoryProperties(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel);
}; };
} // namespace NEO } // namespace NEO

View File

@@ -9,7 +9,7 @@
namespace NEO { namespace NEO {
bool MemObjHelper::validateMemoryPropertiesForBuffer(const MemoryProperties &properties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel) { bool MemObjHelper::validateMemoryPropertiesForBuffer(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel) {
/* Check all the invalid flags combination. */ /* Check all the invalid flags combination. */
if ((isValueSet(flags, CL_MEM_READ_WRITE | CL_MEM_READ_ONLY)) || if ((isValueSet(flags, CL_MEM_READ_WRITE | CL_MEM_READ_ONLY)) ||
(isValueSet(flags, CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY)) || (isValueSet(flags, CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY)) ||
@@ -22,49 +22,49 @@ bool MemObjHelper::validateMemoryPropertiesForBuffer(const MemoryProperties &pro
return false; return false;
} }
return validateExtraMemoryProperties(properties); return validateExtraMemoryProperties(memoryProperties, flags, flagsIntel);
} }
bool MemObjHelper::validateMemoryPropertiesForImage(const MemoryProperties &properties, cl_mem parent) { bool MemObjHelper::validateMemoryPropertiesForImage(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, cl_mem parent) {
/* Check all the invalid flags combination. */ /* Check all the invalid flags combination. */
if ((!isValueSet(properties.flags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) && if ((!isValueSet(flags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) &&
(isValueSet(properties.flags, CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY) || (isValueSet(flags, CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY) ||
isValueSet(properties.flags, CL_MEM_READ_WRITE | CL_MEM_READ_ONLY) || isValueSet(flags, CL_MEM_READ_WRITE | CL_MEM_READ_ONLY) ||
isValueSet(properties.flags, CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY) || isValueSet(flags, CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY) ||
isValueSet(properties.flags, CL_MEM_ALLOC_HOST_PTR | CL_MEM_USE_HOST_PTR) || isValueSet(flags, CL_MEM_ALLOC_HOST_PTR | CL_MEM_USE_HOST_PTR) ||
isValueSet(properties.flags, CL_MEM_COPY_HOST_PTR | CL_MEM_USE_HOST_PTR) || isValueSet(flags, CL_MEM_COPY_HOST_PTR | CL_MEM_USE_HOST_PTR) ||
isValueSet(properties.flags, CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_READ_ONLY) || isValueSet(flags, CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_READ_ONLY) ||
isValueSet(properties.flags, CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_NO_ACCESS) || isValueSet(flags, CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_NO_ACCESS) ||
isValueSet(properties.flags, CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS) || isValueSet(flags, CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS) ||
isValueSet(properties.flags, CL_MEM_NO_ACCESS_INTEL | CL_MEM_READ_WRITE) || isValueSet(flags, CL_MEM_NO_ACCESS_INTEL | CL_MEM_READ_WRITE) ||
isValueSet(properties.flags, CL_MEM_NO_ACCESS_INTEL | CL_MEM_WRITE_ONLY) || isValueSet(flags, CL_MEM_NO_ACCESS_INTEL | CL_MEM_WRITE_ONLY) ||
isValueSet(properties.flags, CL_MEM_NO_ACCESS_INTEL | CL_MEM_READ_ONLY))) { isValueSet(flags, CL_MEM_NO_ACCESS_INTEL | CL_MEM_READ_ONLY))) {
return false; return false;
} }
auto parentMemObj = castToObject<MemObj>(parent); auto parentMemObj = castToObject<MemObj>(parent);
if (parentMemObj != nullptr && properties.flags) { if (parentMemObj != nullptr && flags) {
auto parentFlags = parentMemObj->getFlags(); auto parentFlags = parentMemObj->getMemoryPropertiesFlags();
/* Check whether flags are compatible with parent. */ /* Check whether flags are compatible with parent. */
if (isValueSet(properties.flags, CL_MEM_ALLOC_HOST_PTR) || if (isValueSet(flags, CL_MEM_ALLOC_HOST_PTR) ||
isValueSet(properties.flags, CL_MEM_COPY_HOST_PTR) || isValueSet(flags, CL_MEM_COPY_HOST_PTR) ||
isValueSet(properties.flags, CL_MEM_USE_HOST_PTR) || isValueSet(flags, CL_MEM_USE_HOST_PTR) ||
((!isValueSet(parentFlags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) && ((!isValueSet(parentFlags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) &&
(!isValueSet(properties.flags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) && (!isValueSet(flags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) &&
((isValueSet(parentFlags, CL_MEM_WRITE_ONLY) && isValueSet(properties.flags, CL_MEM_READ_WRITE)) || ((isValueSet(parentFlags, CL_MEM_WRITE_ONLY) && isValueSet(flags, CL_MEM_READ_WRITE)) ||
(isValueSet(parentFlags, CL_MEM_WRITE_ONLY) && isValueSet(properties.flags, CL_MEM_READ_ONLY)) || (isValueSet(parentFlags, CL_MEM_WRITE_ONLY) && isValueSet(flags, CL_MEM_READ_ONLY)) ||
(isValueSet(parentFlags, CL_MEM_READ_ONLY) && isValueSet(properties.flags, CL_MEM_READ_WRITE)) || (isValueSet(parentFlags, CL_MEM_READ_ONLY) && isValueSet(flags, CL_MEM_READ_WRITE)) ||
(isValueSet(parentFlags, CL_MEM_READ_ONLY) && isValueSet(properties.flags, CL_MEM_WRITE_ONLY)) || (isValueSet(parentFlags, CL_MEM_READ_ONLY) && isValueSet(flags, CL_MEM_WRITE_ONLY)) ||
(isValueSet(parentFlags, CL_MEM_NO_ACCESS_INTEL) && isValueSet(properties.flags, CL_MEM_READ_WRITE)) || (isValueSet(parentFlags, CL_MEM_NO_ACCESS_INTEL) && isValueSet(flags, CL_MEM_READ_WRITE)) ||
(isValueSet(parentFlags, CL_MEM_NO_ACCESS_INTEL) && isValueSet(properties.flags, CL_MEM_WRITE_ONLY)) || (isValueSet(parentFlags, CL_MEM_NO_ACCESS_INTEL) && isValueSet(flags, CL_MEM_WRITE_ONLY)) ||
(isValueSet(parentFlags, CL_MEM_NO_ACCESS_INTEL) && isValueSet(properties.flags, CL_MEM_READ_ONLY)) || (isValueSet(parentFlags, CL_MEM_NO_ACCESS_INTEL) && isValueSet(flags, CL_MEM_READ_ONLY)) ||
(isValueSet(parentFlags, CL_MEM_HOST_NO_ACCESS) && isValueSet(properties.flags, CL_MEM_HOST_WRITE_ONLY)) || (isValueSet(parentFlags, CL_MEM_HOST_NO_ACCESS) && isValueSet(flags, CL_MEM_HOST_WRITE_ONLY)) ||
(isValueSet(parentFlags, CL_MEM_HOST_NO_ACCESS) && isValueSet(properties.flags, CL_MEM_HOST_READ_ONLY))))) { (isValueSet(parentFlags, CL_MEM_HOST_NO_ACCESS) && isValueSet(flags, CL_MEM_HOST_READ_ONLY))))) {
return false; return false;
} }
} }
return validateExtraMemoryProperties(properties); return validateExtraMemoryProperties(memoryProperties, flags, flagsIntel);
} }
bool MemObjHelper::parseUnifiedMemoryProperties(cl_mem_properties_intel *properties, SVMAllocsManager::UnifiedMemoryProperties &unifiedMemoryProperties) { bool MemObjHelper::parseUnifiedMemoryProperties(cl_mem_properties_intel *properties, SVMAllocsManager::UnifiedMemoryProperties &unifiedMemoryProperties) {

View File

@@ -25,6 +25,8 @@ Pipe::Pipe(Context *context,
: MemObj(context, : MemObj(context,
CL_MEM_OBJECT_PIPE, CL_MEM_OBJECT_PIPE,
flags, flags,
flags,
0,
static_cast<size_t>(packetSize * (maxPackets + 1) + intelPipeHeaderReservedSpace), static_cast<size_t>(packetSize * (maxPackets + 1) + intelPipeHeaderReservedSpace),
memoryStorage, memoryStorage,
nullptr, nullptr,

View File

@@ -234,7 +234,7 @@ void DebugSettingsManager<DebugLevel>::dumpKernelArgs(const Kernel *kernel) {
if (memObj != nullptr) { if (memObj != nullptr) {
ptr = static_cast<char *>(memObj->getCpuAddress()); ptr = static_cast<char *>(memObj->getCpuAddress());
size = memObj->getSize(); size = memObj->getSize();
flags = memObj->getFlags(); flags = memObj->getMemoryPropertiesFlags();
} }
} else if (argInfo.typeStr.find("sampler") != std::string::npos) { } else if (argInfo.typeStr.find("sampler") != std::string::npos) {
type = "sampler"; type = "sampler";
@@ -245,7 +245,7 @@ void DebugSettingsManager<DebugLevel>::dumpKernelArgs(const Kernel *kernel) {
if (memObj != nullptr) { if (memObj != nullptr) {
ptr = static_cast<char *>(memObj->getCpuAddress()); ptr = static_cast<char *>(memObj->getCpuAddress());
size = memObj->getSize(); size = memObj->getSize();
flags = memObj->getFlags(); flags = memObj->getMemoryPropertiesFlags();
} }
} else { } else {
type = "immediate"; type = "immediate";

View File

@@ -100,7 +100,7 @@ HWTEST_F(EnqueueFillBufferCmdTests, WhenFillingBufferThenIndirectDataGetsAdded)
ASSERT_NE(nullptr, &builder); ASSERT_NE(nullptr, &builder);
BuiltinOpParams dc; BuiltinOpParams dc;
MemObj patternMemObj(&this->context, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), MemObj patternMemObj(&this->context, 0, 0, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(),
patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true); patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true);
dc.srcMemObj = &patternMemObj; dc.srcMemObj = &patternMemObj;
dc.dstMemObj = buffer; dc.dstMemObj = buffer;
@@ -132,7 +132,7 @@ HWTEST_F(EnqueueFillBufferCmdTests, FillBufferRightLeftover) {
ASSERT_NE(nullptr, &builder); ASSERT_NE(nullptr, &builder);
BuiltinOpParams dc; BuiltinOpParams dc;
MemObj patternMemObj(&this->context, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), MemObj patternMemObj(&this->context, 0, 0, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(),
patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true); patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true);
dc.srcMemObj = &patternMemObj; dc.srcMemObj = &patternMemObj;
dc.dstMemObj = buffer; dc.dstMemObj = buffer;
@@ -159,7 +159,7 @@ HWTEST_F(EnqueueFillBufferCmdTests, FillBufferMiddle) {
ASSERT_NE(nullptr, &builder); ASSERT_NE(nullptr, &builder);
BuiltinOpParams dc; BuiltinOpParams dc;
MemObj patternMemObj(&this->context, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), MemObj patternMemObj(&this->context, 0, 0, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(),
patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true); patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true);
dc.srcMemObj = &patternMemObj; dc.srcMemObj = &patternMemObj;
dc.dstMemObj = buffer; dc.dstMemObj = buffer;
@@ -186,7 +186,7 @@ HWTEST_F(EnqueueFillBufferCmdTests, FillBufferLeftLeftover) {
ASSERT_NE(nullptr, &builder); ASSERT_NE(nullptr, &builder);
BuiltinOpParams dc; BuiltinOpParams dc;
MemObj patternMemObj(&this->context, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), MemObj patternMemObj(&this->context, 0, 0, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(),
patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true); patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true);
dc.srcMemObj = &patternMemObj; dc.srcMemObj = &patternMemObj;
dc.dstMemObj = buffer; dc.dstMemObj = buffer;
@@ -279,7 +279,7 @@ HWTEST_F(EnqueueFillBufferCmdTests, WhenFillingBufferThenArgumentZeroShouldMatch
ASSERT_NE(nullptr, &builder); ASSERT_NE(nullptr, &builder);
BuiltinOpParams dc; BuiltinOpParams dc;
MemObj patternMemObj(&this->context, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), MemObj patternMemObj(&this->context, 0, 0, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(),
patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true); patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true);
dc.srcMemObj = &patternMemObj; dc.srcMemObj = &patternMemObj;
dc.dstMemObj = buffer; dc.dstMemObj = buffer;
@@ -315,7 +315,7 @@ HWTEST_F(EnqueueFillBufferCmdTests, DISABLED_WhenFillingBufferThenArgumentOneSho
ASSERT_NE(nullptr, &builder); ASSERT_NE(nullptr, &builder);
BuiltinOpParams dc; BuiltinOpParams dc;
MemObj patternMemObj(&this->context, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), MemObj patternMemObj(&this->context, 0, 0, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(),
patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true); patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true);
dc.srcMemObj = &patternMemObj; dc.srcMemObj = &patternMemObj;
dc.dstMemObj = buffer; dc.dstMemObj = buffer;
@@ -348,7 +348,7 @@ HWTEST_F(EnqueueFillBufferCmdTests, WhenFillingBufferThenArgumentTwoShouldMatchP
ASSERT_NE(nullptr, &builder); ASSERT_NE(nullptr, &builder);
BuiltinOpParams dc; BuiltinOpParams dc;
MemObj patternMemObj(&this->context, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), MemObj patternMemObj(&this->context, 0, 0, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(),
patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true); patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true);
dc.srcMemObj = &patternMemObj; dc.srcMemObj = &patternMemObj;
dc.dstMemObj = buffer; dc.dstMemObj = buffer;

View File

@@ -194,6 +194,8 @@ HWTEST_F(EnqueueMapImageTest, givenTiledImageWhenMapImageIsCalledThenStorageIsSe
auto surfaceFormatInfo = image->getSurfaceFormatInfo(); auto surfaceFormatInfo = image->getSurfaceFormatInfo();
mockedImage<FamilyType> mockImage(context, mockedImage<FamilyType> mockImage(context,
0,
0,
0, 0,
4096u, 4096u,
nullptr, nullptr,
@@ -916,7 +918,7 @@ TEST_F(EnqueueMapImageTest, givenImage1DArrayWhenEnqueueMapImageIsCalledThenRetu
class MockImage : public Image { class MockImage : public Image {
public: public:
MockImage(Context *context, cl_mem_flags flags, GraphicsAllocation *allocation, const SurfaceFormatInfo &surfaceFormat, MockImage(Context *context, cl_mem_flags flags, GraphicsAllocation *allocation, const SurfaceFormatInfo &surfaceFormat,
const cl_image_format &imageFormat, const cl_image_desc &imageDesc) : Image(context, flags, const cl_image_format &imageFormat, const cl_image_desc &imageDesc) : Image(context, flags, flags, 0,
0, nullptr, 0, nullptr,
imageFormat, imageDesc, imageFormat, imageDesc,
true, true,

View File

@@ -81,7 +81,7 @@ HWTEST_F(GetSizeRequiredBufferTest, enqueueFillBuffer) {
ASSERT_NE(nullptr, &builder); ASSERT_NE(nullptr, &builder);
BuiltinOpParams dc; BuiltinOpParams dc;
MemObj patternMemObj(this->context, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), MemObj patternMemObj(this->context, 0, 0, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(),
patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true); patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true);
dc.srcMemObj = &patternMemObj; dc.srcMemObj = &patternMemObj;
dc.dstMemObj = dstBuffer; dc.dstMemObj = dstBuffer;

View File

@@ -90,7 +90,7 @@ struct MultipleMapBufferTest : public DeviceFixture, public ::testing::Test {
template <typename FamilyType> template <typename FamilyType>
std::unique_ptr<MockBuffer<FamilyType>> createMockBuffer(bool mapOnGpu) { std::unique_ptr<MockBuffer<FamilyType>> createMockBuffer(bool mapOnGpu) {
auto mockAlloc = pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); auto mockAlloc = pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
auto buffer = new MockBuffer<FamilyType>(context, 0, 1024, mockAlloc->getUnderlyingBuffer(), mockAlloc->getUnderlyingBuffer(), auto buffer = new MockBuffer<FamilyType>(context, 0, 0, 0, 1024, mockAlloc->getUnderlyingBuffer(), mockAlloc->getUnderlyingBuffer(),
mockAlloc, false, false, false); mockAlloc, false, false, false);
if (mapOnGpu) { if (mapOnGpu) {
buffer->setSharingHandler(new SharingHandler()); buffer->setSharingHandler(new SharingHandler());

View File

@@ -27,6 +27,8 @@ struct MultipleMapImageTest : public DeviceFixture, public ::testing::Test {
static Image *createMockImage(Context *context, static Image *createMockImage(Context *context,
const MemoryProperties &properties, const MemoryProperties &properties,
uint64_t flags,
uint64_t flagsIntel,
size_t size, size_t size,
void *hostPtr, void *hostPtr,
const cl_image_format &imageFormat, const cl_image_format &imageFormat,
@@ -38,7 +40,7 @@ struct MultipleMapImageTest : public DeviceFixture, public ::testing::Test {
uint32_t mipCount, uint32_t mipCount,
const SurfaceFormatInfo *surfaceFormatInfo, const SurfaceFormatInfo *surfaceFormatInfo,
const SurfaceOffsets *surfaceOffsets) { const SurfaceOffsets *surfaceOffsets) {
return new MockImage<T>(context, properties, size, hostPtr, imageFormat, imageDesc, zeroCopy, graphicsAllocation, return new MockImage<T>(context, properties, flags, flagsIntel, size, hostPtr, imageFormat, imageDesc, zeroCopy, graphicsAllocation,
isObjectRedescribed, baseMipLevel, mipCount, *surfaceFormatInfo, surfaceOffsets); isObjectRedescribed, baseMipLevel, mipCount, *surfaceFormatInfo, surfaceOffsets);
}; };

View File

@@ -189,7 +189,7 @@ TEST_F(D3D9Tests, createSurface) {
auto image = castToObject<Image>(memObj); auto image = castToObject<Image>(memObj);
EXPECT_NE(nullptr, image->getSharingHandler()); EXPECT_NE(nullptr, image->getSharingHandler());
EXPECT_TRUE(CL_MEM_READ_WRITE == image->getFlags()); EXPECT_TRUE(CL_MEM_READ_WRITE == image->getMemoryPropertiesFlags());
EXPECT_TRUE(expectedImgFormat.image_channel_data_type == image->getImageFormat().image_channel_data_type); EXPECT_TRUE(expectedImgFormat.image_channel_data_type == image->getImageFormat().image_channel_data_type);
EXPECT_TRUE(expectedImgFormat.image_channel_order == image->getImageFormat().image_channel_order); EXPECT_TRUE(expectedImgFormat.image_channel_order == image->getImageFormat().image_channel_order);
@@ -223,7 +223,7 @@ TEST_F(D3D9Tests, createSurfaceIntel) {
auto image = castToObject<Image>(memObj); auto image = castToObject<Image>(memObj);
EXPECT_NE(nullptr, image->getSharingHandler()); EXPECT_NE(nullptr, image->getSharingHandler());
EXPECT_TRUE(CL_MEM_READ_WRITE == image->getFlags()); EXPECT_TRUE(CL_MEM_READ_WRITE == image->getMemoryPropertiesFlags());
EXPECT_TRUE(expectedImgFormat.image_channel_data_type == image->getImageFormat().image_channel_data_type); EXPECT_TRUE(expectedImgFormat.image_channel_data_type == image->getImageFormat().image_channel_data_type);
EXPECT_TRUE(expectedImgFormat.image_channel_order == image->getImageFormat().image_channel_order); EXPECT_TRUE(expectedImgFormat.image_channel_order == image->getImageFormat().image_channel_order);

View File

@@ -135,7 +135,7 @@ TYPED_TEST_P(D3DTests, createFromD3DBufferKHRApi) {
auto bufferObj = static_cast<D3DBuffer<TypeParam> *>(buffer->getSharingHandler().get()); auto bufferObj = static_cast<D3DBuffer<TypeParam> *>(buffer->getSharingHandler().get());
EXPECT_EQ((D3DResource *)&this->dummyD3DBuffer, *bufferObj->getResourceHandler()); EXPECT_EQ((D3DResource *)&this->dummyD3DBuffer, *bufferObj->getResourceHandler());
EXPECT_TRUE(buffer->getFlags() == CL_MEM_READ_WRITE); EXPECT_TRUE(buffer->getMemoryPropertiesFlags() == CL_MEM_READ_WRITE);
clReleaseMemObject(memObj); clReleaseMemObject(memObj);
} }
@@ -255,7 +255,7 @@ TYPED_TEST_P(D3DTests, createFromD3D2dTextureKHRApi) {
auto textureObj = static_cast<D3DTexture<TypeParam> *>(image->getSharingHandler().get()); auto textureObj = static_cast<D3DTexture<TypeParam> *>(image->getSharingHandler().get());
EXPECT_EQ((D3DResource *)&this->dummyD3DTexture, *textureObj->getResourceHandler()); EXPECT_EQ((D3DResource *)&this->dummyD3DTexture, *textureObj->getResourceHandler());
EXPECT_TRUE(image->getFlags() == CL_MEM_READ_WRITE); EXPECT_TRUE(image->getMemoryPropertiesFlags() == CL_MEM_READ_WRITE);
EXPECT_TRUE(image->getImageDesc().image_type == CL_MEM_OBJECT_IMAGE2D); EXPECT_TRUE(image->getImageDesc().image_type == CL_MEM_OBJECT_IMAGE2D);
EXPECT_EQ(1u, textureObj->getSubresource()); EXPECT_EQ(1u, textureObj->getSubresource());
@@ -287,7 +287,7 @@ TYPED_TEST_P(D3DTests, createFromD3D3dTextureKHRApi) {
auto textureObj = static_cast<D3DTexture<TypeParam> *>(image->getSharingHandler().get()); auto textureObj = static_cast<D3DTexture<TypeParam> *>(image->getSharingHandler().get());
EXPECT_EQ((D3DResource *)&this->dummyD3DTexture, *textureObj->getResourceHandler()); EXPECT_EQ((D3DResource *)&this->dummyD3DTexture, *textureObj->getResourceHandler());
EXPECT_TRUE(image->getFlags() == CL_MEM_READ_WRITE); EXPECT_TRUE(image->getMemoryPropertiesFlags() == CL_MEM_READ_WRITE);
EXPECT_TRUE(image->getImageDesc().image_type == CL_MEM_OBJECT_IMAGE3D); EXPECT_TRUE(image->getImageDesc().image_type == CL_MEM_OBJECT_IMAGE3D);
EXPECT_EQ(1u, textureObj->getSubresource()); EXPECT_EQ(1u, textureObj->getSubresource());

View File

@@ -275,7 +275,7 @@ TEST(CastToImage, fromMemObj) {
extern std::thread::id tempThreadID; extern std::thread::id tempThreadID;
class MockBuffer : public MockBufferStorage, public Buffer { class MockBuffer : public MockBufferStorage, public Buffer {
public: public:
MockBuffer() : MockBufferStorage(), Buffer(nullptr, CL_MEM_USE_HOST_PTR, sizeof(data), &data, &data, &mockGfxAllocation, true, false, false) { MockBuffer() : MockBufferStorage(), Buffer(nullptr, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, sizeof(data), &data, &data, &mockGfxAllocation, true, false, false) {
} }
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) override { void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) override {
@@ -306,7 +306,7 @@ TYPED_TEST(BaseObjectTests, getCond) {
TYPED_TEST(BaseObjectTests, convertToInternalObject) { TYPED_TEST(BaseObjectTests, convertToInternalObject) {
class ObjectForTest : public NEO::MemObj { class ObjectForTest : public NEO::MemObj {
public: public:
ObjectForTest() : MemObj(nullptr, 0, 0, 0u, nullptr, nullptr, nullptr, false, false, false) { ObjectForTest() : MemObj(nullptr, 0, 0, 0, 0, 0u, nullptr, nullptr, nullptr, false, false, false) {
} }
void convertToInternalObject(void) { void convertToInternalObject(void) {

View File

@@ -221,7 +221,7 @@ TEST_F(BufferSetArgTest, givenBufferWhenOffsetedSubbufferIsPassedToSetKernelArgT
region.origin = 0xc0; region.origin = 0xc0;
region.size = 32; region.size = 32;
cl_int error = 0; cl_int error = 0;
auto subBuffer = buffer->createSubBuffer(buffer->getFlags(), &region, error); auto subBuffer = buffer->createSubBuffer(buffer->getMemoryPropertiesFlags(), &region, error);
ASSERT_NE(nullptr, subBuffer); ASSERT_NE(nullptr, subBuffer);

View File

@@ -1238,6 +1238,8 @@ TEST_P(NoHostPtr, GivenNoHostPtrWhenHwBufferCreationFailsThenReturnNullptr) {
bufferFactory[i].createBufferFunction = bufferFactory[i].createBufferFunction =
[](Context *, [](Context *,
MemoryProperties, MemoryProperties,
cl_mem_flags,
cl_mem_flags_intel,
size_t, size_t,
void *, void *,
void *, void *,

View File

@@ -72,7 +72,7 @@ TEST_P(ImageRedescribeTest, givenImageWhenItIsRedescribedThenItContainsProperFor
ASSERT_NE(nullptr, imageNew); ASSERT_NE(nullptr, imageNew);
ASSERT_NE(image, imageNew); ASSERT_NE(image, imageNew);
EXPECT_EQ(static_cast<cl_mem_flags>(CL_MEM_USE_HOST_PTR), imageNew->getFlags() & CL_MEM_USE_HOST_PTR); EXPECT_EQ(static_cast<cl_mem_flags>(CL_MEM_USE_HOST_PTR), imageNew->getMemoryPropertiesFlags() & CL_MEM_USE_HOST_PTR);
EXPECT_EQ(image->getCpuAddress(), imageNew->getCpuAddress()); EXPECT_EQ(image->getCpuAddress(), imageNew->getCpuAddress());
EXPECT_NE(static_cast<cl_channel_type>(CL_FLOAT), imageNew->getSurfaceFormatInfo().OCLImageFormat.image_channel_data_type); EXPECT_NE(static_cast<cl_channel_type>(CL_FLOAT), imageNew->getSurfaceFormatInfo().OCLImageFormat.image_channel_data_type);
EXPECT_NE(static_cast<cl_channel_type>(CL_HALF_FLOAT), imageNew->getSurfaceFormatInfo().OCLImageFormat.image_channel_data_type); EXPECT_NE(static_cast<cl_channel_type>(CL_HALF_FLOAT), imageNew->getSurfaceFormatInfo().OCLImageFormat.image_channel_data_type);

View File

@@ -1463,7 +1463,7 @@ HWTEST_F(ImageTransformTest, givenSurfaceBaseAddressAndUnifiedSurfaceWhenSetUnif
template <typename FamilyName> template <typename FamilyName>
class MockImageHw : public ImageHw<FamilyName> { class MockImageHw : public ImageHw<FamilyName> {
public: public:
MockImageHw(Context *context, const cl_image_format &format, const cl_image_desc &desc, SurfaceFormatInfo &surfaceFormatInfo, GraphicsAllocation *graphicsAllocation) : ImageHw<FamilyName>(context, 0, 0, nullptr, format, desc, false, graphicsAllocation, false, 0, 0, surfaceFormatInfo) { MockImageHw(Context *context, const cl_image_format &format, const cl_image_desc &desc, SurfaceFormatInfo &surfaceFormatInfo, GraphicsAllocation *graphicsAllocation) : ImageHw<FamilyName>(context, 0, 0, 0, 0, nullptr, format, desc, false, graphicsAllocation, false, 0, 0, surfaceFormatInfo) {
} }
void setClearColorParams(typename FamilyName::RENDER_SURFACE_STATE *surfaceState, const Gmm *gmm) override; void setClearColorParams(typename FamilyName::RENDER_SURFACE_STATE *surfaceState, const Gmm *gmm) override;

View File

@@ -669,7 +669,7 @@ TEST(validateAndCreateImage, givenInvalidImageFormatWhenValidateAndCreateImageIs
Image *image; Image *image;
imageFormat.image_channel_order = 0; imageFormat.image_channel_order = 0;
imageFormat.image_channel_data_type = 0; imageFormat.image_channel_data_type = 0;
image = Image::validateAndCreateImage(&context, 0, &imageFormat, &Image1dDefaults::imageDesc, nullptr, retVal); image = Image::validateAndCreateImage(&context, 0, 0, 0, &imageFormat, &Image1dDefaults::imageDesc, nullptr, retVal);
EXPECT_EQ(nullptr, image); EXPECT_EQ(nullptr, image);
EXPECT_EQ(CL_INVALID_IMAGE_FORMAT_DESCRIPTOR, retVal); EXPECT_EQ(CL_INVALID_IMAGE_FORMAT_DESCRIPTOR, retVal);
} }
@@ -679,7 +679,8 @@ TEST(validateAndCreateImage, givenNotSupportedImageFormatWhenValidateAndCreateIm
cl_image_format imageFormat = {CL_INTENSITY, CL_UNORM_INT8}; cl_image_format imageFormat = {CL_INTENSITY, CL_UNORM_INT8};
cl_int retVal = CL_SUCCESS; cl_int retVal = CL_SUCCESS;
Image *image; Image *image;
image = Image::validateAndCreateImage(&context, CL_MEM_READ_WRITE, &imageFormat, &Image1dDefaults::imageDesc, nullptr, retVal); cl_mem_flags flags = CL_MEM_READ_WRITE;
image = Image::validateAndCreateImage(&context, CL_MEM_READ_WRITE, flags, 0, &imageFormat, &Image1dDefaults::imageDesc, nullptr, retVal);
EXPECT_EQ(nullptr, image); EXPECT_EQ(nullptr, image);
EXPECT_EQ(CL_IMAGE_FORMAT_NOT_SUPPORTED, retVal); EXPECT_EQ(CL_IMAGE_FORMAT_NOT_SUPPORTED, retVal);
} }
@@ -708,6 +709,8 @@ TEST(validateAndCreateImage, givenValidImageParamsWhenValidateAndCreateImageIsCa
image.reset(Image::validateAndCreateImage( image.reset(Image::validateAndCreateImage(
&context, &context,
flags, flags,
flags,
0,
&imageFormat, &imageFormat,
&imageDesc, &imageDesc,
nullptr, nullptr,
@@ -757,7 +760,7 @@ struct NullImage : public Image {
using Image::imageDesc; using Image::imageDesc;
using Image::imageFormat; using Image::imageFormat;
NullImage() : Image(nullptr, cl_mem_flags{}, 0, nullptr, cl_image_format{}, NullImage() : Image(nullptr, cl_mem_flags{}, cl_mem_flags{}, 0, 0, nullptr, cl_image_format{},
cl_image_desc{}, false, new MockGraphicsAllocation(nullptr, 0), false, cl_image_desc{}, false, new MockGraphicsAllocation(nullptr, 0), false,
0, 0, SurfaceFormatInfo{}, nullptr) { 0, 0, SurfaceFormatInfo{}, nullptr) {
} }

View File

@@ -38,7 +38,7 @@ class MemObjDestructionTest : public ::testing::TestWithParam<bool> {
allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{size}); allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{size});
memObj = new MemObj(context.get(), CL_MEM_OBJECT_BUFFER, memObj = new MemObj(context.get(), CL_MEM_OBJECT_BUFFER,
CL_MEM_READ_WRITE, CL_MEM_READ_WRITE, CL_MEM_READ_WRITE, 0,
size, size,
nullptr, nullptr, allocation, true, false, false); nullptr, nullptr, allocation, true, false, false);
*device->getDefaultEngine().commandStreamReceiver->getTagAddress() = 0; *device->getDefaultEngine().commandStreamReceiver->getTagAddress() = 0;
@@ -215,7 +215,7 @@ HWTEST_P(MemObjAsyncDestructionTest, givenUsedMemObjWithAsyncDestructionsEnabled
MemObjSizeArray region = {{1, 1, 1}}; MemObjSizeArray region = {{1, 1, 1}};
cl_map_flags mapFlags = CL_MAP_READ; cl_map_flags mapFlags = CL_MAP_READ;
memObj = new MemObj(context.get(), CL_MEM_OBJECT_BUFFER, memObj = new MemObj(context.get(), CL_MEM_OBJECT_BUFFER,
CL_MEM_READ_WRITE, CL_MEM_READ_WRITE, CL_MEM_READ_WRITE, 0,
size, size,
storage, nullptr, allocation, true, false, false); storage, nullptr, allocation, true, false, false);
memObj->addMappedPtr(storage, 1, mapFlags, region, origin, 0); memObj->addMappedPtr(storage, 1, mapFlags, region, origin, 0);

View File

@@ -54,52 +54,65 @@ TEST(MemObjHelper, givenClMemForceLinearStorageFlagWhenCheckForLinearStorageForc
TEST(MemObjHelper, givenValidPropertiesWhenValidatingMemoryPropertiesThenTrueIsReturned) { TEST(MemObjHelper, givenValidPropertiesWhenValidatingMemoryPropertiesThenTrueIsReturned) {
MemoryProperties properties; MemoryProperties properties;
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties);
cl_mem_flags flags = 0; cl_mem_flags flags = 0;
cl_mem_flags_intel flags_intel = 0; cl_mem_flags_intel flags_intel = 0;
EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(properties, flags, flags_intel)); EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flags_intel));
EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(properties, nullptr)); EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, flags_intel, nullptr));
properties.flags = CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL | CL_MEM_NO_ACCESS_INTEL; properties.flags = CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL | CL_MEM_NO_ACCESS_INTEL;
EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(properties, nullptr)); memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties);
flags = CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL | CL_MEM_NO_ACCESS_INTEL;
flags_intel = 0;
EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, flags_intel, nullptr));
properties.flags = CL_MEM_NO_ACCESS_INTEL; properties.flags = CL_MEM_NO_ACCESS_INTEL;
EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(properties, nullptr)); memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties);
flags = CL_MEM_NO_ACCESS_INTEL;
flags_intel = 0;
EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, flags_intel, nullptr));
properties.flags = CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR | CL_MEM_HOST_NO_ACCESS; properties.flags = CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR | CL_MEM_HOST_NO_ACCESS;
memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties);
flags = CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR | CL_MEM_HOST_NO_ACCESS; flags = CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR | CL_MEM_HOST_NO_ACCESS;
flags_intel = 0; flags_intel = 0;
EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(properties, flags, flags_intel)); EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flags_intel));
EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(properties, nullptr)); EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, flags_intel, nullptr));
properties.flags = CL_MEM_WRITE_ONLY | CL_MEM_COPY_HOST_PTR | CL_MEM_HOST_WRITE_ONLY; properties.flags = CL_MEM_WRITE_ONLY | CL_MEM_COPY_HOST_PTR | CL_MEM_HOST_WRITE_ONLY;
memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties);
flags = CL_MEM_WRITE_ONLY | CL_MEM_COPY_HOST_PTR | CL_MEM_HOST_WRITE_ONLY; flags = CL_MEM_WRITE_ONLY | CL_MEM_COPY_HOST_PTR | CL_MEM_HOST_WRITE_ONLY;
flags_intel = 0; flags_intel = 0;
EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(properties, flags, flags_intel)); EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flags_intel));
EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(properties, nullptr)); EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, flags_intel, nullptr));
properties.flags = CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR | CL_MEM_HOST_NO_ACCESS; properties.flags = CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR | CL_MEM_HOST_NO_ACCESS;
memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties);
flags = CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR | CL_MEM_HOST_NO_ACCESS; flags = CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR | CL_MEM_HOST_NO_ACCESS;
flags_intel = 0; flags_intel = 0;
EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(properties, flags, flags_intel)); EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flags_intel));
EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(properties, nullptr)); EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, flags_intel, nullptr));
properties.flags_intel = CL_MEM_LOCALLY_UNCACHED_RESOURCE; properties.flags_intel = CL_MEM_LOCALLY_UNCACHED_RESOURCE;
memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties);
flags = 0; flags = 0;
flags_intel = CL_MEM_LOCALLY_UNCACHED_RESOURCE; flags_intel = CL_MEM_LOCALLY_UNCACHED_RESOURCE;
EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(properties, flags, flags_intel)); EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flags_intel));
EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(properties, nullptr)); EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, flags_intel, nullptr));
properties.flags_intel = CL_MEM_LOCALLY_UNCACHED_SURFACE_STATE_RESOURCE; properties.flags_intel = CL_MEM_LOCALLY_UNCACHED_SURFACE_STATE_RESOURCE;
memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties);
flags = 0; flags = 0;
flags_intel = CL_MEM_LOCALLY_UNCACHED_SURFACE_STATE_RESOURCE; flags_intel = CL_MEM_LOCALLY_UNCACHED_SURFACE_STATE_RESOURCE;
EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(properties, flags, flags_intel)); EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flags_intel));
EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(properties, nullptr)); EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, flags_intel, nullptr));
properties.flags = 0; properties.flags = 0;
memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties);
flags = 0; flags = 0;
flags_intel = 0; flags_intel = 0;
EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(properties, flags, flags_intel)); EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flags_intel));
EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(properties, nullptr)); EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, flags_intel, nullptr));
} }
struct Image1dWithAccessFlagsUnrestricted : public Image1dDefaults { struct Image1dWithAccessFlagsUnrestricted : public Image1dDefaults {
@@ -108,19 +121,26 @@ struct Image1dWithAccessFlagsUnrestricted : public Image1dDefaults {
TEST(MemObjHelper, givenParentMemObjAndHostPtrFlagsWhenValidatingMemoryPropertiesForImageThenFalseIsReturned) { TEST(MemObjHelper, givenParentMemObjAndHostPtrFlagsWhenValidatingMemoryPropertiesForImageThenFalseIsReturned) {
MemoryProperties properties; MemoryProperties properties;
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties);
MockContext context; MockContext context;
auto image = clUniquePtr(Image1dHelper<>::create(&context)); auto image = clUniquePtr(Image1dHelper<>::create(&context));
auto imageWithAccessFlagsUnrestricted = clUniquePtr(ImageHelper<Image1dWithAccessFlagsUnrestricted>::create(&context)); auto imageWithAccessFlagsUnrestricted = clUniquePtr(ImageHelper<Image1dWithAccessFlagsUnrestricted>::create(&context));
cl_mem_flags hostPtrFlags[] = {CL_MEM_USE_HOST_PTR, CL_MEM_ALLOC_HOST_PTR, CL_MEM_COPY_HOST_PTR}; cl_mem_flags hostPtrFlags[] = {CL_MEM_USE_HOST_PTR, CL_MEM_ALLOC_HOST_PTR, CL_MEM_COPY_HOST_PTR};
cl_mem_flags flags = 0;
for (auto hostPtrFlag : hostPtrFlags) { for (auto hostPtrFlag : hostPtrFlags) {
properties.flags = hostPtrFlag; properties.flags = hostPtrFlag;
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(properties, image.get())); memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties);
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(properties, imageWithAccessFlagsUnrestricted.get())); flags = hostPtrFlag;
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, 0, image.get()));
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, 0, imageWithAccessFlagsUnrestricted.get()));
properties.flags |= CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL; properties.flags |= CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL;
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(properties, image.get())); memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties);
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(properties, imageWithAccessFlagsUnrestricted.get())); flags |= CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL;
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, 0, image.get()));
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, 0, imageWithAccessFlagsUnrestricted.get()));
} }
} }

View File

@@ -61,13 +61,13 @@ TEST(MemObj, GivenMemObjWhenInititalizedFromHostPtrThenInitializeFields) {
MockContext context; MockContext context;
MockGraphicsAllocation *mockAllocation = new MockGraphicsAllocation(buffer, sizeof(buffer)); MockGraphicsAllocation *mockAllocation = new MockGraphicsAllocation(buffer, sizeof(buffer));
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0,
sizeof(buffer), buffer, buffer, mockAllocation, true, false, false); sizeof(buffer), buffer, buffer, mockAllocation, true, false, false);
EXPECT_EQ(&buffer, memObj.getCpuAddress()); EXPECT_EQ(&buffer, memObj.getCpuAddress());
EXPECT_EQ(&buffer, memObj.getHostPtr()); EXPECT_EQ(&buffer, memObj.getHostPtr());
EXPECT_EQ(size, memObj.getSize()); EXPECT_EQ(size, memObj.getSize());
EXPECT_EQ(static_cast<cl_mem_flags>(CL_MEM_USE_HOST_PTR), memObj.getFlags()); EXPECT_EQ(static_cast<cl_mem_flags>(CL_MEM_USE_HOST_PTR), memObj.getMemoryPropertiesFlags());
} }
TEST(MemObj, givenMemObjectWhenAskedForTransferToHostPtrThenDoNothing) { TEST(MemObj, givenMemObjectWhenAskedForTransferToHostPtrThenDoNothing) {
@@ -76,7 +76,7 @@ TEST(MemObj, givenMemObjectWhenAskedForTransferToHostPtrThenDoNothing) {
uint8_t expectedHostPtr[size] = {}; uint8_t expectedHostPtr[size] = {};
MockContext context; MockContext context;
MockGraphicsAllocation *mockAllocation = new MockGraphicsAllocation(hostPtr, sizeof(hostPtr)); MockGraphicsAllocation *mockAllocation = new MockGraphicsAllocation(hostPtr, sizeof(hostPtr));
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0,
size, hostPtr, hostPtr, mockAllocation, true, false, false); size, hostPtr, hostPtr, mockAllocation, true, false, false);
memset(memObj.getCpuAddress(), 123, size); memset(memObj.getCpuAddress(), 123, size);
@@ -95,7 +95,7 @@ TEST(MemObj, givenMemObjectWhenAskedForTransferFromHostPtrThenDoNothing) {
uint8_t expectedBufferPtr[size] = {}; uint8_t expectedBufferPtr[size] = {};
MockContext context; MockContext context;
MockGraphicsAllocation *mockAllocation = new MockGraphicsAllocation(hostPtr, sizeof(hostPtr)); MockGraphicsAllocation *mockAllocation = new MockGraphicsAllocation(hostPtr, sizeof(hostPtr));
MemObj memObj(&context, CL_MEM_OBJECT_PIPE, CL_MEM_USE_HOST_PTR, MemObj memObj(&context, CL_MEM_OBJECT_PIPE, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0,
size, hostPtr, hostPtr, mockAllocation, true, false, false); size, hostPtr, hostPtr, mockAllocation, true, false, false);
memset(memObj.getCpuAddress(), 123, size); memset(memObj.getCpuAddress(), 123, size);
@@ -112,7 +112,7 @@ TEST(MemObj, givenHostPtrAndUseHostPtrFlagWhenAskingForBaseMapPtrThenReturnHostP
uint8_t hostPtr = 0; uint8_t hostPtr = 0;
MockContext context; MockContext context;
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0,
1, nullptr, &hostPtr, nullptr, true, false, false); 1, nullptr, &hostPtr, nullptr, true, false, false);
EXPECT_EQ(&hostPtr, memObj.getBasePtrForMap()); EXPECT_EQ(&hostPtr, memObj.getBasePtrForMap());
@@ -122,7 +122,7 @@ TEST(MemObj, givenHostPtrWithoutUseHostPtrFlagWhenAskingForBaseMapPtrThenReturnA
uint8_t hostPtr = 0; uint8_t hostPtr = 0;
MockContext context; MockContext context;
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0,
1, nullptr, &hostPtr, nullptr, true, false, false); 1, nullptr, &hostPtr, nullptr, true, false, false);
EXPECT_NE(&hostPtr, memObj.getBasePtrForMap()); EXPECT_NE(&hostPtr, memObj.getBasePtrForMap());
@@ -134,7 +134,7 @@ TEST(MemObj, givenMemObjWhenReleaseAllocatedPtrIsCalledTwiceThenItDoesntCrash) {
MockContext context; MockContext context;
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0,
1, nullptr, nullptr, nullptr, true, false, false); 1, nullptr, nullptr, nullptr, true, false, false);
memObj.setAllocatedMapPtr(allocatedPtr); memObj.setAllocatedMapPtr(allocatedPtr);
@@ -152,7 +152,7 @@ TEST(MemObj, givenNotReadyGraphicsAllocationWhenMemObjDestroysAllocationAsyncThe
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
allocation->updateTaskCount(2, context.getDevice(0)->getDefaultEngine().osContext->getContextId()); allocation->updateTaskCount(2, context.getDevice(0)->getDefaultEngine().osContext->getContextId());
*(memoryManager->getDefaultCommandStreamReceiver(0)->getTagAddress()) = 1; *(memoryManager->getDefaultCommandStreamReceiver(0)->getTagAddress()) = 1;
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0,
MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false); MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false);
auto &allocationList = memoryManager->getDefaultCommandStreamReceiver(0)->getTemporaryAllocations(); auto &allocationList = memoryManager->getDefaultCommandStreamReceiver(0)->getTemporaryAllocations();
EXPECT_TRUE(allocationList.peekIsEmpty()); EXPECT_TRUE(allocationList.peekIsEmpty());
@@ -170,7 +170,7 @@ TEST(MemObj, givenReadyGraphicsAllocationWhenMemObjDestroysAllocationAsyncThenAl
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
allocation->updateTaskCount(1, device->getDefaultEngine().osContext->getContextId()); allocation->updateTaskCount(1, device->getDefaultEngine().osContext->getContextId());
*device->getDefaultEngine().commandStreamReceiver->getTagAddress() = 1; *device->getDefaultEngine().commandStreamReceiver->getTagAddress() = 1;
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0,
MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false); MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false);
auto &allocationList = device->getDefaultEngine().commandStreamReceiver->getTemporaryAllocations(); auto &allocationList = device->getDefaultEngine().commandStreamReceiver->getTemporaryAllocations();
@@ -187,7 +187,7 @@ TEST(MemObj, givenNotUsedGraphicsAllocationWhenMemObjDestroysAllocationAsyncThen
context.setMemoryManager(&memoryManager); context.setMemoryManager(&memoryManager);
auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0,
MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false); MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false);
auto &allocationList = memoryManager.getDefaultCommandStreamReceiver(0)->getTemporaryAllocations(); auto &allocationList = memoryManager.getDefaultCommandStreamReceiver(0)->getTemporaryAllocations();
@@ -205,7 +205,7 @@ TEST(MemObj, givenMemoryManagerWithoutDeviceWhenMemObjDestroysAllocationAsyncThe
auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0,
MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false); MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false);
auto &allocationList = memoryManager.getDefaultCommandStreamReceiver(0)->getTemporaryAllocations(); auto &allocationList = memoryManager.getDefaultCommandStreamReceiver(0)->getTemporaryAllocations();
@@ -221,7 +221,7 @@ TEST(MemObj, givenMemObjAndPointerToObjStorageWithProperCommandWhenCheckIfMemTra
context.setMemoryManager(&memoryManager); context.setMemoryManager(&memoryManager);
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0,
MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false); MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false);
void *ptr = memObj.getCpuAddressForMemoryTransfer(); void *ptr = memObj.getCpuAddressForMemoryTransfer();
bool isMemTransferNeeded = memObj.checkIfMemoryTransferIsRequired(0, 0, ptr, CL_COMMAND_WRITE_BUFFER); bool isMemTransferNeeded = memObj.checkIfMemoryTransferIsRequired(0, 0, ptr, CL_COMMAND_WRITE_BUFFER);
@@ -248,7 +248,7 @@ TEST(MemObj, givenMemObjAndPointerToObjStorageBadCommandWhenCheckIfMemTransferRe
context.setMemoryManager(&memoryManager); context.setMemoryManager(&memoryManager);
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0,
MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false); MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false);
void *ptr = memObj.getCpuAddressForMemoryTransfer(); void *ptr = memObj.getCpuAddressForMemoryTransfer();
bool isMemTransferNeeded = memObj.checkIfMemoryTransferIsRequired(0, 0, ptr, CL_COMMAND_FILL_BUFFER); bool isMemTransferNeeded = memObj.checkIfMemoryTransferIsRequired(0, 0, ptr, CL_COMMAND_FILL_BUFFER);
@@ -260,7 +260,7 @@ TEST(MemObj, givenMemObjAndPointerToDiffrentStorageAndProperCommandWhenCheckIfMe
context.setMemoryManager(&memoryManager); context.setMemoryManager(&memoryManager);
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0,
MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false); MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false);
void *ptr = (void *)0x1234; void *ptr = (void *)0x1234;
bool isMemTransferNeeded = memObj.checkIfMemoryTransferIsRequired(0, 0, ptr, CL_COMMAND_WRITE_BUFFER); bool isMemTransferNeeded = memObj.checkIfMemoryTransferIsRequired(0, 0, ptr, CL_COMMAND_WRITE_BUFFER);
@@ -272,7 +272,7 @@ TEST(MemObj, givenSharingHandlerWhenAskedForCpuMappingThenReturnFalse) {
MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment()); MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment());
auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0,
MemoryConstants::pageSize, nullptr, nullptr, allocation, true, false, false); MemoryConstants::pageSize, nullptr, nullptr, allocation, true, false, false);
memObj.setSharingHandler(new SharingHandler()); memObj.setSharingHandler(new SharingHandler());
EXPECT_FALSE(memObj.mappingOnCpuAllowed()); EXPECT_FALSE(memObj.mappingOnCpuAllowed());
@@ -283,7 +283,7 @@ TEST(MemObj, givenTiledObjectWhenAskedForCpuMappingThenReturnFalse) {
using MemObj::MemObj; using MemObj::MemObj;
bool isTiledAllocation() const override { return true; } bool isTiledAllocation() const override { return true; }
}; };
MyMemObj memObj(nullptr, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, MyMemObj memObj(nullptr, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0,
MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false); MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false);
EXPECT_FALSE(memObj.mappingOnCpuAllowed()); EXPECT_FALSE(memObj.mappingOnCpuAllowed());
@@ -298,7 +298,7 @@ TEST(MemObj, givenRenderCompressedGmmWhenAskingForMappingOnCpuThenDisallow) {
auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
allocation->setDefaultGmm(new Gmm(nullptr, 1, false)); allocation->setDefaultGmm(new Gmm(nullptr, 1, false));
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_READ_WRITE, MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_READ_WRITE, CL_MEM_READ_WRITE, 0,
1, allocation->getUnderlyingBuffer(), nullptr, allocation, false, false, false); 1, allocation->getUnderlyingBuffer(), nullptr, allocation, false, false, false);
allocation->getDefaultGmm()->isRenderCompressed = false; allocation->getDefaultGmm()->isRenderCompressed = false;
@@ -315,7 +315,7 @@ TEST(MemObj, givenDefaultWhenAskedForCpuMappingThenReturnTrue) {
auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0,
64, allocation->getUnderlyingBuffer(), nullptr, allocation, true, false, false); 64, allocation->getUnderlyingBuffer(), nullptr, allocation, true, false, false);
EXPECT_FALSE(memObj.isTiledAllocation()); EXPECT_FALSE(memObj.isTiledAllocation());
@@ -332,7 +332,7 @@ TEST(MemObj, givenNonCpuAccessibleMemoryWhenAskingForMappingOnCpuThenDisallow) {
auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
allocation->setDefaultGmm(new Gmm(nullptr, 1, false)); allocation->setDefaultGmm(new Gmm(nullptr, 1, false));
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_READ_WRITE, MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_READ_WRITE, CL_MEM_READ_WRITE, 0,
1, allocation->getUnderlyingBuffer(), nullptr, allocation, false, false, false); 1, allocation->getUnderlyingBuffer(), nullptr, allocation, false, false, false);
EXPECT_TRUE(memObj.mappingOnCpuAllowed()); EXPECT_TRUE(memObj.mappingOnCpuAllowed());
@@ -347,13 +347,13 @@ TEST(MemObj, givenMultipleMemObjectsWithReusedGraphicsAllocationWhenDestroyedThe
auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
std::unique_ptr<MemObj> memObj1(new MemObj(&context, CL_MEM_OBJECT_BUFFER, 0, 1, nullptr, nullptr, allocation, true, false, false)); std::unique_ptr<MemObj> memObj1(new MemObj(&context, CL_MEM_OBJECT_BUFFER, 0, 0, 0, 1, nullptr, nullptr, allocation, true, false, false));
memObj1->setSharingHandler(new MySharingHandler(allocation)); memObj1->setSharingHandler(new MySharingHandler(allocation));
std::unique_ptr<MemObj> memObj2(new MemObj(&context, CL_MEM_OBJECT_BUFFER, 0, 1, nullptr, nullptr, allocation, true, false, false)); std::unique_ptr<MemObj> memObj2(new MemObj(&context, CL_MEM_OBJECT_BUFFER, 0, 0, 0, 1, nullptr, nullptr, allocation, true, false, false));
memObj2->setSharingHandler(new MySharingHandler(allocation)); memObj2->setSharingHandler(new MySharingHandler(allocation));
std::unique_ptr<MemObj> memObj3(new MemObj(&context, CL_MEM_OBJECT_BUFFER, 0, 1, nullptr, nullptr, allocation, true, false, false)); std::unique_ptr<MemObj> memObj3(new MemObj(&context, CL_MEM_OBJECT_BUFFER, 0, 0, 0, 1, nullptr, nullptr, allocation, true, false, false));
memObj3->setSharingHandler(new MySharingHandler(allocation)); memObj3->setSharingHandler(new MySharingHandler(allocation));
EXPECT_EQ(3u, allocation->peekReuseCount()); EXPECT_EQ(3u, allocation->peekReuseCount());
@@ -370,7 +370,7 @@ TEST(MemObj, givenMemObjectWhenContextIsNotNullThenContextOutlivesMemobjects) {
MockContext context; MockContext context;
EXPECT_EQ(1, context.getRefInternalCount()); EXPECT_EQ(1, context.getRefInternalCount());
{ {
MemObj memObj(&context, 0, 0, 0, nullptr, nullptr, nullptr, false, false, false); MemObj memObj(&context, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr, false, false, false);
EXPECT_EQ(2, context.getRefInternalCount()); EXPECT_EQ(2, context.getRefInternalCount());
} }
EXPECT_EQ(1, context.getRefInternalCount()); EXPECT_EQ(1, context.getRefInternalCount());
@@ -382,7 +382,7 @@ TEST(MemObj, givenSharedMemObjectWithNullGfxAllocationWhenSettingGfxAllocationTh
context.setMemoryManager(&memoryManager); context.setMemoryManager(&memoryManager);
MockGraphicsAllocation *gfxAllocation = new MockGraphicsAllocation(nullptr, 0); MockGraphicsAllocation *gfxAllocation = new MockGraphicsAllocation(nullptr, 0);
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0,
1, nullptr, nullptr, nullptr, true, false, false); 1, nullptr, nullptr, nullptr, true, false, false);
memObj.setSharingHandler(new MySharingHandler(&memObj)); memObj.setSharingHandler(new MySharingHandler(&memObj));
@@ -399,7 +399,7 @@ TEST(MemObj, givenSharedMemObjectAndNullGfxAllocationProvidedWhenSettingGfxAlloc
context.setMemoryManager(&memoryManager); context.setMemoryManager(&memoryManager);
MockGraphicsAllocation *graphicsAllocation = new MockGraphicsAllocation(nullptr, 0); MockGraphicsAllocation *graphicsAllocation = new MockGraphicsAllocation(nullptr, 0);
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0,
1, nullptr, nullptr, graphicsAllocation, true, false, false); 1, nullptr, nullptr, graphicsAllocation, true, false, false);
memObj.setSharingHandler(new MySharingHandler(&memObj)); memObj.setSharingHandler(new MySharingHandler(&memObj));
@@ -416,7 +416,7 @@ TEST(MemObj, givenSharedMemObjectAndZeroReuseCountWhenChangingGfxAllocationThenO
MockGraphicsAllocation *oldGfxAllocation = new MockGraphicsAllocation(nullptr, 0); MockGraphicsAllocation *oldGfxAllocation = new MockGraphicsAllocation(nullptr, 0);
MockGraphicsAllocation *newGfxAllocation = new MockGraphicsAllocation(nullptr, 0); MockGraphicsAllocation *newGfxAllocation = new MockGraphicsAllocation(nullptr, 0);
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0,
1, nullptr, nullptr, oldGfxAllocation, true, false, false); 1, nullptr, nullptr, oldGfxAllocation, true, false, false);
memObj.setSharingHandler(new MySharingHandler(&memObj)); memObj.setSharingHandler(new MySharingHandler(&memObj));
@@ -435,7 +435,7 @@ TEST(MemObj, givenSharedMemObjectAndNonZeroReuseCountWhenChangingGfxAllocationTh
MockGraphicsAllocation *oldGfxAllocation = new MockGraphicsAllocation(nullptr, 0); MockGraphicsAllocation *oldGfxAllocation = new MockGraphicsAllocation(nullptr, 0);
MockGraphicsAllocation *newGfxAllocation = new MockGraphicsAllocation(nullptr, 0); MockGraphicsAllocation *newGfxAllocation = new MockGraphicsAllocation(nullptr, 0);
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0,
1, nullptr, nullptr, oldGfxAllocation, true, false, false); 1, nullptr, nullptr, oldGfxAllocation, true, false, false);
memObj.setSharingHandler(new MySharingHandler(&memObj)); memObj.setSharingHandler(new MySharingHandler(&memObj));
@@ -454,7 +454,7 @@ TEST(MemObj, givenNotSharedMemObjectWhenChangingGfxAllocationThenOldAllocationIs
MockGraphicsAllocation *oldGfxAllocation = new MockGraphicsAllocation(nullptr, 0); MockGraphicsAllocation *oldGfxAllocation = new MockGraphicsAllocation(nullptr, 0);
MockGraphicsAllocation *newGfxAllocation = new MockGraphicsAllocation(nullptr, 0); MockGraphicsAllocation *newGfxAllocation = new MockGraphicsAllocation(nullptr, 0);
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0,
1, nullptr, nullptr, oldGfxAllocation, true, false, false); 1, nullptr, nullptr, oldGfxAllocation, true, false, false);
memObj.resetGraphicsAllocation(newGfxAllocation); memObj.resetGraphicsAllocation(newGfxAllocation);
@@ -472,7 +472,7 @@ TEST(MemObj, givenGraphicsAllocationWhenCallingIsAllocDumpableThenItReturnsTheCo
TEST(MemObj, givenMemObjNotUsingHostPtrWhenGettingBasePtrTwiceReturnSameMapPtr) { TEST(MemObj, givenMemObjNotUsingHostPtrWhenGettingBasePtrTwiceReturnSameMapPtr) {
MockContext context; MockContext context;
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_READ_WRITE, MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_READ_WRITE, CL_MEM_READ_WRITE, 0,
1, nullptr, nullptr, nullptr, true, false, false); 1, nullptr, nullptr, nullptr, true, false, false);
void *mapPtr = memObj.getBasePtrForMap(); void *mapPtr = memObj.getBasePtrForMap();

View File

@@ -33,10 +33,10 @@ class MockBuffer : public MockBufferStorage, public Buffer {
using MockBufferStorage::device; using MockBufferStorage::device;
MockBuffer(GraphicsAllocation &alloc) MockBuffer(GraphicsAllocation &alloc)
: MockBufferStorage(), Buffer(nullptr, CL_MEM_USE_HOST_PTR, alloc.getUnderlyingBufferSize(), alloc.getUnderlyingBuffer(), alloc.getUnderlyingBuffer(), &alloc, true, false, false), : MockBufferStorage(), Buffer(nullptr, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, alloc.getUnderlyingBufferSize(), alloc.getUnderlyingBuffer(), alloc.getUnderlyingBuffer(), &alloc, true, false, false),
externalAlloc(&alloc) { externalAlloc(&alloc) {
} }
MockBuffer() : MockBufferStorage(), Buffer(nullptr, CL_MEM_USE_HOST_PTR, sizeof(data), &data, &data, &mockGfxAllocation, true, false, false) { MockBuffer() : MockBufferStorage(), Buffer(nullptr, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, sizeof(data), &data, &data, &mockGfxAllocation, true, false, false) {
} }
~MockBuffer() override { ~MockBuffer() override {
if (externalAlloc != nullptr) { if (externalAlloc != nullptr) {
@@ -54,9 +54,9 @@ class MockBuffer : public MockBufferStorage, public Buffer {
class AlignedBuffer : public MockBufferStorage, public Buffer { class AlignedBuffer : public MockBufferStorage, public Buffer {
public: public:
using MockBufferStorage::device; using MockBufferStorage::device;
AlignedBuffer() : MockBufferStorage(false), Buffer(nullptr, CL_MEM_USE_HOST_PTR, sizeof(data) / 2, alignUp(&data, 64), alignUp(&data, 64), &mockGfxAllocation, true, false, false) { AlignedBuffer() : MockBufferStorage(false), Buffer(nullptr, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 64), alignUp(&data, 64), &mockGfxAllocation, true, false, false) {
} }
AlignedBuffer(GraphicsAllocation *gfxAllocation) : MockBufferStorage(), Buffer(nullptr, CL_MEM_USE_HOST_PTR, sizeof(data) / 2, alignUp(&data, 64), alignUp(&data, 64), gfxAllocation, true, false, false) { AlignedBuffer(GraphicsAllocation *gfxAllocation) : MockBufferStorage(), Buffer(nullptr, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 64), alignUp(&data, 64), gfxAllocation, true, false, false) {
} }
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) override { void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) override {
Buffer::setSurfaceState(device.get(), memory, getSize(), getCpuAddress(), &mockGfxAllocation); Buffer::setSurfaceState(device.get(), memory, getSize(), getCpuAddress(), &mockGfxAllocation);
@@ -66,9 +66,9 @@ class AlignedBuffer : public MockBufferStorage, public Buffer {
class UnalignedBuffer : public MockBufferStorage, public Buffer { class UnalignedBuffer : public MockBufferStorage, public Buffer {
public: public:
using MockBufferStorage::device; using MockBufferStorage::device;
UnalignedBuffer() : MockBufferStorage(true), Buffer(nullptr, CL_MEM_USE_HOST_PTR, sizeof(data) / 2, alignUp(&data, 4), alignUp(&data, 4), &mockGfxAllocation, false, false, false) { UnalignedBuffer() : MockBufferStorage(true), Buffer(nullptr, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 4), alignUp(&data, 4), &mockGfxAllocation, false, false, false) {
} }
UnalignedBuffer(GraphicsAllocation *gfxAllocation) : MockBufferStorage(true), Buffer(nullptr, CL_MEM_USE_HOST_PTR, sizeof(data) / 2, alignUp(&data, 4), alignUp(&data, 4), gfxAllocation, false, false, false) { UnalignedBuffer(GraphicsAllocation *gfxAllocation) : MockBufferStorage(true), Buffer(nullptr, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 4), alignUp(&data, 4), gfxAllocation, false, false, false) {
} }
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) override { void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) override {
Buffer::setSurfaceState(device.get(), memory, getSize(), getCpuAddress(), &mockGfxAllocation); Buffer::setSurfaceState(device.get(), memory, getSize(), getCpuAddress(), &mockGfxAllocation);

View File

@@ -14,9 +14,10 @@ struct MockImageBase : public NEO::Image {
using Image::graphicsAllocation; using Image::graphicsAllocation;
using Image::imageDesc; using Image::imageDesc;
MockImageBase() : Image(nullptr, cl_mem_flags{}, 0, nullptr, cl_image_format{}, MockImageBase() : Image(
cl_image_desc{}, false, new NEO::MockGraphicsAllocation(nullptr, 0), false, nullptr, cl_mem_flags{}, cl_mem_flags{}, 0, 0, nullptr, cl_image_format{},
0, 0, NEO::SurfaceFormatInfo{}, nullptr) { cl_image_desc{}, false, new NEO::MockGraphicsAllocation(nullptr, 0), false,
0, 0, NEO::SurfaceFormatInfo{}, nullptr) {
} }
~MockImageBase() override { ~MockImageBase() override {
delete this->graphicsAllocation; delete this->graphicsAllocation;

View File

@@ -1330,7 +1330,7 @@ class DrmMockBuffer : public Buffer {
delete gfxAllocation; delete gfxAllocation;
} }
DrmMockBuffer(char *data, size_t size, DrmAllocation *alloc) : Buffer(nullptr, CL_MEM_USE_HOST_PTR, size, data, data, alloc, true, false, false), DrmMockBuffer(char *data, size_t size, DrmAllocation *alloc) : Buffer(nullptr, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, size, data, data, alloc, true, false, false),
data(data), data(data),
gfxAllocation(alloc) { gfxAllocation(alloc) {
} }

View File

@@ -80,7 +80,7 @@ TEST_F(glSharingTests, givenMockGlWhenGlBufferIsCreatedThenMemObjectHasGlHandler
EXPECT_EQ(bufferId, mockGlSharing->dllParam->getBufferInfo().bufferName); EXPECT_EQ(bufferId, mockGlSharing->dllParam->getBufferInfo().bufferName);
EXPECT_EQ(4096u, glBuffer->getSize()); EXPECT_EQ(4096u, glBuffer->getSize());
size_t flagsExpected = CL_MEM_READ_WRITE; size_t flagsExpected = CL_MEM_READ_WRITE;
EXPECT_EQ(flagsExpected, glBuffer->getFlags()); EXPECT_EQ(flagsExpected, glBuffer->getMemoryPropertiesFlags());
auto handler = glBuffer->peekSharingHandler(); auto handler = glBuffer->peekSharingHandler();
ASSERT_NE(nullptr, handler); ASSERT_NE(nullptr, handler);

View File

@@ -36,7 +36,7 @@ TEST(sharingHandler, givenMemObjWhenAcquireIncrementCounterThenReleaseShouldDecr
char buffer[64]; char buffer[64];
MockContext context; MockContext context;
MockGraphicsAllocation *mockAllocation = new MockGraphicsAllocation(buffer, sizeof(buffer)); MockGraphicsAllocation *mockAllocation = new MockGraphicsAllocation(buffer, sizeof(buffer));
std::unique_ptr<MemObj> memObj(new MemObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, std::unique_ptr<MemObj> memObj(new MemObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0,
sizeof(buffer), buffer, buffer, mockAllocation, true, false, false)); sizeof(buffer), buffer, buffer, mockAllocation, true, false, false));
struct MockSharingHandler : SharingHandler { struct MockSharingHandler : SharingHandler {
@@ -61,7 +61,7 @@ TEST(sharingHandler, givenMemObjWhenAcquireTwoTimesThenReleaseShouldBeCalledTwoT
char buffer[64]; char buffer[64];
MockContext context; MockContext context;
MockGraphicsAllocation *mockAllocation = new MockGraphicsAllocation(buffer, sizeof(buffer)); MockGraphicsAllocation *mockAllocation = new MockGraphicsAllocation(buffer, sizeof(buffer));
std::unique_ptr<MemObj> memObj(new MemObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, std::unique_ptr<MemObj> memObj(new MemObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0,
sizeof(buffer), buffer, buffer, mockAllocation, true, false, false)); sizeof(buffer), buffer, buffer, mockAllocation, true, false, false));
struct MockSharingHandler : SharingHandler { struct MockSharingHandler : SharingHandler {
@@ -106,7 +106,7 @@ TEST(sharingHandler, givenSharingHandlerWhenAcquiringThenReturnErrorCode) {
SharingHandler sharingHandler; SharingHandler sharingHandler;
MockContext context; MockContext context;
MockGraphicsAllocation *graphicsAllocation = new MockGraphicsAllocation(nullptr, 0); MockGraphicsAllocation *graphicsAllocation = new MockGraphicsAllocation(nullptr, 0);
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0,
1, nullptr, nullptr, graphicsAllocation, true, false, false); 1, nullptr, nullptr, graphicsAllocation, true, false, false);
auto result = sharingHandler.acquire(&memObj); auto result = sharingHandler.acquire(&memObj);

View File

@@ -398,7 +398,7 @@ TEST_F(VaSharingTests, givenSimpleParamsWhenCreateSurfaceIsCalledThenSetImgObjec
EXPECT_NE(0u, sharedImg->getImageDesc().image_row_pitch); EXPECT_NE(0u, sharedImg->getImageDesc().image_row_pitch);
EXPECT_EQ(0u, sharedImg->getHostPtrSlicePitch()); EXPECT_EQ(0u, sharedImg->getHostPtrSlicePitch());
EXPECT_NE(0u, sharedImg->getHostPtrRowPitch()); EXPECT_NE(0u, sharedImg->getHostPtrRowPitch());
EXPECT_TRUE(sharedImg->getFlags() == CL_MEM_READ_WRITE); EXPECT_TRUE(sharedImg->getMemoryPropertiesFlags() == CL_MEM_READ_WRITE);
EXPECT_TRUE(sharedImg->getCubeFaceIndex() == __GMM_NO_CUBE_MAP); EXPECT_TRUE(sharedImg->getCubeFaceIndex() == __GMM_NO_CUBE_MAP);
EXPECT_EQ(vaSharing->sharingHandle, sharedImg->getGraphicsAllocation()->peekSharedHandle()); EXPECT_EQ(vaSharing->sharingHandle, sharedImg->getGraphicsAllocation()->peekSharedHandle());