44 vk::Buffer
buffer { VK_NULL_HANDLE };
45 vk::DeviceMemory
memory { VK_NULL_HANDLE };
93 std::unordered_map<std::string, std::any>
metadata;
146 [[nodiscard]] uint64_t get_device_address()
const;
157 void clear()
override;
168 std::vector<Kakshya::DataVariant> get_data();
179 void set_data(
const std::vector<Kakshya::DataVariant>& data);
194 void resize(
size_t new_size,
bool preserve_data =
false);
208 void process_default()
override;
218 void set_default_processor(
const std::shared_ptr<BufferProcessor>& processor)
override;
224 std::shared_ptr<Buffers::BufferProcessor> get_default_processor()
const override;
230 std::shared_ptr<Buffers::BufferProcessingChain> get_processing_chain()
override;
237 void set_processing_chain(
const std::shared_ptr<BufferProcessingChain>&
chain,
bool force =
false)
override;
254 bool expected =
false;
255 return m_is_processing.compare_exchange_strong(expected,
true,
256 std::memory_order_acquire, std::memory_order_relaxed);
264 m_is_processing.store(
false, std::memory_order_release);
273 return m_is_processing.load(std::memory_order_acquire);
298 const std::vector<Kakshya::DataDimension>&
get_dimensions()
const {
return m_dimensions; }
313 void set_memory(vk::DeviceMemory memory) { m_resources.memory = memory; }
321 m_resources = resources;
337 m_resources.index_buffer = buf;
338 m_resources.index_memory = mem;
339 m_resources.index_size_bytes =
size;
366 return static_cast<bool>(m_resources.index_buffer);
375 return m_usage == Usage::STAGING
376 || m_usage == Usage::UNIFORM
377 || m_usage == Usage::UNIFORM_BDA
378 || m_usage == Usage::STORAGE_BDA
379 || m_usage == Usage::HOST_STORAGE;
386 vk::BufferUsageFlags get_usage_flags()
const;
392 vk::MemoryPropertyFlags get_memory_properties()
const;
398 void mark_dirty_range(
size_t offset,
size_t size);
401 void mark_invalid_range(
size_t offset,
size_t size);
404 std::vector<std::pair<size_t, size_t>> get_and_clear_dirty_ranges();
407 std::vector<std::pair<size_t, size_t>> get_and_clear_invalid_ranges();
418 m_window_pipelines[id] =
window;
424 if (
auto window = get_pipeline_window(
id))
425 request_presentation_refresh(
window);
426 m_window_pipelines.erase(
id);
427 m_pipeline_commands.erase(
id);
434 m_pending_presentation_refreshes.insert(
window);
440 return std::exchange(m_pending_presentation_refreshes, {});
449 auto it = m_window_pipelines.find(
id);
450 if (it != m_window_pipelines.end()) {
461 return !m_window_pipelines.empty();
470 return m_window_pipelines;
479 m_pipeline_commands[pipeline_id] = cmd_id;
487 auto it = m_pipeline_commands.find(pipeline_id);
488 return it != m_pipeline_commands.end() ? it->second : 0;
496 m_pipeline_commands.clear();
525 m_vertex_layout.reset();
528 std::shared_ptr<Buffer> clone_to(uint8_t dest_desc)
override;
539 std::shared_ptr<VKBuffer> clone_to(Usage
usage);
584 m_render_config = config;
585 m_render_config_dirty =
true;
615 std::vector<std::shared_ptr<RenderProcessor>> get_additional_render_processors();
633 m_render_config = config;
634 m_render_config_dirty =
false;
640 void apply_render_config(
const RenderConfig& config,
const ShaderConfig& shader_config);
647 void apply_render_config(
648 std::shared_ptr<RenderProcessor>& render_processor,
649 const RenderConfig& config,
652 bool m_render_config_dirty {};
660 size_t m_size_bytes {};
662 bool m_needs_depth {};
671 bool m_has_data {
true };
672 bool m_needs_removal {};
673 bool m_process_default {
true };
674 bool m_internal_usage {};
697 void infer_dimensions_from_data(
size_t byte_count);
705 void initialize_buffer_service();
706 void initialize_compute_service();
707 void ensure_initialized(
const std::shared_ptr<VKBuffer>&
buffer);
727 {
b.get_texture() } -> std::convertible_to<std::shared_ptr<Core::VKImage>>; } ||
requires(
const T&
b) {
728 {
b.get_gpu_texture() } -> std::convertible_to<std::shared_ptr<Core::VKImage>>; });
std::shared_ptr< NetworkGeometryBuffer > buffer
BufferProcessingChain * chain
std::weak_ptr< Core::Window > window
Central computational transformation interface for continuous buffer processing.
Backend-agnostic interface for sequential data storage and transformation.
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.
void request_presentation_refresh(const std::shared_ptr< Core::Window > &window)
Queue a composition change independently of buffer processing.
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.
VKBufferResources & get_buffer_resources()
Get all buffer resources at once (mutable).
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
void set_default_render_config(const RenderConfig &config)
Called by derived classes to set their context-specific defaults.
Kakshya::DataModality m_modality
void remove_pipeline_window(RenderPipelineID id)
Withdraw one pipeline and request presentation of its former window.
void release_processing() override
Release previously acquired processing lock.
void set_buffer_resources(const VKBufferResources &resources)
Set all buffer resources at once.
const VKBufferResources & get_buffer_resources() const
Get all buffer resources at once (read-only)
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::unordered_set< std::shared_ptr< Core::Window > > m_pending_presentation_refreshes
std::unordered_set< std::shared_ptr< Core::Window > > take_presentation_refreshes()
Transfer pending composition changes to the owning graphics root.
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.
Satisfied by any VKBuffer subclass that exposes a GPU-resident image.
ProcessingToken
Bitfield enum defining processing characteristics and backend requirements for buffer operations.
uint64_t RenderPipelineID
DataModality
Data modality types for cross-modal analysis.
BufferUsageHint
Semantic usage hint for buffer allocation and memory properties.
vk::DeviceMemory index_memory
std::vector< GenerationSlot > back_buffers
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< Portal::Graphics::PushConstantBindingInfo > push_constant_bindings
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.