2019-07-18 06:07:10 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 Intel Corporation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "common/helpers/bit_helpers.h"
|
2019-10-31 20:45:30 +08:00
|
|
|
#include "public/cl_ext_private.h"
|
2019-07-18 06:07:10 +08:00
|
|
|
#include "runtime/memory_manager/allocation_properties.h"
|
|
|
|
|
2019-08-12 16:36:23 +08:00
|
|
|
#include "memory_properties_flags.h"
|
2019-07-18 06:07:10 +08:00
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
|
|
|
|
class MemoryPropertiesParser {
|
|
|
|
public:
|
2019-08-29 14:59:15 +08:00
|
|
|
enum class ObjType {
|
|
|
|
UNKNOWN,
|
|
|
|
BUFFER,
|
|
|
|
IMAGE,
|
|
|
|
};
|
|
|
|
|
2019-10-23 01:51:53 +08:00
|
|
|
static bool parseMemoryProperties(const cl_mem_properties_intel *properties, MemoryPropertiesFlags &memoryProperties, cl_mem_flags &flags, cl_mem_flags_intel &flagsIntel, ObjType objectType);
|
2019-07-18 06:07:10 +08:00
|
|
|
|
2019-11-07 21:15:04 +08:00
|
|
|
static AllocationProperties getAllocationProperties(uint32_t rootDeviceIndex, MemoryPropertiesFlags memoryProperties, bool allocateMemory,
|
2019-07-18 06:07:10 +08:00
|
|
|
size_t size, GraphicsAllocation::AllocationType type, bool multiStorageResource) {
|
2019-11-07 21:15:04 +08:00
|
|
|
AllocationProperties allocationProperties(rootDeviceIndex, allocateMemory, size, type, multiStorageResource);
|
2019-07-18 06:07:10 +08:00
|
|
|
fillPoliciesInProperties(allocationProperties, memoryProperties);
|
|
|
|
return allocationProperties;
|
|
|
|
}
|
|
|
|
|
2019-08-12 16:36:23 +08:00
|
|
|
static void fillPoliciesInProperties(AllocationProperties &allocationProperties, const MemoryPropertiesFlags &memoryProperties);
|
2019-07-18 06:07:10 +08:00
|
|
|
|
|
|
|
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
|