GPU texture pool to avoid constant allocation/deallocation.
Pre-allocates a pool of GPU textures and recycles them. Critical for avoiding stutter and memory fragmentation during video playback.
Example
{:ok, pool} = Dala.Media.Texture.new_pool(1920, 1088, count: 8)
# Acquire a texture (blocks if none available)
texture_id = Dala.Media.Texture.acquire(pool)
# Use the texture...
Dala.Gpu.blit(surface, texture_id, 0, 0)
# Release back to pool
Dala.Media.Texture.release(pool, texture_id)
Summary
Functions
Acquire a texture from the pool. Returns texture_id.
Returns a specification to start this module under a supervisor.
Destroy the pool and release all textures.
Create a texture pool with the given dimensions.
Release a texture back to the pool.
Get pool statistics.
Types
@type pool_ref() :: pid()
@type texture_id() :: non_neg_integer()
Functions
@spec acquire(pool_ref(), timeout()) :: texture_id() | nil
Acquire a texture from the pool. Returns texture_id.
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec destroy_pool(pool_ref()) :: :ok
Destroy the pool and release all textures.
@spec new_pool(non_neg_integer(), non_neg_integer(), keyword()) :: {:ok, pool_ref()} | {:error, term()}
Create a texture pool with the given dimensions.
@spec release(pool_ref(), texture_id()) :: :ok
Release a texture back to the pool.
@spec stats(pool_ref()) :: %{ available: non_neg_integer(), in_use: non_neg_integer(), total: non_neg_integer() }
Get pool statistics.