template<typename ResourceWrapperType>
ResourceReleaseQueue class
Facilitates safe resource destruction in D3D12 and Vulkan.
| Template parameters | |
|---|---|
| ResourceWrapperType | - Type of the resource wrapper used by the release queue. |
Contents
- Reference
Resource destruction is a two-stage process:
- When resource is released, it is moved into the stale objects queue along with the next command list number
- When command list is submitted to the command queue, all stale objects associated with this and earlier command lists are moved to the release queue, along with the fence value associated with the command list
- Resources are removed and actually destroyed from the queue when fence is signaled and the queue is Purged
Public static functions
-
template<typename ResourceType, typename = typename std::enable_if<std::is_object<ResourceType>::value>::type>static auto CreateWrapper(ResourceType&& Resource, Atomics::
Long NumReferences) -> ResourceWrapperType - Creates a resource wrapper for the specific resource type.
Public functions
-
template<typename ResourceType, typename = typename std::enable_if<std::is_object<ResourceType>::value>::type>void SafeReleaseResource(ResourceType&& Resource, Uint64 NextCommandListNumber)
- Moves a resource to the stale resources queue.
- void SafeReleaseResource(ResourceWrapperType&& Wrapper, Uint64 NextCommandListNumber)
- Moves a resource wrapper to the stale resources queue.
- void SafeReleaseResource(const ResourceWrapperType& Wrapper, Uint64 NextCommandListNumber)
- Moves a copy of the resource wrapper to the stale resources queue.
-
template<typename ResourceType, typename = typename std::enable_if<std::is_object<ResourceType>::value>::type>void DiscardResource(ResourceType&& Resource, Uint64 FenceValue)
- Adds a resource directly to the release queue.
- void DiscardResource(ResourceWrapperType&& Wrapper, Uint64 FenceValue)
- Adds a resource wrapper directly to the release queue.
- void DiscardResource(const ResourceWrapperType& Wrapper, Uint64 FenceValue)
- Adds a copy of the resource wrapper directly to the release queue.
-
template<typename ResourceType, typename IteratorType>void DiscardResources(Uint64 FenceValue, IteratorType Iterator)
- Adds multiple resources directly to the release queue.
- void DiscardStaleResources(Uint64 SubmittedCmdBuffNumber, Uint64 FenceValue)
- Moves stale objects to the release queue.
- void Purge(Uint64 CompletedFenceValue)
- Removes all objects from the release queue whose fence value is less than or equal to CompletedFenceValue.
- auto GetStaleResourceCount() const -> size_t
- Returns the number of stale resources.
- auto GetPendingReleaseResourceCount() const -> size_t
- Returns the number of resources pending release.
Function documentation
template<typename ResourceWrapperType>
template<typename ResourceType, typename = typename std::enable_if<std::is_object<ResourceType>::value>::type>
static ResourceWrapperType Diligent:: ResourceReleaseQueue<ResourceWrapperType>:: CreateWrapper(ResourceType&& Resource,
Atomics:: Long NumReferences)
Creates a resource wrapper for the specific resource type.
| Parameters | |
|---|---|
| Resource in | - Resource to be released |
| NumReferences in | - Number of references to the resource |
template<typename ResourceWrapperType>
template<typename ResourceType, typename = typename std::enable_if<std::is_object<ResourceType>::value>::type>
void Diligent:: ResourceReleaseQueue<ResourceWrapperType>:: SafeReleaseResource(ResourceType&& Resource,
Uint64 NextCommandListNumber)
Moves a resource to the stale resources queue.
| Parameters | |
|---|---|
| Resource in | - Resource to be released |
| NextCommandListNumber in | - Number of the command list that will be submitted to the queue next |
template<typename ResourceWrapperType>
void Diligent:: ResourceReleaseQueue<ResourceWrapperType>:: SafeReleaseResource(ResourceWrapperType&& Wrapper,
Uint64 NextCommandListNumber)
Moves a resource wrapper to the stale resources queue.
| Parameters | |
|---|---|
| Wrapper in | - Resource wrapper containing the resource to be released |
| NextCommandListNumber in | - Number of the command list that will be submitted to the queue next |
template<typename ResourceWrapperType>
void Diligent:: ResourceReleaseQueue<ResourceWrapperType>:: SafeReleaseResource(const ResourceWrapperType& Wrapper,
Uint64 NextCommandListNumber)
Moves a copy of the resource wrapper to the stale resources queue.
| Parameters | |
|---|---|
| Wrapper in | - Resource wrapper containing the resource to be released |
| NextCommandListNumber in | - Number of the command list that will be submitted to the queue next |
template<typename ResourceWrapperType>
template<typename ResourceType, typename = typename std::enable_if<std::is_object<ResourceType>::value>::type>
void Diligent:: ResourceReleaseQueue<ResourceWrapperType>:: DiscardResource(ResourceType&& Resource,
Uint64 FenceValue)
Adds a resource directly to the release queue.
| Parameters | |
|---|---|
| Resource in | - Resource to be released. |
| FenceValue in | - Fence value indicating when the resource was used last time. |
template<typename ResourceWrapperType>
void Diligent:: ResourceReleaseQueue<ResourceWrapperType>:: DiscardResource(ResourceWrapperType&& Wrapper,
Uint64 FenceValue)
Adds a resource wrapper directly to the release queue.
| Parameters | |
|---|---|
| Wrapper in | - Resource wrapper containing the resource to be released. |
| FenceValue in | - Fence value indicating when the resource was used last time. |
template<typename ResourceWrapperType>
void Diligent:: ResourceReleaseQueue<ResourceWrapperType>:: DiscardResource(const ResourceWrapperType& Wrapper,
Uint64 FenceValue)
Adds a copy of the resource wrapper directly to the release queue.
| Parameters | |
|---|---|
| Wrapper in | - Resource wrapper containing the resource to be released. |
| FenceValue in | - Fence value indicating when the resource was used last time. |
template<typename ResourceWrapperType>
template<typename ResourceType, typename IteratorType>
void Diligent:: ResourceReleaseQueue<ResourceWrapperType>:: DiscardResources(Uint64 FenceValue,
IteratorType Iterator)
Adds multiple resources directly to the release queue.
| Parameters | |
|---|---|
| FenceValue in | - Fence value indicating when the resource was used last time. |
| Iterator in | - Iterator that returns resources to be relased. |
template<typename ResourceWrapperType>
void Diligent:: ResourceReleaseQueue<ResourceWrapperType>:: DiscardStaleResources(Uint64 SubmittedCmdBuffNumber,
Uint64 FenceValue)
Moves stale objects to the release queue.
| Parameters | |
|---|---|
| SubmittedCmdBuffNumber in | - number of the last submitted command list. All resources in the stale object list whose command list number is less than or equal to this value are moved to the release queue. |
| FenceValue in | - Fence value associated with the resources moved to the release queue. A resource will be destroyed by Purge() method when completed fence value is greater or equal to the fence value associated with the resource |
template<typename ResourceWrapperType>
void Diligent:: ResourceReleaseQueue<ResourceWrapperType>:: Purge(Uint64 CompletedFenceValue)
Removes all objects from the release queue whose fence value is less than or equal to CompletedFenceValue.
| Parameters | |
|---|---|
| CompletedFenceValue in | - Value of the fence that has been completed by the GPU |