internal/shader: Add more tests and improve the comment

Updates #1192
This commit is contained in:
Hajime Hoshi 2021-04-09 01:25:34 +09:00
parent 1cdc6ea72b
commit 77b51e4707
3 changed files with 21 additions and 1 deletions

View File

@ -642,7 +642,7 @@ func (cs *compileState) assign(block *block, fname string, pos token.Pos, lhs, r
} }
t := rhsTypes[i] t := rhsTypes[i]
if t.Main == shaderir.None { if t.Main == shaderir.None {
// TODO: This is to determine a type when the rhs is a constant, // TODO: This is to determine a type when the rhs values are constants (not literals),
// but there are no actual cases when len(lhs) != len(rhs). Is this correct? // but there are no actual cases when len(lhs) != len(rhs). Is this correct?
t = toDefaultType(rhsExprs[i].Const) t = toDefaultType(rhsExprs[i].Const)
} }

View File

@ -0,0 +1,14 @@
void F0(out vec2 l0);
void F0(out vec2 l0) {
float l1 = float(0);
float l2 = float(0);
float l3 = float(0);
float l4 = float(0);
l2 = 1.0;
l1 = l2;
l4 = 2.0;
l3 = l4;
l0 = vec2(l1, l3);
return;
}

View File

@ -0,0 +1,6 @@
package main
func Foo() vec2 {
r1, r2 := 1.0, 2.0
return vec2(r1, r2)
}