Nameless Engine
|
#include <DirectXDescriptorHeap.h>
Classes | |
struct | InternalData |
Public Member Functions | |
DirectXDescriptorHeap (const DirectXDescriptorHeap &)=delete | |
DirectXDescriptorHeap & | operator= (const DirectXDescriptorHeap &)=delete |
~DirectXDescriptorHeap () | |
std::variant< std::unique_ptr< ContinuousDirectXDescriptorRange >, Error > | allocateContinuousDescriptorRange (const std::string &sRangeName, const std::function< void()> &onRangeIndicesChanged) |
INT | getHeapCapacity () |
INT | getHeapSize () |
size_t | getNoLongerUsedDescriptorCount () |
UINT | getDescriptorSize () const |
ID3D12DescriptorHeap * | getInternalHeap () const |
std::pair< std::recursive_mutex, InternalData > * | getInternalData () |
Static Public Member Functions | |
static constexpr INT | getHeapGrowSize () |
static std::variant< std::unique_ptr< DirectXDescriptorHeap >, Error > | create (DirectXRenderer *pRenderer, DescriptorHeapType heapType) |
Protected Member Functions | |
DirectXDescriptorHeap (DirectXRenderer *pRenderer, DescriptorHeapType heapType) | |
void | onDescriptorBeingDestroyed (DirectXDescriptor *pDescriptor, ContinuousDirectXDescriptorRange *pRange=nullptr) |
void | onDescriptorRangeBeingDestroyed (ContinuousDirectXDescriptorRange *pRange) |
void | createView (CD3DX12_CPU_DESCRIPTOR_HANDLE heapHandle, const DirectXResource *pResource, DirectXDescriptorType descriptorType, std::optional< size_t > cubemapFaceIndex) const |
std::optional< Error > | expandHeap (ContinuousDirectXDescriptorRange *pChangedRange) |
std::variant< bool, Error > | shrinkHeapIfPossible (ContinuousDirectXDescriptorRange *pChangedRange) |
std::optional< Error > | createHeap (INT iCapacity, ContinuousDirectXDescriptorRange *pChangedRange) |
std::vector< DirectXDescriptorType > | getDescriptorTypesHandledByThisHeap () const |
std::optional< Error > | rebindViewsUpdateIndices () |
Static Protected Member Functions | |
static std::string | convertHeapTypeToString (DescriptorHeapType heapType) |
Private Member Functions | |
std::optional< Error > | assignDescriptor (DirectXResource *pResource, DirectXDescriptorType descriptorType, ContinuousDirectXDescriptorRange *pRange=nullptr, bool bBindDescriptorsToCubemapFaces=true) |
std::optional< Error > | expandRange (ContinuousDirectXDescriptorRange *pRange) |
Static Private Member Functions | |
static bool | isShrinkingPossible (INT iSize, INT iCapacity, INT iGrowSize) |
Private Attributes | |
DirectXRenderer * | pRenderer |
std::pair< std::recursive_mutex, InternalData > | mtxInternalData |
UINT | iDescriptorSize = 0 |
DescriptorHeapType | heapType |
std::string | sHeapType |
D3D12_DESCRIPTOR_HEAP_TYPE | d3dHeapType |
Static Private Attributes | |
static constexpr INT | iHeapGrowSize = 300 |
Friends | |
class | DirectXDescriptor |
class | ContinuousDirectXDescriptorRange |
class | DirectXResource |
Represents a descriptor heap.
ne::DirectXDescriptorHeap::~DirectXDescriptorHeap | ( | ) |
Makes sure no descriptor or range exists.
|
protected |
Constructor.
pRenderer | DirectX renderer that owns this manager. |
heapType | Type of the heap. |
std::variant< std::unique_ptr< ContinuousDirectXDescriptorRange >, Error > ne::DirectXDescriptorHeap::allocateContinuousDescriptorRange | ( | const std::string & | sRangeName, |
const std::function< void()> & | onRangeIndicesChanged | ||
) |
Allocates a continuous range of descriptors that can be used for bindless bindings of descriptor arrays.
sRangeName | Name of the range (used for logging). |
onRangeIndicesChanged | Callback that will be called after the range was moved in the heap due to things like heap expand/shrink. |
|
private |
Creates a new descriptor that points to the given resource, the descriptor is saved in the resource.
pResource | Resource to point new descriptor to. |
descriptorType | Type of the new descriptor. |
pRange | Specify in order to allocate a descriptor from this range. |
bBindDescriptorsToCubemapFaces | If this resource is a cubemap, specify true to also bind descriptors that reference specific cubemap faces, specify false to only bind 1 descriptor that references the entire resource. |
|
staticprotected |
Converts heap type to string.
heapType | Heap type to convert to text. |
|
static |
Creates a new manager that controls a specific heap.
pRenderer | DirectX renderer that owns this manager. |
heapType | Heap type that this manager will control. |
|
protected |
(Re)creates the heap with the specified capacity.
iCapacity | Size of the heap (in descriptors). |
pChangedRange | If this event was caused by changes in descriptor range, specify one for logging purposes. |
|
protected |
Creates a new view using the specified descriptor handle that will point to the specified resource.
heapHandle | A place in the heap to create view. |
pResource | Resource to bind to the new view. |
descriptorType | Descriptor type. |
cubemapFaceIndex | Specify empty if creating a view for the entire resource, otherwise specify index of the cubemap face to bind the descriptor to. |
|
protected |
Re-creates the heap to expand its capacity to support iHeapGrowSize more descriptors.
pChangedRange | If this event was caused by changes in descriptor range, specify one for logging purposes. |
|
private |
Expands the specified descriptor range and expands or re-creates the heap to support updated range.
pRange | Range to expand. |
|
inline |
Returns size of one descriptor in this heap.
|
protected |
Returns an array of descriptor types that this heap handles. For example: for RTV heap it will only be RTV descriptor type, for DSV - DSV, for CBV/UAV/SRV heap it will be CBV, UAV and SRV (3 types).
INT ne::DirectXDescriptorHeap::getHeapCapacity | ( | ) |
Returns current heap capacity (allocated heap size).
This function is used for engine testing and generally should not be used outside of testing.
|
inlinestaticconstexpr |
Returns grow/shrink size for the heap.
INT ne::DirectXDescriptorHeap::getHeapSize | ( | ) |
Returns current heap size (actually used heap size).
This function is used for engine testing and generally should not be used outside of testing.
|
inline |
Returns internal data of the object.
|
inline |
Returns internal DirectX heap.
size_t ne::DirectXDescriptorHeap::getNoLongerUsedDescriptorCount | ( | ) |
Returns amount of descriptors that were created but no longer being used.
|
staticprivate |
Checks shrink condition: if capacity can be decremented by grow size with the current size.
iSize | Current size. |
iCapacity | Current capacity. |
iGrowSize | Grow/shrink size. Expected to be even. |
true
if capacity can be decremented by one grow size, false
if not yet.
|
protected |
Marks resource descriptor as no longer being used so the descriptor's index can be reused by some other descriptor.
pDescriptor | Descriptor that is being destroyed. |
pRange | Range that allocated the descriptor (if the descriptor was allocated from a range). |
|
protected |
Notifies the heap about some range being destroyed.
pRange | Range that is being destroyed. |
|
protected |
Recreates views for previously created descriptors so that they will reference the new re-created heap and reference the correct index inside of the heap.
|
protected |
Checks if the heap can be shrinked (based on the current internal state mtxInternalData) and if possible re-creates the heap to shrink its capacity to support iHeapGrowSize less descriptors.
pChangedRange | If this event was caused by changes in descriptor range, specify one for logging purposes. |
true
if heap was shrinked, false
if no shrinking is needed yet.
|
private |
Direct3D type of this heap.
|
private |
Type of the heap.
|
private |
Size of one descriptor.
|
staticconstexprprivate |
Number of descriptors to add to the heap when there is no more free space left.
|
private |
Descriptor heap internal resources.
|
private |
Do not delete. Owner renderer.
|
private |
String version of heap type (used for logging).