Switched vertex type to be chosen at the shader load

This commit is contained in:
2020-02-13 23:37:41 -08:00
parent fcfa40e335
commit d1051a0ca3
9 changed files with 39 additions and 40 deletions

View File

@@ -26,7 +26,7 @@ use std::borrow::Borrow;
use std::fs::File;
use std::io::Read;
use rusttype::{Font, PositionedGlyph, Scale, Rect, point, GlyphId, Line, Curve, Segment};
use vulkano::pipeline::vertex::VertexDefinition;
use vulkano::pipeline::vertex::{VertexDefinition, Vertex};
use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef;
use crate::canvas::managed::handles::{CanvasTextureHandle, CanvasImageHandle, CanvasFontHandle, CompiledShaderHandle, Handle, DrawableHandle};
use crate::canvas::managed::gpu_buffers::{CanvasImage, CanvasTexture, CanvasFont};
@@ -34,6 +34,7 @@ use crate::canvas::managed::shader::shader_common::CompiledGraphicsPipeline;
use crate::canvas::managed::shader::generic_shader::GenericShader;
use crate::VertexTypes;
use crate::util::vertex::{TextVertex3D, TextureVertex2D, ImageVertex2D, ColorVertex2D, CanvasFrameAllocation};
use shade_runner::Input;
/// Canvas state is used for storage of texture and image buffers in addition to vertex buffers
@@ -255,17 +256,17 @@ impl CanvasState {
/// Load and Compile a shader with the filename at resources/shaders
/// 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,
physical: PhysicalDevice,
capabilities: Capabilities) -> Option<Arc<CompiledShaderHandle>>
where T: CompiledGraphicsPipeline {
where T: CompiledGraphicsPipeline, V: Vertex {
let handle = Arc::new(CompiledShaderHandle {
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(),
self.device.clone(),
handle.clone(),