Skip to content
fn

make_metal_shared

→OwnedMetalBuffer
OwnedMetalBuffer make_metal_shared(int nbytes)

Allocate a shared Metal buffer wrapped in an RAII owner.

Combines allocate_shared with a shared_ptr whose destructor releases the allocation. Preferred entry point for Storage construction code paths that need automatic cleanup.

See Also

allocate_shared — non-owning variant.

Parameters

nbytesstd::size_t
Allocation size in bytes.

Returns

OwnedMetalBuffer

Bundle whose owner keeps buf alive for as long as any copy of the shared_ptr survives.

Examples

Construct a 1 KiB shared buffer::
    auto owned = lucid::gpu::make_metal_shared(1024);
    // owned.buf.cpu_ptr ↔ owned.buf.mtl_handle alias same pages.