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:
Krzysztof Gibala
2019-08-29 08:59:15 +02:00
committed by sys_ocldev
parent 7e14b981e1
commit 6a221bc7fc
9 changed files with 266 additions and 163 deletions

View File

@@ -7,9 +7,11 @@
#include "runtime/helpers/mem_properties_parser_helper.h"
#include "runtime/mem_obj/mem_obj_helper.h"
namespace NEO {
bool NEO::MemoryPropertiesParser::parseMemoryProperties(const cl_mem_properties_intel *properties, MemoryProperties &propertiesStruct) {
bool NEO::MemoryPropertiesParser::parseMemoryProperties(const cl_mem_properties_intel *properties, MemoryProperties &propertiesStruct, ObjType objectType) {
if (properties == nullptr) {
return true;
}
@@ -26,6 +28,17 @@ bool NEO::MemoryPropertiesParser::parseMemoryProperties(const cl_mem_properties_
return false;
}
}
switch (objectType) {
case MemoryPropertiesParser::ObjType::BUFFER:
return isFieldValid(propertiesStruct.flags, MemObjHelper::validFlagsForBuffer) &&
isFieldValid(propertiesStruct.flags_intel, MemObjHelper::validFlagsForBufferIntel);
case MemoryPropertiesParser::ObjType::IMAGE:
return isFieldValid(propertiesStruct.flags, MemObjHelper::validFlagsForImage) &&
isFieldValid(propertiesStruct.flags_intel, MemObjHelper::validFlagsForImageIntel);
default:
break;
}
return true;
}

View File

@@ -16,7 +16,13 @@ namespace NEO {
class MemoryPropertiesParser {
public:
static bool parseMemoryProperties(const cl_mem_properties_intel *properties, MemoryProperties &propertiesStruct);
enum class ObjType {
UNKNOWN,
BUFFER,
IMAGE,
};
static bool parseMemoryProperties(const cl_mem_properties_intel *properties, MemoryProperties &propertiesStruct, ObjType objectType);
static AllocationProperties getAllocationProperties(MemoryPropertiesFlags memoryProperties, bool allocateMemory,
size_t size, GraphicsAllocation::AllocationType type, bool multiStorageResource) {