mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-23 09:22:01 +01:00
shaderir: Add a test for nested function calls
This commit is contained in:
parent
399bb93044
commit
acba49952c
@ -616,6 +616,20 @@ func (cs *compileState) parseBlock(outer *block, b *ast.BlockStmt, inParams, out
|
|||||||
block.ir.Stmts = append(block.ir.Stmts, shaderir.Stmt{
|
block.ir.Stmts = append(block.ir.Stmts, shaderir.Stmt{
|
||||||
Type: shaderir.Return,
|
Type: shaderir.Return,
|
||||||
})
|
})
|
||||||
|
case *ast.ExprStmt:
|
||||||
|
exprs, stmts := cs.parseExpr(block, l.X)
|
||||||
|
block.ir.Stmts = append(block.ir.Stmts, stmts...)
|
||||||
|
for _, expr := range exprs {
|
||||||
|
if expr.Type != shaderir.Call {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
block.ir.Stmts = append(block.ir.Stmts, shaderir.Stmt{
|
||||||
|
Type: shaderir.ExprStmt,
|
||||||
|
Exprs: []shaderir.Expr{expr},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
cs.addError(l.Pos(), fmt.Sprintf("unexpected statement: %#v", l))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,6 +236,32 @@ void F1(in float l0, out float l1, out float l2) {
|
|||||||
l1 = l0;
|
l1 = l0;
|
||||||
l2 = l0;
|
l2 = l0;
|
||||||
return;
|
return;
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "call multiple out params nested",
|
||||||
|
Src: `package main
|
||||||
|
|
||||||
|
func Foo(x vec2) {
|
||||||
|
Bar(Bar(x.x, x.y))
|
||||||
|
}
|
||||||
|
|
||||||
|
func Bar(x, y float) (float, float) {
|
||||||
|
return x, y
|
||||||
|
}`,
|
||||||
|
VS: `void F0(in vec2 l0) {
|
||||||
|
float l1 = 0.0;
|
||||||
|
float l2 = 0.0;
|
||||||
|
float l3 = 0.0;
|
||||||
|
float l4 = 0.0;
|
||||||
|
F1((l0).x, (l0).y, l1, l2);
|
||||||
|
F1(l1, l2, l3, l4);
|
||||||
|
}
|
||||||
|
|
||||||
|
void F1(in float l0, in float l1, out float l2, out float l3) {
|
||||||
|
l2 = l0;
|
||||||
|
l3 = l1;
|
||||||
|
return;
|
||||||
}`,
|
}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user