Skip to content

LiteFX::Rendering::Backends::DirectX12BottomLevelAccelerationStructure::update

Performs an update on the acceleration structure.

Synopsis

Declared in <litefx/backends/dx12.hpp>

[[dllimport, dllexport]] void update(
    DirectX12CommandBuffer const& commandBuffer,
    SharedPtr<IDirectX12Buffer const> const& scratchBuffer = nullptr,
    SharedPtr<IDirectX12Buffer const> const& buffer = nullptr,
    UInt64 offset = 0,
    UInt64 maxSize = 0);

Description

Updating an acceleration structure works similar to performing a build, but may be faster compared to a full re-build. Note that in order to support updates, the acceleration structure must have been created with the <see cref=AccelerationStructureFlags::AllowUpdate" /> flag provided. Note that this flag may cause the acceleration structure build times and memory consumption to increase and may lower the ray-tracing performance.

If no arguments beside commandBuffer are provided, the acceleration structure may re-use the same backing memory used for building, if the buffer holds enough space to contain it. Otherwise, a new buffer will be allocated. Alternatively, it is possible to provide a pre-allocated buffer in the buffer parameter. This allows to re-use memory from another acceleration structure, that no longer uses the memory. It is possible to store the buffer from an acceleration structure (acquired by calling buffer) and destroy it afterwards, which enables re-use scenarios for example for caching. Alternatively, it is possible store multiple acceleration structures within the same buffer, reducing overall memory consumption. This is done by also providing the offset and maxSize parameters to address a range within the buffer itself, the acceleration structure may be written into. Note that the pointer passed to the buffer parameter must have been initialized with the BufferType::AccelerationStructure buffer type and must be writable (ResourceUsage::AllowWrite).

By providing a scratchBuffer, it is possible to re-use temporary memory while building. This can lower memory consumption when building multiple acceleration structures. However, this also requires proper barriers to be executed between two build commands, as they are not allowed to access the same scratch memory simultaneously. Note that the pointer passed to the scratchBuffer parameter must have been initialized on the ResourceHeap::Resource heap and must be writable (ResourceUsage::AllowWrite).

After a successful update, the buffer pointer is stored by the acceleration structure and can be accessed by calling buffer on it.

Parameters

NameDescription
commandBufferThe command buffer used to record the acceleration structure build commands.
scratchBufferThe scratch buffer used during the acceleration structure build, or nullptr if a temporary buffer should be created.
bufferThe buffer that stores the acceleration structure after updating, or nullptr if a new buffer should be created.
offsetThe offset into buffer at which the acceleration structure should be stored. Must be a multiple of 256. Ignored if buffer is nullptr.
maxSizeThe maximum available size within buffer at offset. Ignored if buffer is nullptr.

See Also

build