Skip to content
This repository was archived by the owner on Aug 2, 2025. It is now read-only.

Commit 63e8ae4

Browse files
committed
Add more detail on task graph resources and data dependencies
1 parent 9b7ff70 commit 63e8ae4

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

docs/taskgraph.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,42 @@ For this purpose, Daxa has TaskImageViews. A TaskImageView, similarly to an Imag
4242

4343
All Tasks take in views instead of the resources themselves. Resources implicitly cast to the views but have the explicit conversion function `.view()`. Views also have a `.view()` function to create a new view from an existing one.
4444

45+
### Task Resource Data Dependencies
46+
47+
One of the main functions of the task graph is automatically generate sync and to automatically optimize execution by reordering task callbacks and their recorded commands.
48+
49+
To know how to generate sync and when its safe to reorder commands, the tg builds a literl graph of resource uses between the tasks. Based on this graph we can infer optimal ordering and sync.
50+
51+
#### Usage Implications
52+
53+
when a task is added, tg will immediately form new access dependencies for all resources assigned to attachments of that task.
54+
55+
Example:
56+
57+
`TaskA(write Img0), TaskB(read Img0, write Img1), TaskC(read Img1)`
58+
Here, TaskB reads img0, tg will see that the TaskA writing Img0 was recorded before TaskB. Tg will form a write -> read dependency when adding TaskB, forcing TaskB to be executed AFTER TaskA. Same for TaskC to TaskB. This leaves the only execution order:
59+
`TaskA -> TaskB -> TaskC`
60+
61+
62+
`TaskA(write Img0), TaskB(read Img0, write Img1), TaskC(write Img2), TaskD(read Img2)`
63+
In this example there is no dependency between TaskC to A and B, no dependency between TaskD to A and B. This allows task graph to move the execution of TaskC and TaskD earlier, this will reduce the number of barriers.
64+
`TaskA TaskC -> TaskB TaskD`
65+
66+
Dependencies are always formed immediately when a task is added based on the given task resource views.
67+
68+
### Concurrent Access
69+
70+
Sometimes it is undesirable that two tasks that write the same resource form a `write -> write` order depdendency. For example it could be the case that TaskA writes the left half of an image and TaskB the right half or that the access is synchronized via atomics.
71+
72+
Tg will form dependencies here per default. To avoid this, use a concurrent task access for all tasks that you want to allow them to execute at the same time.
73+
74+
Example:
75+
`TaskA(write ImgA), TaskB(concurrent write ImgA), TaskC(concurrent write ImgA), TaskD(write ImgA),
76+
Likely execution order generated by tg:
77+
`TaskA -> TaskB TaskC -> TaskD`
78+
79+
Notice here that there are still dependencies formed to writes not marked as concurrent. So while B and C execute together, A and D form strong ordering dependencies to the concurrent writes.
80+
4581
## Task
4682

4783
The core part of any render graph is the nodes in the graph. In the case of Daxa, these nodes are called tasks.

0 commit comments

Comments
 (0)