LiteFX::Rendering::IFrameBuffer::allocation_callback_type¶
A function that gets invoked as a callback, if the frame buffer needs to allocate an image.
Synopsis¶
Declared in <litefx/rendering_api.hpp>
template<typename TImage>
using allocation_callback_type = std::function<SharedPtr<TImage const>(Optional<UInt64>, Size2d, ResourceUsage, Format, MultiSamplingLevel, String const&)>;
Description¶
A frame buffer may allocate image resources, during it's initialization stage, as well as during resize events. The default behavior, if no callback is provided, is to re-create the image resource with the same parameters as it has been initialized with, except a different resolution. The resolution in this case is always equal to the frame buffer extent.
Defining render-targets that render at a different resolution is possible by providing an allocation callback that creates the resource externally. Another use case for this callback is to re-use images from a pool of potentially aliasing image resources. Only in case this callback returns nullptr the default behavior gets invoked.
Example¶
auto callback = [this]renderTargetId, Size2d size, ResourceUsage usage, Format format, MultiSamplingLevel samples, const String& name) { return m_device->factory().createTexture(name, format, size, ImageDimensions::DIM_2, 1u, 1u, samples, usage); // Emulates the default behavior. };