feat(memory): slab-backed lambda closures + Bitmap buffer allocation - #729
Merged
Conversation
Closes §10.2 and §10.3 of tlsf-allocator-integration.md. ThreadPool: add m_closure_slab (512 KB, carved from Device->Arena by RRM). Submit<T> allocates [TLSFSlab* header | Fn closure] in one TLSF block instead of new/delete. Callback reads the header to free via slab or ::operator delete. Falls back to ::operator new when InitClosureSlab has not been called (tests, early startup). Eliminates the last system-heap alloc on the upload hot path. Bitmap: replace std::vector<uint8_t> Buffer with raw uint8_t* + BufferSize + TLSFSlab* Slab. Constructors accept an optional slab param; AllocNoZero skips zeroing for data constructors that immediately overwrite. Explicit destructor frees via slab->Free or delete[]. Copy deleted; move transfers ownership. Static methods EquirectangularMapToVerticalCross and VerticalCrossToCubemap forward the slab param so all intermediate Bitmaps live on the worker slab. RenderResourceManager: std::vector<float> output_buf replaced by slab-backed float* for the HDR equirect path. All Bitmap intermediates now slab-backed. EnvironmentMapImporter: passes GetWorkerSlab() to Bitmap constructors and static conversion methods.
JeanPhilippeKernel
force-pushed
the
feat/slab-closure-and-bitmap
branch
from
September 1, 2026 21:19
4f002da to
84ca2c0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes §10.2 and §10.3 of tlsf-allocator-integration.md.
§10.2 — Lambda closure slab
ThreadPool gets a shared 512 KB
m_closure_slab(carved from Device->Arena by RRM alongside upload slabs).Submit<T>allocates[TLSFSlab* header | Fn closure]in one TLSF block instead ofnew/delete. The callback reads the header to free via slab or::operator delete. Falls back to::operator newwhenInitClosureSlabhas not been called (early startup, tests). Eliminates the last system-heap alloc on the upload hot path.§10.3 — Bitmap slab-aware allocation
Replaces
std::vector<uint8_t> Bufferwithuint8_t* Buffer+size_t BufferSize+TLSFSlab* Slab. Constructors accept an optional slab param;AllocNoZeroskips zeroing for data constructors that immediately overwrite. Explicit destructor frees viaslab->Freeordelete[]. Copy deleted; move transfers ownership and nulls the source.Static methods
EquirectangularMapToVerticalCrossandVerticalCrossToCubemapforward the slab so all intermediate Bitmaps live on the worker slab.RenderResourceManager:std::vector<float> output_bufon the HDR equirect path replaced by a slab-backedfloat*. All Bitmap intermediates are now slab-backed.EnvironmentMapImporter: passesGetWorkerSlab()to all Bitmap constructors and static methods.Test plan