master
parent
a3ce819cd9
commit
dcc0df955e
@ -0,0 +1,65 @@
|
|||||||
|
Content-Type: text/x-zim-wiki
|
||||||
|
Wiki-Format: zim 0.4
|
||||||
|
Creation-Date: 2020-01-22T18:39:43-08:00
|
||||||
|
|
||||||
|
====== Dynamic Vertex ======
|
||||||
|
Created Wednesday 22 January 2020
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone)]
|
||||||
|
pub struct RuntimeVertexDef {
|
||||||
|
buffers: Vec<(u32, usize, InputRate)>, // (attribute id, stride, Vertex or Instance data)
|
||||||
|
vertex_buffer_ids: Vec<(usize, usize)>,//
|
||||||
|
attributes: Vec<(String, u32, AttributeInfo)>,
|
||||||
|
num_vertices: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RuntimeVertexDef {
|
||||||
|
|
||||||
|
/// primitive is an input value or struct which can then describe
|
||||||
|
/// these damn values that are required for inputting them into vulkan
|
||||||
|
pub fn from_primitive(primitive: u32) -> RuntimeVertexDef {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the indices of the buffers to bind as vertex buffers and the byte offset, when
|
||||||
|
/// drawing the primitive.
|
||||||
|
pub fn vertex_buffer_ids(&self) -> &[(usize, usize)] {
|
||||||
|
&self.vertex_buffer_ids
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl<I> VertexDefinition<I> for RuntimeVertexDef
|
||||||
|
where I: ShaderInterfaceDef
|
||||||
|
|
||||||
|
/// Iterator that returns the offset, the stride (in bytes) and input rate of each buffer.
|
||||||
|
type BuffersIter = VecIntoIter<(u32, usize, InputRate)>;
|
||||||
|
/// Iterator that returns the attribute location, buffer id, and infos.
|
||||||
|
type AttribsIter = VecIntoIter<(u32, u32, AttributeInfo)>;
|
||||||
|
|
||||||
|
fn definition(&self, interface: &I) ->
|
||||||
|
<(Self::BuffersIter, Self::AttribsIter), IncompatibleVertexDefinitionError>{
|
||||||
|
|
||||||
|
let buffers = vec![
|
||||||
|
(0, mem::size_of::<T>(), InputRate::Vertex),
|
||||||
|
(1, mem::size_of::<U>(), InputRate::Instance),
|
||||||
|
]_iter();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// I don't know what the fuck is going on here... It just repackages the buffs
|
||||||
|
/// Needs the num vertices
|
||||||
|
unsafe impl VertexSource<Vec<Arc<dyn BufferAccess + Send + Sync>>> for RuntimeVertexDef {
|
||||||
|
fn decode(&self, bufs: Vec<Arc<dyn BufferAccess + Send + Sync>>)
|
||||||
|
-> (Vec<Box<dyn BufferAccess + Send + Sync>>, usize, usize)
|
||||||
|
{
|
||||||
|
(
|
||||||
|
bufs.into_iter().map(|b| Box::new(b) as Box<_>).collect(), // Box up the buffers
|
||||||
|
self.num_vertices as usize, // Number of vertices
|
||||||
|
1 // Number of instances
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in new issue