|
|
@ -1,7 +1,7 @@
|
|
|
|
use crate::vertex_2d::{ColoredVertex2D, Vertex2D};
|
|
|
|
use crate::vertex_2d::{ColoredVertex2D, Vertex2D};
|
|
|
|
use vulkano::command_buffer::{AutoCommandBufferBuilder, DynamicState};
|
|
|
|
use vulkano::command_buffer::{AutoCommandBufferBuilder, DynamicState};
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use vulkano::buffer::{BufferAccess, BufferUsage, ImmutableBuffer};
|
|
|
|
use vulkano::buffer::{BufferAccess, BufferUsage, ImmutableBuffer, CpuAccessibleBuffer};
|
|
|
|
use std::sync::Arc;
|
|
|
|
use std::sync::Arc;
|
|
|
|
use vulkano::format::{ClearValue, Format};
|
|
|
|
use vulkano::format::{ClearValue, Format};
|
|
|
|
use vulkano::framebuffer::{FramebufferAbstract, Framebuffer};
|
|
|
|
use vulkano::framebuffer::{FramebufferAbstract, Framebuffer};
|
|
|
@ -85,8 +85,6 @@ pub trait Drawable {
|
|
|
|
fn get_texture_id(&self) -> Option<String>;
|
|
|
|
fn get_texture_id(&self) -> Option<String>;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Need three types of shaders. Solid, Textured, Compute
|
|
|
|
// Need three types of shaders. Solid, Textured, Compute
|
|
|
|
#[derive(PartialEq, Eq, Hash, Clone)]
|
|
|
|
#[derive(PartialEq, Eq, Hash, Clone)]
|
|
|
|
pub enum ShaderType {
|
|
|
|
pub enum ShaderType {
|
|
|
@ -145,10 +143,10 @@ impl CanvasFrame {
|
|
|
|
pub struct Canvas {
|
|
|
|
pub struct Canvas {
|
|
|
|
|
|
|
|
|
|
|
|
colored_drawables : Vec<ColoredVertex2D>,
|
|
|
|
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_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>,
|
|
|
|
shader_kernels: HashMap<ShaderType, ShaderKernels>,
|
|
|
|
|
|
|
|
|
|
|
@ -163,6 +161,7 @@ pub struct Canvas {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl Canvas {
|
|
|
|
impl Canvas {
|
|
|
|
|
|
|
|
|
|
|
|
// needs to take in the texture list
|
|
|
|
// needs to take in the texture list
|
|
|
|
pub fn new(queue: Arc<Queue>,
|
|
|
|
pub fn new(queue: Arc<Queue>,
|
|
|
|
device: Arc<Device>,
|
|
|
|
device: Arc<Device>,
|
|
|
@ -273,6 +272,14 @@ impl Canvas {
|
|
|
|
self.colored_vertex_buffer.clear();
|
|
|
|
self.colored_vertex_buffer.clear();
|
|
|
|
self.textured_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(
|
|
|
|
self.colored_vertex_buffer.push(
|
|
|
|
ImmutableBuffer::from_iter(
|
|
|
|
ImmutableBuffer::from_iter(
|
|
|
|
self.colored_drawables.iter().cloned(),
|
|
|
|
self.colored_drawables.iter().cloned(),
|
|
|
|