convert atom to task graph (#4230)
* Intial attempt to convert the Atom/RHI/FrameScheduler to use the new TaskGraph api Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com> * Avoid enqueuing work on the active task thread if the submitted task graph is waitable When submitting a task graph, supplying a wait event implies that dependent jobs must occur on threads that do not wait on the event (in the absence of work stealing). This change prevents this by adding a notion of a task thread enable/disable state, and prohibiting dependent jobs from being enqueued on waiting threads. Signed-off-by: Jeremy Ong <jcong@amazon.com> * Convert RPI/Scene to use TaskGraph pass 1, Culling jobs remain on the old system Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com> * RemoveTask Graph changes from the FrameScheduler::ExecuteGroups, use old job system instead Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com> * Per review, removing commented out code Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com> * Cleanup debug code, & build fix Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com> * Add a cvar & interface to query whether to use jobs or task graph Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com> * Make TaskGraph assert if you try to wait inside a job Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com> * Fix TaskTest SpawnSubgraph to account for the new TaskGraphEvent assert on wait in a running task Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com> * 3 minor cleanups. 1) Events always store a ptr to their executor 2) Fix clang compile error 3) remove an early out. Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com> * Fix double group end that was causing assert/crash plus misc minor diff's with development Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com> * Fix deallocation failure on deactivation of the TaskGraphSystemComponent. Also make the system component account for multiple creation in Unit Tests. Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com> * Update with PR feedback 1) Rename UseTaskGraph to IsTaskGraphActive & update related code 2) prefer TaskExecutor::SetInstance 3) add comments and remove commented out code Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com> * Fix incorrect RTTI name for TaskGraphActiveInterface Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com> * Move TaskGraphSystemComponent CRC calculation to a shared variable Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com> Co-authored-by: Jeremy Ong <jcong@amazon.com>
This commit is contained in:
@@ -34,7 +34,7 @@ namespace UnitTest
|
||||
AZ::AllocatorInstance<AZ::PoolAllocator>::Create();
|
||||
AZ::AllocatorInstance<AZ::ThreadPoolAllocator>::Create();
|
||||
|
||||
m_executor = aznew TaskExecutor(4);
|
||||
m_executor = aznew TaskExecutor();
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
@@ -236,6 +236,82 @@ namespace UnitTest
|
||||
EXPECT_EQ(x, 1);
|
||||
}
|
||||
|
||||
TEST_F(TaskGraphTestFixture, SingleTask)
|
||||
{
|
||||
AZStd::atomic_int32_t x = 0;
|
||||
|
||||
TaskGraph graph;
|
||||
graph.AddTask(
|
||||
defaultTD,
|
||||
[&x]
|
||||
{
|
||||
x = 1;
|
||||
});
|
||||
|
||||
TaskGraphEvent ev;
|
||||
graph.SubmitOnExecutor(*m_executor, &ev);
|
||||
ev.Wait();
|
||||
|
||||
EXPECT_EQ(1, x);
|
||||
}
|
||||
|
||||
|
||||
TEST_F(TaskGraphTestFixture, SingleTaskChain)
|
||||
{
|
||||
AZStd::atomic_int32_t x = 0;
|
||||
|
||||
TaskGraph graph;
|
||||
auto a = graph.AddTask(
|
||||
defaultTD,
|
||||
[&x]
|
||||
{
|
||||
x += 1;
|
||||
});
|
||||
auto b = graph.AddTask(
|
||||
defaultTD,
|
||||
[&x]
|
||||
{
|
||||
x += 1;
|
||||
});
|
||||
b.Precedes(a);
|
||||
|
||||
TaskGraphEvent ev;
|
||||
graph.SubmitOnExecutor(*m_executor, &ev);
|
||||
ev.Wait();
|
||||
|
||||
EXPECT_EQ(2, x);
|
||||
}
|
||||
|
||||
TEST_F(TaskGraphTestFixture, MultipleIndependentTaskChains)
|
||||
{
|
||||
AZStd::atomic_int32_t x = 0;
|
||||
constexpr int numChains = 5;
|
||||
|
||||
TaskGraph graph;
|
||||
for( int i = 0; i < numChains; ++i)
|
||||
{
|
||||
auto a = graph.AddTask(
|
||||
defaultTD,
|
||||
[&x]
|
||||
{
|
||||
x += 1;
|
||||
});
|
||||
auto b = graph.AddTask(
|
||||
defaultTD,
|
||||
[&x]
|
||||
{
|
||||
x += 1;
|
||||
});
|
||||
b.Precedes(a);
|
||||
}
|
||||
|
||||
TaskGraphEvent ev;
|
||||
graph.SubmitOnExecutor(*m_executor, &ev);
|
||||
ev.Wait();
|
||||
|
||||
EXPECT_EQ(2*numChains, x);
|
||||
}
|
||||
|
||||
TEST_F(TaskGraphTestFixture, VariadicInterface)
|
||||
{
|
||||
int x = 0;
|
||||
@@ -388,6 +464,7 @@ namespace UnitTest
|
||||
EXPECT_EQ(3, x);
|
||||
}
|
||||
|
||||
// Waiting inside a task is disallowed , test that it fails correctly
|
||||
TEST_F(TaskGraphTestFixture, SpawnSubgraph)
|
||||
{
|
||||
AZStd::atomic<int> x = 0;
|
||||
@@ -434,7 +511,10 @@ namespace UnitTest
|
||||
f.Precedes(g);
|
||||
TaskGraphEvent ev;
|
||||
subgraph.SubmitOnExecutor(*m_executor, &ev);
|
||||
// TaskGraphEvent::Wait asserts if called on a worker thread, suppress & validate assert
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
ev.Wait();
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1);
|
||||
});
|
||||
auto d = graph.AddTask(
|
||||
defaultTD,
|
||||
@@ -464,8 +544,6 @@ namespace UnitTest
|
||||
TaskGraphEvent ev;
|
||||
graph.SubmitOnExecutor(*m_executor, &ev);
|
||||
ev.Wait();
|
||||
|
||||
EXPECT_EQ(3 | 0b100000, x);
|
||||
}
|
||||
|
||||
TEST_F(TaskGraphTestFixture, RetainedGraph)
|
||||
|
||||
Reference in New Issue
Block a user