diff --git a/include/merian-nodes/graph/graph.hpp b/include/merian-nodes/graph/graph.hpp index df91c95d..24bbe041 100644 --- a/include/merian-nodes/graph/graph.hpp +++ b/include/merian-nodes/graph/graph.hpp @@ -180,8 +180,8 @@ using namespace std::literals::chrono_literals; * * @tparam RING_SIZE Controls the amount of in-flight processing (frames-in-flight). */ -template -class Graph : public std::enable_shared_from_this> { +template +class Graph : public std::enable_shared_from_this> { // Data that is stored for every iteration in flight. // Created for each iteration in flight in Graph::Graph. struct InFlightData { @@ -193,7 +193,7 @@ class Graph : public std::enable_shared_from_this> { // to device local memory has finished. merian::StagingMemoryManager::SetID staging_set_id{}; // The graph run, holds semaphores and such. - GraphRun graph_run{RING_SIZE}; + GraphRun graph_run{ITERATIONS_IN_FLIGHT}; // Query pools for the profiler QueryPoolHandle profiler_query_pool; // Tasks that should be run in the current iteration after acquiring the fence. @@ -208,7 +208,7 @@ class Graph : public std::enable_shared_from_this> { Graph(const ContextHandle& context, const ResourceAllocatorHandle& resource_allocator) : context(context), resource_allocator(resource_allocator), queue(context->get_queue_GCT()), registry(context, resource_allocator), ring_fences(context) { - for (uint32_t i = 0; i < RING_SIZE; i++) { + for (uint32_t i = 0; i < ITERATIONS_IN_FLIGHT; i++) { InFlightData& in_flight_data = ring_fences.get(i).user_data; in_flight_data.command_pool = std::make_shared(queue); in_flight_data.profiler_query_pool = @@ -331,7 +331,7 @@ class Graph : public std::enable_shared_from_this> { const std::string node_identifier = data.identifier; node_data.erase(node); node_for_identifier.erase(identifier); - for (uint32_t i = 0; i < RING_SIZE; i++) { + for (uint32_t i = 0; i < ITERATIONS_IN_FLIGHT; i++) { InFlightData& in_flight_data = ring_fences.get(i).user_data; in_flight_data.in_flight_data.erase(node); } @@ -440,7 +440,7 @@ class Graph : public std::enable_shared_from_this> { node->on_connected(io_layout, data.descriptor_set_layout); needs_reconnect |= flags & Node::NodeStatusFlagBits::NEEDS_RECONNECT; if ((flags & Node::NodeStatusFlagBits::RESET_IN_FLIGHT_DATA) != 0u) { - for (uint32_t i = 0; i < RING_SIZE; i++) { + for (uint32_t i = 0; i < ITERATIONS_IN_FLIGHT; i++) { ring_fences.get(i).user_data.in_flight_data.at(node).reset(); } } @@ -520,7 +520,7 @@ class Graph : public std::enable_shared_from_this> { } time_delta = duration_elapsed - last_elapsed_ns; - run.reset(run_iteration, run_iteration % RING_SIZE, profiler, cmd_pool, + run.reset(run_iteration, run_iteration % ITERATIONS_IN_FLIGHT, profiler, cmd_pool, resource_allocator, time_delta, duration_elapsed, duration_elapsed_since_connect, total_iteration); @@ -609,7 +609,7 @@ class Graph : public std::enable_shared_from_this> { node_data.clear(); node_for_identifier.clear(); - for (uint32_t i = 0; i < RING_SIZE; i++) { + for (uint32_t i = 0; i < ITERATIONS_IN_FLIGHT; i++) { InFlightData& in_flight_data = ring_fences.get(i).user_data; in_flight_data.in_flight_data.clear(); } @@ -1742,7 +1742,7 @@ class Graph : public std::enable_shared_from_this> { for (uint32_t i = 0; i <= max_delay; i++) { const GraphResourceHandle res = output->create_resource(per_output_info.inputs, resource_allocator, - resource_allocator, i, RING_SIZE); + resource_allocator, i, ITERATIONS_IN_FLIGHT); per_output_info.resources.emplace_back(res); } } @@ -1803,10 +1803,10 @@ class Graph : public std::enable_shared_from_this> { num_resources.push_back(per_output_info.resources.size()); } - uint32_t num_sets = std::max(lcm(num_resources), RING_SIZE); + uint32_t num_sets = std::max(lcm(num_resources), ITERATIONS_IN_FLIGHT); // make sure it is at least RING_SIZE to allow updates while iterations are in-flight // solve k * num_sets >= RING_SIZE - const uint32_t k = (RING_SIZE + num_sets - 1) / num_sets; + const uint32_t k = (ITERATIONS_IN_FLIGHT + num_sets - 1) / num_sets; num_sets *= k; SPDLOG_DEBUG("needing {} descriptor sets for node {} ({})", num_sets, @@ -1928,7 +1928,7 @@ class Graph : public std::enable_shared_from_this> { // clang-format on // Per-iteration data management - merian::RingFences ring_fences; + merian::RingFences ring_fences; // State bool needs_reconnect = false; diff --git a/include/merian-nodes/graph/graph_run.hpp b/include/merian-nodes/graph/graph_run.hpp index 31b877a6..8efbdd26 100644 --- a/include/merian-nodes/graph/graph_run.hpp +++ b/include/merian-nodes/graph/graph_run.hpp @@ -18,7 +18,7 @@ class GraphRun { template friend class Graph; public: - GraphRun(const uint32_t ring_size) : ring_size(ring_size) {} + GraphRun(const uint32_t iterations_in_flight) : iterations_in_flight(iterations_in_flight) {} void add_wait_semaphore(const BinarySemaphoreHandle& wait_semaphore, const vk::PipelineStageFlags& wait_stage_flags) noexcept { @@ -57,7 +57,7 @@ class GraphRun { // Number of iterations since connect. // Use get_total_iteration() for iterations since graph initialization. - // + // // Iterations are 0-indexed. const uint64_t& get_iteration() const noexcept { return iteration; @@ -65,21 +65,21 @@ class GraphRun { // Number of iterations since graph initialization. // Use get_iteration() for iterations since connect. - // + // // Iterations are 0-indexed. const uint64_t& get_total_iteration() const noexcept { return total_iteration; } - // returns the current in-flight index i, with 0 <= i < get_ring_size(). + // returns the current in-flight index i, with 0 <= i < get_iterations_in_flight(). // It is guaranteed that processing of the last iteration with that index has finished. const uint32_t& get_in_flight_index() const noexcept { return in_flight_index; } // returns the number of iterations that might be in flight at a certain time. - const uint32_t& get_ring_size() const noexcept { - return ring_size; + const uint32_t& get_iterations_in_flight() const noexcept { + return iterations_in_flight; } const CommandPoolHandle& get_cmd_pool() noexcept { @@ -122,7 +122,7 @@ class GraphRun { } // Returns the profiler that is attached to this run. - // + // // Can be nullptr if profiling is disabled! const ProfilerHandle& get_profiler() const { return profiler; @@ -173,7 +173,7 @@ class GraphRun { private: void reset(const uint64_t iteration, const uint32_t in_flight_index, - const ProfilerHandle profiler, + const ProfilerHandle& profiler, const CommandPoolHandle& cmd_pool, const ResourceAllocatorHandle& allocator, const std::chrono::nanoseconds time_delta, @@ -201,7 +201,7 @@ class GraphRun { } private: - const uint32_t ring_size; + const uint32_t iterations_in_flight; std::vector wait_semaphores; std::vector wait_values;