You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
shaderc/src/main.rs

116 lines
2.9 KiB

use std::fmt::Write;
pub mod compiler;
pub mod parser;
fn main() {
let mut ops: Vec<(Option<String>, Vec<String>)> = Vec::new();
// OpMemoryModel Logical GLSL450
// OpEntryPoint Fragment %main "main"
// OpExecutionMode %main OriginUpperLeft
// OpSource GLSL 450
// OpSourceExtension "GL_GOOGLE_cpp_style_line_directive"
// OpSourceExtension "GL_GOOGLE_include_directive"
// OpName %main "main"
//%void = OpTypeVoid
//%3 = OpTypeFunction %void
//%main = OpFunction %void None %3
//%5 = OpLabel
// OpReturn
// OpFunctionEnd
ops.push((None, vec!["OpCapability".to_string(), "Shader".to_string()]));
ops.push((
Some("%1".to_string()),
vec![
"OpExtInstImport".to_string(),
"\"GLSL.std.450\"".to_string(),
],
));
ops.push((
None,
vec![
"OpMemoryModel".to_string(),
"Logical".to_string(),
"GLSL450".to_string(),
],
));
ops.push((
None,
vec![
"OpEntryPoint".to_string(),
"Fragment".to_string(),
"%main".to_string(),
"\"main\"".to_string(),
],
));
ops.push((
None,
vec![
"OpExecutionMode".to_string(),
"%main".to_string(),
"OriginUpperLeft".to_string(),
],
));
ops.push((
None,
vec![
"OpSource".to_string(),
"GLSL".to_string(),
"450".to_string(),
],
));
ops.push((
None,
vec![
"OpSourceExtension".to_string(),
"\"GL_GOOGLE_cpp_style_line_directive\"".to_string(),
],
));
ops.push((
None,
vec![
"OpSourceExtension".to_string(),
"\"GL_GOOGLE_include_directive\"".to_string(),
],
));
ops.push((
None,
vec![
"OpName".to_string(),
"%main".to_string(),
"\"main\"".to_string(),
],
));
ops.push((Some("%void".to_string()), vec!["OpTypeVoid".to_string()]));
ops.push((
Some("%3".to_string()),
vec!["OpTypeFunction".to_string(), "%void".to_string()],
));
ops.push((
Some("%main".to_string()),
vec![
"OpFunction".to_string(),
"%void".to_string(),
"None".to_string(),
"%3".to_string(),
],
));
ops.push((Some("%5".to_string()), vec!["OpLabel".to_string()]));
ops.push((None, vec!["OpReturn".to_string()]));
ops.push((None, vec!["OpFunctionEnd".to_string()]));
let mut out: String = String::new();
for op in ops {
if op.0.is_some() {
write!(out, "{} = ", op.0.unwrap()).unwrap();
}
for arg in op.1 {
write!(out, "{} ", arg).unwrap();
}
writeln!(out).unwrap();
}
println!("{}", out);
}