.
This commit is contained in:
65
notes/Dynamic_Vertex.txt
Normal file
65
notes/Dynamic_Vertex.txt
Normal file
@@ -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
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
use vulkano::pipeline::vertex::{VertexDefinition, InputRate, AttributeInfo, IncompatibleVertexDefinitionError, VertexSource};
|
use vulkano::pipeline::vertex::{VertexDefinition, InputRate, AttributeInfo, IncompatibleVertexDefinitionError, VertexSource, VertexMemberInfo, VertexMemberTy};
|
||||||
use vulkano::pipeline::shader::ShaderInterfaceDef;
|
use vulkano::pipeline::shader::ShaderInterfaceDef;
|
||||||
use vulkano::buffer::BufferAccess;
|
use vulkano::buffer::BufferAccess;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|||||||
@@ -183,8 +183,8 @@ pub fn main() {
|
|||||||
// compu_frame.add_with_image_swap(compute_buffer.clone(), compute_kernel.clone(), &compu_sprite1);
|
// compu_frame.add_with_image_swap(compute_buffer.clone(), compute_kernel.clone(), &compu_sprite1);
|
||||||
//
|
//
|
||||||
let mut canvas = CanvasFrame::new();
|
let mut canvas = CanvasFrame::new();
|
||||||
// canvas.draw(&funky_sprite);
|
canvas.draw(&funky_sprite);
|
||||||
// canvas.draw(&test_polygon);
|
canvas.draw(&test_polygon);
|
||||||
|
|
||||||
{
|
{
|
||||||
let g = hprof::enter("Run");
|
let g = hprof::enter("Run");
|
||||||
|
|||||||
Reference in New Issue
Block a user