pulsatrix
Loading...
Searching...
No Matches
pulsatrix::TextureCache Class Reference

Uploads decoded image Tensors to OpenGL textures, keyed and cached by an arbitrary integer key (e.g. a Dataset index) so a scrolling image grid doesn't re-upload the same image every frame. More...

#include <texture_cache.hpp>

Public Member Functions

 TextureCache ()=default
 
 ~TextureCache ()
 
 TextureCache (const TextureCache &)=delete
 
TextureCache & operator= (const TextureCache &)=delete
 
TextureId GetOrUpload (int64_t key, const Tensor &image_chw)
 Returns the cached texture for key, uploading image_chw first if not cached.
 
void Clear ()
 Deletes every cached GL texture and clears the cache.
 

Detailed Description

Uploads decoded image Tensors to OpenGL textures, keyed and cached by an arbitrary integer key (e.g. a Dataset index) so a scrolling image grid doesn't re-upload the same image every frame.

Note
All real pixel-format conversion logic (Tensor -> interleaved RGB bytes) lives in plot_data.hpp's ToRgbImageBuffer, which is unit-tested; this class's only job is the GL-specific glGenTextures/glTexImage2D calls, which are not meaningfully unit-testable – see plans/okay-we-have-now-buzzing-moth.md Testing Strategy.

Constructor & Destructor Documentation

◆ TextureCache() [1/2]

pulsatrix::TextureCache::TextureCache ( )
default

◆ ~TextureCache()

pulsatrix::TextureCache::~TextureCache ( )

◆ TextureCache() [2/2]

pulsatrix::TextureCache::TextureCache ( const TextureCache &  )
delete

Member Function Documentation

◆ Clear()

void pulsatrix::TextureCache::Clear ( )

Deletes every cached GL texture and clears the cache.

◆ GetOrUpload()

TextureId pulsatrix::TextureCache::GetOrUpload ( int64_t  key,
const Tensor &  image_chw 
)

Returns the cached texture for key, uploading image_chw first if not cached.

Parameters
keyCache key (e.g. a Dataset sample index).
image_chwA rank-3 (C,H,W) or batch-1 rank-4 (1,C,H,W) image tensor – see ToRgbImageBuffer's shape contract.

◆ operator=()

TextureCache & pulsatrix::TextureCache::operator= ( const TextureCache &  )
delete

The documentation for this class was generated from the following file: