This commit is contained in:
2020-01-23 23:13:36 -08:00
parent dcc0df955e
commit 2bc9ebdc6b
31829 changed files with 1229378 additions and 17 deletions

View File

@@ -4,6 +4,7 @@ use vulkano::buffer::BufferAccess;
use std::sync::Arc;
use cgmath::num_traits::real::Real;
use std::vec::IntoIter as VecIntoIter;
use std::mem;
/// Runtime Vertex def is just a generic holder of "dynamic vertex definitions"
// This baby needs to be able to be copied....
@@ -111,32 +112,51 @@ unsafe impl<I> VertexDefinition<I> for RuntimeVertexDef
let buffers_iter = self.buffers.clone().into_iter();
let mut attribs_iter = self.attributes.iter().map(|&(ref name, buffer_id, ref infos)| {
let attrib_loc = interface
.elements()
.find(|e| e.name.as_ref().map(|n| &n[..]) == Some(&name[..]))
.unwrap()
.location.start;
(attrib_loc as u32, buffer_id, AttributeInfo { offset: infos.offset, format: infos.format })
}).collect::<Vec<_>>();
let mut attributes = Vec::default();
// Add dummy attributes.
// Binding is
for input in interface.elements() {
attributes.push((
input.location.start as u32,
input.location.start as u32,
AttributeInfo { offset: 0, format: input.format }
));
println!("{:?}", input.location);
println!("{:?}", input.format);
println!("{:?}", input.name);
}
// let mut attribs_iter = self.attributes.iter().map(|&(ref name, buffer_id, ref infos)| {
// let attrib_loc = interface
// .elements()
// .find(|e| e.name.as_ref().map(|n| &n[..]) == Some(&name[..]))
// .unwrap()
// .location.start;
//
// (
// attrib_loc as u32,
// buffer_id,
// AttributeInfo { offset: infos.offset, format: infos.format }
// )
// }).collect::<Vec<_>>();
// This does nothing?
for binding in interface.elements() {
if attribs_iter.iter().any(|a| a.0 == binding.location.start) {
if attributes.iter().any(|a| a.0 == binding.location.start) {
continue;
}
attribs_iter.push((binding.location.start, 0,
attributes.push((binding.location.start, 0,
AttributeInfo { offset: 0, format: binding.format }));
}
// let buffers = vec![
// (0, mem::size_of::<T>(), InputRate::Vertex),
// (1, mem::size_of::<U>(), InputRate::Instance),
// ].into_iter();
let buffers = vec![
(0, mem::size_of::<i32>(), InputRate::Vertex),
].into_iter();
Ok((buffers_iter, attribs_iter.into_iter()))
Ok((buffers_iter, attributes.into_iter()))
}
}