2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2020-02-23 05:21:06 +08:00
|
|
|
* Copyright (C) 2017-2020 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-02-27 18:39:32 +08:00
|
|
|
#include <cinttypes>
|
|
|
|
#include <cstdlib>
|
2020-07-07 14:41:26 +08:00
|
|
|
#include <limits>
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
struct OsHandle;
|
2019-12-17 15:11:16 +08:00
|
|
|
struct ResidencyData;
|
2018-08-27 21:48:29 +08:00
|
|
|
|
|
|
|
using OsGraphicsHandle = OsHandle;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-10-22 20:20:05 +08:00
|
|
|
constexpr int maxFragmentsCount = 3;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-07-12 16:53:18 +08:00
|
|
|
enum class FragmentPosition {
|
2017-12-21 07:45:38 +08: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 16:53:18 +08:00
|
|
|
FragmentPosition fragmentPosition = FragmentPosition::NONE;
|
2017-12-21 07:45:38 +08:00
|
|
|
const void *allocationPtr = nullptr;
|
|
|
|
size_t allocationSize = 0u;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AllocationRequirements {
|
2019-08-07 14:31:20 +08:00
|
|
|
PartialAllocation allocationFragments[maxFragmentsCount];
|
2017-12-21 07:45:38 +08:00
|
|
|
uint64_t totalRequiredSize = 0u;
|
|
|
|
uint32_t requiredFragmentsCount = 0u;
|
2020-07-07 14:41:26 +08:00
|
|
|
uint32_t rootDeviceIndex = std::numeric_limits<uint32_t>::max();
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct FragmentStorage {
|
2018-03-27 20:01:04 +08:00
|
|
|
const void *fragmentCpuPointer = nullptr;
|
2017-12-21 07:45:38 +08:00
|
|
|
size_t fragmentSize = 0;
|
|
|
|
int refCount = 0;
|
|
|
|
OsHandle *osInternalStorage = nullptr;
|
|
|
|
ResidencyData *residency = nullptr;
|
2018-05-08 16:00:23 +08:00
|
|
|
bool driverAllocation = false;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct AllocationStorageData {
|
2019-07-29 22:11:51 +08:00
|
|
|
OsHandle *osHandleStorage = nullptr;
|
2017-12-21 07:45:38 +08:00
|
|
|
size_t fragmentSize = 0;
|
|
|
|
const void *cpuPtr = nullptr;
|
|
|
|
bool freeTheFragment = false;
|
|
|
|
ResidencyData *residency = nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct OsHandleStorage {
|
2018-10-22 20:20:05 +08:00
|
|
|
AllocationStorageData fragmentStorageData[maxFragmentsCount];
|
2017-12-21 07:45:38 +08:00
|
|
|
uint32_t fragmentCount = 0;
|
|
|
|
};
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|