remove build_glsl_shaders (#1047)

This commit is contained in:
Lucas Kent 2018-09-29 15:08:17 +10:00 committed by GitHub
parent 7fea44b4da
commit a42800e0ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 40 deletions

View File

@ -1,5 +1,6 @@
# Unreleased (Breaking)
- Remove vulkano_shaders::build_glsl_shaders
- Split `PersistentDescriptorSetError::MissingUsage` into `MissingImageUsage` and `MissingBufferUsage`
each with a matching enum indicating the usage that was missing.
- Fix instance_count when using draw_index with instance buffers

View File

@ -9,13 +9,7 @@
extern crate shaderc;
use std::env;
use std::fs;
use std::fs::File;
use std::io::Error as IoError;
use std::io::Read;
use std::io::Write;
use std::path::Path;
use shaderc::{Compiler, CompileOptions};
@ -29,40 +23,6 @@ mod parse;
mod spec_consts;
mod structs;
pub fn build_glsl_shaders<'a, I>(shaders: I)
where I: IntoIterator<Item = (&'a str, ShaderKind)>
{
let destination = env::var("OUT_DIR").unwrap();
let destination = Path::new(&destination);
let shaders = shaders.into_iter().collect::<Vec<_>>();
for &(shader, _) in &shaders {
// Run this first so that a panic won't interfere with rerun
println!("cargo:rerun-if-changed={}", shader);
}
for (shader, ty) in shaders {
let shader = Path::new(shader);
let shader_content = {
let mut s = String::new();
File::open(shader)
.expect("failed to open shader")
.read_to_string(&mut s)
.expect("failed to read shader content");
s
};
fs::create_dir_all(&destination.join("shaders").join(shader.parent().unwrap())).unwrap();
let mut file_output = File::create(&destination.join("shaders").join(shader))
.expect("failed to open shader output");
let content = compile(&shader_content, ty).unwrap();
let output = reflect("Shader", content.as_binary()).unwrap();
write!(file_output, "{}", output).unwrap();
}
}
pub fn compile(code: &str, ty: ShaderKind) -> Result<CompilationArtifact, String> {
let mut compiler = Compiler::new().ok_or("failed to create GLSL compiler")?;
let compile_options = CompileOptions::new().ok_or("failed to initialize compile option")?;