Files
compute-runtime/shared/source/helpers/bindless_heaps_helper.h
Mateusz Hoppe 67d39f88e6 feature: bindless addressing - store bindlessInfo in allocation
- store surface state info for bindless addressing in graphics
allocation
- remove map in BindlessHeapsHelper - bindlessInfo is constant for
the lifetime of an allocation
- program bindless offsets and surface states for images when used in
bindless kernel
- handle ouf of memory on surface state heap - return error

Related-To: NEO-7063

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
2023-07-24 14:48:35 +02:00

64 lines
2.0 KiB
C++

/*
* Copyright (C) 2020-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/helpers/constants.h"
#include "shared/source/helpers/heap_helper.h"
#include "shared/source/memory_manager/graphics_allocation.h"
#include <memory>
#include <mutex>
#include <unordered_map>
#include <vector>
namespace NEO {
class IndirectHeap;
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, DeviceBitfield deviceBitfield);
~BindlessHeapsHelper();
BindlessHeapsHelper(const BindlessHeapsHelper &) = delete;
BindlessHeapsHelper &operator=(const BindlessHeapsHelper &) = delete;
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 getDefaultBorderColorOffset();
uint32_t getAlphaBorderColorOffset();
IndirectHeap *getHeap(BindlesHeapType heapType);
void placeSSAllocationInReuseVectorOnFreeMemory(GraphicsAllocation *gfxAllocation);
bool isGlobalDshSupported() {
return globalBindlessDsh;
}
protected:
bool growHeap(BindlesHeapType heapType);
MemoryManager *memManager = nullptr;
bool isMultiOsContextCapable = false;
const uint32_t rootDeviceIndex;
std::unique_ptr<IndirectHeap> surfaceStateHeaps[BindlesHeapType::NUM_HEAP_TYPES];
GraphicsAllocation *borderColorStates;
std::vector<GraphicsAllocation *> ssHeapsAllocations;
std::vector<SurfaceStateInHeapInfo> surfaceStateInHeapVectorReuse;
std::mutex mtx;
DeviceBitfield deviceBitfield;
bool globalBindlessDsh = false;
};
} // namespace NEO