|
|
|
@ -8,9 +8,8 @@ use shade_runner as sr;
|
|
|
|
|
use vulkano::framebuffer::{Subpass, RenderPassAbstract, Framebuffer, FramebufferAbstract};
|
|
|
|
|
use vulkano::pipeline::shader::{GraphicsShaderType, ShaderModule, SpecializationConstants, SpecializationMapEntry};
|
|
|
|
|
use vulkano::swapchain::Capabilities;
|
|
|
|
|
use crate::vertex_2d::Vertex2D;
|
|
|
|
|
use vulkano::pipeline::vertex::SingleBufferDefinition;
|
|
|
|
|
use crate::vertex_3d::Vertex3D;
|
|
|
|
|
use crate::util::vertex_3d::Vertex3D;
|
|
|
|
|
use vulkano::pipeline::depth_stencil::{DepthStencil, Stencil, StencilOp, Compare, DepthBounds};
|
|
|
|
|
use std::collections::HashSet;
|
|
|
|
|
|
|
|
|
@ -21,30 +20,30 @@ pub struct CompiledGraphicsPipelineHandle {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub trait CompiledGraphicsPipeline {
|
|
|
|
|
fn get_paths(&self, filename: String) -> Vec<(ShaderType, PathBuf)> {
|
|
|
|
|
|
|
|
|
|
let project_root =
|
|
|
|
|
std::env::current_dir()
|
|
|
|
|
.expect("failed to get root directory");
|
|
|
|
|
|
|
|
|
|
let mut shader_path = project_root.clone();
|
|
|
|
|
shader_path.push(PathBuf::from("resources/shaders/"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut vertex_shader_path = shader_path.clone();
|
|
|
|
|
vertex_shader_path.push(PathBuf::from("resources/shaders/"));
|
|
|
|
|
vertex_shader_path.push(PathBuf::from(filename.clone() + ".vertex"));
|
|
|
|
|
|
|
|
|
|
let mut fragment_shader_path = project_root.clone();
|
|
|
|
|
fragment_shader_path.push(PathBuf::from("resources/shaders/"));
|
|
|
|
|
fragment_shader_path.push(PathBuf::from(filename.clone() + ".fragment"));
|
|
|
|
|
|
|
|
|
|
(vertex_shader_path, fragment_shader_path)
|
|
|
|
|
}
|
|
|
|
|
fn new(filename: String, shaders: HashSet<ShaderType>) -> Box<dyn CompiledGraphicsPipeline>;
|
|
|
|
|
// fn get_paths(&self, filename: String) -> Vec<(ShaderType, PathBuf)> {
|
|
|
|
|
//
|
|
|
|
|
// let project_root =
|
|
|
|
|
// std::env::current_dir()
|
|
|
|
|
// .expect("failed to get root directory");
|
|
|
|
|
//
|
|
|
|
|
// let mut shader_path = project_root.clone();
|
|
|
|
|
// shader_path.push(PathBuf::from("resources/shaders/"));
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// let mut vertex_shader_path = shader_path.clone();
|
|
|
|
|
// vertex_shader_path.push(PathBuf::from("resources/shaders/"));
|
|
|
|
|
// vertex_shader_path.push(PathBuf::from(filename.clone() + ".vertex"));
|
|
|
|
|
//
|
|
|
|
|
// let mut fragment_shader_path = project_root.clone();
|
|
|
|
|
// fragment_shader_path.push(PathBuf::from("resources/shaders/"));
|
|
|
|
|
// fragment_shader_path.push(PathBuf::from(filename.clone() + ".fragment"));
|
|
|
|
|
//
|
|
|
|
|
// (vertex_shader_path, fragment_shader_path)
|
|
|
|
|
// }
|
|
|
|
|
fn new(filename: String, shaders: HashSet<ShaderType>) -> Self;
|
|
|
|
|
fn get_name() -> String;
|
|
|
|
|
fn get_handle() -> Arc<AbstractCompiledPipelineHandle>;
|
|
|
|
|
fn get_handle() -> Arc<CompiledGraphicsPipelineHandle>;
|
|
|
|
|
fn get_pipeline() -> Arc<dyn GraphicsPipelineAbstract + Sync + Send>;
|
|
|
|
|
fn recompile();
|
|
|
|
|
}
|
|
|
|
@ -78,38 +77,38 @@ pub struct CanvasShader {
|
|
|
|
|
|
|
|
|
|
impl CompiledGraphicsPipeline for CanvasShader {
|
|
|
|
|
|
|
|
|
|
fn get_path(filename: String) -> (PathBuf, PathBuf) {
|
|
|
|
|
let project_root =
|
|
|
|
|
std::env::current_dir()
|
|
|
|
|
.expect("failed to get root directory");
|
|
|
|
|
|
|
|
|
|
let mut shader_path = project_root.clone();
|
|
|
|
|
shader_path.push(PathBuf::from("resources/shaders/"));
|
|
|
|
|
|
|
|
|
|
let mut vertex_shader_path = project_root.clone();
|
|
|
|
|
vertex_shader_path.push(PathBuf::from("resources/shaders/"));
|
|
|
|
|
vertex_shader_path.push(PathBuf::from(filename.clone() + ".vertex"));
|
|
|
|
|
|
|
|
|
|
let mut fragment_shader_path = project_root.clone();
|
|
|
|
|
fragment_shader_path.push(PathBuf::from("resources/shaders/"));
|
|
|
|
|
fragment_shader_path.push(PathBuf::from(filename.clone() + ".fragment"));
|
|
|
|
|
|
|
|
|
|
(vertex_shader_path, fragment_shader_path)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn new(filename: String, shaders: HashSet<ShaderType>) -> Box<dyn CompiledGraphicsPipeline> {
|
|
|
|
|
|
|
|
|
|
// fn get_path(filename: String) -> (PathBuf, PathBuf) {
|
|
|
|
|
// let project_root =
|
|
|
|
|
// std::env::current_dir()
|
|
|
|
|
// .expect("failed to get root directory");
|
|
|
|
|
//
|
|
|
|
|
// let mut shader_path = project_root.clone();
|
|
|
|
|
// shader_path.push(PathBuf::from("resources/shaders/"));
|
|
|
|
|
//
|
|
|
|
|
// let mut vertex_shader_path = project_root.clone();
|
|
|
|
|
// vertex_shader_path.push(PathBuf::from("resources/shaders/"));
|
|
|
|
|
// vertex_shader_path.push(PathBuf::from(filename.clone() + ".vertex"));
|
|
|
|
|
//
|
|
|
|
|
// let mut fragment_shader_path = project_root.clone();
|
|
|
|
|
// fragment_shader_path.push(PathBuf::from("resources/shaders/"));
|
|
|
|
|
// fragment_shader_path.push(PathBuf::from(filename.clone() + ".fragment"));
|
|
|
|
|
//
|
|
|
|
|
// (vertex_shader_path, fragment_shader_path)
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
fn new(filename: String, shaders: HashSet<ShaderType>) -> Self {
|
|
|
|
|
unimplemented!()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn get_name() -> String {
|
|
|
|
|
unimplemented!()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn get_handle() -> Arc<_> {
|
|
|
|
|
fn get_handle() -> Arc<CompiledGraphicsPipelineHandle> {
|
|
|
|
|
unimplemented!()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn get_pipeline() -> Arc<dyn GraphicsPipelineAbstract> {
|
|
|
|
|
fn get_pipeline() -> Arc<dyn GraphicsPipelineAbstract + Sync + Send> {
|
|
|
|
|
unimplemented!()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -120,6 +119,24 @@ impl CompiledGraphicsPipeline for CanvasShader {
|
|
|
|
|
|
|
|
|
|
impl CanvasShader {
|
|
|
|
|
|
|
|
|
|
fn get_path(filename: String) -> (PathBuf, PathBuf) {
|
|
|
|
|
let project_root =
|
|
|
|
|
std::env::current_dir()
|
|
|
|
|
.expect("failed to get root directory");
|
|
|
|
|
|
|
|
|
|
let mut shader_path = project_root.clone();
|
|
|
|
|
shader_path.push(PathBuf::from("resources/shaders/"));
|
|
|
|
|
|
|
|
|
|
let mut vertex_shader_path = project_root.clone();
|
|
|
|
|
vertex_shader_path.push(PathBuf::from("resources/shaders/"));
|
|
|
|
|
vertex_shader_path.push(PathBuf::from(filename.clone() + ".vertex"));
|
|
|
|
|
|
|
|
|
|
let mut fragment_shader_path = project_root.clone();
|
|
|
|
|
fragment_shader_path.push(PathBuf::from("resources/shaders/"));
|
|
|
|
|
fragment_shader_path.push(PathBuf::from(filename.clone() + ".fragment"));
|
|
|
|
|
|
|
|
|
|
(vertex_shader_path, fragment_shader_path)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Clone and returns the compiled graphics pipeline
|
|
|
|
|
pub fn get_pipeline(&self) -> Arc<dyn GraphicsPipelineAbstract + Sync + Send> {
|