TextureTable class

Public static variables

static uint32_t Capacity constexpr
static TextureIndex White constexpr
static TextureIndex NoTexture constexpr

Public functions

auto Initialize(const VulkanContext& context, VulkanMemory& memory, uint32_t framesInFlight) -> bool
void Shutdown()
auto Create(uint32_t width, uint32_t height, VkFormat format, const void* pixels, size_t bytes) -> TextureIndex
auto Update(TextureIndex index, const void* pixels, uint32_t rowLength, uint32_t x, uint32_t y, uint32_t width, uint32_t height) -> bool
auto AddView(VkImageView view, VkImageLayout layout) -> TextureIndex
An image owned elsewhere (a render target), in a layout it can be sampled in.
void ReplaceView(TextureIndex index, VkImageView view, VkImageLayout layout) const
void Remove(TextureIndex index)
void RemoveView(TextureIndex index)
void AdvanceFrame()
End of a frame: release what has waited out its window.
auto GetLayout() const -> VkDescriptorSetLayout
Set 0 for any pipeline that samples: binding 0 the images, binding 1 the samplers.
auto GetSet() const -> VkDescriptorSet
auto LiveCount() const -> uint32_t

Function documentation

TextureIndex TextureTable::Create(uint32_t width, uint32_t height, VkFormat format, const void* pixels, size_t bytes)

A texture the table owns, filled with pixels (tightly packed, format). NoTexture if the table is full or the image could not be made.

bool TextureTable::Update(TextureIndex index, const void* pixels, uint32_t rowLength, uint32_t x, uint32_t y, uint32_t width, uint32_t height)

Rewrite one rectangle of a texture Create made. pixels is the rectangle's first texel, in memory whose rows are rowLength texels apart. Only for texels no frame in flight samples yet (new glyphs in an atlas): the texture is written where it is. False if it could not be.

void TextureTable::ReplaceView(TextureIndex index, VkImageView view, VkImageLayout layout) const

Point an AddView entry at another view: its image was made again (a resized target). Only while no frame in flight samples it (the device is idle); what names the index keeps working.

void TextureTable::Remove(TextureIndex index)

Stop using an entry. The index, and the image if the table owns it, live on until the frames in flight have drained.

void TextureTable::RemoveView(TextureIndex index)

Stop using an AddView entry whose image is about to be destroyed: until the index is given out again it samples white, so a UI snapshot that still names it draws nothing harmful. Only while no frame in flight samples it (the device is idle).