mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00

-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>
45 lines
1.6 KiB
C++
45 lines
1.6 KiB
C++
/*
|
|
* Copyright (C) 2019 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
#include "common/helpers/bit_helpers.h"
|
|
#include "runtime/memory_manager/allocation_properties.h"
|
|
|
|
#include "mem_obj_types.h"
|
|
#include "memory_properties_flags.h"
|
|
|
|
namespace NEO {
|
|
|
|
class MemoryPropertiesParser {
|
|
public:
|
|
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) {
|
|
AllocationProperties allocationProperties(allocateMemory, size, type, multiStorageResource);
|
|
fillPoliciesInProperties(allocationProperties, memoryProperties);
|
|
return allocationProperties;
|
|
}
|
|
|
|
static void fillPoliciesInProperties(AllocationProperties &allocationProperties, const MemoryPropertiesFlags &memoryProperties);
|
|
|
|
static void fillCachePolicyInProperties(AllocationProperties &allocationProperties, bool uncached, bool readOnly,
|
|
bool deviceOnlyVisibilty) {
|
|
allocationProperties.flags.uncacheable = uncached;
|
|
auto cacheFlushRequired = !uncached && !readOnly && !deviceOnlyVisibilty;
|
|
allocationProperties.flags.flushL3RequiredForRead = cacheFlushRequired;
|
|
allocationProperties.flags.flushL3RequiredForWrite = cacheFlushRequired;
|
|
}
|
|
};
|
|
} // namespace NEO
|