mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 17:29:14 +08:00
Refactor flags validation
-create masks for buffer and image flags -create common file for mem_obj_helper -refactor parseMemoryProperties -remove: checkUsedFlagsForBuffer, checkUsedFlagsForImage, addCommonMemoryProperties, addBufferMemoryProperties, addExtraMemoryProperties, addImageMemoryProperties Related-To: NEO-3132 Change-Id: I3c147799de7b104d10d25b2f5262aeda58241d84 Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
7e14b981e1
commit
6a221bc7fc
@@ -591,7 +591,12 @@ cl_mem CL_API_CALL clCreateBuffer(cl_context context,
|
||||
|
||||
MemoryProperties propertiesStruct;
|
||||
propertiesStruct.flags = flags;
|
||||
Buffer::validateInputAndCreateBuffer(context, propertiesStruct, size, hostPtr, retVal, buffer);
|
||||
|
||||
if (isFieldValid(propertiesStruct.flags, MemObjHelper::validFlagsForBuffer)) {
|
||||
Buffer::validateInputAndCreateBuffer(context, propertiesStruct, size, hostPtr, retVal, buffer);
|
||||
} else {
|
||||
retVal = CL_INVALID_VALUE;
|
||||
}
|
||||
|
||||
err.set(retVal);
|
||||
DBG_LOG_INPUTS("buffer", buffer);
|
||||
@@ -616,10 +621,10 @@ cl_mem CL_API_CALL clCreateBufferWithPropertiesINTEL(cl_context context,
|
||||
ErrorCodeHelper err(errcodeRet, CL_SUCCESS);
|
||||
|
||||
MemoryProperties propertiesStruct;
|
||||
if (!MemoryPropertiesParser::parseMemoryProperties(properties, propertiesStruct)) {
|
||||
retVal = CL_INVALID_VALUE;
|
||||
} else {
|
||||
if (MemoryPropertiesParser::parseMemoryProperties(properties, propertiesStruct, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::BUFFER)) {
|
||||
Buffer::validateInputAndCreateBuffer(context, propertiesStruct, size, hostPtr, retVal, buffer);
|
||||
} else {
|
||||
retVal = CL_INVALID_VALUE;
|
||||
}
|
||||
|
||||
err.set(retVal);
|
||||
@@ -759,7 +764,11 @@ cl_mem CL_API_CALL clCreateImage(cl_context context,
|
||||
|
||||
if (retVal == CL_SUCCESS) {
|
||||
MemoryProperties propertiesStruct(flags);
|
||||
image = Image::validateAndCreateImage(pContext, propertiesStruct, imageFormat, imageDesc, hostPtr, retVal);
|
||||
if (isFieldValid(propertiesStruct.flags, MemObjHelper::validFlagsForImage)) {
|
||||
image = Image::validateAndCreateImage(pContext, propertiesStruct, imageFormat, imageDesc, hostPtr, retVal);
|
||||
} else {
|
||||
retVal = CL_INVALID_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
ErrorCodeHelper err(errcodeRet, retVal);
|
||||
@@ -794,7 +803,7 @@ cl_mem CL_API_CALL clCreateImageWithPropertiesINTEL(cl_context context,
|
||||
retVal = validateObjects(WithCastToInternal(context, &pContext));
|
||||
|
||||
if (retVal == CL_SUCCESS) {
|
||||
if (MemoryPropertiesParser::parseMemoryProperties(properties, propertiesStruct)) {
|
||||
if (MemoryPropertiesParser::parseMemoryProperties(properties, propertiesStruct, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::IMAGE)) {
|
||||
image = Image::validateAndCreateImage(pContext, propertiesStruct, imageFormat, imageDesc, hostPtr, retVal);
|
||||
} else {
|
||||
retVal = CL_INVALID_VALUE;
|
||||
|
||||
Reference in New Issue
Block a user