remove scripts

This commit is contained in:
2021-02-25 22:43:28 +01:00
parent 8735f2d409
commit 45286b8178
5 changed files with 35 additions and 43 deletions

View File

@@ -1,4 +1,4 @@
use std::{convert::TryInto, io::{Read, Write}, sync::Arc};
use std::{convert::TryInto, io::{self, ErrorKind, Read, Write}, path::PathBuf, sync::Arc};
use vulkano::{command_buffer::AutoCommandBufferBuilder, descriptor::{descriptor::ShaderStages, descriptor_set::PersistentDescriptorSet}, pipeline::shader::ShaderModule};
use vulkano::command_buffer::DynamicState;
@@ -53,6 +53,38 @@ fn shader_module_from_file(device: Arc<Device>, path: &str) -> Arc<ShaderModule>
}
}
fn matches_extension(path: &PathBuf, extensions: &Vec<&str>) -> bool {
if let Some(Some(path_extension)) = path.extension().map(|e| e.to_str()) {
for extension in extensions {
if *extension == path_extension { return true; }
}
}
return false;
}
fn compile_shaders() -> io::Result<()> {
for file_maybe in std::fs::read_dir("./shaders")? {
let path = file_maybe?.path();
if !path.is_dir() && matches_extension(&path, &vec!["frag", "vert"]) {
let mut target_path = path.to_str().ok_or(ErrorKind::Other)?.to_string();
target_path.push_str(".spv");
let output = std::process::Command::new("glslangValidator")
.arg("-V")
.arg(path.to_str().ok_or(ErrorKind::Other)?)
.arg("-o")
.arg(target_path)
.output().unwrap();
std::io::stdout().write_all(&output.stdout)?;
if !output.status.success() {
eprintln!("Shader compiler {:?}", output.status);
}
}
}
Ok(())
}
impl DefaultShader {
pub fn new(device: Arc<Device>, render_pass: RP) -> Self {
DefaultShader {
@@ -66,12 +98,7 @@ impl DefaultShader {
#[cfg(debug_assertions)]
{
println!("Compiling shaders...");
let output = std::process::Command::new("cmd.exe")
.arg("/c")
.arg("compile.bat")
.current_dir("shaders")
.output().unwrap();
std::io::stdout().write_all(&output.stdout).unwrap();
compile_shaders().unwrap();
}
unsafe {