pub struct TaskGraph<W: ?Sized> { /* private fields */ }
Expand description
The task graph is a directed acyclic graph consisting of Task
nodes, with edges
representing happens-before relations.
Implementations§
Source§impl<W: ?Sized> TaskGraph<W>
impl<W: ?Sized> TaskGraph<W>
Sourcepub unsafe fn compile(
self,
compile_info: &CompileInfo<'_>,
) -> Result<ExecutableTaskGraph<W>, CompileError<W>>
pub unsafe fn compile( self, compile_info: &CompileInfo<'_>, ) -> Result<ExecutableTaskGraph<W>, CompileError<W>>
Compiles the task graph into an executable form.
§Safety
- There must be no conflicting device accesses in task nodes with no path between them.
- There must be no accesses that are incompatible with the queue family type of the task node.
- There must be no accesses that are unsupported by the device.
§Panics
- Panics if
compile_info.queues
is empty. - Panics if the device of any queue in
compile_info.queues
orcompile_info.present_queue
is not the same as that ofself
. - Panics if
compile_info.queues
contains duplicate queue families. - Panics if
compile_info.present_queue
isNone
and the task graph uses any swapchains.
§Errors
In order to get a successful compilation, the graph must satisfy the following conditions:
- It must be weakly connected: every node must be able to reach every other node when disregarding the direction of the edges.
- It must have no directed cycles: if you were to walk starting from any node following the direction of the edges, there must be no way to end up at the node you started at.
Source§impl<W: ?Sized> TaskGraph<W>
impl<W: ?Sized> TaskGraph<W>
Sourcepub fn new(
physical_resources: &Arc<Resources>,
max_nodes: u32,
max_resources: u32,
) -> Self
pub fn new( physical_resources: &Arc<Resources>, max_nodes: u32, max_resources: u32, ) -> Self
Creates a new TaskGraph
.
max_nodes
is the maximum number of nodes the graph can ever have. max_resources
is the
maximum number of virtual resources the graph can ever have.
Sourcepub fn create_task_node(
&mut self,
name: impl Into<Cow<'static, str>>,
queue_family_type: QueueFamilyType,
task: impl Task<World = W>,
) -> TaskNodeBuilder<'_>
pub fn create_task_node( &mut self, name: impl Into<Cow<'static, str>>, queue_family_type: QueueFamilyType, task: impl Task<World = W>, ) -> TaskNodeBuilder<'_>
Creates a new TaskNode
from the given task
and adds it to the graph. Returns a
builder allowing you to add resource accesses to the task node.
queue_family_type
is the type of queue family the task can be executed on.
Sourcepub fn remove_task_node(
&mut self,
id: NodeId,
) -> Result<TaskNode<W>, TaskGraphError>
pub fn remove_task_node( &mut self, id: NodeId, ) -> Result<TaskNode<W>, TaskGraphError>
Removes the task node corresponding to id
from the graph.
Sourcepub fn add_edge(
&mut self,
from: NodeId,
to: NodeId,
) -> Result<(), TaskGraphError>
pub fn add_edge( &mut self, from: NodeId, to: NodeId, ) -> Result<(), TaskGraphError>
Adds an edge starting at the node corresponding to from
and ending at the node
corresponding to to
.
Sourcepub fn remove_edge(
&mut self,
from: NodeId,
to: NodeId,
) -> Result<(), TaskGraphError>
pub fn remove_edge( &mut self, from: NodeId, to: NodeId, ) -> Result<(), TaskGraphError>
Removes an edge starting at the node corresponding to from
and ending at the node
corresponding to to
.
Sourcepub fn task_node(&self, id: NodeId) -> Result<&TaskNode<W>, TaskGraphError>
pub fn task_node(&self, id: NodeId) -> Result<&TaskNode<W>, TaskGraphError>
Returns a reference to the task node corresponding to id
.
Sourcepub fn task_node_mut(
&mut self,
id: NodeId,
) -> Result<&mut TaskNode<W>, TaskGraphError>
pub fn task_node_mut( &mut self, id: NodeId, ) -> Result<&mut TaskNode<W>, TaskGraphError>
Returns a mutable reference to the task node corresponding to id
.
Sourcepub fn task_nodes(&self) -> TaskNodes<'_, W> ⓘ
pub fn task_nodes(&self) -> TaskNodes<'_, W> ⓘ
Returns an iterator over all TaskNode
s.
Sourcepub fn task_nodes_mut(&mut self) -> TaskNodesMut<'_, W> ⓘ
pub fn task_nodes_mut(&mut self) -> TaskNodesMut<'_, W> ⓘ
Returns an iterator over all TaskNode
s that allows you to mutate them.
Sourcepub fn add_buffer(&mut self, create_info: &BufferCreateInfo) -> Id<Buffer>
pub fn add_buffer(&mut self, create_info: &BufferCreateInfo) -> Id<Buffer>
Add a [virtual buffer resource] to the task graph.
Sourcepub fn add_image(&mut self, create_info: &ImageCreateInfo) -> Id<Image>
pub fn add_image(&mut self, create_info: &ImageCreateInfo) -> Id<Image>
Add a [virtual image resource] to the task graph.
Sourcepub fn add_swapchain(
&mut self,
create_info: &SwapchainCreateInfo,
) -> Id<Swapchain>
pub fn add_swapchain( &mut self, create_info: &SwapchainCreateInfo, ) -> Id<Swapchain>
Add a [virtual swapchain resource] to the task graph.
Sourcepub fn add_host_buffer_access(
&mut self,
id: Id<Buffer>,
access_type: HostAccessType,
)
pub fn add_host_buffer_access( &mut self, id: Id<Buffer>, access_type: HostAccessType, )
Adds a host buffer access to the task graph.
§Panics
- Panics if
id
is not a valid virtual resource ID nor a valid physical ID.
Sourcepub fn add_framebuffer(&mut self) -> Id<Framebuffer>
pub fn add_framebuffer(&mut self) -> Id<Framebuffer>
Adds a [virtual framebuffer] to the task graph.