Sorta want this type of API, but, CanvasFrame would be tied to a single type...

This commit is contained in:
2020-02-05 22:10:38 -08:00
parent 0c1f513225
commit 1597f0e380
5 changed files with 71 additions and 27 deletions

View File

@@ -18,7 +18,7 @@ use vulkano::swapchain::Capabilities;
use winit::Window;
use vulkano::pipeline::viewport::Viewport;
use vulkano::descriptor::descriptor::DescriptorDescTy::TexelBuffer;
use crate::canvas::canvas_frame::CanvasFrame;
use crate::canvas::canvas_frame::{CanvasFrame, CanvasFrameTest, VertexData};
use std::hash::Hash;
use crate::util::vertex_3d::{Vertex3D, TextVertex3D};
use vulkano::pipeline::depth_stencil::{StencilFaceFlags, DynamicStencilValue};
@@ -35,8 +35,6 @@ use crate::canvas::managed::shader::shader_common::CompiledGraphicsPipeline;
use crate::canvas::managed::shader::generic_shader::GenericShader;
/// Canvas state is used for storage of texture and image buffers in addition to vertex buffers
/// Canvas state also contains logic for writing the stored buffers to the command_buffer
#[derive(Clone)]
@@ -276,7 +274,6 @@ impl CanvasState {
physical: PhysicalDevice,
capabilities: Capabilities) -> Option<Arc<CompiledShaderHandle>>
where T: CompiledGraphicsPipeline {
let handle = Arc::new(CompiledShaderHandle {
handle: self.shader_buffers.len() as u32
});
@@ -314,7 +311,7 @@ impl CanvasState {
for i in (0..255) {
let glyph = font.glyph('d');
let s = glyph.scaled(Scale{ x: 1.0, y: 1.0 });
let s = glyph.scaled(Scale { x: 1.0, y: 1.0 });
let shape = s.shape().unwrap();
@@ -325,7 +322,7 @@ impl CanvasState {
accumulator.push(TextVertex3D {
position: [l.p[0].x as f32, l.p[0].y as f32, 0.0],
});
},
}
Segment::Curve(c) => {
accumulator.push(TextVertex3D {
position: [c.p[0].x as f32, c.p[0].y as f32, 0.0],
@@ -421,7 +418,7 @@ impl CanvasState {
let g = hprof::enter("Textured Vertex Buffer");
for (k, v) in textured_drawables.drain() {
let vertex_buffer = v.clone().get(0).unwrap().clone();
// TODO
// TODO
// v.clone().iter()
// .fold(Vec::new(), |mut a: Vec<RuntimeVertexDef>, b| {
// a.extend(b);
@@ -487,6 +484,27 @@ impl CanvasState {
o
}
// This is taking in a canvas frame, which should be some sort of matrix of vertices of generic
// types and handles
pub fn draw_commands_test<V: 'static + VertexData + Sized + Clone + Send + Sync, H: Handle + Sized>
(&mut self,
mut command_buffer: AutoCommandBufferBuilder,
framebuffers: Vec<Arc<dyn FramebufferAbstract + Send + Sync>>,
image_num: usize,
canvas_frame: CanvasFrameTest<V, H>) -> AutoCommandBufferBuilder {
let v = Vec::<V>::new();
let x = ImmutableBuffer::from_iter(
v.iter().cloned(),
BufferUsage::all(),
self.queue.clone(),
).unwrap().0;
command_buffer
}
/// Pushes the draw commands to the command buffer. Requires the framebuffers and
/// image number to be passed in as they are taken care of by the vkprocessor
pub fn draw_commands(&mut self,