From ddc07f92b954fe99a61babff946098dad1737290 Mon Sep 17 00:00:00 2001 From: Vladislav Belov Date: Thu, 22 Oct 2026 23:22:33 +0200 Subject: [PATCH] Replaces legacy ProxyAllocator by AllocatorAdapter --- source/graphics/ParticleEmitter.cpp | 6 +++--- source/graphics/TextRenderer.cpp | 6 +++--- source/graphics/TextRenderer.h | 8 ++++---- source/gui/GUIObjectEventBroadcaster.h | 4 ++-- source/ps/memory/tests/test_LinearAllocator.h | 12 ++++++------ source/renderer/DecalRData.cpp | 4 ++-- source/renderer/ModelRenderer.cpp | 18 +++++++++--------- source/renderer/PatchRData.cpp | 14 +++++++------- 8 files changed, 36 insertions(+), 36 deletions(-) diff --git a/source/graphics/ParticleEmitter.cpp b/source/graphics/ParticleEmitter.cpp index 20d2513a7d..a9fab76e26 100644 --- a/source/graphics/ParticleEmitter.cpp +++ b/source/graphics/ParticleEmitter.cpp @@ -25,12 +25,12 @@ #include "graphics/ParticleManager.h" #include "graphics/RenderableObject.h" #include "graphics/TextureManager.h" -#include "lib/allocators/STLAllocators.h" #include "lib/debug.h" #include "maths/Matrix3D.h" -#include "ps/memory/LinearAllocator.h" #include "ps/CStrIntern.h" #include "ps/CStrInternStatic.h" +#include "ps/memory/AllocatorAdapter.h" +#include "ps/memory/LinearAllocator.h" #include "renderer/Renderer.h" #include "renderer/Scene.h" #include "renderer/SceneRenderer.h" @@ -183,7 +183,7 @@ void CParticleEmitter::UpdateArrayData(int frameNumber) PS::Memory::ScopedLinearAllocator scopedLinearAllocator{g_Renderer.GetLinearAllocator()}; - using ParticlesVector = std::vector>; + using ParticlesVector = std::vector>; ParticlesVector sortedParticles((ParticlesVector::allocator_type(scopedLinearAllocator))); m_LastFrameNumber = frameNumber; diff --git a/source/graphics/TextRenderer.cpp b/source/graphics/TextRenderer.cpp index 49b4b14c9d..586e7676a7 100644 --- a/source/graphics/TextRenderer.cpp +++ b/source/graphics/TextRenderer.cpp @@ -210,9 +210,9 @@ void CTextRenderer::Render( const CVector2D& transformScale, const CVector2D& translation, const bool debugFontBox, const CColor& debugBoxColor) { - std::vector> indices{m_ScopedLinearAllocator}; - std::vector> positions{m_ScopedLinearAllocator}; - std::vector> uvs{m_ScopedLinearAllocator}; + std::vector> indices{m_ScopedLinearAllocator}; + std::vector> positions{m_ScopedLinearAllocator}; + std::vector> uvs{m_ScopedLinearAllocator}; // Try to merge non-consecutive batches that share the same font/color/translate: // sort the batch list by font, then merge the runs of adjacent compatible batches diff --git a/source/graphics/TextRenderer.h b/source/graphics/TextRenderer.h index 2846644e29..e52678f5f8 100644 --- a/source/graphics/TextRenderer.h +++ b/source/graphics/TextRenderer.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2025 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -19,10 +19,10 @@ #define INCLUDED_TEXTRENDERER #include "graphics/Color.h" -#include "lib/allocators/STLAllocators.h" #include "maths/Rect.h" #include "maths/Vector2D.h" #include "ps/CStrIntern.h" +#include "ps/memory/AllocatorAdapter.h" #include "ps/memory/LinearAllocator.h" #include @@ -161,7 +161,7 @@ private: CVector2D translate; CColor color; CFont* font; - using SBatchRunList = std::list>; + using SBatchRunList = std::list>; SBatchRunList runs; SBatch(PS::Memory::ScopedLinearAllocator& allocator) : runs{allocator} {} @@ -180,7 +180,7 @@ private: bool m_Dirty = true; - using SBatchList = std::list>; + using SBatchList = std::list>; SBatchList m_Batches; }; diff --git a/source/gui/GUIObjectEventBroadcaster.h b/source/gui/GUIObjectEventBroadcaster.h index 0b66e8e14b..5f5311633e 100644 --- a/source/gui/GUIObjectEventBroadcaster.h +++ b/source/gui/GUIObjectEventBroadcaster.h @@ -23,7 +23,7 @@ #include "gui/ObjectBases/IGUIObject.h" #include "lib/alignment.h" #include "lib/allocators/DynamicArena.h" -#include "lib/allocators/STLAllocators.h" +#include "ps/memory/AllocatorAdapter.h" #include #include @@ -60,7 +60,7 @@ public: static void RecurseVisibleObject(IGUIObject* object, void(IGUIObject::* callbackFunction)(Args... args), Args&&... args) { using Arena = Allocators::DynamicArena<128 * KiB>; - using ObjectListAllocator = ProxyAllocator; + using ObjectListAllocator = PS::Memory::AllocatorAdapter; Arena arena; std::vector visibleObjects((ObjectListAllocator(arena))); diff --git a/source/ps/memory/tests/test_LinearAllocator.h b/source/ps/memory/tests/test_LinearAllocator.h index 2bfe6bedee..7329f0dd63 100644 --- a/source/ps/memory/tests/test_LinearAllocator.h +++ b/source/ps/memory/tests/test_LinearAllocator.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2025 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -17,7 +17,7 @@ #include "lib/self_test.h" -#include "lib/allocators/STLAllocators.h" +#include "ps/memory/AllocatorAdapter.h" #include "ps/memory/LinearAllocator.h" #include @@ -67,10 +67,10 @@ public: { PS::Memory::ScopedLinearAllocator scopedAllocator1{allocator}; PS::Memory::ScopedLinearAllocator scopedAllocator2{allocator}; - ProxyAllocator proxyAllocator1{scopedAllocator1}; - ProxyAllocator proxyAllocator2{scopedAllocator2}; - TS_ASSERT_EQUALS(proxyAllocator1, proxyAllocator1); - TS_ASSERT_DIFFERS(proxyAllocator1, proxyAllocator2); + PS::Memory::AllocatorAdapter allocatorAdapter1{scopedAllocator1}; + PS::Memory::AllocatorAdapter allocatorAdapter2{scopedAllocator2}; + TS_ASSERT_EQUALS(allocatorAdapter1, allocatorAdapter1); + TS_ASSERT_DIFFERS(allocatorAdapter1, allocatorAdapter2); } } diff --git a/source/renderer/DecalRData.cpp b/source/renderer/DecalRData.cpp index adeb20cecd..e9b7bdf539 100644 --- a/source/renderer/DecalRData.cpp +++ b/source/renderer/DecalRData.cpp @@ -29,13 +29,13 @@ #include "graphics/Terrain.h" #include "graphics/TextureManager.h" #include "lib/alignment.h" -#include "lib/allocators/STLAllocators.h" #include "lib/debug.h" #include "lib/posix/posix_types.h" #include "maths/Matrix3D.h" #include "ps/CLogger.h" #include "ps/CStrIntern.h" #include "ps/CStrInternStatic.h" +#include "ps/memory/AllocatorAdapter.h" #include "ps/memory/LinearAllocator.h" #include "ps/Profile.h" #include "renderer/Renderer.h" @@ -145,7 +145,7 @@ void CDecalRData::RenderDecals( PS::Memory::ScopedLinearAllocator scopedLinearAllocator{g_Renderer.GetLinearAllocator()}; - using Batches = std::vector>; + using Batches = std::vector>; Batches batches((Batches::allocator_type(scopedLinearAllocator))); batches.reserve(decals.size()); diff --git a/source/renderer/ModelRenderer.cpp b/source/renderer/ModelRenderer.cpp index 995fd96fa2..40fa1730d5 100644 --- a/source/renderer/ModelRenderer.cpp +++ b/source/renderer/ModelRenderer.cpp @@ -31,7 +31,6 @@ #include "graphics/Texture.h" #include "graphics/TextureManager.h" #include "lib/alignment.h" -#include "lib/allocators/STLAllocators.h" #include "lib/debug.h" #include "lib/hash.h" #include "maths/Matrix3D.h" @@ -40,6 +39,7 @@ #include "ps/CLogger.h" #include "ps/CStrIntern.h" #include "ps/CStrInternStatic.h" +#include "ps/memory/AllocatorAdapter.h" #include "ps/memory/LinearAllocator.h" #include "ps/Profile.h" #include "renderer/MikktspaceWrap.h" @@ -349,14 +349,14 @@ void ModelRenderer::Render( PS::Memory::ScopedLinearAllocator scopedLinearAllocator{g_Renderer.GetLinearAllocator()}; - using ModelListAllocator = ProxyAllocator; + using ModelListAllocator = PS::Memory::AllocatorAdapter; using ModelList_t = std::vector; using MaterialBuckets_t = std::unordered_map< SMRMaterialBucketKey, ModelList_t, SMRMaterialBucketKeyHash, std::equal_to, - ProxyAllocator< + PS::Memory::AllocatorAdapter< std::pair, PS::Memory::ScopedLinearAllocator>>; @@ -387,10 +387,10 @@ void ModelRenderer::Render( } } - using SortByDistItemsAllocator = ProxyAllocator; + using SortByDistItemsAllocator = PS::Memory::AllocatorAdapter; std::vector sortByDistItems((SortByDistItemsAllocator(scopedLinearAllocator))); - using SortByTechItemsAllocator = ProxyAllocator; + using SortByTechItemsAllocator = PS::Memory::AllocatorAdapter; std::vector sortByDistTechs((SortByTechItemsAllocator(scopedLinearAllocator))); // indexed by sortByDistItems[i].techIdx // (which stores indexes instead of CShaderTechniquePtr directly @@ -398,7 +398,7 @@ void ModelRenderer::Render( // if we just stored raw CShaderTechnique* and assumed the shader manager // will keep it alive long enough) - using TechBucketsAllocator = ProxyAllocator; + using TechBucketsAllocator = PS::Memory::AllocatorAdapter; std::vector techBuckets((TechBucketsAllocator(scopedLinearAllocator))); { @@ -514,18 +514,18 @@ void ModelRenderer::Render( // This vector keeps track of texture changes during rendering. It is kept outside the // loops to avoid excessive reallocations. The token allocation of 64 elements // should be plenty, though it is reallocated below (at a cost) if necessary. - using TextureListAllocator = ProxyAllocator; + using TextureListAllocator = PS::Memory::AllocatorAdapter; std::vector currentTexs((TextureListAllocator(scopedLinearAllocator))); currentTexs.reserve(64); // texBindings holds the identifier bindings in the shader, which can no longer be defined // statically in the ShaderRenderModifier class. texBindingNames uses interned strings to // keep track of when bindings need to be reevaluated. - using BindingListAllocator = ProxyAllocator; + using BindingListAllocator = PS::Memory::AllocatorAdapter; std::vector texBindings((BindingListAllocator(scopedLinearAllocator))); texBindings.reserve(64); - using BindingNamesListAllocator = ProxyAllocator; + using BindingNamesListAllocator = PS::Memory::AllocatorAdapter; std::vector texBindingNames((BindingNamesListAllocator(scopedLinearAllocator))); texBindingNames.reserve(64); diff --git a/source/renderer/PatchRData.cpp b/source/renderer/PatchRData.cpp index 7687dd3566..82d87cdfbf 100644 --- a/source/renderer/PatchRData.cpp +++ b/source/renderer/PatchRData.cpp @@ -35,7 +35,6 @@ #include "graphics/TextRenderer.h" #include "graphics/TextureManager.h" #include "lib/alignment.h" -#include "lib/allocators/STLAllocators.h" #include "lib/code_generation.h" #include "lib/debug.h" #include "maths/Matrix3D.h" @@ -44,6 +43,7 @@ #include "ps/CStrIntern.h" #include "ps/CStrInternStatic.h" #include "ps/Game.h" +#include "ps/memory/AllocatorAdapter.h" #include "ps/memory/LinearAllocator.h" #include "ps/Profile.h" #include "renderer/AlphaMapCalculator.h" @@ -846,7 +846,7 @@ void CPatchRData::Update(CSimulation2* simulation) // std::map types with appropriate arena allocators and default comparison operator template -using PooledBatchMap = std::map, ProxyAllocator, PS::Memory::ScopedLinearAllocator>>; +using PooledBatchMap = std::map, PS::Memory::AllocatorAdapter, PS::Memory::ScopedLinearAllocator>>; // Equivalent to "m[k]", when it returns a arena-allocated std::map (since we can't // use the default constructor in that case) @@ -870,8 +870,8 @@ typename M::mapped_type& PooledPairGet(M& m, const typename M::key_type& k, PS:: // Each multidraw batch has a list of index counts, and a list of pointers-to-first-indexes using BatchElements = std::pair< - std::vector>, - std::vector>>; + std::vector>, + std::vector>>; // Group batches by index buffer using IndexBufferBatches = PooledBatchMap; @@ -1042,7 +1042,7 @@ struct SBlendStackItem { } - using SplatStack = std::vector>; + using SplatStack = std::vector>; CVertexBuffer::VBChunk* vertices; CVertexBuffer::VBChunk* indices; SplatStack splats; @@ -1059,7 +1059,7 @@ void CPatchRData::RenderBlends( PS::Memory::ScopedLinearAllocator scopedLinearAllocator{g_Renderer.GetLinearAllocator()}; - using BatchesStack = std::vector>; + using BatchesStack = std::vector>; BatchesStack batches((BatchesStack::allocator_type(scopedLinearAllocator))); CShaderDefines contextBlend = context; @@ -1071,7 +1071,7 @@ void CPatchRData::RenderBlends( // to avoid heavy reallocations batches.reserve(256); - using BlendStacks = std::vector>; + using BlendStacks = std::vector>; BlendStacks blendStacks((BlendStacks::allocator_type(scopedLinearAllocator))); blendStacks.reserve(patches.size());