Skip to content

cvedia::rt::BufferLua

Public Functions

Name
BufferLua()
BufferLua(cbuffer buffer, bool ephemeral =false)
~BufferLua()
cbuffer lock_or_error(::lua_State * L) const
void invalidate()
Invalidate this BufferLua, releasing buffer memory immediately.
bool isRegistered() const
Check if this buffer is registered with the frame cleanup registry.
void setRegistered(bool reg)
Set the registered state for frame cleanup tracking.
void persist()
Mark this buffer as persistent so it survives per-frame cleanup.
void persist(std::string origin)
void release()
Explicitly release this buffer's GPU memory and mark it invalid.
bool isPersistent() const

Public Attributes

Name
cbuffer buffer_
bool valid
bool ephemeral_
std::weak_ptr< iface::Buffer > weak_
cbuffer keepalive_
bool registered_
bool persistent_
std::string persistenceOrigin_

Public Functions Documentation

function BufferLua

BufferLua()

function BufferLua

BufferLua(
    cbuffer buffer,
    bool ephemeral =false
)

function ~BufferLua

~BufferLua()

function lock_or_error

cbuffer lock_or_error(
    ::lua_State * L
) const

function invalidate

void invalidate()

Invalidate this BufferLua, releasing buffer memory immediately.

Called by BufferLuaRegistry at frame end. After invalidation:

  • valid is set to false
  • buffer_ and keepalive_ are reset to nullptr
  • weak_ is reset
  • registered_ is set to false Any subsequent use via lock_or_error() will get a "Buffer is invalid" error.

function isRegistered

inline bool isRegistered() const

Check if this buffer is registered with the frame cleanup registry.

function setRegistered

inline void setRegistered(
    bool reg
)

Set the registered state for frame cleanup tracking.

function persist

void persist()

Mark this buffer as persistent so it survives per-frame cleanup.

After calling persist(), invalidateAll() will skip this buffer. Use when a buffer must live across frame boundaries (e.g. crops stored for second-stage verification).

function persist

void persist(
    std::string origin
)

function release

void release()

Explicitly release this buffer's GPU memory and mark it invalid.

Must be called instead of relying on Lua GC for persistent buffers. After release(), the buffer is invalid and any use will error.

function isPersistent

inline bool isPersistent() const

Public Attributes Documentation

variable buffer_

cbuffer buffer_;

variable valid

bool valid;

variable ephemeral_

bool ephemeral_ = false;

variable weak_

std::weak_ptr< iface::Buffer > weak_;

variable keepalive_

cbuffer keepalive_;

variable registered_

bool registered_ = false;

variable persistent_

bool persistent_ = false;

variable persistenceOrigin_

std::string persistenceOrigin_;