6#include <unordered_set>
13#include "render/directx/descriptors/DirectXDescriptor.h"
14#include "render/general/resources/GpuResource.h"
15#include "DirectXDescriptorType.hpp"
18#include "directx/d3dx12.h"
19#include "misc/Error.h"
25 using namespace Microsoft::WRL;
27 class DirectXRenderer;
28 class DirectXResource;
29 class DirectXDescriptorHeap;
32 enum class DescriptorHeapType :
int {
279 static std::variant<std::unique_ptr<DirectXDescriptorHeap>,
Error>
292 std::variant<std::unique_ptr<ContinuousDirectXDescriptorRange>,
Error>
294 const std::string& sRangeName,
const std::function<
void()>& onRangeIndicesChanged);
397 CD3DX12_CPU_DESCRIPTOR_HANDLE heapHandle,
399 DirectXDescriptorType descriptorType,
400 std::optional<size_t> cubemapFaceIndex)
const;
427 [[nodiscard]] std::variant<bool, Error>
442 [[nodiscard]] std::optional<Error>
484 DirectXDescriptorType descriptorType,
486 bool bBindDescriptorsToCubemapFaces =
true);
Definition: DirectXDescriptorHeap.h:44
size_t getRangeSize()
Definition: DirectXDescriptorHeap.cpp:1047
const std::string sRangeName
Definition: DirectXDescriptorHeap.h:184
std::variant< std::optional< INT >, Error > tryReserveFreeHeapIndexToCreateDescriptor()
Definition: DirectXDescriptorHeap.cpp:1109
INT getRangeStartInHeap()
Definition: DirectXDescriptorHeap.cpp:1057
size_t getRangeCapacity()
Definition: DirectXDescriptorHeap.cpp:1052
D3D12_GPU_DESCRIPTOR_HANDLE getGpuDescriptorHandleToRangeStart() const
Definition: DirectXDescriptorHeap.cpp:1062
const std::function< void()> onRangeIndicesChanged
Definition: DirectXDescriptorHeap.h:181
DirectXDescriptorHeap *const pHeap
Definition: DirectXDescriptorHeap.h:187
std::optional< Error > markDescriptorAsUnused(DirectXDescriptor *pDescriptor)
Definition: DirectXDescriptorHeap.cpp:1087
static constexpr INT iRangeGrowSize
Definition: DirectXDescriptorHeap.h:194
static constexpr INT getRangeGrowSize()
Definition: DirectXDescriptorHeap.h:68
std::pair< std::recursive_mutex, InternalData > mtxInternalData
Definition: DirectXDescriptorHeap.h:178
Definition: DirectXDescriptorHeap.h:198
INT getHeapSize()
Definition: DirectXDescriptorHeap.cpp:217
static std::string convertHeapTypeToString(DescriptorHeapType heapType)
Definition: DirectXDescriptorHeap.cpp:227
void onDescriptorRangeBeingDestroyed(ContinuousDirectXDescriptorRange *pRange)
Definition: DirectXDescriptorHeap.cpp:427
static std::variant< std::unique_ptr< DirectXDescriptorHeap >, Error > create(DirectXRenderer *pRenderer, DescriptorHeapType heapType)
Definition: DirectXDescriptorHeap.cpp:11
DirectXRenderer * pRenderer
Definition: DirectXDescriptorHeap.h:509
static constexpr INT getHeapGrowSize()
Definition: DirectXDescriptorHeap.h:269
void onDescriptorBeingDestroyed(DirectXDescriptor *pDescriptor, ContinuousDirectXDescriptorRange *pRange=nullptr)
Definition: DirectXDescriptorHeap.cpp:320
D3D12_DESCRIPTOR_HEAP_TYPE d3dHeapType
Definition: DirectXDescriptorHeap.h:524
std::string sHeapType
Definition: DirectXDescriptorHeap.h:521
std::optional< Error > expandRange(ContinuousDirectXDescriptorRange *pRange)
Definition: DirectXDescriptorHeap.cpp:542
std::variant< bool, Error > shrinkHeapIfPossible(ContinuousDirectXDescriptorRange *pChangedRange)
Definition: DirectXDescriptorHeap.cpp:574
~DirectXDescriptorHeap()
Definition: DirectXDescriptorHeap.cpp:286
std::vector< DirectXDescriptorType > getDescriptorTypesHandledByThisHeap() const
Definition: DirectXDescriptorHeap.cpp:912
UINT getDescriptorSize() const
Definition: DirectXDescriptorHeap.h:328
std::optional< Error > assignDescriptor(DirectXResource *pResource, DirectXDescriptorType descriptorType, ContinuousDirectXDescriptorRange *pRange=nullptr, bool bBindDescriptorsToCubemapFaces=true)
Definition: DirectXDescriptorHeap.cpp:47
static bool isShrinkingPossible(INT iSize, INT iCapacity, INT iGrowSize)
Definition: DirectXDescriptorHeap.cpp:520
std::pair< std::recursive_mutex, InternalData > mtxInternalData
Definition: DirectXDescriptorHeap.h:512
DescriptorHeapType heapType
Definition: DirectXDescriptorHeap.h:518
std::pair< std::recursive_mutex, InternalData > * getInternalData()
Definition: DirectXDescriptorHeap.h:344
std::variant< std::unique_ptr< ContinuousDirectXDescriptorRange >, Error > allocateContinuousDescriptorRange(const std::string &sRangeName, const std::function< void()> &onRangeIndicesChanged)
Definition: DirectXDescriptorHeap.cpp:25
std::optional< Error > expandHeap(ContinuousDirectXDescriptorRange *pChangedRange)
Definition: DirectXDescriptorHeap.cpp:472
size_t getNoLongerUsedDescriptorCount()
Definition: DirectXDescriptorHeap.cpp:222
std::optional< Error > rebindViewsUpdateIndices()
Definition: DirectXDescriptorHeap.cpp:927
UINT iDescriptorSize
Definition: DirectXDescriptorHeap.h:515
ID3D12DescriptorHeap * getInternalHeap() const
Definition: DirectXDescriptorHeap.h:335
void createView(CD3DX12_CPU_DESCRIPTOR_HANDLE heapHandle, const DirectXResource *pResource, DirectXDescriptorType descriptorType, std::optional< size_t > cubemapFaceIndex) const
Definition: DirectXDescriptorHeap.cpp:596
INT getHeapCapacity()
Definition: DirectXDescriptorHeap.cpp:212
static constexpr INT iHeapGrowSize
Definition: DirectXDescriptorHeap.h:527
std::optional< Error > createHeap(INT iCapacity, ContinuousDirectXDescriptorRange *pChangedRange)
Definition: DirectXDescriptorHeap.cpp:859
Definition: DirectXDescriptor.h:18
Definition: DirectXRenderer.h:36
Definition: DirectXResource.h:32
Definition: DirectXDescriptorHeap.h:103
std::unordered_set< DirectXDescriptor * > allocatedDescriptors
Definition: DirectXDescriptorHeap.h:112
INT iRangeStartInHeap
Definition: DirectXDescriptorHeap.h:123
INT iRangeCapacity
Definition: DirectXDescriptorHeap.h:126
std::queue< INT > noLongerUsedDescriptorIndices
Definition: DirectXDescriptorHeap.h:115
INT iNextFreeIndexInRange
Definition: DirectXDescriptorHeap.h:136
Definition: DirectXDescriptorHeap.h:210
std::queue< INT > noLongerUsedSingleDescriptorIndices
Definition: DirectXDescriptorHeap.h:243
std::unordered_set< ContinuousDirectXDescriptorRange * > continuousDescriptorRanges
Definition: DirectXDescriptorHeap.h:215
std::unordered_set< DirectXDescriptor * > bindedSingleDescriptors
Definition: DirectXDescriptorHeap.h:254
INT iNextFreeHeapIndex
Definition: DirectXDescriptorHeap.h:235
INT iHeapCapacity
Definition: DirectXDescriptorHeap.h:218
INT iHeapSize
Definition: DirectXDescriptorHeap.h:225
ComPtr< ID3D12DescriptorHeap > pHeap
Definition: DirectXDescriptorHeap.h:212