Skip to content

LiteFX::Rendering::VirtualAllocator::tryAllocate

Attempts to allocate a piece of memory of size bytes, aligned to alignment. If the allocation fails std::nullopt is returned.

Synopsis

Declared in <litefx/rendering_api.hpp>

[[dllimport, nodiscard, dllexport]] Optional<Allocation> tryAllocate(
    UInt64 size,
    UInt32 alignment = 1u,
    AllocationStrategy strategy = AllocationStrategy::OptimizePacking,
    void* privateData = nullptr) const;

Return Value

An object that contains details about the allocation, or std::nullopt if the allocation fails.

Note

The return value should not be discarded.

Parameters

NameDescription
sizeThe size (in bytes) of the resource to place in the allocation.
alignmentThe alignment requirements of the resource.
strategyThe strategy to look for a place to put the allocation in.
privateDataA pointer to an object that should be internally associated with the allocation.