pub struct TaskContext<'a> { /* private fields */ }
Expand description
The context of a task.
This gives you access to the resources.
Implementations§
Source§impl<'a> TaskContext<'a>
impl<'a> TaskContext<'a>
Sourcepub fn buffer(&self, id: Id<Buffer>) -> TaskResult<&'a BufferState>
pub fn buffer(&self, id: Id<Buffer>) -> TaskResult<&'a BufferState>
Returns the buffer corresponding to id
, or returns an error if it isn’t present.
Sourcepub fn image(&self, id: Id<Image>) -> TaskResult<&'a ImageState>
pub fn image(&self, id: Id<Image>) -> TaskResult<&'a ImageState>
Returns the image corresponding to id
, or returns an error if it isn’t present.
§Panics
- Panics if
id
refers to a swapchain image.
Sourcepub fn swapchain(&self, id: Id<Swapchain>) -> TaskResult<&'a SwapchainState>
pub fn swapchain(&self, id: Id<Swapchain>) -> TaskResult<&'a SwapchainState>
Returns the swapchain corresponding to id
, or returns an error if it isn’t present.
Sourcepub fn resource_map(&self) -> &'a ResourceMap<'a>
pub fn resource_map(&self) -> &'a ResourceMap<'a>
Returns the ResourceMap
.
Sourcepub fn current_frame_index(&self) -> u32
pub fn current_frame_index(&self) -> u32
Returns the index of the current [frame] in [flight].
Sourcepub fn read_buffer<T: BufferContents + ?Sized>(
&self,
id: Id<Buffer>,
range: impl RangeBounds<DeviceSize>,
) -> TaskResult<&T>
pub fn read_buffer<T: BufferContents + ?Sized>( &self, id: Id<Buffer>, range: impl RangeBounds<DeviceSize>, ) -> TaskResult<&T>
Tries to get read access to a portion of the buffer corresponding to id
.
If host read access for the buffer is not accounted for in the [task graph’s host access set], this method will return an error.
If the memory backing the buffer is not managed by vulkano (i.e. the buffer was created
by RawBuffer::assume_bound
), then it can’t be read using this method and an error will
be returned.
§Panics
- Panics if the alignment of
T
is greater than 64. - Panics if
Subbuffer::slice
with the givenrange
panics. - Panics if
Subbuffer::reinterpret
to the givenT
panics.
Sourcepub unsafe fn read_buffer_unchecked<T: BufferContents + ?Sized>(
&self,
id: Id<Buffer>,
range: impl RangeBounds<DeviceSize>,
) -> TaskResult<&T>
pub unsafe fn read_buffer_unchecked<T: BufferContents + ?Sized>( &self, id: Id<Buffer>, range: impl RangeBounds<DeviceSize>, ) -> TaskResult<&T>
Gets read access to a portion of the buffer corresponding to id
without checking if this
access is accounted for in the [task graph’s host access set].
If the memory backing the buffer is not managed by vulkano (i.e. the buffer was created
by RawBuffer::assume_bound
), then it can’t be read using this method and an error will
be returned.
§Safety
This access must be accounted for in the task graph’s host access set.
§Panics
- Panics if the alignment of
T
is greater than 64. - Panics if
Subbuffer::slice
with the givenrange
panics. - Panics if
Subbuffer::reinterpret
to the givenT
panics.
Sourcepub fn write_buffer<T: BufferContents + ?Sized>(
&mut self,
id: Id<Buffer>,
range: impl RangeBounds<DeviceSize>,
) -> TaskResult<&mut T>
pub fn write_buffer<T: BufferContents + ?Sized>( &mut self, id: Id<Buffer>, range: impl RangeBounds<DeviceSize>, ) -> TaskResult<&mut T>
Tries to get write access to a portion of the buffer corresponding to id
.
If host write access for the buffer is not accounted for in the [task graph’s host access set], this method will return an error.
If the memory backing the buffer is not managed by vulkano (i.e. the buffer was created
by RawBuffer::assume_bound
), then it can’t be written using this method and an error
will be returned.
§Panics
- Panics if the alignment of
T
is greater than 64. - Panics if
Subbuffer::slice
with the givenrange
panics. - Panics if
Subbuffer::reinterpret
to the givenT
panics.
Sourcepub unsafe fn write_buffer_unchecked<T: BufferContents + ?Sized>(
&mut self,
id: Id<Buffer>,
range: impl RangeBounds<DeviceSize>,
) -> TaskResult<&mut T>
pub unsafe fn write_buffer_unchecked<T: BufferContents + ?Sized>( &mut self, id: Id<Buffer>, range: impl RangeBounds<DeviceSize>, ) -> TaskResult<&mut T>
Gets write access to a portion of the buffer corresponding to id
without checking if this
access is accounted for in the [task graph’s host access set].
If the memory backing the buffer is not managed by vulkano (i.e. the buffer was created
by RawBuffer::assume_bound
), then it can’t be written using this method and an error
will be returned.
§Safety
This access must be accounted for in the task graph’s host access set.
§Panics
- Panics if the alignment of
T
is greater than 64. - Panics if
Subbuffer::slice
with the givenrange
panics. - Panics if
Subbuffer::reinterpret
to the givenT
panics.
Sourcepub unsafe fn push_command_buffer(&mut self, command_buffer: Arc<CommandBuffer>)
pub unsafe fn push_command_buffer(&mut self, command_buffer: Arc<CommandBuffer>)
Pushes a command buffer into the list of command buffers to be executed on the queue.
All command buffers will be executed in the order in which they are pushed after the task has finished execution. That means in particular, that commands recorded by the task will start execution before execution of any pushed command buffers starts.
§Safety
Since the command buffer will be executed on the same queue right after the current command buffer, without any added synchronization, it must be safe to do so. The given command buffer must not do any accesses not accounted for in the [task’s access set], or ensure that such accesses are appropriately synchronized.
Sourcepub unsafe fn extend_command_buffers(
&mut self,
command_buffers: impl IntoIterator<Item = Arc<CommandBuffer>>,
)
pub unsafe fn extend_command_buffers( &mut self, command_buffers: impl IntoIterator<Item = Arc<CommandBuffer>>, )
Extends the list of command buffers to be executed on the queue.
This function behaves identically to the push_command_buffer
method, except that it
pushes all command buffers from the given iterator in order.
§Safety
See the push_command_buffer
method for the safety preconditions.