2023-01-11 17:51:31 +00:00
|
|
|
use std::{fs::File, io::Write, path::Path, process::Command, str::from_utf8};
|
|
|
|
|
|
|
|
const VK_INCLUDE: &str = "/usr/include/vulkan";
|
|
|
|
const VK_HEADER: &[&str] = &[
|
|
|
|
"vulkan_core.h",
|
|
|
|
"vulkan_xcb.h",
|
|
|
|
"vulkan_xlib.h",
|
|
|
|
"vulkan_wayland.h",
|
|
|
|
];
|
|
|
|
const FN_PREFIX: &str = "PFN_";
|
|
|
|
|
2023-01-13 07:11:53 +00:00
|
|
|
const SHADER: &[&str] = &[
|
2023-01-18 10:51:16 +00:00
|
|
|
"src/overlay/elements/radar/single_color.vert",
|
|
|
|
"src/overlay/elements/radar/single_color.frag",
|
|
|
|
"src/overlay/elements/pedals/history.vert",
|
|
|
|
"src/overlay/elements/pedals/history.frag",
|
2023-01-20 15:08:14 +00:00
|
|
|
"src/overlay/elements/leaderboard/generator.frag",
|
|
|
|
"src/overlay/elements/leaderboard/generator.vert",
|
2023-01-13 07:11:53 +00:00
|
|
|
];
|
|
|
|
|
2023-01-12 12:52:44 +00:00
|
|
|
fn query_vulkan_function_typedefs() {
|
2023-01-11 17:51:31 +00:00
|
|
|
let mut fns = Vec::new();
|
|
|
|
|
|
|
|
for header in VK_HEADER {
|
|
|
|
Command::new("ctags")
|
|
|
|
.arg("--help")
|
|
|
|
.output()
|
|
|
|
.expect("Failed to execute ctags. Maybe you need to install it first?");
|
|
|
|
|
|
|
|
let output = Command::new("ctags")
|
|
|
|
.arg("-x")
|
|
|
|
.arg("--c-types=t")
|
|
|
|
.arg(format!("{}/{}", VK_INCLUDE, header))
|
|
|
|
.output()
|
|
|
|
.expect(&format!("failed to open file {}/{}", VK_INCLUDE, header));
|
|
|
|
|
|
|
|
let output_splits = from_utf8(&output.stdout).unwrap().split_whitespace();
|
|
|
|
|
|
|
|
for split in output_splits {
|
|
|
|
if split.starts_with(FN_PREFIX) {
|
|
|
|
fns.push(split.trim_start_matches(FN_PREFIX).to_string())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let path = Path::new("vk_functions");
|
|
|
|
let mut file = File::create(path).unwrap();
|
|
|
|
|
|
|
|
for func in fns {
|
|
|
|
file.write_all(format!("{}\n", func).as_bytes()).unwrap();
|
|
|
|
}
|
|
|
|
}
|
2023-01-12 12:52:44 +00:00
|
|
|
|
|
|
|
fn compile_shader() {
|
|
|
|
Command::new("glslangValidator")
|
|
|
|
.arg("--help")
|
|
|
|
.output()
|
|
|
|
.expect("Failed to execute glslangValidator. Maybe you need to install it first?");
|
|
|
|
|
2023-01-13 07:11:53 +00:00
|
|
|
for shader in SHADER {
|
|
|
|
Command::new("glslangValidator")
|
|
|
|
.arg("-V")
|
|
|
|
.arg(shader)
|
|
|
|
.arg("-o")
|
|
|
|
.arg(&format!("{}.spv", shader))
|
|
|
|
.output()
|
|
|
|
.expect(&format!("Failed to compile {}", shader));
|
|
|
|
}
|
2023-01-12 12:52:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
query_vulkan_function_typedefs();
|
|
|
|
compile_shader();
|
|
|
|
}
|