mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-27 01:05:03 +00:00
Merge pull request #229 from tomaka/extract-extract
Extract the state-extraction functions to their own trait
This commit is contained in:
commit
8b1cb63f4f
@ -14,6 +14,7 @@ use smallvec::SmallVec;
|
||||
|
||||
use buffer::traits::TrackedBuffer;
|
||||
use command_buffer::std::OutsideRenderPass;
|
||||
use command_buffer::std::ResourcesStates;
|
||||
use command_buffer::std::StdCommandsList;
|
||||
use command_buffer::submit::CommandBuffer;
|
||||
use command_buffer::submit::SubmitInfo;
|
||||
@ -62,7 +63,7 @@ impl<'a, L, Pl, S, Pc> DispatchCommand<'a, L, Pl, S, Pc>
|
||||
push_constants: &'a Pc) -> DispatchCommand<'a, L, Pl, S, Pc>
|
||||
{
|
||||
let (sets_state, barrier_loc, barrier) = unsafe {
|
||||
sets.extract_from_commands_list_and_transition(&mut previous)
|
||||
sets.extract_states_and_transition(&mut previous)
|
||||
};
|
||||
|
||||
DispatchCommand {
|
||||
@ -97,27 +98,6 @@ unsafe impl<'a, L, Pl, S, Pc> StdCommandsList for DispatchCommand<'a, L, Pl, S,
|
||||
self.previous.check_queue_validity(queue)
|
||||
}
|
||||
|
||||
unsafe fn extract_current_buffer_state<Ob>(&mut self, buffer: &Ob)
|
||||
-> Option<Ob::CommandListState>
|
||||
where Ob: TrackedBuffer
|
||||
{
|
||||
if let Some(s) = self.sets_state.extract_buffer_state(buffer) {
|
||||
return Some(s);
|
||||
}
|
||||
|
||||
self.previous.extract_current_buffer_state(buffer)
|
||||
}
|
||||
|
||||
unsafe fn extract_current_image_state<I>(&mut self, image: &I) -> Option<I::CommandListState>
|
||||
where I: TrackedImage
|
||||
{
|
||||
if let Some(s) = self.sets_state.extract_image_state(image) {
|
||||
return Some(s);
|
||||
}
|
||||
|
||||
self.previous.extract_current_image_state(image)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_compute_pipeline_bound<OPl>(&self, pipeline: &Arc<ComputePipeline<OPl>>) -> bool {
|
||||
pipeline.internal_object() == self.pipeline.internal_object()
|
||||
@ -197,6 +177,31 @@ unsafe impl<'a, L, Pl, S, Pc> StdCommandsList for DispatchCommand<'a, L, Pl, S,
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<'a, L, Pl, S, Pc> ResourcesStates for DispatchCommand<'a, L, Pl, S, Pc>
|
||||
where L: StdCommandsList, Pl: PipelineLayout, S: TrackedDescriptorSetsCollection, Pc: 'a
|
||||
{
|
||||
unsafe fn extract_buffer_state<Ob>(&mut self, buffer: &Ob)
|
||||
-> Option<Ob::CommandListState>
|
||||
where Ob: TrackedBuffer
|
||||
{
|
||||
if let Some(s) = self.sets_state.extract_buffer_state(buffer) {
|
||||
return Some(s);
|
||||
}
|
||||
|
||||
self.previous.extract_buffer_state(buffer)
|
||||
}
|
||||
|
||||
unsafe fn extract_image_state<I>(&mut self, image: &I) -> Option<I::CommandListState>
|
||||
where I: TrackedImage
|
||||
{
|
||||
if let Some(s) = self.sets_state.extract_image_state(image) {
|
||||
return Some(s);
|
||||
}
|
||||
|
||||
self.previous.extract_image_state(image)
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<'a, L, Pl, S, Pc> OutsideRenderPass for DispatchCommand<'a, L, Pl, S, Pc>
|
||||
where L: StdCommandsList, Pl: PipelineLayout, S: TrackedDescriptorSetsCollection, Pc: 'a
|
||||
{
|
||||
|
@ -16,6 +16,7 @@ use buffer::traits::Buffer;
|
||||
use buffer::traits::TrackedBuffer;
|
||||
use command_buffer::DynamicState;
|
||||
use command_buffer::std::InsideRenderPass;
|
||||
use command_buffer::std::ResourcesStates;
|
||||
use command_buffer::std::StdCommandsList;
|
||||
use command_buffer::submit::CommandBuffer;
|
||||
use command_buffer::submit::SubmitInfo;
|
||||
@ -88,7 +89,7 @@ impl<'a, L, Pv, Pl, Prp, S, Pc> DrawCommand<'a, L, Pv, Pl, Prp, S, Pc>
|
||||
where Pv: Source<V>
|
||||
{
|
||||
let (sets_state, barrier_loc, barrier) = unsafe {
|
||||
sets.extract_from_commands_list_and_transition(&mut previous)
|
||||
sets.extract_states_and_transition(&mut previous)
|
||||
};
|
||||
|
||||
// FIXME: lot of stuff missing here
|
||||
@ -134,27 +135,6 @@ unsafe impl<'a, L, Pv, Pl, Prp, S, Pc> StdCommandsList for DrawCommand<'a, L, Pv
|
||||
self.previous.check_queue_validity(queue)
|
||||
}
|
||||
|
||||
unsafe fn extract_current_buffer_state<Ob>(&mut self, buffer: &Ob)
|
||||
-> Option<Ob::CommandListState>
|
||||
where Ob: TrackedBuffer
|
||||
{
|
||||
if let Some(s) = self.sets_state.extract_buffer_state(buffer) {
|
||||
return Some(s);
|
||||
}
|
||||
|
||||
self.previous.extract_current_buffer_state(buffer)
|
||||
}
|
||||
|
||||
unsafe fn extract_current_image_state<I>(&mut self, image: &I) -> Option<I::CommandListState>
|
||||
where I: TrackedImage
|
||||
{
|
||||
if let Some(s) = self.sets_state.extract_image_state(image) {
|
||||
return Some(s);
|
||||
}
|
||||
|
||||
self.previous.extract_current_image_state(image)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_compute_pipeline_bound<OPl>(&self, pipeline: &Arc<ComputePipeline<OPl>>) -> bool {
|
||||
|
||||
@ -253,6 +233,32 @@ unsafe impl<'a, L, Pv, Pl, Prp, S, Pc> StdCommandsList for DrawCommand<'a, L, Pv
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<'a, L, Pv, Pl, Prp, S, Pc> ResourcesStates for DrawCommand<'a, L, Pv, Pl, Prp, S, Pc>
|
||||
where L: StdCommandsList, Pl: PipelineLayout,
|
||||
S: TrackedDescriptorSetsCollection, Pc: 'a
|
||||
{
|
||||
unsafe fn extract_buffer_state<Ob>(&mut self, buffer: &Ob)
|
||||
-> Option<Ob::CommandListState>
|
||||
where Ob: TrackedBuffer
|
||||
{
|
||||
if let Some(s) = self.sets_state.extract_buffer_state(buffer) {
|
||||
return Some(s);
|
||||
}
|
||||
|
||||
self.previous.extract_buffer_state(buffer)
|
||||
}
|
||||
|
||||
unsafe fn extract_image_state<I>(&mut self, image: &I) -> Option<I::CommandListState>
|
||||
where I: TrackedImage
|
||||
{
|
||||
if let Some(s) = self.sets_state.extract_image_state(image) {
|
||||
return Some(s);
|
||||
}
|
||||
|
||||
self.previous.extract_image_state(image)
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<'a, L, Pv, Pl, Prp, S, Pc> InsideRenderPass for DrawCommand<'a, L, Pv, Pl, Prp, S, Pc>
|
||||
where L: StdCommandsList + InsideRenderPass, Pl: PipelineLayout,
|
||||
S: TrackedDescriptorSetsCollection, Pc: 'a
|
||||
|
@ -15,6 +15,7 @@ use buffer::traits::TrackedBuffer;
|
||||
use command_buffer::pool::CommandPool;
|
||||
use command_buffer::pool::StandardCommandPool;
|
||||
use command_buffer::std::OutsideRenderPass;
|
||||
use command_buffer::std::ResourcesStates;
|
||||
use command_buffer::std::StdCommandsList;
|
||||
use command_buffer::submit::CommandBuffer;
|
||||
use command_buffer::submit::SubmitInfo;
|
||||
@ -73,20 +74,6 @@ unsafe impl<P> StdCommandsList for PrimaryCbBuilder<P> where P: CommandPool {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn extract_current_buffer_state<B>(&mut self, buffer: &B) -> Option<B::CommandListState>
|
||||
where B: TrackedBuffer
|
||||
{
|
||||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn extract_current_image_state<I>(&mut self, image: &I) -> Option<I::CommandListState>
|
||||
where I: TrackedImage
|
||||
{
|
||||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_compute_pipeline_bound<Pl>(&self, pipeline: &Arc<ComputePipeline<Pl>>) -> bool {
|
||||
|
||||
@ -132,6 +119,22 @@ unsafe impl<P> StdCommandsList for PrimaryCbBuilder<P> where P: CommandPool {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<P> ResourcesStates for PrimaryCbBuilder<P> where P: CommandPool {
|
||||
#[inline]
|
||||
unsafe fn extract_buffer_state<B>(&mut self, buffer: &B) -> Option<B::CommandListState>
|
||||
where B: TrackedBuffer
|
||||
{
|
||||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn extract_image_state<I>(&mut self, image: &I) -> Option<I::CommandListState>
|
||||
where I: TrackedImage
|
||||
{
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<P> OutsideRenderPass for PrimaryCbBuilder<P> where P: CommandPool {}
|
||||
|
||||
pub struct PrimaryCb<P = Arc<StandardCommandPool>> where P: CommandPool {
|
||||
|
@ -37,7 +37,7 @@ pub mod render_pass;
|
||||
pub mod update_buffer;
|
||||
|
||||
/// A list of commands that can be turned into a command buffer.
|
||||
pub unsafe trait StdCommandsList {
|
||||
pub unsafe trait StdCommandsList: ResourcesStates {
|
||||
/// The type of the pool that will be used to create the command buffer.
|
||||
type Pool: CommandPool;
|
||||
/// The type of the command buffer that will be generated.
|
||||
@ -142,35 +142,6 @@ pub unsafe trait StdCommandsList {
|
||||
// TODO: error type?
|
||||
fn check_queue_validity(&self, queue: QueueFamily) -> Result<(), ()>;
|
||||
|
||||
/// Returns the current status of a buffer, or `None` if the buffer hasn't been used yet.
|
||||
///
|
||||
/// Whether the buffer passed as parameter is the same as the one in the commands list must be
|
||||
/// determined with the `is_same` method of `TrackedBuffer`.
|
||||
///
|
||||
/// Calling this function tells the commands list that you are going to manage the
|
||||
/// synchronization that buffer yourself. Hence why the function is unsafe.
|
||||
///
|
||||
/// This function is not meant to be called, except when writing a wrapper around a
|
||||
/// commands list.
|
||||
///
|
||||
/// # Panic
|
||||
///
|
||||
/// - Panics if the state of that buffer has already been previously extracted.
|
||||
///
|
||||
unsafe fn extract_current_buffer_state<B>(&mut self, buffer: &B) -> Option<B::CommandListState>
|
||||
where B: TrackedBuffer;
|
||||
|
||||
/// Returns the current status of an image, or `None` if the image hasn't been used yet.
|
||||
///
|
||||
/// See the description of `extract_current_buffer_state`.
|
||||
///
|
||||
/// # Panic
|
||||
///
|
||||
/// - Panics if the state of that image has already been previously extracted.
|
||||
///
|
||||
unsafe fn extract_current_image_state<I>(&mut self, image: &I) -> Option<I::CommandListState>
|
||||
where I: TrackedImage;
|
||||
|
||||
/// Returns true if the given compute pipeline is currently binded in the commands list.
|
||||
fn is_compute_pipeline_bound<Pl>(&self, pipeline: &Arc<ComputePipeline<Pl>>) -> bool;
|
||||
|
||||
@ -220,3 +191,33 @@ pub unsafe trait InsideRenderPass: StdCommandsList {
|
||||
|
||||
fn framebuffer(&self) -> &Self::Framebuffer;
|
||||
}
|
||||
|
||||
/// Trait for objects that hold states of buffers and images.
|
||||
pub unsafe trait ResourcesStates {
|
||||
/// Returns the state of a buffer, or `None` if the buffer hasn't been used yet.
|
||||
///
|
||||
/// Whether the buffer passed as parameter is the same as the one in the commands list must be
|
||||
/// determined with the `is_same` method of `TrackedBuffer`.
|
||||
///
|
||||
/// Calling this function extracts the state from the list, meaning that the state will be
|
||||
/// managed by the code that called this function instead of being managed by the object
|
||||
/// itself. Hence why the function is unsafe.
|
||||
///
|
||||
/// # Panic
|
||||
///
|
||||
/// - Panics if the state of that buffer has already been previously extracted.
|
||||
///
|
||||
unsafe fn extract_buffer_state<B>(&mut self, buffer: &B) -> Option<B::CommandListState>
|
||||
where B: TrackedBuffer;
|
||||
|
||||
/// Returns the state of an image, or `None` if the image hasn't been used yet.
|
||||
///
|
||||
/// See the description of `extract_buffer_state`.
|
||||
///
|
||||
/// # Panic
|
||||
///
|
||||
/// - Panics if the state of that image has already been previously extracted.
|
||||
///
|
||||
unsafe fn extract_image_state<I>(&mut self, image: &I) -> Option<I::CommandListState>
|
||||
where I: TrackedImage;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ use smallvec::SmallVec;
|
||||
use buffer::traits::TrackedBuffer;
|
||||
use command_buffer::std::InsideRenderPass;
|
||||
use command_buffer::std::OutsideRenderPass;
|
||||
use command_buffer::std::ResourcesStates;
|
||||
use command_buffer::std::StdCommandsList;
|
||||
use command_buffer::submit::CommandBuffer;
|
||||
use command_buffer::submit::SubmitInfo;
|
||||
@ -97,21 +98,6 @@ unsafe impl<L, Rp, Rpf> StdCommandsList for BeginRenderPassCommand<L, Rp, Rpf>
|
||||
false
|
||||
}
|
||||
|
||||
unsafe fn extract_current_buffer_state<Ob>(&mut self, buffer: &Ob)
|
||||
-> Option<Ob::CommandListState>
|
||||
where Ob: TrackedBuffer
|
||||
{
|
||||
// FIXME: state of images in the framebuffer
|
||||
self.previous.extract_current_buffer_state(buffer)
|
||||
}
|
||||
|
||||
unsafe fn extract_current_image_state<I>(&mut self, image: &I) -> Option<I::CommandListState>
|
||||
where I: TrackedImage
|
||||
{
|
||||
// FIXME: state of images in the framebuffer
|
||||
self.previous.extract_current_image_state(image)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_compute_pipeline_bound<Pl>(&self, pipeline: &Arc<ComputePipeline<Pl>>) -> bool {
|
||||
|
||||
@ -153,6 +139,25 @@ unsafe impl<L, Rp, Rpf> StdCommandsList for BeginRenderPassCommand<L, Rp, Rpf>
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<L, Rp, Rpf> ResourcesStates for BeginRenderPassCommand<L, Rp, Rpf>
|
||||
where L: StdCommandsList, Rp: RenderPass, Rpf: RenderPass
|
||||
{
|
||||
unsafe fn extract_buffer_state<Ob>(&mut self, buffer: &Ob)
|
||||
-> Option<Ob::CommandListState>
|
||||
where Ob: TrackedBuffer
|
||||
{
|
||||
// FIXME: state of images in the framebuffer
|
||||
self.previous.extract_buffer_state(buffer)
|
||||
}
|
||||
|
||||
unsafe fn extract_image_state<I>(&mut self, image: &I) -> Option<I::CommandListState>
|
||||
where I: TrackedImage
|
||||
{
|
||||
// FIXME: state of images in the framebuffer
|
||||
self.previous.extract_image_state(image)
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<L, Rp, Rpf> InsideRenderPass for BeginRenderPassCommand<L, Rp, Rpf>
|
||||
where L: StdCommandsList, Rp: RenderPass, Rpf: RenderPass
|
||||
{
|
||||
@ -259,21 +264,6 @@ unsafe impl<L> StdCommandsList for NextSubpassCommand<L>
|
||||
false
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn extract_current_buffer_state<Ob>(&mut self, buffer: &Ob)
|
||||
-> Option<Ob::CommandListState>
|
||||
where Ob: TrackedBuffer
|
||||
{
|
||||
self.previous.extract_current_buffer_state(buffer)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn extract_current_image_state<I>(&mut self, image: &I) -> Option<I::CommandListState>
|
||||
where I: TrackedImage
|
||||
{
|
||||
self.previous.extract_current_image_state(image)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_compute_pipeline_bound<Pl>(&self, pipeline: &Arc<ComputePipeline<Pl>>) -> bool {
|
||||
|
||||
@ -305,6 +295,25 @@ unsafe impl<L> StdCommandsList for NextSubpassCommand<L>
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<L> ResourcesStates for NextSubpassCommand<L>
|
||||
where L: StdCommandsList + InsideRenderPass
|
||||
{
|
||||
#[inline]
|
||||
unsafe fn extract_buffer_state<Ob>(&mut self, buffer: &Ob)
|
||||
-> Option<Ob::CommandListState>
|
||||
where Ob: TrackedBuffer
|
||||
{
|
||||
self.previous.extract_buffer_state(buffer)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn extract_image_state<I>(&mut self, image: &I) -> Option<I::CommandListState>
|
||||
where I: TrackedImage
|
||||
{
|
||||
self.previous.extract_image_state(image)
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<L> InsideRenderPass for NextSubpassCommand<L>
|
||||
where L: StdCommandsList + InsideRenderPass
|
||||
{
|
||||
@ -399,21 +408,6 @@ unsafe impl<L> StdCommandsList for EndRenderPassCommand<L> where L: StdCommandsL
|
||||
true
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn extract_current_buffer_state<Ob>(&mut self, buffer: &Ob)
|
||||
-> Option<Ob::CommandListState>
|
||||
where Ob: TrackedBuffer
|
||||
{
|
||||
self.previous.extract_current_buffer_state(buffer)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn extract_current_image_state<I>(&mut self, image: &I) -> Option<I::CommandListState>
|
||||
where I: TrackedImage
|
||||
{
|
||||
self.previous.extract_current_image_state(image)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_compute_pipeline_bound<Pl>(&self, pipeline: &Arc<ComputePipeline<Pl>>) -> bool {
|
||||
|
||||
@ -453,6 +447,23 @@ unsafe impl<L> StdCommandsList for EndRenderPassCommand<L> where L: StdCommandsL
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<L> ResourcesStates for EndRenderPassCommand<L> where L: StdCommandsList {
|
||||
#[inline]
|
||||
unsafe fn extract_buffer_state<Ob>(&mut self, buffer: &Ob)
|
||||
-> Option<Ob::CommandListState>
|
||||
where Ob: TrackedBuffer
|
||||
{
|
||||
self.previous.extract_buffer_state(buffer)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn extract_image_state<I>(&mut self, image: &I) -> Option<I::CommandListState>
|
||||
where I: TrackedImage
|
||||
{
|
||||
self.previous.extract_image_state(image)
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<L> OutsideRenderPass for EndRenderPassCommand<L> where L: StdCommandsList {
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ use buffer::traits::CommandListState;
|
||||
use buffer::traits::PipelineBarrierRequest;
|
||||
use buffer::traits::TrackedBuffer;
|
||||
use command_buffer::std::OutsideRenderPass;
|
||||
use command_buffer::std::ResourcesStates;
|
||||
use command_buffer::std::StdCommandsList;
|
||||
use command_buffer::submit::CommandBuffer;
|
||||
use command_buffer::submit::SubmitInfo;
|
||||
@ -63,7 +64,7 @@ impl<'a, L, B, D: ?Sized> UpdateCommand<'a, L, B, D>
|
||||
let stage = PipelineStages { transfer: true, .. PipelineStages::none() };
|
||||
let access = AccessFlagBits { transfer_write: true, .. AccessFlagBits::none() };
|
||||
|
||||
previous.extract_current_buffer_state(&buffer)
|
||||
previous.extract_buffer_state(&buffer)
|
||||
.unwrap_or(buffer.initial_state())
|
||||
.transition(previous.num_commands() + 1, buffer.inner(),
|
||||
0, buffer.size(), true, stage, access)
|
||||
@ -108,33 +109,6 @@ unsafe impl<'a, L, B, D: ?Sized> StdCommandsList for UpdateCommand<'a, L, B, D>
|
||||
true
|
||||
}
|
||||
|
||||
unsafe fn extract_current_buffer_state<Ob>(&mut self, buffer: &Ob)
|
||||
-> Option<Ob::CommandListState>
|
||||
where Ob: TrackedBuffer
|
||||
{
|
||||
if self.buffer.is_same_buffer(buffer) {
|
||||
let s: &mut Option<Ob::CommandListState> = (&mut self.buffer_state as &mut Any)
|
||||
.downcast_mut().unwrap();
|
||||
Some(s.take().unwrap())
|
||||
|
||||
} else {
|
||||
self.previous.extract_current_buffer_state(buffer)
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn extract_current_image_state<I>(&mut self, image: &I) -> Option<I::CommandListState>
|
||||
where I: TrackedImage
|
||||
{
|
||||
if self.buffer.is_same_image(image) {
|
||||
let s: &mut Option<I::CommandListState> = (&mut self.buffer_state as &mut Any)
|
||||
.downcast_mut().unwrap();
|
||||
Some(s.take().unwrap())
|
||||
|
||||
} else {
|
||||
self.previous.extract_current_image_state(image)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_compute_pipeline_bound<Pl>(&self, pipeline: &Arc<ComputePipeline<Pl>>) -> bool {
|
||||
|
||||
@ -209,6 +183,39 @@ unsafe impl<'a, L, B, D: ?Sized> StdCommandsList for UpdateCommand<'a, L, B, D>
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<'a, L, B, D: ?Sized> ResourcesStates for UpdateCommand<'a, L, B, D>
|
||||
where B: TrackedBuffer,
|
||||
L: StdCommandsList,
|
||||
D: Copy + 'static,
|
||||
{
|
||||
unsafe fn extract_buffer_state<Ob>(&mut self, buffer: &Ob)
|
||||
-> Option<Ob::CommandListState>
|
||||
where Ob: TrackedBuffer
|
||||
{
|
||||
if self.buffer.is_same_buffer(buffer) {
|
||||
let s: &mut Option<Ob::CommandListState> = (&mut self.buffer_state as &mut Any)
|
||||
.downcast_mut().unwrap();
|
||||
Some(s.take().unwrap())
|
||||
|
||||
} else {
|
||||
self.previous.extract_buffer_state(buffer)
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn extract_image_state<I>(&mut self, image: &I) -> Option<I::CommandListState>
|
||||
where I: TrackedImage
|
||||
{
|
||||
if self.buffer.is_same_image(image) {
|
||||
let s: &mut Option<I::CommandListState> = (&mut self.buffer_state as &mut Any)
|
||||
.downcast_mut().unwrap();
|
||||
Some(s.take().unwrap())
|
||||
|
||||
} else {
|
||||
self.previous.extract_image_state(image)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<'a, L, B, D: ?Sized> OutsideRenderPass for UpdateCommand<'a, L, B, D>
|
||||
where B: TrackedBuffer,
|
||||
L: StdCommandsList,
|
||||
|
@ -14,7 +14,7 @@ use std::sync::Arc;
|
||||
use std::vec::IntoIter as VecIntoIter;
|
||||
|
||||
use buffer::traits::TrackedBuffer;
|
||||
use command_buffer::std::StdCommandsList;
|
||||
use command_buffer::std::ResourcesStates;
|
||||
use command_buffer::submit::SubmitInfo;
|
||||
use command_buffer::sys::PipelineBarrierBuilder;
|
||||
use descriptor::descriptor::DescriptorDesc;
|
||||
@ -52,43 +52,19 @@ pub unsafe trait TrackedDescriptorSetsCollection: DescriptorSetsCollection {
|
||||
/// Finished state of the resources inside the collection.
|
||||
type Finished: TrackedDescriptorSetsCollectionFinished;
|
||||
|
||||
/// Extracts from the commands list the states relevant to the buffers and images contained in
|
||||
/// the descriptor sets. Then transitions them to the right state and returns a pipeline
|
||||
/// barrier to insert as part of the transition. The `usize` is the location of the barrier.
|
||||
unsafe fn extract_from_commands_list_and_transition<L>(&self, list: &mut L)
|
||||
-> (Self::State, usize, PipelineBarrierBuilder)
|
||||
where L: StdCommandsList;
|
||||
/// Extracts the states relevant to the buffers and images contained in the descriptor sets.
|
||||
/// Then transitions them to the right state and returns a pipeline barrier to insert as part
|
||||
/// of the transition. The `usize` is the location of the barrier.
|
||||
unsafe fn extract_states_and_transition<S>(&self, list: &mut S)
|
||||
-> (Self::State, usize, PipelineBarrierBuilder)
|
||||
where S: ResourcesStates;
|
||||
}
|
||||
|
||||
/// State of the resources inside the collection.
|
||||
pub unsafe trait TrackedDescriptorSetsCollectionState {
|
||||
pub unsafe trait TrackedDescriptorSetsCollectionState: ResourcesStates {
|
||||
/// Finished state of the resources inside the collection.
|
||||
type Finished: TrackedDescriptorSetsCollectionFinished;
|
||||
|
||||
/// Extracts the state of a buffer of the collection, or `None` if the buffer isn't in the
|
||||
/// collection.
|
||||
///
|
||||
/// Whether the buffer passed as parameter is the same as one in the collection must be
|
||||
/// determined with the `is_same` method of `TrackedBuffer` or `TrackedImage`.
|
||||
///
|
||||
/// # Panic
|
||||
///
|
||||
/// - Panics if the state of that buffer has already been previously extracted.
|
||||
///
|
||||
unsafe fn extract_buffer_state<B>(&mut self, buffer: &B) -> Option<B::CommandListState>
|
||||
where B: TrackedBuffer;
|
||||
|
||||
/// Returns the state of an image, or `None` if the image isn't in the collection.
|
||||
///
|
||||
/// See the description of `extract_buffer_state`.
|
||||
///
|
||||
/// # Panic
|
||||
///
|
||||
/// - Panics if the state of that image has already been previously extracted.
|
||||
///
|
||||
unsafe fn extract_image_state<I>(&mut self, image: &I) -> Option<I::CommandListState>
|
||||
where I: TrackedImage;
|
||||
|
||||
/// Turns the object into a `TrackedDescriptorSetsCollectionFinished`. All the buffers and
|
||||
/// images whose state hasn't been extracted must be have `finished()` called on them as well.
|
||||
///
|
||||
@ -134,9 +110,9 @@ unsafe impl TrackedDescriptorSetsCollection for () {
|
||||
type Finished = EmptyState;
|
||||
|
||||
#[inline]
|
||||
unsafe fn extract_from_commands_list_and_transition<L>(&self, list: &mut L)
|
||||
unsafe fn extract_states_and_transition<S>(&self, list: &mut S)
|
||||
-> (Self::State, usize, PipelineBarrierBuilder)
|
||||
where L: StdCommandsList
|
||||
where S: ResourcesStates
|
||||
{
|
||||
(EmptyState, 0, PipelineBarrierBuilder::new())
|
||||
}
|
||||
@ -148,6 +124,13 @@ pub struct EmptyState;
|
||||
unsafe impl TrackedDescriptorSetsCollectionState for EmptyState {
|
||||
type Finished = EmptyState;
|
||||
|
||||
#[inline]
|
||||
unsafe fn finish(self) -> (Self::Finished, PipelineBarrierBuilder) {
|
||||
(EmptyState, PipelineBarrierBuilder::new())
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl ResourcesStates for EmptyState {
|
||||
#[inline]
|
||||
unsafe fn extract_buffer_state<B>(&mut self, buffer: &B) -> Option<B::CommandListState>
|
||||
where B: TrackedBuffer
|
||||
@ -161,11 +144,6 @@ unsafe impl TrackedDescriptorSetsCollectionState for EmptyState {
|
||||
{
|
||||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn finish(self) -> (Self::Finished, PipelineBarrierBuilder) {
|
||||
(EmptyState, PipelineBarrierBuilder::new())
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl TrackedDescriptorSetsCollectionFinished for EmptyState {
|
||||
|
@ -10,7 +10,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use buffer::traits::TrackedBuffer;
|
||||
use command_buffer::std::StdCommandsList;
|
||||
use command_buffer::std::ResourcesStates;
|
||||
use command_buffer::submit::SubmitInfo;
|
||||
use command_buffer::sys::PipelineBarrierBuilder;
|
||||
use descriptor::descriptor::DescriptorDesc;
|
||||
@ -57,15 +57,15 @@ pub unsafe trait TrackedDescriptorSet: DescriptorSet {
|
||||
type State: TrackedDescriptorSetState<Finished = Self::Finished>;
|
||||
type Finished: TrackedDescriptorSetFinished;
|
||||
|
||||
/// Extracts from the commands list the states relevant to the buffers and images contained in
|
||||
/// the descriptor set. Then transitions them to the right state.
|
||||
unsafe fn extract_from_commands_list_and_transition<L>(&self, list: &mut L)
|
||||
-> (Self::State, usize, PipelineBarrierBuilder)
|
||||
where L: StdCommandsList;
|
||||
/// Extracts the states relevant to the buffers and images contained in the descriptor set.
|
||||
/// Then transitions them to the right state.
|
||||
unsafe fn extract_states_and_transition<L>(&self, list: &mut L)
|
||||
-> (Self::State, usize, PipelineBarrierBuilder)
|
||||
where L: ResourcesStates;
|
||||
}
|
||||
|
||||
// TODO: re-read docs
|
||||
pub unsafe trait TrackedDescriptorSetState {
|
||||
pub unsafe trait TrackedDescriptorSetState: ResourcesStates {
|
||||
type Finished: TrackedDescriptorSetFinished;
|
||||
|
||||
/// Extracts the state of a buffer of the descriptor set, or `None` if the buffer isn't in
|
||||
@ -83,7 +83,7 @@ pub unsafe trait TrackedDescriptorSetState {
|
||||
|
||||
/// Returns the state of an image, or `None` if the image isn't in the descriptor set.
|
||||
///
|
||||
/// See the description of `extract_current_buffer_state`.
|
||||
/// See the description of `extract_buffer_state`.
|
||||
///
|
||||
/// # Panic
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user