From a8d2b6a774ad44d28368caddc44f3b7dbfd89386 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Sun, 2 Oct 2016 18:17:41 +0200 Subject: [PATCH] Add StdDescriptorSetBufView --- vulkano/src/descriptor/descriptor_set/std.rs | 53 ++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/vulkano/src/descriptor/descriptor_set/std.rs b/vulkano/src/descriptor/descriptor_set/std.rs index 969116a1..78301597 100644 --- a/vulkano/src/descriptor/descriptor_set/std.rs +++ b/vulkano/src/descriptor/descriptor_set/std.rs @@ -10,6 +10,8 @@ use std::cmp; use std::sync::Arc; +use buffer::Buffer; +use buffer::BufferView; use buffer::TrackedBuffer; use command_buffer::submit::SubmitInfo; use command_buffer::sys::PipelineBarrierBuilder; @@ -165,6 +167,57 @@ pub enum StdDescriptorSetBufTy { DynamicUniformBuffer, } +pub struct StdDescriptorSetBufView where B: Buffer { + pub view: Arc>, + pub ty: StdDescriptorSetBufViewTy, + pub write: bool, + pub stage: PipelineStages, + pub access: AccessFlagBits, +} + +unsafe impl StdDescriptorSetResourcesCollection for StdDescriptorSetBufView + where B: TrackedBuffer +{ + #[inline] + unsafe fn transition(&self, states: &mut S, num_command: usize) + -> (usize, PipelineBarrierBuilder) + { + let trans = self.view.buffer().transition(states, num_command, 0, self.view.buffer().size(), + self.write, self.stage, self.access); + + if let Some(trans) = trans { + let n = trans.after_command_num; + let mut b = PipelineBarrierBuilder::new(); + b.add_buffer_barrier_request(&self.view.buffer(), trans); + (n, b) + } else { + (0, PipelineBarrierBuilder::new()) + } + } + + #[inline] + unsafe fn finish(&self, in_s: &mut S, out: &mut S) -> PipelineBarrierBuilder { + if let Some(trans) = self.view.buffer().finish(in_s, out) { + let mut b = PipelineBarrierBuilder::new(); + b.add_buffer_barrier_request(&self.view.buffer(), trans); + b + } else { + PipelineBarrierBuilder::new() + } + } + + unsafe fn on_submit(&self, _: &S, queue: &Arc, fence: Fe) -> SubmitInfo + where Fe: FnMut() -> Arc + { + unimplemented!() // FIXME: + } +} + +pub enum StdDescriptorSetBufViewTy { + StorageBufferView, + UniformBufferView, +} + macro_rules! tuple_impl { ($first:ident, $($rest:ident),+) => ( unsafe impl StdDescriptorSetResourcesCollection for ($first $(, $rest)+)