vulkan: include precompiled shaders
This commit is contained in:
parent
2dc9695621
commit
51575fce39
31 changed files with 425 additions and 122 deletions
9
compile-shaders/core/Cargo.toml
Normal file
9
compile-shaders/core/Cargo.toml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
[package]
|
||||
name = "compile-shaders-core"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.79"
|
||||
walkdir = "2.5.0"
|
||||
blake3 = "1.8.2"
|
||||
38
compile-shaders/core/src/lib.rs
Normal file
38
compile-shaders/core/src/lib.rs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
use {std::fmt::Write, walkdir::WalkDir};
|
||||
|
||||
pub const ROOT: &str = "src/gfx_apis/vulkan/shaders";
|
||||
pub const BIN: &str = "src/gfx_apis/vulkan/shaders_bin";
|
||||
pub const HASH: &str = "src/gfx_apis/vulkan/shaders_hash.txt";
|
||||
|
||||
fn calculate_hash() -> anyhow::Result<String> {
|
||||
let dir = WalkDir::new(ROOT);
|
||||
let mut files = vec![];
|
||||
for file in dir {
|
||||
let file = file?;
|
||||
if file.file_type().is_file() {
|
||||
files.push(file.path().to_path_buf());
|
||||
}
|
||||
}
|
||||
files.sort();
|
||||
let mut out = String::new();
|
||||
for file in files {
|
||||
let data = std::fs::read(&file)?;
|
||||
writeln!(out, "{} {}", blake3::hash(&data).to_hex(), file.display())?;
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
pub fn unchanged() -> bool {
|
||||
let Ok(actual) = std::fs::read_to_string(HASH) else {
|
||||
return false;
|
||||
};
|
||||
let Ok(expected) = calculate_hash() else {
|
||||
return false;
|
||||
};
|
||||
actual == expected
|
||||
}
|
||||
|
||||
pub fn update_hash() -> anyhow::Result<()> {
|
||||
std::fs::write(HASH, calculate_hash()?)?;
|
||||
Ok(())
|
||||
}
|
||||
5
compile-shaders/core/src/main.rs
Normal file
5
compile-shaders/core/src/main.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
use compile_shaders_core::update_hash;
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
update_hash()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue