UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VVMLocalAllocator.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#if WITH_VERSE_VM || defined(__INTELLISENSE__)
6
7#include "HAL/Platform.h" // IWYU pragma: keep
8#include "verse_local_allocator_ue.h"
9#include <cstddef>
10
11namespace Verse
12{
13class FSubspace;
14
15// This is really pas_local_allocator.
16struct alignas(PAS_LOCAL_ALLOCATOR_ALIGNMENT) FLocalAllocator final
17{
18 FLocalAllocator() = default;
20
21 void Initialize(FSubspace* Subspace, size_t Size)
22 {
23 verse_local_allocator_construct(reinterpret_cast<pas_local_allocator*>(this), reinterpret_cast<pas_heap*>(Subspace), Size, sizeof(FLocalAllocator));
24 }
25
26 void Stop()
27 {
28 verse_local_allocator_stop(reinterpret_cast<pas_local_allocator*>(this));
29 }
30
31 std::byte* Allocate()
32 {
33 return static_cast<std::byte*>(verse_local_allocator_allocate(reinterpret_cast<pas_local_allocator*>(this)));
34 }
35
36 std::byte* TryAllocate()
37 {
38 return static_cast<std::byte*>(verse_local_allocator_try_allocate(reinterpret_cast<pas_local_allocator*>(this)));
39 }
40
41private:
42 // It so happens to be the case that we only create FLocalAllocators on the UE side when it's for sizes that qualify for the small segregated page config variant.
43 // That variant may require a smaller local allocator size, because it has fewer bits, depending on system page size.
44 //
45 // If we ever started getting panics inside verse_local_allocator_construct() because our size was two small, we should change this to use
46 // VERSE_MAX_SEGREGATED_LOCAL_ALLOCATOR_SIZE instead.
47#if defined(__clang__)
48#pragma clang diagnostic push
49#pragma clang diagnostic ignored "-Wgnu-folding-constant"
50#pragma clang diagnostic ignored "-Wvla-cxx-extension"
51#endif // defined(__clang__)
53#if defined(__clang__)
54#pragma clang diagnostic pop
55#endif // defined(__clang__)
56};
57
58} // namespace Verse
59#endif // WITH_VERSE_VM
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
@ Stop
Definition PrecomputedVolumetricLightmapStreaming.cpp:26
uint32 Size
Definition VulkanMemory.cpp:4034
Definition Archive.h:36