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

@@ -10,7 +10,7 @@ use shade_runner::{Input, Output, Layout, Entry};
use std::ffi::CStr;
use std::marker::PhantomData;
use vulkano::pipeline::depth_stencil::{DepthStencil, Compare, DepthBounds, Stencil, StencilOp};
use vulkano::pipeline::vertex::{SingleBufferDefinition, VertexDefinition};
use vulkano::pipeline::vertex::{SingleBufferDefinition, VertexDefinition, Vertex};
use shade_runner as sr;
use vulkano::memory::pool::PotentialDedicatedAllocation::Generic;
use vulkano::SafeDeref;
@@ -18,7 +18,7 @@ use crate::canvas::managed::shader::shader_common::{ShaderType, CompiledGraphics
use crate::canvas::managed::handles::CompiledShaderHandle;
use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef;
use crate::canvas::managed::ShaderSpecializationConstants;
use crate::util::vertex::VertexTypes;
use crate::util::vertex::{VertexTypes, ColorVertex2D};
/// CanvasShader holds the pipeline and render pass for the input shader source
#[derive(Clone)]
@@ -34,10 +34,6 @@ pub struct GenericShader {
impl GenericShader {
fn get(&self) -> VertexTypes {
VertexTypes::ImageType
}
}
/// Gives CanvasShader the resource functions
@@ -47,7 +43,7 @@ impl CompiledGraphicsPipelineResources for GenericShader {}
impl CompiledGraphicsPipeline for GenericShader {
/// This will explode when the shader does not want to compile
fn new(filename: String,
fn new<V: Vertex>(filename: String,
device: Arc<Device>,
handle: Arc<CompiledShaderHandle>,
render_pass: Arc<dyn RenderPassAbstract + Send + Sync>) -> GenericShader {
@@ -88,8 +84,8 @@ impl CompiledGraphicsPipeline for GenericShader {
graphics_pipeline:
Some(Arc::new(GraphicsPipeline::start()
//SingleBufferDefinition::<Vertex3D>
.vertex_input(vertex_definition)
.vertex_input(SingleBufferDefinition::<V>::new())
//.vertex_input(vertex_definition)
.vertex_shader(vertex_entry_point.clone(), ShaderSpecializationConstants {
first_constant: 0,
@@ -139,8 +135,8 @@ impl CompiledGraphicsPipeline for GenericShader {
self.renderpass.clone()
}
fn recompile(self, render_pass: Arc<dyn RenderPassAbstract + Send + Sync>) -> GenericShader {
GenericShader::new(self.name,
fn recompile<V: Vertex>(self, render_pass: Arc<dyn RenderPassAbstract + Send + Sync>) -> GenericShader {
GenericShader::new::<V>(self.name,
self.device,
self.handle,
render_pass.clone())