MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
TextureProcessor.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace MayaFlux::Core {
6class VKImage;
7}
8
9namespace MayaFlux::Buffers {
10
11class TextureBuffer;
12
13/**
14 * @class TextureProcessor
15 * @brief Internal processor: handles CPU→GPU transfers for TextureBuffer
16 *
17 * TextureProcessor is automatically created and attached by TextureBuffer.
18 * Users never instantiate or interact with it directly.
19 *
20 * Responsibilities:
21 * - Initialize GPU texture (VKImage)
22 * - Upload pixel data to GPU (initial + dirty updates)
23 * - Generate and upload quad geometry respecting transform
24 * - Detect changes and re-upload as needed
25 *
26 * All work is invisible to the user. They just modify TextureBuffer
27 * (set_pixel_data, set_position, etc.) and it "just works."
28 */
29class MAYAFLUX_API TextureProcessor : public VKBufferProcessor {
30public:
33
34protected:
35 void on_attach(std::shared_ptr<Buffer> buffer) override;
36 void on_detach(std::shared_ptr<Buffer> buffer) override;
37 void processing_function(std::shared_ptr<Buffer> buffer) override;
38
39private:
40 std::shared_ptr<TextureBuffer> m_texture_buffer;
41
42 // =========================================================================
43 // Initialization (on_attach)
44 // =========================================================================
45
46 /**
47 * Initialize all GPU resources:
48 * - VKImage for texture
49 * - Vertex buffer with quad geometry
50 * - Pixel upload
51 */
52 void initialize_gpu_resources();
53
54 /**
55 * Upload initial quad geometry based on default or custom vertices
56 */
57 void upload_initial_geometry();
58
59 /**
60 * Upload initial pixel data to GPU texture
61 */
62 void upload_initial_pixels();
63
64 // =========================================================================
65 // Per-Frame Updates (processing_function)
66 // =========================================================================
67
68 /**
69 * Regenerate quad vertices if transform changed, upload if needed
70 */
71 void update_geometry_if_dirty();
72
73 /**
74 * Re-upload pixels to GPU if they changed
75 */
76 void update_pixels_if_dirty();
77
78 // =========================================================================
79 // GPU Resource Creation
80 // =========================================================================
81
82 /**
83 * Create VKImage for texture storage
84 */
85 std::shared_ptr<Core::VKImage> create_gpu_texture();
86
87 /**
88 * Generate quad vertices respecting current transform
89 * Handles both default quad and custom vertices
90 */
91 void generate_quad_vertices(std::vector<uint8_t>& out_bytes);
92};
93
94} // namespace MayaFlux::Buffers
std::shared_ptr< TextureBuffer > m_texture_buffer
Internal processor: handles CPU→GPU transfers for TextureBuffer.