Initial commit
CI / cargo test (GPU) (push) Failing after 20s
CI / cargo fmt (push) Successful in 11m1s
CI / cargo test (push) Failing after 10m13s

This commit is contained in:
2026-06-19 11:42:50 -04:00
commit 64b2863fc2
10 changed files with 1123 additions and 0 deletions
+67
View File
@@ -0,0 +1,67 @@
#[cfg(test)]
mod test {
use rspirv::binary::parse_bytes;
use rspirv::dr::{Module, Operand};
use rspirv::spirv::ExecutionModel;
use std::sync::OnceLock;
static SHADER_MODULE: OnceLock<Module> = OnceLock::new();
fn shader() -> &'static Module {
SHADER_MODULE.get_or_init(|| {
let shader_bytes = include_bytes!(env!("SHADER_SPV_PATH"));
let mut loader = rspirv::dr::Loader::new();
parse_bytes(shader_bytes, &mut loader).expect("Unable to parse shader");
loader.module()
})
}
fn has_entry_point(execution_model: ExecutionModel, name: &str) -> bool {
for ref entry_point in shader().entry_points.iter() {
let operands: Vec<Operand> = entry_point
.operands
.iter()
.filter(|op| match op {
Operand::ExecutionModel(_) | Operand::LiteralString(_) => true,
_ => false,
})
.map(|op| op.clone())
.collect();
assert_eq!(operands.len(), 2);
match &operands[0] {
Operand::ExecutionModel(actual) => {
if execution_model != *actual {
continue;
}
}
op => panic!("Unexpected operand; {}", op),
}
match &operands[1] {
Operand::LiteralString(actual) => {
if name != actual {
continue;
}
}
op => panic!("Unexpected operand; {}", op),
}
return true;
}
false
}
#[test]
pub fn has_entry_main_fs() {
assert!(has_entry_point(ExecutionModel::Fragment, "main_fs"))
}
#[test]
pub fn has_entry_main_vs() {
assert!(has_entry_point(ExecutionModel::Vertex, "main_vs"))
}
}