mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 23:03:02 +08:00
Dates corrected in copyright headers to reflect original publication date (2018 for OpenCL, 2020 for Level Zero). Signed-off-by: lgotszal <lukasz.gotszald@intel.com>
65 lines
2.1 KiB
C++
65 lines
2.1 KiB
C++
/*
|
|
* Copyright (C) 2020-2021 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
#include "shared/source/helpers/constants.h"
|
|
#include "shared/source/helpers/heap_helper.h"
|
|
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
|
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
|
|
namespace NEO {
|
|
|
|
constexpr size_t ssAligment = MemoryConstants::cacheLineSize;
|
|
|
|
class IndirectHeap;
|
|
class GraphicsAllocation;
|
|
|
|
struct SurfaceStateInHeapInfo {
|
|
GraphicsAllocation *heapAllocation;
|
|
uint64_t surfaceStateOffset;
|
|
void *ssPtr;
|
|
};
|
|
|
|
class BindlessHeapsHelper {
|
|
public:
|
|
enum BindlesHeapType {
|
|
SPECIAL_SSH = 0,
|
|
GLOBAL_SSH,
|
|
GLOBAL_DSH,
|
|
SCRATCH_SSH,
|
|
NUM_HEAP_TYPES
|
|
};
|
|
BindlessHeapsHelper(MemoryManager *memManager, bool isMultiOsContextCapable, const uint32_t rootDeviceIndex);
|
|
~BindlessHeapsHelper();
|
|
GraphicsAllocation *getHeapAllocation(size_t heapSize, size_t alignment, bool allocInFrontWindow);
|
|
|
|
SurfaceStateInHeapInfo allocateSSInHeap(size_t ssSize, GraphicsAllocation *surfaceAllocation, BindlesHeapType heapType);
|
|
uint64_t getGlobalHeapsBase();
|
|
void *getSpaceInHeap(size_t ssSize, BindlesHeapType heapType);
|
|
uint32_t getBorderColorOffset();
|
|
void setBorderColor(void *borderColor, size_t size);
|
|
IndirectHeap *getHeap(BindlesHeapType heapType);
|
|
void placeSSAllocationInReuseVectorOnFreeMemory(GraphicsAllocation *gfxAllocation);
|
|
|
|
protected:
|
|
void growHeap(BindlesHeapType heapType);
|
|
MemoryManager *memManager = nullptr;
|
|
bool isMultiOsContextCapable = false;
|
|
const uint32_t rootDeviceIndex;
|
|
uint32_t borderColorOffset = std::numeric_limits<uint32_t>::max();
|
|
std::unique_ptr<IndirectHeap> surfaceStateHeaps[BindlesHeapType::NUM_HEAP_TYPES];
|
|
GraphicsAllocation *borderColorStates;
|
|
std::vector<GraphicsAllocation *> ssHeapsAllocations;
|
|
std::vector<std::unique_ptr<SurfaceStateInHeapInfo>> surfaceStateInHeapVectorReuse;
|
|
std::unordered_map<GraphicsAllocation *, std::unique_ptr<SurfaceStateInHeapInfo>> surfaceStateInHeapAllocationMap;
|
|
std::mutex mtx;
|
|
};
|
|
} // namespace NEO
|