This commit is contained in:
2026-08-15 17:44:35 +08:00
parent b4094ede44
commit d48f6608ad
18 changed files with 310 additions and 280 deletions
@@ -1,5 +1,6 @@
#include <gtest/gtest.h>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
@@ -72,6 +73,20 @@ TEST(external_operation_test,
EXPECT_TRUE(subscribed_first.complete());
}
TEST(render_graph_runtime_test, reusable_topology_executes_multiple_frames) {
const auto plan = two_node_plan();
renderive::render_graph::detail::Render_Graph_Runtime runtime(*plan);
std::array<std::size_t, 2> execution_count{};
const auto execute_node = [&](std::size_t index, Node_Execution_Metrics*) {
++execution_count.at(index);
return Node_Execution_Result::completed();
};
runtime.execute({}, execute_node);
runtime.execute({}, execute_node);
EXPECT_EQ(execution_count[0], 2U);
EXPECT_EQ(execution_count[1], 2U);
}
TEST(render_graph_runtime_test,
external_successor_stays_blocked_until_operation_completes) {
const auto plan = two_node_plan();
@@ -81,19 +96,18 @@ TEST(render_graph_runtime_test,
std::atomic<bool> submit_started{};
std::atomic<bool> publish_executed{};
renderive::render_graph::detail::Render_Graph_Runtime runtime(
*plan, slots,
[&](std::size_t index, Node_Execution_Metrics*) {
if (index == 0) {
submit_started.store(true, std::memory_order_release);
submit_started.notify_all();
return Node_Execution_Result::external(source.operation());
}
publish_executed.store(true, std::memory_order_release);
return Node_Execution_Result::completed();
});
renderive::render_graph::detail::Render_Graph_Runtime runtime(*plan);
const auto execute_node = [&](std::size_t index, Node_Execution_Metrics*) {
if (index == 0) {
submit_started.store(true, std::memory_order_release);
submit_started.notify_all();
return Node_Execution_Result::external(source.operation());
}
publish_executed.store(true, std::memory_order_release);
return Node_Execution_Result::completed();
};
std::thread execution([&] { runtime.execute(); });
std::thread execution([&] { runtime.execute(slots, execute_node); });
submit_started.wait(false, std::memory_order_acquire);
EXPECT_FALSE(publish_executed.load(std::memory_order_acquire));
EXPECT_TRUE(source.complete());
@@ -115,21 +129,20 @@ TEST(render_graph_runtime_test,
std::atomic<bool> publish_executed{};
std::exception_ptr graph_error;
renderive::render_graph::detail::Render_Graph_Runtime runtime(
*plan, {},
[&](std::size_t index, Node_Execution_Metrics*) {
if (index == 0) {
submit_started.store(true, std::memory_order_release);
submit_started.notify_all();
return Node_Execution_Result::external(source.operation());
}
publish_executed.store(true, std::memory_order_release);
return Node_Execution_Result::completed();
});
renderive::render_graph::detail::Render_Graph_Runtime runtime(*plan);
const auto execute_node = [&](std::size_t index, Node_Execution_Metrics*) {
if (index == 0) {
submit_started.store(true, std::memory_order_release);
submit_started.notify_all();
return Node_Execution_Result::external(source.operation());
}
publish_executed.store(true, std::memory_order_release);
return Node_Execution_Result::completed();
};
std::thread execution([&] {
try {
runtime.execute();
runtime.execute({}, execute_node);
} catch (...) {
graph_error = std::current_exception();
}
@@ -156,15 +169,14 @@ TEST(render_graph_runtime_test,
std::condition_variable probe_completed;
bool probe_ran{};
renderive::render_graph::detail::Render_Graph_Runtime runtime(
*plan, {},
[&](std::size_t, Node_Execution_Metrics*) {
external_started.store(true, std::memory_order_release);
external_started.notify_all();
return Node_Execution_Result::external(source.operation());
});
renderive::render_graph::detail::Render_Graph_Runtime runtime(*plan);
const auto execute_node = [&](std::size_t, Node_Execution_Metrics*) {
external_started.store(true, std::memory_order_release);
external_started.notify_all();
return Node_Execution_Result::external(source.operation());
};
std::thread execution([&] { runtime.execute(); });
std::thread execution([&] { runtime.execute({}, execute_node); });
external_started.wait(false, std::memory_order_acquire);
renderive::scheduling::detail::OneTBB_Runtime::instance().enqueue([&] {
{