Skip to content

feat(memory): slab-backed lambda closures + Bitmap buffer allocation - #729

Merged
JeanPhilippeKernel merged 3 commits into
developfrom
feat/slab-closure-and-bitmap
Sep 1, 2026
Merged

feat(memory): slab-backed lambda closures + Bitmap buffer allocation#729
JeanPhilippeKernel merged 3 commits into
developfrom
feat/slab-closure-and-bitmap

Conversation

@JeanPhilippeKernel

@JeanPhilippeKernel JeanPhilippeKernel commented Sep 1, 2026

Copy link
Copy Markdown
Owner

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 of new/delete. The callback reads the header to free via slab or ::operator delete. Falls back to ::operator new when InitClosureSlab has 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> Buffer with uint8_t* Buffer + size_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 and nulls the source.

Static methods EquirectangularMapToVerticalCross and VerticalCrossToCubemap forward the slab so all intermediate Bitmaps live on the worker slab.

RenderResourceManager: std::vector<float> output_buf on the HDR equirect path replaced by a slab-backed float*. All Bitmap intermediates are now slab-backed.

EnvironmentMapImporter: passes GetWorkerSlab() to all Bitmap constructors and static methods.

Test plan

  • All existing allocator and bitmap tests pass
  • Manual: HDR cubemap import — all intermediate Bitmaps freed from slab after upload, no arena growth
  • Submit fallback path works when closure slab not yet initialized (pre-RRM tests)

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
JeanPhilippeKernel force-pushed the feat/slab-closure-and-bitmap branch from 4f002da to 84ca2c0 Compare September 1, 2026 21:19
@JeanPhilippeKernel JeanPhilippeKernel added this to the Stable Core (1.0.0) milestone Sep 1, 2026
@JeanPhilippeKernel JeanPhilippeKernel self-assigned this Sep 1, 2026
@JeanPhilippeKernel JeanPhilippeKernel added area-linux Work on Linux system area-window Work on Window system area-macOS Work on macOS system labels Sep 1, 2026
@JeanPhilippeKernel
JeanPhilippeKernel merged commit a568759 into develop Sep 1, 2026
17 checks passed
@JeanPhilippeKernel
JeanPhilippeKernel deleted the feat/slab-closure-and-bitmap branch September 1, 2026 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-linux Work on Linux system area-macOS Work on macOS system area-window Work on Window system

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant