2019-07-18 06:07:10 +08:00
|
|
|
/*
|
2019-12-30 21:40:24 +08:00
|
|
|
* Copyright (C) 2019-2020 Intel Corporation
|
2019-07-18 06:07:10 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/helpers/bit_helpers.h"
|
|
|
|
#include "shared/source/memory_manager/allocation_properties.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/extensions/public/cl_ext_private.h"
|
2019-07-18 06:07:10 +08:00
|
|
|
|
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-12-05 17:32:42 +08:00
|
|
|
static bool parseMemoryProperties(const cl_mem_properties_intel *properties, MemoryPropertiesFlags &memoryProperties,
|
|
|
|
cl_mem_flags &flags, cl_mem_flags_intel &flagsIntel, cl_mem_alloc_flags_intel &allocflags, 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
|