pub trait Task:
Any
+ Send
+ Sync {
type World: ?Sized;
// Required method
unsafe fn execute(
&self,
cbf: &mut RecordingCommandBuffer<'_>,
tcx: &mut TaskContext<'_>,
world: &Self::World,
) -> TaskResult;
// Provided method
fn clear_values(&self, clear_values: &mut ClearValues<'_>) { ... }
}
Expand description
A task represents a unit of work to be recorded to a command buffer.
Required Associated Types§
Required Methods§
Sourceunsafe fn execute(
&self,
cbf: &mut RecordingCommandBuffer<'_>,
tcx: &mut TaskContext<'_>,
world: &Self::World,
) -> TaskResult
unsafe fn execute( &self, cbf: &mut RecordingCommandBuffer<'_>, tcx: &mut TaskContext<'_>, world: &Self::World, ) -> TaskResult
Executes the task, which should record its commands using the provided command buffer and context.
§Safety
- Every resource in the [task’s access set] must not be written to concurrently in any other tasks during execution on the device.
- Every resource in the task’s access set, if it’s an [image access], must have had its layout transitioned to the layout specified in the access.
- Every resource in the task’s access set, if the resource’s sharing mode is exclusive, must be currently owned by the queue family the task is executing on.
Provided Methods§
Sourcefn clear_values(&self, clear_values: &mut ClearValues<'_>)
fn clear_values(&self, clear_values: &mut ClearValues<'_>)
If the task node was created with any attachments which were set to be cleared, this method is invoked to allow the task to set clear values for such attachments.
This method is invoked at least once for every attachment to be cleared before every
execution of the task. It’s possible that it is invoked multiple times before the task is
executed, and it may not be invoked right before execute
, just at some point between
when the task graph has begun execution and when the task is executed.
Implementations§
Source§impl<W: ?Sized + 'static> dyn Task<World = W>
impl<W: ?Sized + 'static> dyn Task<World = W>
Sourcepub fn downcast_ref<T: Task<World = W>>(&self) -> Option<&T>
pub fn downcast_ref<T: Task<World = W>>(&self) -> Option<&T>
Returns a reference to the inner value if it is of type T
, or returns None
otherwise.
Sourcepub fn downcast_mut<T: Task<World = W>>(&mut self) -> Option<&mut T>
pub fn downcast_mut<T: Task<World = W>>(&mut self) -> Option<&mut T>
Returns a reference to the inner value if it is of type T
, or returns None
otherwise.
Sourcepub unsafe fn downcast_unchecked_ref<T: Task<World = W>>(&self) -> &T
pub unsafe fn downcast_unchecked_ref<T: Task<World = W>>(&self) -> &T
Returns a reference to the inner value without checking if it is of type T
.
§Safety
self
must be of type T
.
Sourcepub unsafe fn downcast_unchecked_mut<T: Task<World = W>>(&mut self) -> &mut T
pub unsafe fn downcast_unchecked_mut<T: Task<World = W>>(&mut self) -> &mut T
Returns a reference to the inner value without checking if it is of type T
.
§Safety
self
must be of type T
.
Trait Implementations§
Implementations on Foreign Types§
Source§impl<W: ?Sized + 'static> Task for PhantomData<fn() -> W>
An implementation of a phantom task, which is zero-sized and doesn’t do anything.
impl<W: ?Sized + 'static> Task for PhantomData<fn() -> W>
An implementation of a phantom task, which is zero-sized and doesn’t do anything.
You may want to use this if all you’re interested in is the automatic synchronization and don’t have any other commands to execute. A common example would be doing a queue family ownership transfer after doing an upload.