pulsatrix
Loading...
Searching...
No Matches
texture_cache.hpp
Go to the documentation of this file.
1
5#pragma once
6
7#include <cstdint>
8#include <unordered_map>
9
10#include "pulsatrix/tensor.hpp"
11
12namespace pulsatrix {
13
15using TextureId = unsigned int;
16
27public:
28 TextureCache() = default;
30
31 TextureCache(const TextureCache&) = delete;
33
40 [[nodiscard]] TextureId GetOrUpload(int64_t key, const Tensor& image_chw);
41
43 void Clear();
44
45private:
46 std::unordered_map<int64_t, TextureId> textures_;
47};
48
49} // namespace pulsatrix
N-dimensional tensor. Owns its data buffer exclusively; a DeviceBackend* is injected (not owned) – th...
Definition tensor.hpp:29
Uploads decoded image Tensors to OpenGL textures, keyed and cached by an arbitrary integer key (e....
Definition texture_cache.hpp:26
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.
Definition acquisition_functions.hpp:16
unsigned int TextureId
Opaque GL texture handle, typed to avoid a GL header include in this public header.
Definition texture_cache.hpp:15
N-dimensional tensor – owns a buffer via DeviceBackend*, RAII (Rule of Five).