32 template<
typename T, std::
size_t N>
33 using Mipmaps = std::vector<TFrame<T, N>>;
35 template<
typename T, std::
size_t N>
37 -> std::future<Mipmaps<T, N>>
43 auto promisedMipmaps = std::make_shared<std::promise<Mipmaps<T, N>>>();
45 std::future<Mipmaps<T, N>> futureMipmaps = promisedMipmaps->get_future();
47 m_workers.
queueWork([workingResult = promisedMipmaps, src = source]()
50 if(math::is_power_of_2(src.widthPx()) && math::is_power_of_2(src.heightPx()))
66 for(std::size_t level = 1; level < numMipmapLevels; ++level)
68 auto& previous = mipmaps[level - 1];
69 auto& current = mipmaps[level];
71 current =
TFrame<T, N>(std::max(
static_cast<uint32
>(1), previous.widthPx() / 2),
72 std::max(
static_cast<uint32
>(1), previous.heightPx() / 2));
76 workingResult->set_value(std::move(mipmaps));
79 return std::move(futureMipmaps);
A thread pool where works are accessed concurrently by blocking other threads. A thread pool that con...
Definition FixedSizeThreadPool.h:21
void queueWork(const Work &work)
Queue up a work to the pool. Workers start to process the work right away. The works are guaranteed t...
Definition FixedSizeThreadPool.cpp:50
void waitAllWorks()
Blocks until all queued works are finished. Should not be called on worker thread....
Definition FixedSizeThreadPool.cpp:129
Marks the derived class as move only.
Definition IMoveOnly.h:23
uint32 heightPx() const
Definition TFrame.ipp:440
uint32 widthPx() const
Definition TFrame.ipp:434
Definition TConstant2D.h:10
Definition _mipmap_gen.h:19
~mipmapgen()
Definition _mipmap_gen.h:22
mipmapgen(const std::size_t numThreads)
Definition _mipmap_gen.cpp:6
std::vector< TFrame< T, N > > Mipmaps
Definition _mipmap_gen.h:33
auto genMipmaps(const TFrame< T, N > &source) -> std::future< Mipmaps< T, N > >
Definition _mipmap_gen.h:36
Miscellaneous math utilities.
uint32 next_power_of_2(uint32 value)
Gets the minimum power of 2 value that is >= value.
Definition math.h:167
T log2_floor(const T value)
Calculate a positive number's base 2 logarithm (floored).
Definition math.h:187
The root for all renderer implementations.
Definition EEngineProject.h:6