lots of refactoring for the dynamic vertex in addition to planning out documentation

master
mitchellhansen 5 years ago
parent 8db858b29a
commit 83a5e9b997

File diff suppressed because one or more lines are too long

@ -0,0 +1,5 @@
strict graph {
a -- b
a -- b
b -- a [color=blue]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

File diff suppressed because one or more lines are too long

@ -0,0 +1,12 @@
[Notebook]
version=0.4
name=zim-notes
interwiki=
home=Home
icon=
document_root=
shared=True
endofline=unix
disable_trash=False
profile=

File diff suppressed because one or more lines are too long

@ -10,7 +10,7 @@ layout(location = 2) in vec2 ti_position;
layout(location = 3) in vec2 screen_position; layout(location = 3) in vec2 screen_position;
layout(location = 4) in vec2 atlas_position; layout(location = 4) in vec2 atlas_position;
layout(location = 5) in vec2 atlas_size; layout(location = 5) in vec2 atlas_size;
layout(location = 6 in float scale; layout(location = 6) in float scale;
// These are made up in the shader themselves // These are made up in the shader themselves
layout(location = 0) out vec2 tex_coords; layout(location = 0) out vec2 tex_coords;

@ -21,6 +21,11 @@ use vulkano::pipeline::viewport::Viewport;
use vulkano::descriptor::descriptor::DescriptorDescTy::TexelBuffer; use vulkano::descriptor::descriptor::DescriptorDescTy::TexelBuffer;
use crate::canvas::canvas_frame::CanvasFrame; use crate::canvas::canvas_frame::CanvasFrame;
use std::hash::Hash; use std::hash::Hash;
use crate::canvas::shader::generic_shader::GenericShader;
use crate::canvas::shader::common::CompiledGraphicsPipeline;
use shade_runner::CompiledShader;
use crate::canvas::{CanvasTextureHandle, CanvasImageHandle};
use crate::canvas::shader::dynamic_vertex::RuntimeVertexDef;
// Canvas is the accumulator of Sprites for drawing // Canvas is the accumulator of Sprites for drawing
@ -61,15 +66,6 @@ pub trait Vertex {
} }
impl Vertex for ColoredVertex2D {
fn position(&self) -> (f32, f32) {
(0.0, 0.0)
}
fn color(&self) -> Option<(f32, f32, f32, f32)> {
Some((0., 0., 0., 0.))
}
}
pub trait Drawable { pub trait Drawable {
fn get_vertices(&self) -> Vec<(f32, f32)>; fn get_vertices(&self) -> Vec<(f32, f32)>;
@ -87,20 +83,7 @@ pub enum ShaderType {
} }
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct CanvasTextureHandle {
pub handle: u32
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct CanvasImageHandle {
pub handle: u32
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct CanvasShaderHandle {
pub handle: u32
}
#[derive(Clone)] #[derive(Clone)]
pub struct CanvasTexture { pub struct CanvasTexture {
@ -112,7 +95,7 @@ pub struct CanvasTexture {
impl CanvasTexture { impl CanvasTexture {
fn get_descriptor_set(&self, fn get_descriptor_set(&self,
shader: Arc<CanvasShader>, shader: Arc<CompiledGraphicsPipeline>,
sampler: Arc<Sampler>) -> Box<dyn DescriptorSet + Send + Sync> { sampler: Arc<Sampler>) -> Box<dyn DescriptorSet + Send + Sync> {
let o: Box<dyn DescriptorSet + Send + Sync> = Box::new( let o: Box<dyn DescriptorSet + Send + Sync> = Box::new(
PersistentDescriptorSet::start( PersistentDescriptorSet::start(
@ -132,7 +115,7 @@ pub struct CanvasImage {
} }
impl CanvasImage { impl CanvasImage {
fn get_descriptor_set(&mut self, shader: Arc<CanvasShader>) fn get_descriptor_set(&mut self, shader: Arc<CompiledGraphicsPipeline>)
-> Box<dyn DescriptorSet + Send + Sync> { -> Box<dyn DescriptorSet + Send + Sync> {
let o: Box<dyn DescriptorSet + Send + Sync> = Box::new( let o: Box<dyn DescriptorSet + Send + Sync> = Box::new(
PersistentDescriptorSet::start( PersistentDescriptorSet::start(
@ -152,17 +135,17 @@ pub struct CanvasState {
// hold the image, texture, and shader buffers the same was as we do CompuState // hold the image, texture, and shader buffers the same was as we do CompuState
image_buffers: Vec<Arc<CanvasImage>>, image_buffers: Vec<Arc<CanvasImage>>,
texture_buffers: Vec<Arc<CanvasTexture>>, texture_buffers: Vec<Arc<CanvasTexture>>,
shader_buffers: HashMap<String, Arc<CanvasShader>>, shader_buffers: HashMap<String, Arc<CompiledGraphicsPipeline>>,
// Hold onto the vertices we get from the Compu and Canvas Frames // Hold onto the vertices we get from the Compu and Canvas Frames
// When the run comes around, push the vertices to the GPU // When the run comes around, push the vertices to the GPU
colored_drawables: Vec<ColoredVertex2D>, colored_drawables: Vec<RuntimeVertexDef>,
colored_vertex_buffer: Vec<Arc<(dyn BufferAccess + std::marker::Send + std::marker::Sync)>>, colored_vertex_buffer: Vec<Arc<(dyn BufferAccess + std::marker::Send + std::marker::Sync)>>,
textured_drawables: HashMap<Arc<CanvasTextureHandle>, Vec<Vec<Vertex2D>>>, textured_drawables: HashMap<Arc<CanvasTextureHandle>, Vec<Vec<RuntimeVertexDef>>>,
textured_vertex_buffer: HashMap<Arc<CanvasTextureHandle>, Arc<(dyn BufferAccess + std::marker::Send + std::marker::Sync)>>, textured_vertex_buffer: HashMap<Arc<CanvasTextureHandle>, Arc<(dyn BufferAccess + std::marker::Send + std::marker::Sync)>>,
image_drawables: HashMap<Arc<CanvasImageHandle>, Vec<Vec<Vertex2D>>>, image_drawables: HashMap<Arc<CanvasImageHandle>, Vec<Vec<RuntimeVertexDef>>>,
image_vertex_buffer: HashMap<Arc<CanvasImageHandle>, Arc<(dyn BufferAccess + std::marker::Send + std::marker::Sync)>>, image_vertex_buffer: HashMap<Arc<CanvasImageHandle>, Arc<(dyn BufferAccess + std::marker::Send + std::marker::Sync)>>,
// Looks like we gotta hold onto the queue for managing textures // Looks like we gotta hold onto the queue for managing textures
@ -186,7 +169,7 @@ impl CanvasState {
images.iter().map(|image| { images.iter().map(|image| {
Arc::new( Arc::new(
Framebuffer::start(self.shader_buffers.get("color-passthrough").unwrap().render_pass.clone()) Framebuffer::start(self.shader_buffers.get("color-passthrough").unwrap().get_renderpass().clone())
.add(image.clone()).unwrap() .add(image.clone()).unwrap()
.build().unwrap() .build().unwrap()
) as Arc<dyn FramebufferAbstract + Send + Sync> ) as Arc<dyn FramebufferAbstract + Send + Sync>
@ -210,18 +193,25 @@ impl CanvasState {
image_buffers: vec![], image_buffers: vec![],
texture_buffers: vec![], texture_buffers: vec![],
shader_buffers: HashMap::from_iter(vec![ shader_buffers: HashMap::from_iter(vec![
(solid_color_kernel.clone(), Arc::new(CanvasShader::new_colored(solid_color_kernel.clone(), // (solid_color_kernel.clone(), Arc::new(GenericShader::new(solid_color_kernel.clone(),
capabilities.clone(), // device.clone(),
queue.clone(), //
physical.clone(), // capabilities.clone(),
device.clone())) // queue.clone(),
), // physical.clone(),
(texture_kernel.clone(), Arc::new(CanvasShader::new_textured(texture_kernel.clone(), // ))),
capabilities.clone(), // (solid_color_kernel.clone(), Arc::new(CanvasShader::new_colored(solid_color_kernel.clone(),
queue.clone(), // capabilities.clone(),
physical.clone(), // queue.clone(),
device.clone())) // physical.clone(),
), // device.clone()))
// ),
// (texture_kernel.clone(), Arc::new(CanvasShader::new_textured(texture_kernel.clone(),
// capabilities.clone(),
// queue.clone(),
// physical.clone(),
// device.clone()))
// ),
]), ]),
colored_drawables: vec![], colored_drawables: vec![],
@ -389,7 +379,7 @@ impl CanvasState {
} }
} }
fn get_solid_color_descriptor_set(&self, kernel: Arc<CanvasShader>) -> Box<dyn DescriptorSet + Send + Sync> { fn get_solid_color_descriptor_set(&self, kernel: Arc<CompiledGraphicsPipeline>) -> Box<dyn DescriptorSet + Send + Sync> {
let o: Box<dyn DescriptorSet + Send + Sync> = Box::new( let o: Box<dyn DescriptorSet + Send + Sync> = Box::new(
PersistentDescriptorSet::start( PersistentDescriptorSet::start(

@ -1,4 +1,3 @@
use crate::canvas::canvas_state::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle};
use vulkano::image::{ImmutableImage, AttachmentImage}; use vulkano::image::{ImmutableImage, AttachmentImage};
use std::sync::Arc; use std::sync::Arc;
use vulkano::format::{Format, R8Unorm}; use vulkano::format::{Format, R8Unorm};
@ -8,6 +7,7 @@ use vulkano::descriptor::descriptor_set::PersistentDescriptorSet;
use vulkano::buffer::{CpuAccessibleBuffer, BufferAccess}; use vulkano::buffer::{CpuAccessibleBuffer, BufferAccess};
use vulkano::pipeline::GraphicsPipelineAbstract; use vulkano::pipeline::GraphicsPipelineAbstract;
use rusttype::Font; use rusttype::Font;
use crate::canvas::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle};
/// Canvas buffer which represents an allocated Texture with a key and dimensions /// Canvas buffer which represents an allocated Texture with a key and dimensions

@ -1,15 +1,17 @@
use crate::util::vertex_3d::{Vertex3D}; use crate::util::vertex_3d::{Vertex3D};
use std::sync::Arc; use std::sync::Arc;
use std::collections::HashMap; use std::collections::HashMap;
use crate::canvas::canvas_state::{Drawable, CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle, DrawableTest}; use crate::canvas::canvas_state::{Drawable};
use crate::canvas::shader::text_shader::GlyphInstance; use crate::canvas::shader::text_shader::GlyphInstance;
use std::hash::Hash; use std::hash::Hash;
use crate::canvas::*;
use crate::canvas::shader::dynamic_vertex::RuntimeVertexDef;
/// ///
pub struct CanvasFrame { pub struct CanvasFrame {
pub colored_drawables: Vec<Vertex3D>, pub colored_drawables: Vec<RuntimeVertexDef>,
pub textured_drawables: HashMap<Arc<CanvasTextureHandle>, Vec<Vec<Vertex3D>>>, pub textured_drawables: HashMap<Arc<CanvasTextureHandle>, Vec<Vec<RuntimeVertexDef>>>,
pub image_drawables: HashMap<Arc<CanvasImageHandle>, Vec<Vec<Vertex3D>>>, pub image_drawables: HashMap<Arc<CanvasImageHandle>, Vec<Vec<RuntimeVertexDef>>>,
pub text_drawables: HashMap<Arc<CanvasFontHandle>, Vec<GlyphInstance>> pub text_drawables: HashMap<Arc<CanvasFontHandle>, Vec<GlyphInstance>>
} }

@ -23,7 +23,7 @@ use std::hash::Hash;
use crate::canvas::canvas_buffer::{CanvasImage, CanvasTexture, CanvasFont}; use crate::canvas::canvas_buffer::{CanvasImage, CanvasTexture, CanvasFont};
use crate::util::vertex_3d::{Vertex3D, TextVertex3D}; use crate::util::vertex_3d::{Vertex3D, TextVertex3D};
use vulkano::pipeline::depth_stencil::{StencilFaceFlags, DynamicStencilValue}; use vulkano::pipeline::depth_stencil::{StencilFaceFlags, DynamicStencilValue};
use crate::canvas::shader::common::{CompiledGraphicsPipeline, CompiledGraphicsPipelineHandle}; use crate::canvas::shader::common::{CompiledGraphicsPipeline};
use crate::canvas::shader::generic_shader::GenericShader; use crate::canvas::shader::generic_shader::GenericShader;
use vulkano::memory::pool::PotentialDedicatedAllocation::Generic; use vulkano::memory::pool::PotentialDedicatedAllocation::Generic;
use std::borrow::Borrow; use std::borrow::Borrow;
@ -32,6 +32,8 @@ use std::fs::File;
use std::io::Read; use std::io::Read;
use rusttype::{Font, PositionedGlyph, Scale, Rect, point, GlyphId}; use rusttype::{Font, PositionedGlyph, Scale, Rect, point, GlyphId};
use vulkano::pipeline::vertex::VertexDefinition; use vulkano::pipeline::vertex::VertexDefinition;
use crate::canvas::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle, CompiledGraphicsPipelineHandle};
use crate::canvas::shader::dynamic_vertex::RuntimeVertexDef;
// I don't think this is going to work without getting into Box'ing // I don't think this is going to work without getting into Box'ing
@ -57,34 +59,20 @@ pub trait Drawable {
fn get_image_handle(&self) -> Option<Arc<CanvasImageHandle>>; fn get_image_handle(&self) -> Option<Arc<CanvasImageHandle>>;
// fn get_text_handle(&self) -> Option<Arc<CanvasTextHandle>>; // fn get_text_handle(&self) -> Option<Arc<CanvasTextHandle>>;
fn collect(&self) -> Vec<Vertex3D> { fn collect(&self) -> Vec<RuntimeVertexDef> {
let color = self.get_color(); let color = self.get_color();
self.get_vertices().iter().zip(self.get_ti_coords().iter()).map(|(a, b)| // self.get_vertices().iter().zip(self.get_ti_coords().iter()).map(|(a, b)|
Vertex3D { // Vertex3D {
v_position: [a.0, a.1, a.2], // v_position: [a.0, a.1, a.2],
color: [color.0, color.1, color.2, color.3], // color: [color.0, color.1, color.2, color.3],
ti_position: [b.0, b.1], // ti_position: [b.0, b.1],
}).collect() // }).collect()
// TODO
vec![RuntimeVertexDef::from_primitive(0)]
} }
} }
/// Typed wrapper for a u32 texture handle (index id)
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct CanvasTextureHandle {
pub handle: u32
}
/// Typed wrapper for a u32 image handle (index id)
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct CanvasImageHandle {
pub handle: u32
}
/// Typed wrapper for a u32 font handle (index id)
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct CanvasFontHandle {
pub handle: u32
}
/// Canvas state is used for storage of texture and image buffers in addition to vertex buffers /// 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 /// Canvas state also contains logic for writing the stored buffers to the command_buffer
@ -100,6 +88,7 @@ pub struct CanvasState {
texture_buffers: Vec<Arc<CanvasTexture>>, texture_buffers: Vec<Arc<CanvasTexture>>,
font_buffers: Vec<Arc<CanvasFont>>, font_buffers: Vec<Arc<CanvasFont>>,
// Compiled Graphics pipelines have a handle which self describe their position in this vector
shader_buffers: Vec<Arc<Box<dyn CompiledGraphicsPipeline>>>, shader_buffers: Vec<Arc<Box<dyn CompiledGraphicsPipeline>>>,
// Hold onto the vertices we get from the Compu and Canvas Frames // Hold onto the vertices we get from the Compu and Canvas Frames
@ -455,7 +444,7 @@ impl CanvasState {
let g = hprof::enter("Textured Vertex Buffer"); let g = hprof::enter("Textured Vertex Buffer");
for (k, v) in textured_drawables.drain() { for (k, v) in textured_drawables.drain() {
let vertex_buffer = v.clone().iter() let vertex_buffer = v.clone().iter()
.fold(Vec::new(), |mut a: Vec<Vertex3D>, b| { .fold(Vec::new(), |mut a: Vec<RuntimeVertexDef>, b| {
a.extend(b); a.extend(b);
a a
}); });
@ -476,7 +465,7 @@ impl CanvasState {
let g = hprof::enter("Image Vertex Buffer"); let g = hprof::enter("Image Vertex Buffer");
for (k, v) in image_drawables.drain() { for (k, v) in image_drawables.drain() {
let vertex_buffer = v.clone().iter() let vertex_buffer = v.clone().iter()
.fold(Vec::new(), |mut a: Vec<Vertex3D>, b| { .fold(Vec::new(), |mut a: Vec<&RuntimeVertexDef>, b| {
a.extend(b); a.extend(b);
a a
}); });

@ -8,3 +8,35 @@ pub mod canvas;
use crate::canvas::canvas_frame::CanvasFrame; use crate::canvas::canvas_frame::CanvasFrame;
/// Typed wrapper for a u32 font handle (index id)
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct CanvasFontHandle {
pub handle: u32
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct CanvasTextureHandle {
pub handle: u32
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct CanvasImageHandle {
pub handle: u32
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct CanvasShaderHandle {
pub handle: u32
}
/// Typed wrapper for a u32 handle
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct CompiledGraphicsPipelineHandle {
pub handle: u32
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct CompuBufferHandle {
pub handle: u32,
}

@ -8,6 +8,7 @@ use vulkano::pipeline::shader::{ShaderModule, GraphicsShaderType, GeometryShader
use vulkano::device::Device; use vulkano::device::Device;
use shade_runner::Entry; use shade_runner::Entry;
use shaderc::ShaderKind; use shaderc::ShaderKind;
use crate::canvas::CompiledGraphicsPipelineHandle;
/* /*
@ -96,11 +97,7 @@ pub(super) trait CompiledGraphicsPipelineResources {
} }
} }
/// Typed wrapper for a u32 handle
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct CompiledGraphicsPipelineHandle {
pub handle: u32
}
pub trait CompiledGraphicsPipeline { pub trait CompiledGraphicsPipeline {
fn new(filename: String, fn new(filename: String,
@ -110,6 +107,7 @@ pub trait CompiledGraphicsPipeline {
fn get_name(&self) -> String; fn get_name(&self) -> String;
fn get_handle(&self) -> Arc<CompiledGraphicsPipelineHandle>; fn get_handle(&self) -> Arc<CompiledGraphicsPipelineHandle>;
fn get_pipeline(&self) -> Arc<dyn GraphicsPipelineAbstract + Sync + Send>; fn get_pipeline(&self) -> Arc<dyn GraphicsPipelineAbstract + Sync + Send>;
fn get_renderpass(&self) -> Arc<dyn RenderPassAbstract + Send + Sync>;
fn recompile(self, render_pass: Arc<dyn RenderPassAbstract + Send + Sync>) fn recompile(self, render_pass: Arc<dyn RenderPassAbstract + Send + Sync>)
-> Self where Self: Sized; -> Self where Self: Sized;
} }

@ -6,6 +6,8 @@ use cgmath::num_traits::real::Real;
use std::vec::IntoIter as VecIntoIter; use std::vec::IntoIter as VecIntoIter;
/// Runtime Vertex def is just a generic holder of "dynamic vertex definitions" /// Runtime Vertex def is just a generic holder of "dynamic vertex definitions"
// This baby needs to be able to be copied....
#[derive(Default, Debug, Clone)]
pub struct RuntimeVertexDef { pub struct RuntimeVertexDef {
buffers: Vec<(u32, usize, InputRate)>, // (attribute id, stride, Vertex or Instance data) buffers: Vec<(u32, usize, InputRate)>, // (attribute id, stride, Vertex or Instance data)
vertex_buffer_ids: Vec<(usize, usize)>,// vertex_buffer_ids: Vec<(usize, usize)>,//
@ -25,6 +27,12 @@ impl RuntimeVertexDef {
let mut attributes = Vec::new(); let mut attributes = Vec::new();
let mut num_vertices = u32::max_value(); let mut num_vertices = u32::max_value();
// https://github.com/KhronosGroup/glTF-Sample-Models/blob/master/2.0/Box/glTF/Box.gltf
// https://github.com/tomaka/vulkano-examples/blob/gltf/gltf/gltf_system.rs
// for (attribute_id, attribute) in primitive.attributes().enumerate() { // for (attribute_id, attribute) in primitive.attributes().enumerate() {
// let (name, accessor) = match attribute.clone() { // let (name, accessor) = match attribute.clone() {
@ -56,7 +64,10 @@ impl RuntimeVertexDef {
// }; // };
// //
// let view = accessor.view(); // let view = accessor.view();
// buffers.push((attribute_id as u32, view.stride().unwrap_or(accessor.size()), InputRate::Vertex)); // buffers.push((attribute_id as u32,
// view.stride().unwrap_or(accessor.size()),
// InputRate::Vertex
// ));
// attributes.push((name, attribute_id as u32, infos)); // attributes.push((name, attribute_id as u32, infos));
// vertex_buffer_ids.push((view.buffer().index(), view.offset() + accessor.offset())); // vertex_buffer_ids.push((view.buffer().index(), view.offset() + accessor.offset()));
// } // }

@ -1,7 +1,7 @@
use vulkano::pipeline::GraphicsPipelineAbstract; use vulkano::pipeline::GraphicsPipelineAbstract;
use std::sync::Arc; use std::sync::Arc;
use crate::canvas::shader::common::{CompiledGraphicsPipelineHandle, ShaderType, CompiledGraphicsPipeline}; use crate::canvas::shader::common::{ShaderType, CompiledGraphicsPipeline};
use std::collections::{HashSet, HashMap}; use std::collections::{HashSet, HashMap};
use vulkano::device::Device; use vulkano::device::Device;
use vulkano::framebuffer::{RenderPassAbstract, Subpass}; use vulkano::framebuffer::{RenderPassAbstract, Subpass};
@ -19,6 +19,7 @@ use crate::canvas::shader::common::CompiledGraphicsPipelineResources;
use vulkano::memory::pool::PotentialDedicatedAllocation::Generic; use vulkano::memory::pool::PotentialDedicatedAllocation::Generic;
use vulkano::SafeDeref; use vulkano::SafeDeref;
use crate::canvas::shader::dynamic_vertex::RuntimeVertexDef; use crate::canvas::shader::dynamic_vertex::RuntimeVertexDef;
use crate::canvas::CompiledGraphicsPipelineHandle;
/// CanvasShader holds the pipeline and render pass for the input shader source /// CanvasShader holds the pipeline and render pass for the input shader source
#[derive(Clone)] #[derive(Clone)]
@ -29,6 +30,7 @@ pub struct GenericShader {
name: String, name: String,
device: Arc<Device>, device: Arc<Device>,
renderpass: Arc<dyn RenderPassAbstract + Send + Sync>,
} }
@ -113,6 +115,7 @@ impl CompiledGraphicsPipeline for GenericShader {
device: device, device: device,
handle: handle.clone(), handle: handle.clone(),
name: filename.clone(), name: filename.clone(),
renderpass: render_pass.clone(),
} }
} }
@ -128,6 +131,10 @@ impl CompiledGraphicsPipeline for GenericShader {
self.graphics_pipeline.clone().unwrap() self.graphics_pipeline.clone().unwrap()
} }
fn get_renderpass(&self) -> Arc<dyn RenderPassAbstract + Send + Sync> {
self.renderpass.clone()
}
fn recompile(self, render_pass: Arc<dyn RenderPassAbstract + Send + Sync>) -> GenericShader { fn recompile(self, render_pass: Arc<dyn RenderPassAbstract + Send + Sync>) -> GenericShader {
GenericShader::new(self.name, GenericShader::new(self.name,
self.device, self.device,

@ -1,6 +1,6 @@
use vulkano::pipeline::GraphicsPipelineAbstract; use vulkano::pipeline::GraphicsPipelineAbstract;
use std::sync::Arc; use std::sync::Arc;
use crate::canvas::shader::common::{CompiledGraphicsPipelineHandle, ShaderType, CompiledGraphicsPipeline, CompiledGraphicsPipelineResources}; use crate::canvas::shader::common::{ShaderType, CompiledGraphicsPipeline, CompiledGraphicsPipelineResources};
use std::collections::{HashSet, HashMap}; use std::collections::{HashSet, HashMap};
use vulkano::device::Device; use vulkano::device::Device;
use vulkano::framebuffer::{RenderPassAbstract, Subpass}; use vulkano::framebuffer::{RenderPassAbstract, Subpass};
@ -16,6 +16,7 @@ use crate::util::vertex_3d::Vertex3D;
use crate::canvas::shader::generic_shader::GenericShader; use crate::canvas::shader::generic_shader::GenericShader;
use shade_runner as sr; use shade_runner as sr;
use crate::canvas::shader::dynamic_vertex::RuntimeVertexDef; use crate::canvas::shader::dynamic_vertex::RuntimeVertexDef;
use crate::canvas::CompiledGraphicsPipelineHandle;
#[derive(Default, Debug, Clone, Copy)] #[derive(Default, Debug, Clone, Copy)]
pub struct GlyphInstance { pub struct GlyphInstance {
@ -35,6 +36,7 @@ pub struct TextShader {
name: String, name: String,
device: Arc<Device>, device: Arc<Device>,
renderpass: Arc<dyn RenderPassAbstract + Send + Sync>,
} }
impl TextShader {} impl TextShader {}
@ -141,6 +143,7 @@ impl CompiledGraphicsPipeline for TextShader {
device: device, device: device,
handle: handle.clone(), handle: handle.clone(),
name: filename.clone(), name: filename.clone(),
renderpass: render_pass.clone(),
} }
} }
@ -155,12 +158,14 @@ impl CompiledGraphicsPipeline for TextShader {
fn get_pipeline(&self) -> Arc<dyn GraphicsPipelineAbstract + Sync + Send> { fn get_pipeline(&self) -> Arc<dyn GraphicsPipelineAbstract + Sync + Send> {
self.graphics_pipeline.clone().unwrap() self.graphics_pipeline.clone().unwrap()
} }
fn get_renderpass(&self) -> Arc<dyn RenderPassAbstract + Send + Sync> {
self.renderpass.clone()
}
fn recompile(self, render_pass: Arc<dyn RenderPassAbstract + Send + Sync>) -> TextShader { fn recompile(self, render_pass: Arc<dyn RenderPassAbstract + Send + Sync>) -> TextShader {
TextShader::new(self.name, TextShader::new(self.name,
self.device, self.device,
self.handle, self.handle,
render_pass.clone()) self.renderpass.clone())
} }
} }

@ -7,11 +7,7 @@ use vulkano::descriptor::descriptor_set::{PersistentDescriptorSet, PersistentDes
use image::ImageBuffer; use image::ImageBuffer;
use image::Rgba; use image::Rgba;
use shade_runner::Layout; use shade_runner::Layout;
use crate::canvas::CompuBufferHandle;
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct CompuBufferHandle {
pub handle: u32,
}
#[derive(Clone)] #[derive(Clone)]

@ -1,8 +1,9 @@
use crate::canvas::canvas_state::{CanvasImageHandle, Drawable}; use crate::canvas::canvas_state::{Drawable};
use std::sync::Arc; use std::sync::Arc;
use crate::compute::compu_sprite::CompuSprite; use crate::compute::compu_sprite::CompuSprite;
use crate::compute::compu_kernel::{CompuKernel, CompuKernelHandle}; use crate::compute::compu_kernel::{CompuKernel, CompuKernelHandle};
use crate::compute::compu_buffer::{CompuBuffers, CompuBufferHandle}; use crate::compute::compu_buffer::{CompuBuffers};
use crate::canvas::{CompuBufferHandle, CanvasImageHandle};
pub struct CompuFrame { pub struct CompuFrame {
// Vec<(Buffer, Kernel)> // Vec<(Buffer, Kernel)>

@ -8,7 +8,7 @@ use vulkano::descriptor::pipeline_layout::PipelineLayout;
use shade_runner::{CompileError, Layout, Input, Output, CompiledShaders, Entry, CompiledShader}; use shade_runner::{CompileError, Layout, Input, Output, CompiledShaders, Entry, CompiledShader};
use shaderc::CompileOptions; use shaderc::CompileOptions;
use vulkano::pipeline::shader::{ShaderModule, GraphicsEntryPoint, SpecializationConstants, SpecializationMapEntry}; use vulkano::pipeline::shader::{ShaderModule, GraphicsEntryPoint, SpecializationConstants, SpecializationMapEntry};
use crate::compute::compu_buffer::{CompuBuffers, CompuBufferHandle}; use crate::compute::compu_buffer::{CompuBuffers};
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct CompuKernelHandle { pub struct CompuKernelHandle {

@ -1,5 +1,6 @@
use crate::canvas::canvas_state::{CanvasImageHandle, Drawable, CanvasTextureHandle}; use crate::canvas::canvas_state::{Drawable};
use std::sync::Arc; use std::sync::Arc;
use crate::canvas::{CanvasImageHandle, CanvasTextureHandle};
pub struct CompuSprite { pub struct CompuSprite {
pub vertices: [(f32, f32, f32); 6], pub vertices: [(f32, f32, f32); 6],

@ -1,7 +1,7 @@
use std::ffi::CStr; use std::ffi::CStr;
use vulkano::buffer::{CpuAccessibleBuffer, BufferUsage}; use vulkano::buffer::{CpuAccessibleBuffer, BufferUsage};
use std::sync::Arc; use std::sync::Arc;
use crate::canvas::canvas_state::{Drawable, CanvasState, CanvasImageHandle, CanvasTextureHandle}; use crate::canvas::canvas_state::{Drawable, CanvasState};
use vulkano::framebuffer::RenderPassAbstract; use vulkano::framebuffer::RenderPassAbstract;
use vulkano::pipeline::{GraphicsPipelineAbstract, ComputePipeline}; use vulkano::pipeline::{GraphicsPipelineAbstract, ComputePipeline};
use vulkano::device::Device; use vulkano::device::Device;
@ -19,8 +19,9 @@ use shade_runner::{CompiledShaders, Entry, CompileError};
use vulkano::pipeline::shader::ShaderModule; use vulkano::pipeline::shader::ShaderModule;
use shaderc::CompileOptions; use shaderc::CompileOptions;
use crate::compute::compu_kernel::{CompuKernel, CompuKernelHandle}; use crate::compute::compu_kernel::{CompuKernel, CompuKernelHandle};
use crate::compute::compu_buffer::{CompuBuffers, CompuBufferHandle}; use crate::compute::compu_buffer::{CompuBuffers};
use crate::compute::compu_frame::CompuFrame; use crate::compute::compu_frame::CompuFrame;
use crate::canvas::CompuBufferHandle;
/// State holding the compute buffers for computation and the kernels which will compute them /// State holding the compute buffers for computation and the kernels which will compute them

@ -178,11 +178,11 @@ pub fn main() {
break; break;
} }
// let mut compu_frame = CompuFrame::new(); let mut compu_frame = CompuFrame::new();
// compu_frame.add(compute_buffer.clone(), compute_kernel.clone()); // compu_frame.add(compute_buffer.clone(), compute_kernel.clone());
// 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);

@ -1,8 +1,9 @@
use crate::canvas::canvas_state::{Drawable, CanvasTextureHandle, CanvasImageHandle, DrawableTest, CanvasFontHandle}; use crate::canvas::canvas_state::{Drawable, DrawableTest};
use std::sync::Arc; use std::sync::Arc;
use crate::canvas::shader::text_shader::GlyphInstance; use crate::canvas::shader::text_shader::GlyphInstance;
use crate::canvas::canvas_buffer::CanvasFont; use crate::canvas::canvas_buffer::CanvasFont;
use crate::util::vertex_3d::Vertex3D; use crate::util::vertex_3d::Vertex3D;
use crate::canvas::*;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Sprite { pub struct Sprite {

@ -11,17 +11,17 @@ use winit::Window;
use crate::compute::compu_state::CompuState; use crate::compute::compu_state::CompuState;
use vulkano::image::ImageUsage; use vulkano::image::ImageUsage;
use crate::compute::compu_frame::CompuFrame; use crate::compute::compu_frame::CompuFrame;
use crate::canvas::canvas_state::{CanvasState, CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle}; use crate::canvas::canvas_state::{CanvasState};
use crate::canvas::canvas_frame::CanvasFrame; use crate::canvas::canvas_frame::CanvasFrame;
use crate::compute::compu_kernel::{CompuKernel, CompuKernelHandle}; use crate::compute::compu_kernel::{CompuKernel, CompuKernelHandle};
use crate::compute::compu_buffer::{CompuBuffers, CompuBufferHandle}; use crate::compute::compu_buffer::{CompuBuffers};
use std::time::Duration; use std::time::Duration;
use vulkano::pipeline::depth_stencil::{DynamicStencilValue, StencilFaceFlags}; use vulkano::pipeline::depth_stencil::{DynamicStencilValue, StencilFaceFlags};
use crate::canvas::shader::common::CompiledGraphicsPipelineHandle;
use crate::canvas::shader::generic_shader::GenericShader; use crate::canvas::shader::generic_shader::GenericShader;
use crate::canvas::shader::text_shader::{TextShader, GlyphInstance}; use crate::canvas::shader::text_shader::{TextShader, GlyphInstance};
use vulkano::pipeline::vertex::{OneVertexOneInstanceDefinition, SingleBufferDefinition}; use vulkano::pipeline::vertex::{OneVertexOneInstanceDefinition, SingleBufferDefinition};
use crate::util::vertex_3d::Vertex3D; use crate::util::vertex_3d::Vertex3D;
use crate::canvas::{CanvasTextureHandle, CompiledGraphicsPipelineHandle, CanvasFontHandle, CanvasImageHandle, CompuBufferHandle};
/// VKProcessor holds the vulkan instance information, the swapchain, /// VKProcessor holds the vulkan instance information, the swapchain,
/// and the compute and canvas states /// and the compute and canvas states
@ -90,7 +90,8 @@ impl<'a> VkProcessor<'a> {
/// VKProcessor controls the window. So it will let the main loop know when it is done /// VKProcessor controls the window. So it will let the main loop know when it is done
pub fn is_open(&mut self) -> bool { pub fn is_open(&mut self) -> bool {
self.surfcae // self.surface
true
} }
/// Using the surface, we calculate the surface capabilities and create the swapchain and swapchain images /// Using the surface, we calculate the surface capabilities and create the swapchain and swapchain images

Loading…
Cancel
Save