diff --git a/vulkano/src/buffer.rs b/vulkano/src/buffer.rs index 169166b0..df13b721 100644 --- a/vulkano/src/buffer.rs +++ b/vulkano/src/buffer.rs @@ -250,33 +250,6 @@ impl Buffer { pub fn usage_indirect_buffer(&self) -> bool { (self.inner.usage & vk::BUFFER_USAGE_INDIRECT_BUFFER_BIT) != 0 } - - /*pub fn try_read(&self) -> Option { - - } - - pub fn read(&self, timeout_ns: u64) -> Result { - - } - - pub fn try_write(&self) -> Option { - } - - pub fn write(&self) -> Result { - }*/ - - /// Builds a slice without checking neither the type nor the range. - #[inline] - pub unsafe fn unchecked_slice(&self, range: Range) -> BufferSlice { - unimplemented!() - /*BufferSlice { - marker: PhantomData, - - inner: &self.inner, - offset: range.start, - size: range.end - range.start, - }*/ - } } impl Buffer<[T], M> { diff --git a/vulkano/src/command_buffer/inner.rs b/vulkano/src/command_buffer/inner.rs index f4f14117..281a9b55 100644 --- a/vulkano/src/command_buffer/inner.rs +++ b/vulkano/src/command_buffer/inner.rs @@ -276,8 +276,9 @@ impl InnerCommandBufferBuilder { let vk = self.device.pointers(); - let ids = vertices.ids(); - let offsets = (0 .. ids.len()).map(|_| 0).collect::>(); + let buffers = vertices.buffers(); + let offsets = (0 .. buffers.len()).map(|_| 0).collect::>(); + let ids = buffers.iter().map(|b| b.internal_object()).collect::>(); vk.CmdBindVertexBuffers(self.cmd.unwrap(), 0, ids.len() as u32, ids.as_ptr(), offsets.as_ptr()); vk.CmdDraw(self.cmd.unwrap(), 3, 1, 0, 0); // FIXME: params diff --git a/vulkano/src/pipeline/vertex.rs b/vulkano/src/pipeline/vertex.rs index 78f364c7..136b5e51 100644 --- a/vulkano/src/pipeline/vertex.rs +++ b/vulkano/src/pipeline/vertex.rs @@ -1,9 +1,10 @@ use std::mem; use std::sync::Arc; -use VulkanObject; use buffer::Buffer; +use buffer::BufferResource; use formats::Format; +use memory::MemorySourceChunk; use vk; #[derive(Copy, Clone, Debug)] @@ -34,11 +35,12 @@ pub unsafe trait MultiVertex { fn buffer_info(buffer_id: u32) -> (u32, VertexInputRate); - // TODO: hacky - fn ids(&self) -> Vec; + fn buffers(&self) -> Vec>; } -unsafe impl MultiVertex for Arc> where T: Vertex { +unsafe impl MultiVertex for Arc> + where T: 'static + Vertex, M: 'static + MemorySourceChunk +{ #[inline] fn attrib(name: &str) -> Option<(u32, VertexAttribute)> { T::attrib(name).map(|attr| (0, attr)) @@ -55,12 +57,15 @@ unsafe impl MultiVertex for Arc> where T: Vertex { (mem::size_of::() as u32, VertexInputRate::Vertex) } - fn ids(&self) -> Vec { - vec![self.internal_object()] + #[inline] + fn buffers(&self) -> Vec> { + vec![self.clone()] } } -unsafe impl MultiVertex for Arc> where T: Vertex { +unsafe impl MultiVertex for Arc> + where T: 'static + Vertex, M: 'static + MemorySourceChunk +{ #[inline] fn attrib(name: &str) -> Option<(u32, VertexAttribute)> { T::attrib(name).map(|attr| (0, attr)) @@ -77,14 +82,17 @@ unsafe impl MultiVertex for Arc> where T: Vertex { (mem::size_of::() as u32, VertexInputRate::Vertex) } - fn ids(&self) -> Vec { - vec![self.internal_object()] + #[inline] + fn buffers(&self) -> Vec> { + vec![self.clone()] } } macro_rules! impl_mv { ($t1:ident, $t2:ty) => ( - unsafe impl<$t1, M> MultiVertex for Arc> where T: Vertex { + unsafe impl<$t1, M> MultiVertex for Arc> + where T: 'static + Vertex, M: 'static + MemorySourceChunk + { #[inline] fn attrib(name: &str) -> Option<(u32, VertexAttribute)> { T::attrib(name).map(|attr| (0, attr)) @@ -101,8 +109,8 @@ macro_rules! impl_mv { (mem::size_of::() as u32, VertexInputRate::Vertex) } - fn ids(&self) -> Vec { - vec![self.internal_object()] + fn buffers(&self) -> Vec> { + vec![self.clone()] } } );