Add support for return value to SPIR-V backend (#79)

* Add test for `glsl_phong_lighting`

* Implement `ReturnValue` op for SPIR-V backend
This commit is contained in:
Gabriel Majeri
2020-06-22 17:11:40 +03:00
committed by GitHub
parent 70054b7693
commit 84615eead3
2 changed files with 50 additions and 8 deletions

View File

@@ -883,10 +883,24 @@ impl Writer {
output: &mut Vec<Instruction>,
) -> Instruction {
match statement {
crate::Statement::Return { value: _ } => match function.return_type {
Some(_) => unimplemented!(),
None => Instruction::new(Op::Return),
},
crate::Statement::Return { value } => {
match function.return_type {
Some(_) => {
let value = value.unwrap();
// Parse the expression
let value_expression = &function.expressions[value];
let (value_id, _) =
self.parse_expression(ir_module, function, value_expression, output);
// Construct the return value instruction
let mut instruction = Instruction::new(Op::ReturnValue);
instruction.add_operand(value_id);
instruction
}
None => Instruction::new(Op::Return),
}
}
crate::Statement::Store { pointer, value } => {
let mut instruction = Instruction::new(Op::Store);