mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-22 06:45:23 +00:00
Minor cleanup with buffers
This commit is contained in:
parent
16eb2de55e
commit
8527843f2d
@ -250,33 +250,6 @@ impl<T: ?Sized, M> Buffer<T, M> {
|
||||
pub fn usage_indirect_buffer(&self) -> bool {
|
||||
(self.inner.usage & vk::BUFFER_USAGE_INDIRECT_BUFFER_BIT) != 0
|
||||
}
|
||||
|
||||
/*pub fn try_read(&self) -> Option<Read> {
|
||||
|
||||
}
|
||||
|
||||
pub fn read(&self, timeout_ns: u64) -> Result<Read, > {
|
||||
|
||||
}
|
||||
|
||||
pub fn try_write(&self) -> Option<ReadWrite> {
|
||||
}
|
||||
|
||||
pub fn write(&self) -> Result<ReadWrite, > {
|
||||
}*/
|
||||
|
||||
/// Builds a slice without checking neither the type nor the range.
|
||||
#[inline]
|
||||
pub unsafe fn unchecked_slice<U: ?Sized>(&self, range: Range<usize>) -> BufferSlice<U, M> {
|
||||
unimplemented!()
|
||||
/*BufferSlice {
|
||||
marker: PhantomData,
|
||||
|
||||
inner: &self.inner,
|
||||
offset: range.start,
|
||||
size: range.end - range.start,
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, M> Buffer<[T], M> {
|
||||
|
@ -276,8 +276,9 @@ impl InnerCommandBufferBuilder {
|
||||
|
||||
let vk = self.device.pointers();
|
||||
|
||||
let ids = vertices.ids();
|
||||
let offsets = (0 .. ids.len()).map(|_| 0).collect::<Vec<_>>();
|
||||
let buffers = vertices.buffers();
|
||||
let offsets = (0 .. buffers.len()).map(|_| 0).collect::<Vec<_>>();
|
||||
let ids = buffers.iter().map(|b| b.internal_object()).collect::<Vec<_>>();
|
||||
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
|
||||
|
@ -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<u64>;
|
||||
fn buffers(&self) -> Vec<Arc<BufferResource>>;
|
||||
}
|
||||
|
||||
unsafe impl<T, M> MultiVertex for Arc<Buffer<T, M>> where T: Vertex {
|
||||
unsafe impl<T, M> MultiVertex for Arc<Buffer<T, M>>
|
||||
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<T, M> MultiVertex for Arc<Buffer<T, M>> where T: Vertex {
|
||||
(mem::size_of::<T>() as u32, VertexInputRate::Vertex)
|
||||
}
|
||||
|
||||
fn ids(&self) -> Vec<u64> {
|
||||
vec![self.internal_object()]
|
||||
#[inline]
|
||||
fn buffers(&self) -> Vec<Arc<BufferResource>> {
|
||||
vec![self.clone()]
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<T, M> MultiVertex for Arc<Buffer<[T], M>> where T: Vertex {
|
||||
unsafe impl<T, M> MultiVertex for Arc<Buffer<[T], M>>
|
||||
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<T, M> MultiVertex for Arc<Buffer<[T], M>> where T: Vertex {
|
||||
(mem::size_of::<T>() as u32, VertexInputRate::Vertex)
|
||||
}
|
||||
|
||||
fn ids(&self) -> Vec<u64> {
|
||||
vec![self.internal_object()]
|
||||
#[inline]
|
||||
fn buffers(&self) -> Vec<Arc<BufferResource>> {
|
||||
vec![self.clone()]
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! impl_mv {
|
||||
($t1:ident, $t2:ty) => (
|
||||
unsafe impl<$t1, M> MultiVertex for Arc<Buffer<$t2, M>> where T: Vertex {
|
||||
unsafe impl<$t1, M> MultiVertex for Arc<Buffer<$t2, M>>
|
||||
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::<T>() as u32, VertexInputRate::Vertex)
|
||||
}
|
||||
|
||||
fn ids(&self) -> Vec<u64> {
|
||||
vec![self.internal_object()]
|
||||
fn buffers(&self) -> Vec<Arc<BufferResource>> {
|
||||
vec![self.clone()]
|
||||
}
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user