more brainstorming on how spriting and computing is going to work

This commit is contained in:
2019-08-27 01:46:25 -07:00
parent be20f3ae2a
commit c39994a7ae
4 changed files with 120 additions and 11 deletions

View File

@@ -1,7 +1,7 @@
use crate::vertex_2d::{ColoredVertex2D, Vertex2D};
use vulkano::command_buffer::{AutoCommandBufferBuilder, DynamicState};
use std::collections::HashMap;
use vulkano::buffer::{BufferAccess, BufferUsage, ImmutableBuffer};
use vulkano::buffer::{BufferAccess, BufferUsage, ImmutableBuffer, CpuAccessibleBuffer};
use std::sync::Arc;
use vulkano::format::{ClearValue, Format};
use vulkano::framebuffer::{FramebufferAbstract, Framebuffer};
@@ -85,8 +85,6 @@ pub trait Drawable {
fn get_texture_id(&self) -> Option<String>;
}
// Need three types of shaders. Solid, Textured, Compute
#[derive(PartialEq, Eq, Hash, Clone)]
pub enum ShaderType {
@@ -145,10 +143,10 @@ impl CanvasFrame {
pub struct Canvas {
colored_drawables : Vec<ColoredVertex2D>,
colored_vertex_buffer: Vec<Arc<(dyn BufferAccess + std::marker::Send + std::marker::Sync + 'static)>>,
colored_vertex_buffer: Vec<Arc<(dyn BufferAccess + std::marker::Send + std::marker::Sync)>>,
textured_drawables: HashMap<String, Vec<Vertex2D>>,
textured_vertex_buffer: HashMap<String, Arc<(dyn BufferAccess + std::marker::Send + std::marker::Sync + 'static)>>,
textured_vertex_buffer: HashMap<String, Arc<(dyn BufferAccess + std::marker::Send + std::marker::Sync)>>,
shader_kernels: HashMap<ShaderType, ShaderKernels>,
@@ -163,6 +161,7 @@ pub struct Canvas {
impl Canvas {
// needs to take in the texture list
pub fn new(queue: Arc<Queue>,
device: Arc<Device>,
@@ -273,6 +272,14 @@ impl Canvas {
self.colored_vertex_buffer.clear();
self.textured_vertex_buffer.clear();
//TODO should probably use cpu accessible buffer instead of recreating immutes each frame
// CpuAccessibleBuffer::from_iter(
// device.clone(),
// BufferUsage::vertex_buffer(),
// self.colored_drawables.iter().cloned(),
// ).unwrap().0;
self.colored_vertex_buffer.push(
ImmutableBuffer::from_iter(
self.colored_drawables.iter().cloned(),