Got the vertex definition into the load function. Which is something
This commit is contained in:
1
notes/vkprocessor.drawio
Normal file
1
notes/vkprocessor.drawio
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<mxfile modified="2019-10-10T04:31:44.745Z" host="www.draw.io" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) snap Chromium/77.0.3865.90 Chrome/77.0.3865.90 Safari/537.36" etag="0BJjIPUqMBAUJHbaiwQ_" version="12.1.0" type="device" pages="1"><diagram id="eBoc7Yustm6TUbQq-vnT" name="Page-1">7V3bkps4EP2aqdp9sAskro9zycxkd1I1tZPKJo8aLNskGLlAzCVfv5JBNiDZxjZYsIkfJiAkDKe7j1rdLecCXi/e7hK0nH8iExxdAGPydgFvLgAwPc9j//CW96IFGDBvmSXhpGjbNDyFP3HRaBStWTjBaaUjJSSi4bLaGJA4xgGttKEkIa/VblMSVb91iWbFNxqbhqcARVjq9m84oXPxdOyzuXKPw9mcSpcWSPQvGtI5mpDXUhP8cAGvE0JofrR4u8YRB1BAk4+73XJ1/WwJjmmTAeBqEbow87OZ+SOdPXx/uLt5G5nFbV5QlBUvfY3iF5R+xm80S/AFcCJ296vnhB3N+JHulhWU9F2IKCFZPMH8FQ12+XUeUvy0RAG/+sq0krXN6SJiZ+Z6dBky8fo4ofit1FRAeIfJAtPknXUprlpCvoVOj0wI8obXkoZ4Rad5WTesohEVWjlb33wjNXZQCO4QIYItQvy44Ar+W4RVEdp+XYTCRMsi9M8rQrhFhLeEvedvCVYl6EoSNI2xrd0MHVmGZLEMI7yaH8MgfQyXOApjhUn+EcYUJ1OOGZ+nEo5Q0flP7XBDtwq3CYAKbUuBttMZ2O4Wg9GO1hqHnTMEUIAF20CLfFs+BJ/vHet9eftPZvx17//8MnKhBAueMFenOCUJnZMZiVH0YdN6VQVu0+eBkGUB13dM6Xvht6GMkiqY+C2kX0vH3/itmObkZzdvxZ1XJ+/iJGbv+3XV0WDeYtGQj4S2Kxo2g1dnldGPOAkZbD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/8hKOpdhgdEaMX0X1VPkRVqQM6w02OO11SioL5gr1SsQXREAVjfUNPpXVK9LrKjJhyYv0GUxRGrexkahcslSekAgt2pmryyryHJmqZtQScD3SbqOyCf1ws8lLpnlmoBJ7j6rZQeULti4VKYMGGYHVnoXJuvIcW6hnGGJgW8Gx39derougqdxOf1WIVuxu+5G/cG0vdA6JlNwaxK8td1070z3L3gGc2Bq8zSwayO7yu+g9KVf8Ge2f2l8QRf70sZSAC45kf0zm/EKi3ZadztOSHAYoiktH9oC9LgYFiUClW0IZMQH3nNhBLgv2FM10JQfat/2E3DvELh1Yw6ym6PCdJ+JOLUyypWwDSbPIjKVCB4/pXN9pfFPdoBzxoGC8Z8T3wtSgatPYl/fq3B15drNA4FXhqceRqKHsz9F7qsORFGGnpzrVqjvr21pFnlXVQ7m/v7M8O8idoteDD01q88GtmsJvrLdCit7WNXCPL2K239Y1fu7s7nr2je0darrU+rqrl7m81V/5y1dnVvEa39kHkXPxMx7bunrerezdKDuXIlnKPbd9cPeAe6+oJj6z9zJi8dB6AzzxSOM1yZF+FJGjjF83UiXt547dMxSpaUqWRx06FSU3D2k2l7KTuxZbpFdbqj7ne6a0/Fnq3N3EMtlBmSc62Qs6i7cQ65VE9ZlhfvOYvKlUpSzeSf+esdqOOy51dmTJ/Ve3UpkuCxIU7aI59x9h8xKx2qGqZpjX2/dKNzOrXsIWxV7pqnVXvvDb0bltNBNOUoxb4G0V2q4oMzIMVuUVOFPGrvZwIt2zKOI8em5IXYx9JiuuMwDqGaJyXFT051fdraqc2XQJVsoK+ksoOVixp5T32XeCvP7ZzXjUbYPlZVZWHV+3rNa4/07r905Pz5WID2mYpK2mP9gVYfSUr3Mt961jLOhhHdrr53f/cIjf/gwL88B8=</diagram></mxfile>
|
||||||
@@ -53,20 +53,44 @@ impl CanvasFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct Pair<T> {
|
||||||
|
x: T,
|
||||||
|
y: T,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Pair<Vertex3D> {
|
||||||
|
fn new(x: Vertex3D, y: Vertex3D) -> Self {
|
||||||
|
Self {
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Pair<GlyphInstance> {
|
||||||
|
fn new(x: GlyphInstance, y: GlyphInstance) -> Self {
|
||||||
|
Self {
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct GenericCanvasFrame<H, V, In> {
|
pub struct GenericCanvasFrame<H, V, In> {
|
||||||
frame_data: HashMap<H, Vec<(Vec<V>, Vec<In>)>>
|
frame_data: HashMap<H, Vec<(Vec<V>, Vec<In>)>>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<H, V, In> GenericCanvasFrame<H, V, In> {
|
impl<V, In> GenericCanvasFrame<Vertex3D, V, In> {
|
||||||
|
|
||||||
/// Creates a bare canvas frame with empty accumulators
|
/// Creates a bare canvas frame with empty accumulators
|
||||||
pub fn new() -> GenericCanvasFrame<H, V, In> where H: Eq + Hash {
|
pub fn new() -> GenericCanvasFrame<Vertex3D, V, In> {
|
||||||
GenericCanvasFrame {
|
GenericCanvasFrame {
|
||||||
frame_data: Default::default()
|
frame_data: Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw(&mut self, drawable: &dyn DrawableTest<V, H, In>) where H: Eq + Hash + Clone {
|
pub fn draw(&mut self, drawable: &dyn DrawableTest<V, Vertex3D, In>) {
|
||||||
self.frame_data
|
self.frame_data
|
||||||
.entry(drawable.get_handle().clone())
|
.entry(drawable.get_handle().clone())
|
||||||
.or_insert(Vec::new())
|
.or_insert(Vec::new())
|
||||||
|
|||||||
@@ -318,16 +318,17 @@ impl CanvasState {
|
|||||||
|
|
||||||
/// Load and Compile a shader with the filename at resources/shaders
|
/// Load and Compile a shader with the filename at resources/shaders
|
||||||
/// Takes physical and capabilities as we don't store that in Canvas
|
/// Takes physical and capabilities as we don't store that in Canvas
|
||||||
pub fn load_shader<T: 'static>(&mut self,
|
pub fn load_shader<T: 'static, V>(&mut self,
|
||||||
filename: String,
|
filename: String,
|
||||||
physical: PhysicalDevice,
|
physical: PhysicalDevice,
|
||||||
capabilities: Capabilities) -> Option<Arc<CompiledGraphicsPipelineHandle>>
|
capabilities: Capabilities) -> Option<Arc<CompiledGraphicsPipelineHandle>>
|
||||||
where T: CompiledGraphicsPipeline {
|
where T: CompiledGraphicsPipeline {
|
||||||
|
|
||||||
let handle = Arc::new(CompiledGraphicsPipelineHandle {
|
let handle = Arc::new(CompiledGraphicsPipelineHandle {
|
||||||
handle: self.shader_buffers.len() as u32
|
handle: self.shader_buffers.len() as u32
|
||||||
});
|
});
|
||||||
|
|
||||||
let shader: Box<dyn CompiledGraphicsPipeline> = Box::new(T::new(
|
let shader: Box<dyn CompiledGraphicsPipeline> = Box::new(T::new::<V>(
|
||||||
filename.clone(),
|
filename.clone(),
|
||||||
self.device.clone(),
|
self.device.clone(),
|
||||||
handle.clone(),
|
handle.clone(),
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ pub struct CompiledGraphicsPipelineHandle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub trait CompiledGraphicsPipeline {
|
pub trait CompiledGraphicsPipeline {
|
||||||
fn new(filename: String,
|
fn new<T>(filename: String,
|
||||||
device: Arc<Device>,
|
device: Arc<Device>,
|
||||||
handle: Arc<CompiledGraphicsPipelineHandle>,
|
handle: Arc<CompiledGraphicsPipelineHandle>,
|
||||||
render_pass: Arc<dyn RenderPassAbstract + Send + Sync>) -> Self where Self: Sized;
|
render_pass: Arc<dyn RenderPassAbstract + Send + Sync>) -> Self where Self: Sized;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ impl CompiledGraphicsPipelineResources for GenericShader {}
|
|||||||
impl CompiledGraphicsPipeline for GenericShader {
|
impl CompiledGraphicsPipeline for GenericShader {
|
||||||
|
|
||||||
/// This will explode when the shader does not want to compile
|
/// This will explode when the shader does not want to compile
|
||||||
fn new(filename: String,
|
fn new<T>(filename: String,
|
||||||
device: Arc<Device>,
|
device: Arc<Device>,
|
||||||
handle: Arc<CompiledGraphicsPipelineHandle>,
|
handle: Arc<CompiledGraphicsPipelineHandle>,
|
||||||
render_pass: Arc<dyn RenderPassAbstract + Send + Sync>) -> GenericShader {
|
render_pass: Arc<dyn RenderPassAbstract + Send + Sync>) -> GenericShader {
|
||||||
@@ -78,7 +78,8 @@ impl CompiledGraphicsPipeline for GenericShader {
|
|||||||
graphics_pipeline:
|
graphics_pipeline:
|
||||||
Some(Arc::new(GraphicsPipeline::start()
|
Some(Arc::new(GraphicsPipeline::start()
|
||||||
|
|
||||||
.vertex_input(SingleBufferDefinition::<Vertex3D>::new())
|
//SingleBufferDefinition::<Vertex3D>
|
||||||
|
.vertex_input(T::new())
|
||||||
|
|
||||||
.vertex_shader(vertex_entry_point.clone(), ShaderSpecializationConstants {
|
.vertex_shader(vertex_entry_point.clone(), ShaderSpecializationConstants {
|
||||||
first_constant: 0,
|
first_constant: 0,
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ impl CompiledGraphicsPipelineResources for TextShader {}
|
|||||||
impl CompiledGraphicsPipeline for TextShader {
|
impl CompiledGraphicsPipeline for TextShader {
|
||||||
|
|
||||||
/// This will explode when the shader does not want to compile
|
/// This will explode when the shader does not want to compile
|
||||||
fn new(filename: String,
|
fn new<T>(filename: String,
|
||||||
device: Arc<Device>,
|
device: Arc<Device>,
|
||||||
handle: Arc<CompiledGraphicsPipelineHandle>,
|
handle: Arc<CompiledGraphicsPipelineHandle>,
|
||||||
render_pass: Arc<dyn RenderPassAbstract + Send + Sync>) -> TextShader {
|
render_pass: Arc<dyn RenderPassAbstract + Send + Sync>) -> TextShader {
|
||||||
@@ -107,8 +107,8 @@ impl CompiledGraphicsPipeline for TextShader {
|
|||||||
TextShader {
|
TextShader {
|
||||||
graphics_pipeline:
|
graphics_pipeline:
|
||||||
Some(Arc::new(GraphicsPipeline::start()
|
Some(Arc::new(GraphicsPipeline::start()
|
||||||
|
//OneVertexOneInstanceDefinition::<Vertex3D, GlyphInstance>
|
||||||
.vertex_input(OneVertexOneInstanceDefinition::<Vertex3D, GlyphInstance>::new())
|
.vertex_input(T::new())
|
||||||
|
|
||||||
.vertex_shader(vertex_entry_point.clone(), ShaderSpecializationConstants {
|
.vertex_shader(vertex_entry_point.clone(), ShaderSpecializationConstants {
|
||||||
first_constant: 0,
|
first_constant: 0,
|
||||||
|
|||||||
@@ -169,8 +169,8 @@ pub fn main() {
|
|||||||
canvas.draw(&funky_sprite);
|
canvas.draw(&funky_sprite);
|
||||||
canvas.draw(&test_polygon);
|
canvas.draw(&test_polygon);
|
||||||
|
|
||||||
let mut gencanvas = GenericCanvasFrame::new();
|
// let mut gencanvas = GenericCanvasFrame::new();
|
||||||
gencanvas.draw(&text_sprite);
|
// gencanvas.draw(&text_sprite);
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -97,8 +97,8 @@ impl Sprite {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<V, H, In> DrawableTest<V, H, In> for Sprite {
|
impl<H, In> DrawableTest<Vertex3D, H, In> for Sprite {
|
||||||
fn get_vertices(&self) -> Vec<V> {
|
fn get_vertices(&self) -> Vec<Vertex3D> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,7 +301,7 @@ pub trait TextVertex {
|
|||||||
fn get_vertices() -> Vec<(u32, u32, u32)>;
|
fn get_vertices() -> Vec<(u32, u32, u32)>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<V: TextVertex, H: TextHandle, In: TextInstance> DrawableTest<V, H, In> for Text {
|
impl<V: TextVertex, H, In: TextInstance> DrawableTest<V, H, In> for Text {
|
||||||
fn get_vertices(&self) -> Vec<V> {
|
fn get_vertices(&self) -> Vec<V> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ 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::common::CompiledGraphicsPipelineHandle;
|
||||||
use crate::canvas::shader::generic_shader::GenericShader;
|
use crate::canvas::shader::generic_shader::GenericShader;
|
||||||
use crate::canvas::shader::text_shader::TextShader;
|
use crate::canvas::shader::text_shader::{TextShader, GlyphInstance};
|
||||||
|
use vulkano::pipeline::vertex::{OneVertexOneInstanceDefinition, SingleBufferDefinition};
|
||||||
|
use crate::util::vertex_3d::Vertex3D;
|
||||||
|
|
||||||
/// VKProcessor holds the vulkan instance information, the swapchain, and the compute and canvas states
|
/// VKProcessor holds the vulkan instance information, the swapchain, and the compute and canvas states
|
||||||
///
|
///
|
||||||
@@ -157,10 +159,10 @@ impl<'a> VkProcessor<'a> {
|
|||||||
|
|
||||||
/// A hardcoded list of shaders which can be proloaded from this function
|
/// A hardcoded list of shaders which can be proloaded from this function
|
||||||
pub fn preload_shaders(&mut self) {
|
pub fn preload_shaders(&mut self) {
|
||||||
self.canvas_state.load_shader::<GenericShader>(String::from("color-passthrough"), self.physical.clone(), self.capabilities.clone());
|
self.canvas_state.load_shader::<GenericShader, SingleBufferDefinition::<Vertex3D>>(String::from("color-passthrough"), self.physical.clone(), self.capabilities.clone());
|
||||||
self.canvas_state.load_shader::<GenericShader>(String::from("simple_texture"), self.physical.clone(), self.capabilities.clone());
|
self.canvas_state.load_shader::<GenericShader, SingleBufferDefinition::<Vertex3D>>(String::from("simple_texture"), self.physical.clone(), self.capabilities.clone());
|
||||||
self.canvas_state.load_shader::<GenericShader>(String::from("simple_image"), self.physical.clone(), self.capabilities.clone());
|
self.canvas_state.load_shader::<GenericShader, SingleBufferDefinition::<Vertex3D>>(String::from("simple_image"), self.physical.clone(), self.capabilities.clone());
|
||||||
self.canvas_state.load_shader::<TextShader>(String::from("simple_text"), self.physical.clone(), self.capabilities.clone());
|
self.canvas_state.load_shader::<TextShader, OneVertexOneInstanceDefinition::<Vertex3D, GlyphInstance>>(String::from("simple_text"), self.physical.clone(), self.capabilities.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A hardcoded list of shaders which can be proloaded from this function
|
/// A hardcoded list of shaders which can be proloaded from this function
|
||||||
|
|||||||
Reference in New Issue
Block a user