This patch introduces a new Derived Resources concept to the compositor. Derived resources are resources that are computed from a particular result and cached in it in case it is needed by another operation, which can greatly improve performance in some cases at the cost of more memory usage. The first use case is to store denoised versions of the Denoising Albedo and Denoising Normals passes if auxiliary pass denoising is enabled in the denoise node. Consequently, multi-pass denoising setups where the same auxiliary passes are used in multiple denoise nodes should be much faster due to caching of the derived resources. This implementation has the limitation that it can't preemptively invalidate the cache when the derived resources are no longer needed to free up memory. This requires a special resource tracking mechanism that need to happen during node tree compilation, and will be submitted later. The limitation is not significant in the particular derived resources that is currently implemented. Since the auxiliary passes are rarely used outside of denoising. Fixes #131171. Pull Request: https://projects.blender.org/blender/blender/pulls/125671
37 lines
1.4 KiB
C++
37 lines
1.4 KiB
C++
/* SPDX-FileCopyrightText: 2025 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
#include "COM_denoised_auxiliary_pass.hh"
|
|
|
|
namespace blender::compositor {
|
|
|
|
/* -------------------------------------------------------------------------------------------------
|
|
* Derived Resources.
|
|
*
|
|
* Derived resources are resources that are computed from a particular result, stored in it, and
|
|
* freed when the result is freed. The same resources might be needed by multiple operations, so
|
|
* caching them on the result will improve performance at the cost of higher memory usage.
|
|
*
|
|
* The DerivedResources class stores instances of the container classes that store derived
|
|
* resources. This is very similar in design to the StaticCacheManager, see its description for
|
|
* more information. Destroying an instance of this class is expected to destroy all derived
|
|
* resources in it.
|
|
*
|
|
* To add a new derived resource:
|
|
*
|
|
* - Create a key class that can be used to identify the resource in a Map if needed.
|
|
* - Create a resource class to compute and store the resource.
|
|
* - Create a container class to store the resources in a map identified by their keys.
|
|
* - Add an instance of the container to the DerivedResources class.
|
|
*
|
|
* See the existing derived resources for reference. */
|
|
class DerivedResources {
|
|
public:
|
|
DenoisedAuxiliaryPassContainer denoised_auxiliary_passes;
|
|
};
|
|
|
|
} // namespace blender::compositor
|