-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68601d2
commit ebfe411
Showing
11 changed files
with
161 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
/target | ||
/.idea | ||
engine/target | ||
/.idea |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
target | ||
res |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
fn main() -> anyhow::Result<()> { | ||
println!("cargo:rerun-if-changed=devres"); | ||
println!("cargo:rerun-if-changed=res"); | ||
|
||
let compiler = shaderc::Compiler::new().unwrap(); | ||
let mut options = shaderc::CompileOptions::new().unwrap(); | ||
options.set_target_env( | ||
shaderc::TargetEnv::Vulkan, | ||
shaderc::EnvVersion::Vulkan1_3 as u32, | ||
); | ||
options.set_source_language(shaderc::SourceLanguage::GLSL); | ||
|
||
let is_debug_build = std::env::var("OPT_LEVEL")? == "0"; | ||
|
||
if is_debug_build { | ||
options.set_optimization_level(shaderc::OptimizationLevel::Zero); | ||
options.set_generate_debug_info(); | ||
} else { | ||
options.set_optimization_level(shaderc::OptimizationLevel::Performance); | ||
} | ||
|
||
std::fs::create_dir_all("res/shaders")?; | ||
|
||
for entry in std::fs::read_dir("devres/shaders")? { | ||
let entry = entry?; | ||
let path = entry.path(); | ||
let extension = path.extension().unwrap().to_str().unwrap(); | ||
let file_name = path.file_name().unwrap().to_str().unwrap(); | ||
let shader_kind = match extension { | ||
"vert" => shaderc::ShaderKind::Vertex, | ||
"frag" => shaderc::ShaderKind::Fragment, | ||
"comp" => shaderc::ShaderKind::Compute, | ||
"geom" => shaderc::ShaderKind::Geometry, | ||
"tesc" => shaderc::ShaderKind::TessControl, | ||
"tese" => shaderc::ShaderKind::TessEvaluation, | ||
_ => continue, | ||
}; | ||
|
||
let source = std::fs::read_to_string(&path)?; | ||
let binary_result = | ||
compiler.compile_into_spirv(&source, shader_kind, file_name, "main", Some(&options))?; | ||
|
||
let binary = binary_result.as_binary_u8(); | ||
let output_path = format!("res/shaders/{}.spv", file_name); | ||
std::fs::write(output_path, binary)?; | ||
} | ||
|
||
Ok(()) | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.