Trait Task

Source
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§

Source

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§

Source

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>

Source

pub fn is<T: Task<World = W>>(&self) -> bool

Returns true if self is of type T.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl<W: ?Sized> Debug for dyn Task<World = W>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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.

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.

Source§

type World = W

Source§

unsafe fn execute( &self, _cbf: &mut RecordingCommandBuffer<'_>, _tcx: &mut TaskContext<'_>, _world: &Self::World, ) -> TaskResult

Implementors§