56 auto channel_bit =
static_cast<uint32_t
>((0x0ffffffff) & (1ULL << (uint64_t)channel_id));
65 auto channel_bit =
static_cast<uint32_t
>((0x0ffffffff) & (1ULL << (uint64_t)channel_id));
76 auto channel_bit =
static_cast<uint32_t
>((0x0ffffffff) & (1ULL << (uint64_t)channel_id));
78 return (active_mask & channel_bit) != 0;
85 auto channel_bit =
static_cast<uint32_t
>((0x0ffffffff) & (1ULL << (uint64_t)channel_id));
87 uint32_t new_pending = old_pending | channel_bit;
90 if ((new_pending & active_channels) == active_channels && active_channels != 0) {
91 uint32_t expected = new_pending;
106 if (active_mask == 0) {
118 uint64_t expected = 0;
120 expected, context_id,
121 std::memory_order_acq_rel,
122 std::memory_order_acquire);
132 uint64_t expected = context_id;
135 std::memory_order_release,
136 std::memory_order_relaxed);
157 auto state =
m_state.load(std::memory_order_acquire);
163 bool expected =
false;
165 std::memory_order_acq_rel)) {
176 uint32_t buffer_count =
m_buffer_count.load(std::memory_order_acquire);
178 if (reset_count + 1 == buffer_count || buffer_count <= 1) {
bool remove_by_key(const std::type_info &key)
Removes every entry registered with this callable type.
bool remove(HookId id)
Removes the registration with this id.
HookId add_conditional_unique(NodeHook hook, NodeCondition condition, const std::type_info &key, uint8_t tag=0)
As add_conditional, returning the existing id when the same hook and condition types exist.
bool remove_by_condition_key(const std::type_info &key)
Removes every entry whose condition has this callable type.
HookId add_unique(NodeHook hook, const std::type_info &key, uint8_t tag=0, std::array< double, 2 > params={})
Appends unless an entry with the same key and params exists, in which case that entry's id is returne...
Stores, fires and clears the hooks of one node channel.
bool try_claim_snapshot_context(uint64_t context_id)
Attempt to claim snapshot context for this processing cycle.
std::atomic< uint32_t > m_active_channels_mask
Bitmask tracking which channels are currently using this node.
virtual HookId on_tick(const NodeHook &callback)
Registers a callback to be called on each tick.
bool has_active_snapshot() const
Check if node is currently being snapshotted by any context.
void add_buffer_reference()
Increments the buffer reference count This method is called when a new buffer starts using this node ...
HookList m_conditional_callbacks
Hooks fired on a tick only while their condition holds.
bool is_in_snapshot_context(uint64_t context_id) const
Check if currently in a snapshot context.
void request_buffer_reset()
Requests a reset of the buffer state.
void remove_buffer_reference()
Decrements the buffer reference count This method is called when a buffer stops using this node to en...
std::atomic< uint32_t > m_pending_reset_mask
Bitmask tracking which channels have requested a reset.
std::atomic< bool > m_buffer_processed
Flag indicating whether the buffer has been processed This atomic flag is set when the buffer has bee...
std::atomic< uint64_t > m_snapshot_context_id
Unique identifier for the current snapshot context.
virtual void reset_processed_state()
Resets the processed state of the node and any attached input nodes.
std::atomic< NodeState > m_state
Atomic state flag tracking the node's processing status.
virtual bool unhook(HookId id)
Removes the one registration with this id, whichever hook list holds it.
virtual bool is_output_excluded_from_graph() const
True if the node's output is excluded from the graph.
std::atomic< uint32_t > m_buffer_reset_count
Counter tracking how many buffers have requested a reset.
HookList m_callbacks
Hooks fired on every tick.
bool is_used_by_channel(uint32_t channel_id) const
Checks if the node is currently used by a specific channel.
virtual void exclude_output_from_graph(bool excluded=true)
Exclude this node's output from the graph it is registered in.
void unregister_channel_usage(uint32_t channel_id)
Removes the specified channel from the usage tracking.
virtual void reset_processed_state_internal()
Resets the processed state of the node directly.
std::atomic< uint32_t > m_buffer_count
Counter tracking how many buffers are using this node This counter is incremented when a buffer start...
virtual void remove_all_hooks()
Removes all registered callbacks.
virtual HookId on_tick_if(const NodeCondition &condition, const NodeHook &callback)
Registers a conditional callback.
virtual bool remove_hook(const NodeHook &callback)
Removes a previously registered callback.
void register_channel_usage(uint32_t channel_id)
Mark the specificed channel as a processor/user.
void request_reset_from_channel(uint32_t channel_id)
Requests a reset of the processed state from a specific channel.
virtual bool remove_conditional_hook(const NodeCondition &callback)
Removes a previously registered conditional callback.
std::vector< float > m_gpu_data_buffer
GPU data buffer for context objects.
std::span< const float > get_gpu_data_buffer() const
Provides access to the GPU data buffer.
std::vector< HookList * > m_hook_lists
bool mark_buffer_processed()
Marks the node as having been processed by a buffer.
void release_snapshot_context(uint64_t context_id)
Release snapshot context.
TypedHook<> NodeHook
Alias for TypedHook<NodeContext>.
@ PROCESSED
Node has been processed this cycle.
@ INACTIVE
Engine is not processing this node.
@ OUTPUT_EXCLUDED
Node is processed but its output is left out of the graph.
uint64_t HookId
Identifies one registration inside a HookList.
void atomic_remove_flag(std::atomic< NodeState > &state, NodeState flag)
Atomically removes a flag from a node state.
std::function< bool(NodeContext &)> NodeCondition
Predicate function type for conditional callbacks.
void atomic_add_flag(std::atomic< NodeState > &state, NodeState flag)
Atomically adds a flag to a node state.
Contains the node-based computational processing system components.