94 std::unordered_map<std::string, std::any>
metadata;
147 [[nodiscard]] uint64_t get_device_address()
const;
156 void clear()
override;
167 std::vector<Kakshya::DataVariant> get_data();
178 void set_data(
const std::vector<Kakshya::DataVariant>& data);
193 void resize(
size_t new_size,
bool preserve_data =
false);
207 void process_default()
override;
217 void set_default_processor(
const std::shared_ptr<BufferProcessor>& processor)
override;
223 std::shared_ptr<Buffers::BufferProcessor> get_default_processor()
const override;
229 std::shared_ptr<Buffers::BufferProcessingChain> get_processing_chain()
override;
236 void set_processing_chain(
const std::shared_ptr<BufferProcessingChain>& chain,
bool force =
false)
override;
253 bool expected =
false;
254 return m_is_processing.compare_exchange_strong(expected,
true,
255 std::memory_order_acquire, std::memory_order_relaxed);
263 m_is_processing.store(
false, std::memory_order_release);
272 return m_is_processing.load(std::memory_order_acquire);
297 const std::vector<Kakshya::DataDimension>&
get_dimensions()
const {
return m_dimensions; }
309 void set_buffer(vk::Buffer buffer) { m_resources.buffer = buffer; }
312 void set_memory(vk::DeviceMemory memory) { m_resources.memory = memory; }
320 m_resources = resources;
336 m_resources.index_buffer = buf;
337 m_resources.index_memory = mem;
338 m_resources.index_size_bytes = size;
362 return static_cast<bool>(m_resources.index_buffer);
371 return m_usage == Usage::STAGING
372 || m_usage == Usage::UNIFORM
373 || m_usage == Usage::UNIFORM_BDA
374 || m_usage == Usage::STORAGE_BDA
375 || m_usage == Usage::HOST_STORAGE;
382 vk::BufferUsageFlags get_usage_flags()
const;
388 vk::MemoryPropertyFlags get_memory_properties()
const;
394 void mark_dirty_range(
size_t offset,
size_t size);
397 void mark_invalid_range(
size_t offset,
size_t size);
400 std::vector<std::pair<size_t, size_t>> get_and_clear_dirty_ranges();
403 std::vector<std::pair<size_t, size_t>> get_and_clear_invalid_ranges();
414 m_window_pipelines[id] = window;
423 auto it = m_window_pipelines.find(
id);
424 if (it != m_window_pipelines.end()) {
435 return !m_window_pipelines.empty();
444 return m_window_pipelines;
453 m_pipeline_commands[pipeline_id] = cmd_id;
461 auto it = m_pipeline_commands.find(pipeline_id);
462 return it != m_pipeline_commands.end() ? it->second : 0;
470 m_pipeline_commands.clear();
499 m_vertex_layout.reset();
502 std::shared_ptr<Buffer> clone_to(uint8_t dest_desc)
override;
513 std::shared_ptr<VKBuffer> clone_to(Usage usage);
558 m_render_config = config;
559 m_render_config_dirty =
true;
597 m_render_config = config;
598 m_render_config_dirty =
false;
604 void apply_render_config(
const RenderConfig& config,
const ShaderConfig& shader_config);
611 void apply_render_config(
612 std::shared_ptr<RenderProcessor>& render_processor,
613 const RenderConfig& config,
616 bool m_render_config_dirty {};
624 size_t m_size_bytes {};
626 bool m_needs_depth {};
635 bool m_has_data {
true };
636 bool m_needs_removal {};
637 bool m_process_default {
true };
638 bool m_internal_usage {};
660 void infer_dimensions_from_data(
size_t byte_count);
Central computational transformation interface for continuous buffer processing.
Backend-agnostic interface for sequential data storage and transformation.
Registry::Service::ComputeService * m_compute_service
void initialize_compute_service()
void initialize_buffer_service()
Registry::Service::BufferService * m_buffer_service
void ensure_initialized(const std::shared_ptr< VKBuffer > &buffer)
RenderConfig m_render_config
std::vector< std::pair< size_t, size_t > > m_dirty_ranges
bool is_render_config_dirty() const
Check if config has changed since last frame.
std::unordered_map< RenderPipelineID, std::shared_ptr< Core::Window > > get_render_pipelines() const
Get all render pipelines associated with this buffer.
size_t get_index_buffer_size() const
Number of bytes in the index buffer.
void * get_mapped_ptr() const
Get mapped host pointer (nullptr if not host-visible or unmapped)
CommandBufferID get_pipeline_command(RenderPipelineID pipeline_id) const
Get recorded command buffer for a pipeline.
ProcessingToken m_processing_token
void set_pipeline_command(RenderPipelineID pipeline_id, CommandBufferID cmd_id)
Store recorded command buffer for a pipeline.
PipelineContext m_pipeline_context
void set_render_processor(std::shared_ptr< RenderProcessor > rp)
std::unordered_map< RenderPipelineID, std::shared_ptr< Core::Window > > m_window_pipelines
std::optional< Kakshya::VertexLayout > m_vertex_layout
std::vector< Kakshya::DataDimension > m_dimensions
std::shared_ptr< Buffers::BufferProcessingChain > m_processing_chain
bool is_processing() const override
Query whether the buffer is currently being processed.
RenderConfig get_render_config() const
Get the current render configuration.
EngineContext m_engine_context
bool has_render_pipeline() const
Check if this buffer has a rendering pipeline configured.
bool needs_depth_attachment() const
Check if this buffer requires depth attachment for rendering.
bool needs_removal() const override
Checks if the buffer should be removed from processing chains.
bool has_data_for_cycle() const override
Checks if the buffer has data for the current processing cycle.
virtual std::shared_ptr< RenderProcessor > get_render_processor() const
Get a RenderProcessor suitable for rendering this buffer.
void clear_pipeline_commands()
Clear all recorded commands (called after presentation)
vk::Buffer get_index_buffer() const
Return the raw index buffer handle.
Usage get_usage() const
Retrieve the declared usage intent.
const EngineContext & get_engine_context() const
Kakshya::DataModality get_modality() const
Get the buffer's semantic modality.
const PipelineContext & get_pipeline_context() const
Access the pipeline context for custom metadata (const)
EngineContext & get_engine_context()
std::vector< std::pair< size_t, size_t > > m_invalid_ranges
void set_mapped_ptr(void *ptr)
Set mapped host pointer (for host-visible allocations)
vk::DeviceSize get_size_bytes() const
bool has_index_buffer() const
True when an index buffer has been associated with this buffer.
std::optional< Kakshya::VertexLayout > get_vertex_layout() const
Get vertex layout if set.
VKBufferResources m_resources
PipelineContext & get_pipeline_context()
Access the pipeline context for custom metadata (non-const)
void clear_vertex_layout()
Clear vertex layout.
void set_memory(vk::DeviceMemory memory)
Set device memory handle after backend allocation.
void set_needs_depth_attachment(bool needs)
Mark this buffer as requiring depth testing when rendered.
vk::Buffer & get_buffer()
Get VkBuffer handle (VK_NULL_HANDLE if not registered)
bool needs_default_processing() override
Checks if the buffer should undergo default processing.
std::shared_ptr< Buffers::BufferProcessor > m_default_processor
virtual void setup_processors(ProcessingToken token)
Setup processors with a processing token.
virtual void mark_render_config_dirty(bool is_dirty=true)
Mark config as changed (processors will detect and react)
void set_pipeline_window(RenderPipelineID id, const std::shared_ptr< Core::Window > &window)
Associate this buffer with a window for rendering.
bool is_initialized() const
Check whether Vulkan handles are present (buffer registered)
void enforce_default_processing(bool should_process) override
Controls whether the buffer should use default processing.
bool is_internal_only() const override
Check whether this buffer is for internal engine usage.
void set_buffer(vk::Buffer buffer)
Set VkBuffer handle after backend allocation.
bool has_vertex_layout() const
Check if this buffer has vertex layout configured.
const std::vector< Kakshya::DataDimension > & get_dimensions() const
Get the inferred data dimensions for the buffer contents.
std::shared_ptr< RenderProcessor > m_render_processor
virtual void set_render_config(const RenderConfig &config)
Update the render configuration and mark as dirty.
void set_index_resources(vk::Buffer buf, vk::DeviceMemory mem, size_t size)
Store raw index buffer handles produced by the geometry upload path.
std::atomic< bool > m_is_processing
const VKBufferResources & get_buffer_resources()
Get all buffer resources at once.
void set_default_render_config(const RenderConfig &config)
Called by derived classes to set their context-specific defaults.
Kakshya::DataModality m_modality
void release_processing() override
Release previously acquired processing lock.
void set_buffer_resources(const VKBufferResources &resources)
Set all buffer resources at once.
void force_internal_usage(bool internal) override
Set whether this buffer is for internal engine usage.
size_t get_size() const
Get current logical size in bytes.
void mark_for_removal() override
Marks the buffer for removal from processing chains.
std::unordered_map< RenderPipelineID, CommandBufferID > m_pipeline_commands
bool is_host_visible() const
Whether this VKBuffer should be host-visible.
void mark_for_processing(bool has_data) override
Marks the buffer's data availability for the current processing cycle.
std::shared_ptr< Core::Window > get_pipeline_window(RenderPipelineID id) const
Get the window associated with this buffer.
~VKBuffer() override
Virtual destructor.
bool try_acquire_processing() override
Try to acquire processing lock for this buffer.
Vulkan-backed buffer wrapper used in processing chains.
ProcessingToken
Bitfield enum defining processing characteristics and backend requirements for buffer operations.
uint64_t RenderPipelineID
DataModality
Data modality types for cross-modal analysis.
vk::DeviceMemory index_memory
Raw Vulkan handles owned by a VKBuffer instance.
std::vector< Portal::Graphics::DescriptorBindingInfo > ssbo_bindings
Engine-internal per-frame binding state.
std::vector< Portal::Graphics::DescriptorBindingInfo > descriptor_buffer_bindings
std::vector< uint8_t > push_constant_staging
std::unordered_map< std::string, std::any > metadata
Context shared with BufferProcessors during pipeline execution.
Complete description of vertex data layout in a buffer.
Unified rendering configuration for graphics buffers.
Backend buffer management service interface.
Backend compute shader and pipeline service interface.