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-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?");
|
|
|
|
|
|
|
|
Command::new("glslangValidator")
|
|
|
|
.arg("-V")
|
|
|
|
.arg("src/overlay/shader/single_color.vert")
|
|
|
|
.arg("-o")
|
|
|
|
.arg("src/overlay/shader/single_color.vert.spv")
|
|
|
|
.output()
|
|
|
|
.expect("Failed to compile single_color.vert");
|
|
|
|
|
|
|
|
Command::new("glslangValidator")
|
|
|
|
.arg("-V")
|
|
|
|
.arg("src/overlay/shader/single_color.frag")
|
|
|
|
.arg("-o")
|
|
|
|
.arg("src/overlay/shader/single_color.frag.spv")
|
|
|
|
.output()
|
|
|
|
.expect("Failed to compile single_color.frag");
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
query_vulkan_function_typedefs();
|
|
|
|
compile_shader();
|
|
|
|
}
|