35 error<std::runtime_error>(
38 std::source_location::current(),
39 "TextureProcessor requires a valid buffer service");
42 auto tex_buffer = std::dynamic_pointer_cast<TextureBuffer>(buffer);
49 if (!tex_buffer->is_initialized()) {
52 }
catch (
const std::exception& e) {
56 std::source_location::current(),
57 "Failed to initialize texture buffer: {}", e.what());
63 if (
auto rp = tex_buffer->get_render_processor()) {
65 tex_buffer->get_render_config().default_texture_binding,
66 tex_buffer->get_texture());
70 "TextureProcessor attached to {}x{} TextureBuffer",
71 tex_buffer->get_width(), tex_buffer->get_height());
113 "TextureProcessor: GPU resources initialized");
129 "TextureProcessor: uploaded {} bytes of geometry data",
131 }
catch (
const std::exception& e) {
133 "Failed to upload initial geometry: {}", e.what());
144 if (pixel_data.empty()) {
146 "TextureProcessor: no pixel data to upload (uninitialized texture)");
157 "TextureProcessor: uploaded {} bytes of pixel data", pixel_data.size());
181 "TextureProcessor: geometry updated and uploaded");
182 }
catch (
const std::exception& e) {
184 "Failed to update geometry: {}", e.what());
234 "TextureProcessor: external variant data updated ({} bytes)", access->byte_count);
249 if (pixel_data.empty()) {
276 "TextureProcessor: pixel data updated ({} bytes)", pixel_data.size());
291 auto texture = loom.create_2d(
299 error<std::runtime_error>(
302 std::source_location::current(),
303 "Failed to create GPU texture via TextureLoom");
307 "TextureProcessor: created GPU VKImage {}x{}",
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
ProcessingToken m_processing_token
std::shared_ptr< Core::VKImage > create_gpu_texture()
Create VKImage for texture storage.
void on_detach(const std::shared_ptr< Buffer > &buffer) override
Called when this processor is detached from a buffer.
void update_geometry_if_dirty()
Regenerate quad vertices if transform changed, upload if needed.
void processing_function(const std::shared_ptr< Buffer > &buffer) override
The core processing function that must be implemented by derived classes.
void initialize_gpu_resources()
Initialize all GPU resources:
void update_pixels_if_dirty()
Re-upload pixels to GPU if they changed.
virtual std::optional< Kakshya::DataVariant > get_variant_source()
void upload_initial_pixels()
Upload initial pixel data to GPU texture.
PixelSource m_pixel_source
~TextureProcessor() override
void on_attach(const std::shared_ptr< Buffer > &buffer) override
Called when this processor is attached to a buffer.
void generate_quad_vertices(std::vector< uint8_t > &out_bytes)
Generate quad vertices respecting current transform Handles both default quad and custom vertices.
std::shared_ptr< TextureBuffer > m_texture_buffer
std::shared_ptr< Buffers::VKBuffer > m_stream_staging
Persistent host-visible staging buffer for streaming pixel uploads.
void upload_initial_geometry()
Upload initial quad geometry based on default or custom vertices.
void initialize_buffer_service()
Registry::Service::BufferService * m_buffer_service
Interface * get_service()
Query for a backend service.
static BackendRegistry & instance()
Get the global registry instance.
std::shared_ptr< VKBuffer > create_image_staging_buffer(size_t size)
Allocate a persistent host-visible staging buffer sized for repeated streaming uploads to an image of...
@ GRAPHICS_BACKEND
Standard graphics processing backend configuration.
void upload_to_gpu(const void *data, size_t size, const std::shared_ptr< VKBuffer > &target, const std::shared_ptr< VKBuffer > &staging)
Upload raw data to GPU buffer (auto-detects host-visible vs device-local)
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.
std::optional< TextureAccess > as_texture_access(const DataVariant &variant)
Extract a TextureAccess from a DataVariant.
MAYAFLUX_API TextureLoom & get_texture_manager()
Get the global texture manager instance.
std::function< void(const std::shared_ptr< void > &)> initialize_buffer
Initialize a buffer object.
Backend buffer management service interface.