Nameless Engine
Loading...
Searching...
No Matches
ne::ContinuousDirectXDescriptorRange Class Reference

#include <DirectXDescriptorHeap.h>

Classes

struct  InternalData
 

Public Member Functions

 ContinuousDirectXDescriptorRange (const ContinuousDirectXDescriptorRange &other)=delete
 
ContinuousDirectXDescriptorRangeoperator= (const ContinuousDirectXDescriptorRange &other)=delete
 
 ContinuousDirectXDescriptorRange (ContinuousDirectXDescriptorRange &&other) noexcept=delete
 
ContinuousDirectXDescriptorRangeoperator= (ContinuousDirectXDescriptorRange &&other) noexcept=delete
 
size_t getRangeSize ()
 
size_t getRangeCapacity ()
 
INT getRangeStartInHeap ()
 
D3D12_GPU_DESCRIPTOR_HANDLE getGpuDescriptorHandleToRangeStart () const
 

Static Public Member Functions

static constexpr INT getRangeGrowSize ()
 

Private Member Functions

 ContinuousDirectXDescriptorRange (DirectXDescriptorHeap *pHeap, const std::function< void()> &onRangeIndicesChanged, const std::string &sRangeName)
 
std::optional< ErrormarkDescriptorAsUnused (DirectXDescriptor *pDescriptor)
 
std::variant< std::optional< INT >, ErrortryReserveFreeHeapIndexToCreateDescriptor ()
 

Private Attributes

std::pair< std::recursive_mutex, InternalDatamtxInternalData
 
const std::function< void()> onRangeIndicesChanged
 
const std::string sRangeName
 
DirectXDescriptorHeap *const pHeap = nullptr
 

Static Private Attributes

static constexpr INT iRangeGrowSize = 50
 

Friends

class DirectXDescriptorHeap
 

Detailed Description

Works as a mini descriptor heap that operates on descriptors in a continuous range (can be used for bindless bindings of descriptor arrays).

Remarks
Size of this range automatically changes (expands/shrinks) depending on the usage.

Constructor & Destructor Documentation

◆ ContinuousDirectXDescriptorRange()

ne::ContinuousDirectXDescriptorRange::ContinuousDirectXDescriptorRange ( DirectXDescriptorHeap pHeap,
const std::function< void()> &  onRangeIndicesChanged,
const std::string &  sRangeName 
)
private

Creates a new range (with capacity iRangeGrowSize but no descriptor is used) allocated in a descriptor heap.

Parameters
pHeapHeap that allocated the range.
onRangeIndicesChangedCallback that will be called after the range was moved in the heap due to things like heap expand/shrink.
sRangeNameName of this range (used for logging).

Member Function Documentation

◆ getGpuDescriptorHandleToRangeStart()

D3D12_GPU_DESCRIPTOR_HANDLE ne::ContinuousDirectXDescriptorRange::getGpuDescriptorHandleToRangeStart ( ) const

Returns a GPU descriptor handle to the current range start.

Warning
Returned handle is only valid for limited amount of time, until range is moved to other place in heap (because heap is being re-created for example).
Returns
GPU descriptor handle to range start.

◆ getRangeCapacity()

size_t ne::ContinuousDirectXDescriptorRange::getRangeCapacity ( )

Returns the total number of descriptors that this range can currently store.

Returns
Total capacity.

◆ getRangeGrowSize()

static constexpr INT ne::ContinuousDirectXDescriptorRange::getRangeGrowSize ( )
inlinestaticconstexpr

Returns grow/shrink size for all continuous descriptor ranges.

Returns
Grow/shrink size.

◆ getRangeSize()

size_t ne::ContinuousDirectXDescriptorRange::getRangeSize ( )

Returns the number of active (currently in-use) descriptors that were allocated from this range.

Returns
Active descriptors.

◆ getRangeStartInHeap()

INT ne::ContinuousDirectXDescriptorRange::getRangeStartInHeap ( )

Returns index of the first descriptor of this range in the heap.

Returns
Negative if not initialized yet, otherwise descriptor index in the heap.

◆ markDescriptorAsUnused()

std::optional< Error > ne::ContinuousDirectXDescriptorRange::markDescriptorAsUnused ( DirectXDescriptor pDescriptor)
private

Removes the specified descriptor from the range and marks descriptor's index as unused.

Remarks
Does not shrink the range.
Parameters
pDescriptorDescriptor to remove.
Returns
Error if something went wrong.

◆ tryReserveFreeHeapIndexToCreateDescriptor()

std::variant< std::optional< INT >, Error > ne::ContinuousDirectXDescriptorRange::tryReserveFreeHeapIndexToCreateDescriptor ( )
private

Looks if there is a free index in the range that can be used to create a new descriptor or if there is no space (expansion needed).

Remarks
Marks returned index as "in-use" and expects a new descriptor to be assigned to the range after this function.
Returns
Error if something went wrong, otherwise empty if no free space (expansion needed) or an index relative to heap start.

Member Data Documentation

◆ iRangeGrowSize

constexpr INT ne::ContinuousDirectXDescriptorRange::iRangeGrowSize = 50
staticconstexprprivate

Grow/shrink size for all ranges. Constant for all ranges because it causes the heap to be re-created and we want to avoid small ranges and big ranges (due to how heap expands/shrinks) which also depends on the heap grow size.

◆ mtxInternalData

std::pair<std::recursive_mutex, InternalData> ne::ContinuousDirectXDescriptorRange::mtxInternalData
private

Internal data.

◆ onRangeIndicesChanged

const std::function<void()> ne::ContinuousDirectXDescriptorRange::onRangeIndicesChanged
private

Called after the range was moved in the heap due to things like heap expand/shrink.

◆ pHeap

DirectXDescriptorHeap* const ne::ContinuousDirectXDescriptorRange::pHeap = nullptr
private

Heap that allocated the range.

◆ sRangeName

const std::string ne::ContinuousDirectXDescriptorRange::sRangeName
private

Name of this range (used for logging).


The documentation for this class was generated from the following files: