2020-10-19 10:02:28 +02:00
|
|
|
/*
|
2023-06-26 17:49:16 +00:00
|
|
|
* Copyright (C) 2020-2023 Intel Corporation
|
2020-10-19 10:02:28 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
#include "shared/source/helpers/constants.h"
|
|
|
|
|
#include "shared/source/helpers/heap_helper.h"
|
2023-07-21 11:55:22 +00:00
|
|
|
#include "shared/source/memory_manager/graphics_allocation.h"
|
2020-10-19 10:02:28 +02:00
|
|
|
|
|
|
|
|
#include <memory>
|
2021-01-27 14:31:29 +01:00
|
|
|
#include <mutex>
|
2020-10-19 10:02:28 +02:00
|
|
|
#include <unordered_map>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
|
|
|
|
|
|
class IndirectHeap;
|
|
|
|
|
|
|
|
|
|
class BindlessHeapsHelper {
|
|
|
|
|
public:
|
2020-11-03 11:42:35 +01:00
|
|
|
enum BindlesHeapType {
|
|
|
|
|
SPECIAL_SSH = 0,
|
|
|
|
|
GLOBAL_SSH,
|
|
|
|
|
GLOBAL_DSH,
|
|
|
|
|
NUM_HEAP_TYPES
|
|
|
|
|
};
|
2021-10-05 10:30:14 +00:00
|
|
|
BindlessHeapsHelper(MemoryManager *memManager, bool isMultiOsContextCapable, const uint32_t rootDeviceIndex, DeviceBitfield deviceBitfield);
|
2023-07-31 14:33:30 +00:00
|
|
|
MOCKABLE_VIRTUAL ~BindlessHeapsHelper();
|
2022-05-17 19:04:23 +00:00
|
|
|
|
|
|
|
|
BindlessHeapsHelper(const BindlessHeapsHelper &) = delete;
|
|
|
|
|
BindlessHeapsHelper &operator=(const BindlessHeapsHelper &) = delete;
|
|
|
|
|
|
2020-11-03 11:42:35 +01:00
|
|
|
GraphicsAllocation *getHeapAllocation(size_t heapSize, size_t alignment, bool allocInFrontWindow);
|
2020-10-19 10:02:28 +02:00
|
|
|
|
2023-07-31 14:33:30 +00:00
|
|
|
MOCKABLE_VIRTUAL SurfaceStateInHeapInfo allocateSSInHeap(size_t ssSize, GraphicsAllocation *surfaceAllocation, BindlesHeapType heapType);
|
2020-11-03 11:42:35 +01:00
|
|
|
uint64_t getGlobalHeapsBase();
|
|
|
|
|
void *getSpaceInHeap(size_t ssSize, BindlesHeapType heapType);
|
2021-05-17 10:08:54 +00:00
|
|
|
uint32_t getDefaultBorderColorOffset();
|
|
|
|
|
uint32_t getAlphaBorderColorOffset();
|
2020-11-26 09:04:26 +00:00
|
|
|
IndirectHeap *getHeap(BindlesHeapType heapType);
|
2021-01-27 14:31:29 +01:00
|
|
|
void placeSSAllocationInReuseVectorOnFreeMemory(GraphicsAllocation *gfxAllocation);
|
2023-06-26 17:49:16 +00:00
|
|
|
bool isGlobalDshSupported() {
|
|
|
|
|
return globalBindlessDsh;
|
|
|
|
|
}
|
2020-10-19 10:02:28 +02:00
|
|
|
|
2023-08-17 08:17:57 +00:00
|
|
|
int getReusedSshVectorIndex(size_t ssSize) {
|
|
|
|
|
int index = 0;
|
|
|
|
|
if (ssSize == 2 * surfaceStateSize) {
|
|
|
|
|
index = 1;
|
|
|
|
|
} else {
|
|
|
|
|
UNRECOVERABLE_IF(ssSize != surfaceStateSize);
|
|
|
|
|
}
|
|
|
|
|
return index;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-19 10:02:28 +02:00
|
|
|
protected:
|
2023-08-17 08:17:57 +00:00
|
|
|
const size_t surfaceStateSize;
|
2023-07-21 11:55:22 +00:00
|
|
|
bool growHeap(BindlesHeapType heapType);
|
2020-10-19 10:02:28 +02:00
|
|
|
MemoryManager *memManager = nullptr;
|
|
|
|
|
bool isMultiOsContextCapable = false;
|
|
|
|
|
const uint32_t rootDeviceIndex;
|
2020-11-03 11:42:35 +01:00
|
|
|
std::unique_ptr<IndirectHeap> surfaceStateHeaps[BindlesHeapType::NUM_HEAP_TYPES];
|
2020-10-19 10:02:28 +02:00
|
|
|
GraphicsAllocation *borderColorStates;
|
|
|
|
|
std::vector<GraphicsAllocation *> ssHeapsAllocations;
|
2023-08-17 08:17:57 +00:00
|
|
|
std::vector<SurfaceStateInHeapInfo> surfaceStateInHeapVectorReuse[2];
|
2021-01-27 14:31:29 +01:00
|
|
|
std::mutex mtx;
|
2021-10-05 10:30:14 +00:00
|
|
|
DeviceBitfield deviceBitfield;
|
2023-06-26 17:49:16 +00:00
|
|
|
bool globalBindlessDsh = false;
|
2020-10-19 10:02:28 +02:00
|
|
|
};
|
2022-05-17 19:04:23 +00:00
|
|
|
} // namespace NEO
|