struct
Diorite::ArenaVertexBuffer(T)
- Diorite::ArenaVertexBuffer(T)
- Struct
- Value
- Object
Overview
Stack-allocated, pass-by-value vertex/color buffer view backed by a Slice(T)
and an arena-allocated Pointer(Int32) element counter carved out of
Lapis::Core::FrameArena.
Because @size_ptr points to a 4-byte Int32 slot in the FrameArena, passing
an ArenaVertexBuffer(T) by value into GeometryBuilder, ChartBuilder, and
TelemetryGraph methods mutates the shared element count in-place with
strictly zero heap allocations and zero struct boxing.
Defined in:
diorite/core/frame_arena_batch.crConstructors
Class Method Summary
-
.from_arena(arena : Lapis::Core::FrameArena = Lapis::Core::FrameArena.current, capacity : Int32 = 1024, alignment : Int32 = Lapis::Core::FrameArena::DEFAULT_ALIGNMENT) : ArenaVertexBuffer(T)
Carves an
ArenaVertexBuffer(T)with#capacityelements and an arena-backed size counter directly fromarena. - .from_parts(raw_slice : Slice(T), size_ptr : Pointer(Int32)) : ArenaVertexBuffer(T)
Instance Method Summary
-
#<<(value : T) : self
Fluent append operator (
verts << pt), drop-in compatible withArray(T)#<<. - #[](index : Int32) : T
- #[]=(index : Int32, value : T) : T
- #[]?(index : Int32) : T | Nil
-
#capacity : Int32
Maximum number of elements this buffer can hold.
-
#clear : self
Resets the logical element count to 0 while retaining the underlying arena slice.
- #each(& : T -> ) : Nil
-
#empty? : Bool
Returns true if no elements have been written.
-
#full? : Bool
Returns true if the buffer has reached capacity.
-
#push(value : T) : Bool
Appends a single element to the arena buffer if space remains.
-
#push_line(a : T, b : T) : Bool
Appends a pair of elements (start/end vertices or colors for a line segment) atomically if at least 2 slots remain.
- #raw_slice : Slice(T)
-
#remaining : Int32
Remaining unwritten element slots.
-
#size : Int32
Current number of written elements.
- #size_ptr : Pointer(Int32)
-
#to_arena_buffer : Lapis::Core::ArenaBuffer(T)
Returns a
Lapis::Core::ArenaBuffer(T)snapshot of the written elements. -
#to_slice : Slice(T)
Returns a zero-allocation
Slice(T)view over the written elements (0...size). - #to_unsafe : Pointer(T)
- #unsafe_fetch(index : Int32) : T
Constructor Detail
Class Method Detail
Carves an ArenaVertexBuffer(T) with #capacity elements and an arena-backed
size counter directly from arena.
Instance Method Detail
Fluent append operator (verts << pt), drop-in compatible with Array(T)#<<.
Resets the logical element count to 0 while retaining the underlying arena slice.
Appends a pair of elements (start/end vertices or colors for a line segment) atomically if at least 2 slots remain.
Returns a Lapis::Core::ArenaBuffer(T) snapshot of the written elements.
Returns a zero-allocation Slice(T) view over the written elements (0...size).