MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
TextureWriteProcessor.hpp
Go to the documentation of this file.
1#pragma once
2
5
6namespace MayaFlux::Buffers {
7
8/**
9 * @class TextureWriteProcessor
10 * @brief TextureProcessor subclass accepting externally-supplied pixel data
11 * via DataVariant each frame.
12 *
13 * Sets PixelSource::EXTERNAL_DATA so update_pixels_if_dirty() routes through
14 * get_variant_source() rather than TextureBuffer::m_pixel_data. All other
15 * behaviour — geometry updates, GPU upload, staging buffer management,
16 * streaming mode — is inherited unchanged from TextureProcessor.
17 *
18 * Caller supplies data via set_data(). The dirty flag on the TextureBuffer
19 * is set on each set_data() call and cleared by the parent after upload.
20 * If no new data has been set since the last cycle, the upload is skipped
21 * and the dirty flag is cleared — no stale re-upload.
22 *
23 * Thread safety: set_data() and the graphics thread may run concurrently.
24 * Lock-free double-buffer swap via atomic_flag ensures the graphics thread
25 * never blocks on the supplier thread.
26 */
27class MAYAFLUX_API TextureWriteProcessor : public TextureProcessor {
28public:
30 ~TextureWriteProcessor() override = default;
31
32 /**
33 * @brief Supply pixel data for the next cycle.
34 * @param variant Routed through Kakshya::as_texture_access() inside
35 * update_pixels_if_dirty() for type validation and promotion.
36 * Sets TextureBuffer dirty flag so upload is scheduled.
37 */
38 void set_data(Kakshya::DataVariant variant);
39
40 /**
41 * @brief Returns true if a snapshot has been set and not yet consumed.
42 */
43 [[nodiscard]] bool has_pending() const noexcept;
44
45protected:
46 std::optional<Kakshya::DataVariant> get_variant_source() override;
47
48private:
49 std::optional<Kakshya::DataVariant> m_pending;
50 std::optional<Kakshya::DataVariant> m_active;
51 std::atomic_flag m_dirty;
52};
53
54} // namespace MayaFlux::Buffers
Internal processor: handles CPU→GPU transfers for TextureBuffer.
TextureProcessor subclass accepting externally-supplied pixel data via DataVariant each frame.
std::variant< std::vector< double >, std::vector< float >, std::vector< uint8_t >, std::vector< uint16_t >, std::vector< uint32_t >, std::vector< std::complex< float > >, std::vector< std::complex< double > >, std::vector< glm::vec2 >, std::vector< glm::vec3 >, std::vector< glm::vec4 >, std::vector< glm::mat4 > > DataVariant
Multi-type data storage for different precision needs.
Definition NDData.hpp:76