mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
shaderir: Add more tests
This commit is contained in:
parent
af5249de4d
commit
5b69e81bd7
@ -77,6 +77,13 @@ func varNameExpr(vt VariableType, index int) Expr {
|
||||
}
|
||||
}
|
||||
|
||||
func identExpr(ident string) Expr {
|
||||
return Expr{
|
||||
Type: Ident,
|
||||
Ident: ident,
|
||||
}
|
||||
}
|
||||
|
||||
func binaryExpr(op Op, exprs ...Expr) Expr {
|
||||
return Expr{
|
||||
Type: Binary,
|
||||
@ -92,6 +99,13 @@ func selectionExpr(cond, a, b Expr) Expr {
|
||||
}
|
||||
}
|
||||
|
||||
func fieldSelectorExpr(a, b Expr) Expr {
|
||||
return Expr{
|
||||
Type: FieldSelector,
|
||||
Exprs: []Expr{a, b},
|
||||
}
|
||||
}
|
||||
|
||||
func TestOutput(t *testing.T) {
|
||||
tests := []struct {
|
||||
Name string
|
||||
@ -310,6 +324,35 @@ varying vec3 V0;`,
|
||||
},
|
||||
Glsl: `void F0(in bool l0, in float l1, in float l2, out float l3) {
|
||||
l3 = (l0) ? (l1) : (l2);
|
||||
}`,
|
||||
},
|
||||
{
|
||||
Name: "FieldSelector",
|
||||
Program: Program{
|
||||
Funcs: []Func{
|
||||
{
|
||||
Name: "F0",
|
||||
InParams: []Type{
|
||||
{Main: Vec4},
|
||||
},
|
||||
OutParams: []Type{
|
||||
{Main: Float},
|
||||
},
|
||||
Block: block(
|
||||
nil,
|
||||
assignStmt(
|
||||
varNameExpr(Local, 1),
|
||||
fieldSelectorExpr(
|
||||
varNameExpr(Local, 0),
|
||||
identExpr("x"),
|
||||
),
|
||||
),
|
||||
),
|
||||
},
|
||||
},
|
||||
},
|
||||
Glsl: `void F0(in vec4 l0, out float l1) {
|
||||
l1 = (l0).x;
|
||||
}`,
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user