2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2019-02-27 11:39:32 +01:00
|
|
|
* Copyright (C) 2017-2019 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
2018-09-05 15:17:52 +02:00
|
|
|
#include "runtime/memory_manager/residency.h"
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-02-27 11:39:32 +01:00
|
|
|
#include <cinttypes>
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
struct OsHandle;
|
2018-08-27 15:48:29 +02:00
|
|
|
|
|
|
|
|
using OsGraphicsHandle = OsHandle;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-10-22 14:20:05 +02:00
|
|
|
constexpr int maxFragmentsCount = 3;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-07-12 10:53:18 +02:00
|
|
|
enum class FragmentPosition {
|
2017-12-21 00:45:38 +01:00
|
|
|
NONE = 0,
|
|
|
|
|
LEADING,
|
|
|
|
|
MIDDLE,
|
|
|
|
|
TRAILING
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum OverlapStatus {
|
|
|
|
|
FRAGMENT_NOT_OVERLAPING_WITH_ANY_OTHER = 0,
|
|
|
|
|
FRAGMENT_WITHIN_STORED_FRAGMENT,
|
|
|
|
|
FRAGMENT_WITH_EXACT_SIZE_AS_STORED_FRAGMENT,
|
|
|
|
|
FRAGMENT_OVERLAPING_AND_BIGGER_THEN_STORED_FRAGMENT,
|
|
|
|
|
FRAGMENT_NOT_CHECKED
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum RequirementsStatus {
|
|
|
|
|
SUCCESS = 0,
|
|
|
|
|
FATAL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct PartialAllocation {
|
2018-07-12 10:53:18 +02:00
|
|
|
FragmentPosition fragmentPosition = FragmentPosition::NONE;
|
2017-12-21 00:45:38 +01:00
|
|
|
const void *allocationPtr = nullptr;
|
|
|
|
|
size_t allocationSize = 0u;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct AllocationRequirements {
|
2018-10-22 14:20:05 +02:00
|
|
|
PartialAllocation AllocationFragments[maxFragmentsCount];
|
2017-12-21 00:45:38 +01:00
|
|
|
uint64_t totalRequiredSize = 0u;
|
|
|
|
|
uint32_t requiredFragmentsCount = 0u;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct FragmentStorage {
|
2018-03-27 14:01:04 +02:00
|
|
|
const void *fragmentCpuPointer = nullptr;
|
2017-12-21 00:45:38 +01:00
|
|
|
size_t fragmentSize = 0;
|
|
|
|
|
int refCount = 0;
|
|
|
|
|
OsHandle *osInternalStorage = nullptr;
|
|
|
|
|
ResidencyData *residency = nullptr;
|
2018-05-08 10:00:23 +02:00
|
|
|
bool driverAllocation = false;
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct AllocationStorageData {
|
|
|
|
|
OsHandle *osHandleStorage;
|
|
|
|
|
size_t fragmentSize = 0;
|
|
|
|
|
const void *cpuPtr = nullptr;
|
|
|
|
|
bool freeTheFragment = false;
|
|
|
|
|
ResidencyData *residency = nullptr;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct OsHandleStorage {
|
2018-10-22 14:20:05 +02:00
|
|
|
AllocationStorageData fragmentStorageData[maxFragmentsCount];
|
2017-12-21 00:45:38 +01:00
|
|
|
uint32_t fragmentCount = 0;
|
|
|
|
|
OsHandleStorage() {
|
2018-10-22 14:20:05 +02:00
|
|
|
for (int i = 0; i < maxFragmentsCount; i++) {
|
2017-12-21 00:45:38 +01:00
|
|
|
fragmentStorageData[i].osHandleStorage = nullptr;
|
|
|
|
|
fragmentStorageData[i].cpuPtr = nullptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|