internal/shader: optimization: use a regular return for a function with one output parameter

Updates #2034
Updates #2188
This commit is contained in:
Hajime Hoshi 2022-07-10 15:45:28 +09:00
parent 8c879c7bcf
commit b6a340a96f
49 changed files with 474 additions and 511 deletions

View File

@ -261,7 +261,7 @@ func (cs *compileState) parse(f *ast.File) {
} }
} }
inParams, outParams := cs.parseFuncParams(&cs.global, fd) inParams, outParams, ret := cs.parseFuncParams(&cs.global, fd)
var inT, outT []shaderir.Type var inT, outT []shaderir.Type
for _, v := range inParams { for _, v := range inParams {
inT = append(inT, v.typ) inT = append(inT, v.typ)
@ -276,6 +276,7 @@ func (cs *compileState) parse(f *ast.File) {
Index: len(cs.funcs), Index: len(cs.funcs),
InParams: inT, InParams: inT,
OutParams: outT, OutParams: outT,
Return: ret,
Block: &shaderir.Block{}, Block: &shaderir.Block{},
}, },
}) })
@ -620,7 +621,7 @@ func (s *compileState) parseConstant(block *block, vs *ast.ValueSpec) ([]constan
return cs, true return cs, true
} }
func (cs *compileState) parseFuncParams(block *block, d *ast.FuncDecl) (in, out []variable) { func (cs *compileState) parseFuncParams(block *block, d *ast.FuncDecl) (in, out []variable, ret shaderir.Type) {
for _, f := range d.Type.Params.List { for _, f := range d.Type.Params.List {
t, ok := cs.parseType(block, f.Type) t, ok := cs.parseType(block, f.Type)
if !ok { if !ok {
@ -657,6 +658,12 @@ func (cs *compileState) parseFuncParams(block *block, d *ast.FuncDecl) (in, out
} }
} }
} }
if len(out) == 1 && out[0].name == "" {
ret = out[0].typ
out = nil
}
return return
} }
@ -674,7 +681,7 @@ func (cs *compileState) parseFunc(block *block, d *ast.FuncDecl) (function, bool
return function{}, false return function{}, false
} }
inParams, outParams := cs.parseFuncParams(block, d) inParams, outParams, returnType := cs.parseFuncParams(block, d)
checkVaryings := func(vs []variable) { checkVaryings := func(vs []variable) {
if len(cs.ir.Varyings) != len(vs) { if len(cs.ir.Varyings) != len(vs) {
@ -695,11 +702,15 @@ func (cs *compileState) parseFunc(block *block, d *ast.FuncDecl) (function, bool
cs.ir.Attributes = append(cs.ir.Attributes, v.typ) cs.ir.Attributes = append(cs.ir.Attributes, v.typ)
} }
// The first out-param is treated as gl_Position in GLSL. // For the vertex entry, a parameter (variable) is used as a returning value.
// For example, GLSL doesn't treat gl_Position as a returning value.
if len(outParams) == 0 { if len(outParams) == 0 {
cs.addError(d.Pos(), fmt.Sprintf("vertex entry point must have at least one returning vec4 value for a position")) outParams = append(outParams, variable{
return function{}, false typ: shaderir.Type{Main: shaderir.Vec4},
})
} }
// The first out-param is treated as gl_Position in GLSL.
if outParams[0].typ.Main != shaderir.Vec4 { if outParams[0].typ.Main != shaderir.Vec4 {
cs.addError(d.Pos(), fmt.Sprintf("vertex entry point must have at least one returning vec4 value for a position")) cs.addError(d.Pos(), fmt.Sprintf("vertex entry point must have at least one returning vec4 value for a position"))
return function{}, false return function{}, false
@ -724,11 +735,14 @@ func (cs *compileState) parseFunc(block *block, d *ast.FuncDecl) (function, bool
return function{}, false return function{}, false
} }
if len(outParams) != 1 { // For the fragment entry, a parameter (variable) is used as a returning value.
cs.addError(d.Pos(), fmt.Sprintf("fragment entry point must have one returning vec4 value for a color")) // For example, GLSL doesn't treat gl_FragColor as a returning value.
return function{}, false if len(outParams) == 0 {
outParams = append(outParams, variable{
typ: shaderir.Type{Main: shaderir.Vec4},
})
} }
if outParams[0].typ.Main != shaderir.Vec4 { if len(outParams) != 1 || outParams[0].typ.Main != shaderir.Vec4 {
cs.addError(d.Pos(), fmt.Sprintf("fragment entry point must have one returning vec4 value for a color")) cs.addError(d.Pos(), fmt.Sprintf("fragment entry point must have one returning vec4 value for a color"))
return function{}, false return function{}, false
} }
@ -744,12 +758,12 @@ func (cs *compileState) parseFunc(block *block, d *ast.FuncDecl) (function, bool
} }
} }
b, ok := cs.parseBlock(block, d.Name.Name, d.Body.List, inParams, outParams, true) b, ok := cs.parseBlock(block, d.Name.Name, d.Body.List, inParams, outParams, returnType, true)
if !ok { if !ok {
return function{}, false return function{}, false
} }
if len(outParams) > 0 { if len(outParams) > 0 || returnType.Main != shaderir.None {
var hasReturn func(stmts []shaderir.Stmt) bool var hasReturn func(stmts []shaderir.Stmt) bool
hasReturn = func(stmts []shaderir.Stmt) bool { hasReturn = func(stmts []shaderir.Stmt) bool {
for _, stmt := range stmts { for _, stmt := range stmts {
@ -785,12 +799,13 @@ func (cs *compileState) parseFunc(block *block, d *ast.FuncDecl) (function, bool
ir: shaderir.Func{ ir: shaderir.Func{
InParams: inT, InParams: inT,
OutParams: outT, OutParams: outT,
Return: returnType,
Block: b.ir, Block: b.ir,
}, },
}, true }, true
} }
func (cs *compileState) parseBlock(outer *block, fname string, stmts []ast.Stmt, inParams, outParams []variable, checkLocalVariableUsage bool) (*block, bool) { func (cs *compileState) parseBlock(outer *block, fname string, stmts []ast.Stmt, inParams, outParams []variable, returnType shaderir.Type, checkLocalVariableUsage bool) (*block, bool) {
var vars []variable var vars []variable
if outer == &cs.global { if outer == &cs.global {
vars = make([]variable, 0, len(inParams)+len(outParams)) vars = make([]variable, 0, len(inParams)+len(outParams))
@ -838,7 +853,7 @@ func (cs *compileState) parseBlock(outer *block, fname string, stmts []ast.Stmt,
} }
for _, stmt := range stmts { for _, stmt := range stmts {
ss, ok := cs.parseStmt(block, fname, stmt, inParams, outParams) ss, ok := cs.parseStmt(block, fname, stmt, inParams, outParams, returnType)
if !ok { if !ok {
return nil, false return nil, false
} }

View File

@ -34,7 +34,7 @@ func (cs *compileState) forceToInt(node ast.Node, expr *shaderir.Expr) bool {
return true return true
} }
func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inParams, outParams []variable) ([]shaderir.Stmt, bool) { func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inParams, outParams []variable, returnType shaderir.Type) ([]shaderir.Stmt, bool) {
var stmts []shaderir.Stmt var stmts []shaderir.Stmt
switch stmt := stmt.(type) { switch stmt := stmt.(type) {
@ -166,7 +166,7 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
cs.addError(stmt.Pos(), fmt.Sprintf("unexpected token: %s", stmt.Tok)) cs.addError(stmt.Pos(), fmt.Sprintf("unexpected token: %s", stmt.Tok))
} }
case *ast.BlockStmt: case *ast.BlockStmt:
b, ok := cs.parseBlock(block, fname, stmt.List, inParams, outParams, true) b, ok := cs.parseBlock(block, fname, stmt.List, inParams, outParams, returnType, true)
if !ok { if !ok {
return nil, false return nil, false
} }
@ -201,7 +201,7 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
// Create a new pseudo block for the initial statement, so that the counter variable belongs to the // Create a new pseudo block for the initial statement, so that the counter variable belongs to the
// new pseudo block for each for-loop. Without this, the samely named counter variables in different // new pseudo block for each for-loop. Without this, the samely named counter variables in different
// for-loops confuses the parser. // for-loops confuses the parser.
pseudoBlock, ok := cs.parseBlock(block, fname, []ast.Stmt{stmt.Init}, inParams, outParams, false) pseudoBlock, ok := cs.parseBlock(block, fname, []ast.Stmt{stmt.Init}, inParams, outParams, returnType, false)
if !ok { if !ok {
return nil, false return nil, false
} }
@ -267,7 +267,7 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
} }
end := exprs[0].Exprs[1].Const end := exprs[0].Exprs[1].Const
postSs, ok := cs.parseStmt(pseudoBlock, fname, stmt.Post, inParams, outParams) postSs, ok := cs.parseStmt(pseudoBlock, fname, stmt.Post, inParams, outParams, returnType)
if !ok { if !ok {
return nil, false return nil, false
} }
@ -313,7 +313,7 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
return nil, false return nil, false
} }
b, ok := cs.parseBlock(pseudoBlock, fname, []ast.Stmt{stmt.Body}, inParams, outParams, true) b, ok := cs.parseBlock(pseudoBlock, fname, []ast.Stmt{stmt.Body}, inParams, outParams, returnType, true)
if !ok { if !ok {
return nil, false return nil, false
} }
@ -344,7 +344,7 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
if stmt.Init != nil { if stmt.Init != nil {
init := stmt.Init init := stmt.Init
stmt.Init = nil stmt.Init = nil
b, ok := cs.parseBlock(block, fname, []ast.Stmt{init, stmt}, inParams, outParams, true) b, ok := cs.parseBlock(block, fname, []ast.Stmt{init, stmt}, inParams, outParams, returnType, true)
if !ok { if !ok {
return nil, false return nil, false
} }
@ -371,7 +371,7 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
stmts = append(stmts, ss...) stmts = append(stmts, ss...)
var bs []*shaderir.Block var bs []*shaderir.Block
b, ok := cs.parseBlock(block, fname, stmt.Body.List, inParams, outParams, true) b, ok := cs.parseBlock(block, fname, stmt.Body.List, inParams, outParams, returnType, true)
if !ok { if !ok {
return nil, false return nil, false
} }
@ -380,13 +380,13 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
if stmt.Else != nil { if stmt.Else != nil {
switch s := stmt.Else.(type) { switch s := stmt.Else.(type) {
case *ast.BlockStmt: case *ast.BlockStmt:
b, ok := cs.parseBlock(block, fname, s.List, inParams, outParams, true) b, ok := cs.parseBlock(block, fname, s.List, inParams, outParams, returnType, true)
if !ok { if !ok {
return nil, false return nil, false
} }
bs = append(bs, b.ir) bs = append(bs, b.ir)
default: default:
b, ok := cs.parseBlock(block, fname, []ast.Stmt{s}, inParams, outParams, true) b, ok := cs.parseBlock(block, fname, []ast.Stmt{s}, inParams, outParams, returnType, true)
if !ok { if !ok {
return nil, false return nil, false
} }
@ -473,8 +473,14 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
for i, t := range types { for i, t := range types {
expr := exprs[i] expr := exprs[i]
var outT shaderir.Type
if len(outParams) == 0 {
outT = returnType
} else {
outT = outParams[i].typ
}
if expr.Type == shaderir.NumberExpr { if expr.Type == shaderir.NumberExpr {
switch outParams[i].typ.Main { switch outT.Main {
case shaderir.Int: case shaderir.Int:
if !cs.forceToInt(stmt, &expr) { if !cs.forceToInt(stmt, &expr) {
return nil, false return nil, false
@ -485,26 +491,37 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
} }
} }
if !t.Equal(&outParams[i].typ) { if !t.Equal(&outT) {
cs.addError(stmt.Pos(), fmt.Sprintf("cannot use type %s as type %s in return argument", t.String(), &outParams[i].typ)) cs.addError(stmt.Pos(), fmt.Sprintf("cannot use type %s as type %s in return argument", t.String(), &outT))
return nil, false return nil, false
} }
stmts = append(stmts, shaderir.Stmt{ if len(outParams) > 0 {
Type: shaderir.Assign, stmts = append(stmts, shaderir.Stmt{
Exprs: []shaderir.Expr{ Type: shaderir.Assign,
{ Exprs: []shaderir.Expr{
Type: shaderir.LocalVariable, {
Index: len(inParams) + i, Type: shaderir.LocalVariable,
Index: len(inParams) + i,
},
expr,
}, },
expr, })
}, } else {
}) stmts = append(stmts, shaderir.Stmt{
Type: shaderir.Return,
Exprs: []shaderir.Expr{expr},
})
// When a return type is specified, there should be only one expr here.
break
}
} }
stmts = append(stmts, shaderir.Stmt{ if len(outParams) > 0 {
Type: shaderir.Return, stmts = append(stmts, shaderir.Stmt{
}) Type: shaderir.Return,
})
}
case *ast.BranchStmt: case *ast.BranchStmt:
switch stmt.Tok { switch stmt.Tok {

View File

@ -1,29 +1,25 @@
uniform vec2 U0[4]; uniform vec2 U0[4];
void F0(out vec2 l0[2]); vec2[2] F0(void);
void F1(out vec2 l0[2]); vec2[2] F1(void);
void F0(out vec2 l0[2]) { vec2[2] F0(void) {
vec2 l0[2];
l0[0] = vec2(0);
l0[1] = vec2(0);
return l0;
}
vec2[2] F1(void) {
vec2 l0[2];
l0[0] = vec2(0);
l0[1] = vec2(0);
vec2 l1[2]; vec2 l1[2];
l1[0] = vec2(0); l1[0] = vec2(0);
l1[1] = vec2(0); l1[1] = vec2(0);
l0[0] = l1[0]; (l0)[0] = vec2(1.0);
l0[1] = l1[1]; l1[0] = l0[0];
return; l1[1] = l0[1];
} (l1)[1] = vec2(2.0);
return l1;
void F1(out vec2 l0[2]) {
vec2 l1[2];
l1[0] = vec2(0);
l1[1] = vec2(0);
vec2 l2[2];
l2[0] = vec2(0);
l2[1] = vec2(0);
(l1)[0] = vec2(1.0);
l2[0] = l1[0];
l2[1] = l1[1];
(l2)[1] = vec2(2.0);
l0[0] = l2[0];
l0[1] = l2[1];
return;
} }

View File

@ -1,12 +1,11 @@
void F0(thread array<float2, 3>& l0); array<float2, 3> F0(void);
void F0(thread array<float2, 3>& l0) { array<float2, 3> F0(void) {
array<float2, 2> l1 = {}; array<float2, 2> l0 = {};
array<float2, 3> l2 = {}; array<float2, 3> l1 = {};
{ {
array<float2, 2> l2 = {}; array<float2, 2> l1 = {};
l2 = l1; l1 = l0;
} }
l0 = l2; return l1;
return;
} }

View File

@ -1,22 +1,19 @@
void F0(out vec2 l0[3]); vec2[3] F0(void);
void F0(out vec2 l0[3]) { vec2[3] F0(void) {
vec2 l1[2]; vec2 l0[2];
l0[0] = vec2(0);
l0[1] = vec2(0);
vec2 l1[3];
l1[0] = vec2(0); l1[0] = vec2(0);
l1[1] = vec2(0); l1[1] = vec2(0);
vec2 l2[3]; l1[2] = vec2(0);
l2[0] = vec2(0);
l2[1] = vec2(0);
l2[2] = vec2(0);
{ {
vec2 l2[2]; vec2 l1[2];
l2[0] = vec2(0); l1[0] = vec2(0);
l2[1] = vec2(0); l1[1] = vec2(0);
l2[0] = l1[0]; l1[0] = l0[0];
l2[1] = l1[1]; l1[1] = l0[1];
} }
l0[0] = l2[0]; return l1;
l0[1] = l2[1];
l0[2] = l2[2];
return;
} }

View File

@ -1,9 +1,8 @@
void F0(in vec2 l0, out vec4 l1); vec4 F0(in vec2 l0);
void F0(in vec2 l0, out vec4 l1) { vec4 F0(in vec2 l0) {
float l2 = float(0); float l1 = float(0);
l2 = 0.0; l1 = 0.0;
l2 = (l2) + (1.0); l1 = (l1) + (1.0);
l1 = vec4(l0, l2, l2); return vec4(l0, l1, l1);
return;
} }

View File

@ -1,16 +1,15 @@
void F0(in vec2 l0, out vec4 l1); vec4 F0(in vec2 l0);
void F1(out float l0, out float l1); void F1(out float l0, out float l1);
void F0(in vec2 l0, out vec4 l1) { vec4 F0(in vec2 l0) {
float l1 = float(0);
float l2 = float(0); float l2 = float(0);
float l3 = float(0); float l3 = float(0);
float l4 = float(0); float l4 = float(0);
float l5 = float(0); F1(l3, l4);
F1(l4, l5); l1 = l3;
l2 = l4; l2 = l4;
l3 = l5; return vec4(l0, l1, l2);
l1 = vec4(l0, l2, l3);
return;
} }
void F1(out float l0, out float l1) { void F1(out float l0, out float l1) {

View File

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

View File

@ -1,10 +1,9 @@
void F0(float l0, float l1, thread bool& l2); bool F0(float l0, float l1);
void F0(float l0, float l1, thread bool& l2) { bool F0(float l0, float l1) {
float l2 = float(0);
float l3 = float(0); float l3 = float(0);
float l4 = float(0); l2 = atan((l1) / (l0));
l3 = atan((l1) / (l0)); l3 = atan2(l1, l0);
l4 = atan2(l1, l0); return (l2) == (l3);
l2 = (l3) == (l4);
return;
} }

View File

@ -1,10 +1,9 @@
void F0(in float l0, in float l1, out bool l2); bool F0(in float l0, in float l1);
void F0(in float l0, in float l1, out bool l2) { bool F0(in float l0, in float l1) {
float l2 = float(0);
float l3 = float(0); float l3 = float(0);
float l4 = float(0); l2 = atan((l1) / (l0));
l3 = atan((l1) / (l0)); l3 = atan(l1, l0);
l4 = atan(l1, l0); return (l2) == (l3);
l2 = (l3) == (l4);
return;
} }

View File

@ -1,21 +1,20 @@
void F0(in vec2 l0, out vec4 l1); vec4 F0(in vec2 l0);
void F0(in vec2 l0, out vec4 l1) { vec4 F0(in vec2 l0) {
vec4 l2 = vec4(0); vec4 l1 = vec4(0);
{ {
vec3 l3 = vec3(0); vec3 l2 = vec3(0);
(l2).x = (l0).x; (l1).x = (l0).x;
{ {
vec4 l4 = vec4(0); vec4 l3 = vec4(0);
(l2).y = (l3).y; (l1).y = (l2).y;
(l2).z = (l4).z; (l1).z = (l3).z;
} }
{ {
vec4 l4 = vec4(0); vec4 l3 = vec4(0);
(l2).y = (l3).y; (l1).y = (l2).y;
(l2).z = (l4).z; (l1).z = (l3).z;
} }
} }
l1 = l2; return l1;
return;
} }

View File

@ -1,14 +1,12 @@
void F0(out vec2 l0); vec2 F0(void);
void F0(out vec2 l0) { vec2 F0(void) {
bool l1 = false; bool l0 = false;
l1 = true; l0 = true;
{ {
int l2 = 0; int l1 = 0;
l2 = 0; l1 = 0;
l0 = vec2(l2); return vec2(l1);
return;
} }
l0 = vec2(1.0); return vec2(1.0);
return;
} }

View File

@ -1,22 +1,21 @@
void F0(in vec2 l0, out vec4 l1); vec4 F0(in vec2 l0);
void F0(in vec2 l0, out vec4 l1) { vec4 F0(in vec2 l0) {
vec4 l2 = vec4(0); vec4 l1 = vec4(0);
{ {
vec3 l2 = vec3(0);
vec3 l3 = vec3(0); vec3 l3 = vec3(0);
vec3 l4 = vec3(0); (l1).x = (l0).x;
(l2).x = (l0).x; {
vec4 l3 = vec4(0);
(l1).y = (l2).y;
(l1).z = (l3).z;
}
{ {
vec4 l4 = vec4(0); vec4 l4 = vec4(0);
(l2).y = (l3).y; (l1).y = (l2).y;
(l2).z = (l4).z; (l1).z = (l3).z;
}
{
vec4 l5 = vec4(0);
(l2).y = (l3).y;
(l2).z = (l4).z;
} }
} }
l1 = l2; return l1;
return;
} }

View File

@ -1,6 +1,5 @@
void F0(out bool l0); bool F0(void);
void F0(out bool l0) { bool F0(void) {
l0 = true; return true;
return;
} }

View File

@ -1,14 +1,12 @@
void F0(in vec2 l0, out vec2 l1); vec2 F0(in vec2 l0);
void F1(in vec2 l0, out vec2 l1); vec2 F1(in vec2 l0);
void F0(in vec2 l0, out vec2 l1) { vec2 F0(in vec2 l0) {
vec2 l2 = vec2(0); vec2 l1 = vec2(0);
F1(l0, l2); l1 = F1(l0);
l1 = l2; return l1;
return;
} }
void F1(in vec2 l0, out vec2 l1) { vec2 F1(in vec2 l0) {
l1 = l0; return l0;
return;
} }

View File

@ -1,16 +1,15 @@
void F0(in vec2 l0, out vec2 l1); vec2 F0(in vec2 l0);
void F1(in float l0, out float l1, out float l2); void F1(in float l0, out float l1, out float l2);
void F0(in vec2 l0, out vec2 l1) { vec2 F0(in vec2 l0) {
float l1 = float(0);
float l2 = float(0); float l2 = float(0);
float l3 = float(0); float l3 = float(0);
float l4 = float(0); float l4 = float(0);
float l5 = float(0); F1((l0).x, l1, l2);
F1((l0).x, l2, l3); l3 = l1;
l4 = l2; l4 = l2;
l5 = l3; return vec2(l3, l4);
l1 = vec2(l4, l5);
return;
} }
void F1(in float l0, out float l1, out float l2) { void F1(in float l0, out float l1, out float l2) {

View File

@ -1,6 +1,5 @@
void F0(out vec2 l0); vec2 F0(void);
void F0(out vec2 l0) { vec2 F0(void) {
l0 = vec2(3.5000000000e+00); return vec2(3.5000000000e+00);
return;
} }

View File

@ -1,6 +1,5 @@
void F0(out vec2 l0); vec2 F0(void);
void F0(out vec2 l0) { vec2 F0(void) {
l0 = vec2(3.5000000000e+00); return vec2(3.5000000000e+00);
return;
} }

View File

@ -1,28 +1,24 @@
void F0(in int l0, out int l1); int F0(in int l0);
void F1(in float l0, out float l1); float F1(in float l0);
void F2(out int l0); int F2(void);
void F3(out float l0); float F3(void);
void F0(in int l0, out int l1) { int F0(in int l0) {
l1 = (1) + (l0); return (1) + (l0);
return;
} }
void F1(in float l0, out float l1) { float F1(in float l0) {
l1 = (1.0) + (l0); return (1.0) + (l0);
return;
} }
void F2(out int l0) { int F2(void) {
int l1 = 0; int l0 = 0;
F0(1, l1); l0 = F0(1);
l0 = l1; return l0;
return;
} }
void F3(out float l0) { float F3(void) {
float l1 = float(0); float l0 = float(0);
F1(1.0, l1); l0 = F1(1.0);
l0 = l1; return l0;
return;
} }

View File

@ -1,8 +1,7 @@
void F0(in vec2 l0, out vec4 l1); vec4 F0(in vec2 l0);
void F0(in vec2 l0, out vec4 l1) { vec4 F0(in vec2 l0) {
vec4 l2 = vec4(0); vec4 l1 = vec4(0);
l2 = vec4(l0, 0.0, 1.0); l1 = vec4(l0, 0.0, 1.0);
l1 = l2; return l1;
return;
} }

View File

@ -1,20 +1,18 @@
void F0(out vec2 l0); vec2 F0(void);
void F1(out vec2 l0); vec2 F1(void);
void F0(out vec2 l0) { vec2 F0(void) {
vec2 l0 = vec2(0);
vec2 l1 = vec2(0); vec2 l1 = vec2(0);
vec2 l2 = vec2(0); vec2 l2 = vec2(0);
vec2 l3 = vec2(0); vec2 l3 = vec2(0);
vec2 l4 = vec2(0); l0 = F1();
F1(l1); l1 = (1.0) * (l0);
l2 = (1.0) * (l1); l2 = F1();
F1(l3); l3 = (l2) * (1.0);
l4 = (l3) * (1.0); return l1;
l0 = l2;
return;
} }
void F1(out vec2 l0) { vec2 F1(void) {
l0 = vec2(0.0); return vec2(0.0);
return;
} }

View File

@ -1,16 +1,15 @@
void F0(in vec2 l0, out vec4 l1); vec4 F0(in vec2 l0);
void F1(out float l0, out float l1); void F1(out float l0, out float l1);
void F0(in vec2 l0, out vec4 l1) { vec4 F0(in vec2 l0) {
float l1 = float(0);
float l2 = float(0); float l2 = float(0);
float l3 = float(0); float l3 = float(0);
float l4 = float(0); float l4 = float(0);
float l5 = float(0); F1(l1, l2);
F1(l2, l3); l3 = l1;
l4 = l2; l4 = l2;
l5 = l3; return vec4(l0, l3, l3);
l1 = vec4(l0, l4, l4);
return;
} }
void F1(out float l0, out float l1) { void F1(out float l0, out float l1) {

View File

@ -1,8 +1,7 @@
void F0(in vec2 l0, out vec4 l1); vec4 F0(in vec2 l0);
void F0(in vec2 l0, out vec4 l1) { vec4 F0(in vec2 l0) {
vec4 l2 = vec4(0); vec4 l1 = vec4(0);
l2 = (vec4(0.0)) * (vec4(0.0)); l1 = (vec4(0.0)) * (vec4(0.0));
l1 = l2; return l1;
return;
} }

View File

@ -1,16 +1,15 @@
void F0(out vec2 l0); vec2 F0(void);
void F0(out vec2 l0) { vec2 F0(void) {
vec2 l1 = vec2(0); vec2 l0 = vec2(0);
vec2 l3 = vec2(0); vec2 l2 = vec2(0);
l1 = vec2(0.0); l0 = vec2(0.0);
for (int l2 = 0; l2 < 100; l2++) { for (int l1 = 0; l1 < 100; l1++) {
(l1).x = ((l1).x) + (float(l2)); (l0).x = ((l0).x) + (float(l1));
} }
l3 = vec2(0.0); l2 = vec2(0.0);
for (float l4 = 10.0; l4 >= 0.0; l4 -= 2.0) { for (float l3 = 10.0; l3 >= 0.0; l3 -= 2.0) {
(l3).x = ((l3).x) + (float(l4)); (l2).x = ((l2).x) + (float(l3));
} }
l0 = l1; return l0;
return;
} }

View File

@ -1,22 +1,21 @@
void F0(out vec2 l0); vec2 F0(void);
void F0(out vec2 l0) { vec2 F0(void) {
vec2 l1 = vec2(0); vec2 l0 = vec2(0);
vec2 l3 = vec2(0); vec2 l2 = vec2(0);
l1 = vec2(0.0); l0 = vec2(0.0);
for (int l2 = 0; l2 < 100; l2++) { for (int l1 = 0; l1 < 100; l1++) {
(l1).x = ((l1).x) + (float(l2)); (l0).x = ((l0).x) + (float(l1));
if (((l1).x) >= (100.0)) { if (((l0).x) >= (100.0)) {
break; break;
} }
} }
l3 = vec2(0.0); l2 = vec2(0.0);
for (float l4 = 10.0; l4 >= 0.0; l4 -= 2.0) { for (float l3 = 10.0; l3 >= 0.0; l3 -= 2.0) {
if (((l3).x) < (100.0)) { if (((l2).x) < (100.0)) {
continue; continue;
} }
(l3).x = ((l3).x) + (l4); (l2).x = ((l2).x) + (l3);
} }
l0 = l1; return l0;
return;
} }

View File

@ -1,20 +1,19 @@
void F0(out vec2 l0); vec2 F0(void);
void F0(out vec2 l0) { vec2 F0(void) {
vec2 l1 = vec2(0); vec2 l0 = vec2(0);
vec2 l3 = vec2(0); vec2 l2 = vec2(0);
l1 = vec2(0.0); l0 = vec2(0.0);
for (int l2 = 0; l2 < 100; l2++) { for (int l1 = 0; l1 < 100; l1++) {
vec2 l3 = vec2(0); vec2 l2 = vec2(0);
l3 = vec2(0.0); l2 = vec2(0.0);
l1 = l3; l0 = l2;
} }
l3 = vec2(0.0); l2 = vec2(0.0);
for (int l4 = 0; l4 < 100; l4++) { for (int l3 = 0; l3 < 100; l3++) {
vec2 l5 = vec2(0); vec2 l4 = vec2(0);
l5 = vec2(0.0); l4 = vec2(0.0);
l3 = l5; l2 = l4;
} }
l0 = l1; return l0;
return;
} }

View File

@ -1,24 +1,22 @@
void F0(in int l0, out int l1); int F0(in int l0);
void F1(out int l0); int F1(void);
void F0(in int l0, out int l1) { int F0(in int l0) {
l1 = l0; return l0;
return;
} }
void F1(out int l0) { int F1(void) {
int l1 = 0; int l0 = 0;
int l3 = 0; int l2 = 0;
l1 = 0; l0 = 0;
for (int l2 = 0; l2 < 10; l2++) { for (int l1 = 0; l1 < 10; l1++) {
int l2 = 0;
int l3 = 0; int l3 = 0;
int l4 = 0; l2 = F0(l1);
F0(l2, l3); l3 = l2;
l4 = l3; l0 = (l0) + (l3);
l1 = (l1) + (l4);
} }
l3 = 0; l2 = 0;
l1 = (l1) + (l3); l0 = (l0) + (l2);
l0 = l1; return l0;
return;
} }

View File

@ -2,11 +2,10 @@ uniform float U0;
uniform float U1; uniform float U1;
uniform float U2; uniform float U2;
void F0(in int l0, out int l1); int F0(in int l0);
void F0(in int l0, out int l1) { int F0(in int l0) {
l1 = l0; return l0;
return;
} }
void main(void) { void main(void) {
@ -16,13 +15,13 @@ void main(void) {
for (int l1 = 0; l1 < 10; l1++) { for (int l1 = 0; l1 < 10; l1++) {
int l2 = 0; int l2 = 0;
int l3 = 0; int l3 = 0;
F0(l1, l2); l2 = F0(l1);
l3 = l2; l3 = l2;
l0 = (l0) + (l3); l0 = (l0) + (l3);
for (int l4 = 0; l4 < 10; l4++) { for (int l4 = 0; l4 < 10; l4++) {
int l5 = 0; int l5 = 0;
int l6 = 0; int l6 = 0;
F0(l4, l5); l5 = F0(l4);
l6 = l5; l6 = l5;
l0 = (l0) + (l6); l0 = (l0) + (l6);
} }

View File

@ -3,11 +3,10 @@ uniform float U1;
uniform float U2; uniform float U2;
attribute vec2 A0; attribute vec2 A0;
void F0(in int l0, out int l1); int F0(in int l0);
void F0(in int l0, out int l1) { int F0(in int l0) {
l1 = l0; return l0;
return;
} }
void main(void) { void main(void) {
@ -17,13 +16,13 @@ void main(void) {
for (int l1 = 0; l1 < 10; l1++) { for (int l1 = 0; l1 < 10; l1++) {
int l2 = 0; int l2 = 0;
int l3 = 0; int l3 = 0;
F0(l1, l2); l2 = F0(l1);
l3 = l2; l3 = l2;
l0 = (l0) + (l3); l0 = (l0) + (l3);
for (int l4 = 0; l4 < 10; l4++) { for (int l4 = 0; l4 < 10; l4++) {
int l5 = 0; int l5 = 0;
int l6 = 0; int l6 = 0;
F0(l4, l5); l5 = F0(l4);
l6 = l5; l6 = l5;
l0 = (l0) + (l6); l0 = (l0) + (l6);
} }

View File

@ -1,6 +1,5 @@
void F0(in vec2 l0, out vec4 l1); vec4 F0(in vec2 l0);
void F0(in vec2 l0, out vec4 l1) { vec4 F0(in vec2 l0) {
l1 = vec4(0.0); return vec4(0.0);
return;
} }

View File

@ -1,6 +1,5 @@
void F0(in vec2 l0, out vec4 l1); vec4 F0(in vec2 l0);
void F0(in vec2 l0, out vec4 l1) { vec4 F0(in vec2 l0) {
l1 = vec4(l0, 0.0, 1.0); return vec4(l0, 0.0, 1.0);
return;
} }

View File

@ -1,12 +1,10 @@
void F0(out vec2 l0); vec2 F0(void);
void F0(out vec2 l0) { vec2 F0(void) {
bool l1 = false; bool l0 = false;
l1 = true; l0 = true;
if (l1) { if (l0) {
l0 = vec2(0.0); return vec2(0.0);
return;
} }
l0 = vec2(1.0); return vec2(1.0);
return;
} }

View File

@ -1,13 +1,11 @@
void F0(out vec2 l0); vec2 F0(void);
void F0(out vec2 l0) { vec2 F0(void) {
bool l1 = false; bool l0 = false;
l1 = true; l0 = true;
if (l1) { if (l0) {
l0 = vec2(0.0); return vec2(0.0);
return;
} else { } else {
l0 = vec2(1.0); return vec2(1.0);
return;
} }
} }

View File

@ -1,16 +1,14 @@
void F0(in vec2 l0, out vec2 l1); vec2 F0(in vec2 l0);
void F0(in vec2 l0, out vec2 l1) { vec2 F0(in vec2 l0) {
vec2 l2 = vec2(0); vec2 l1 = vec2(0);
l2 = vec2(0.0); l1 = vec2(0.0);
{ {
vec2 l3 = vec2(0); vec2 l2 = vec2(0);
l3 = vec2(1.0); l2 = vec2(1.0);
if (((l3).x) == (1.0)) { if (((l2).x) == (1.0)) {
l1 = l3; return l2;
return;
} }
} }
l1 = l2; return l1;
return;
} }

View File

@ -1,12 +1,11 @@
void F0(out vec2 l0); vec2 F0(void);
void F0(out vec2 l0) { vec2 F0(void) {
int l0 = 0;
int l1 = 0; int l1 = 0;
int l2 = 0; l0 = 0;
l1 = 0; l0 = (l0) + (1);
l1 = (l1) + (1); l1 = 1;
l2 = 1; l1 = (l1) - (1);
l2 = (l2) - (1); return vec2(l0, l1);
l0 = vec2(l1, l2);
return;
} }

View File

@ -1,8 +1,7 @@
void F0(in float4 l0, out float4 l1); float4 F0(in float4 l0);
void F0(in float4 l0, out float4 l1) { float4 F0(in float4 l0) {
float4 l2 = 0.0; float4 l1 = 0.0;
l2 = mul(l0, float4x4FromScalar(1.0)); l1 = mul(l0, float4x4FromScalar(1.0));
l1 = l2; return l1;
return;
} }

View File

@ -1,8 +1,7 @@
void F0(in vec4 l0, out vec4 l1); vec4 F0(in vec4 l0);
void F0(in vec4 l0, out vec4 l1) { vec4 F0(in vec4 l0) {
vec4 l2 = vec4(0); vec4 l1 = vec4(0);
l2 = (mat4(1.0)) * (l0); l1 = (mat4(1.0)) * (l0);
l1 = l2; return l1;
return;
} }

View File

@ -1,6 +1,7 @@
void F0(out vec2 l0); vec2 F0(void);
void F0(out vec2 l0) { vec2 F0(void) {
vec2 l0 = vec2(0);
vec2 l1 = vec2(0); vec2 l1 = vec2(0);
vec2 l2 = vec2(0); vec2 l2 = vec2(0);
vec2 l3 = vec2(0); vec2 l3 = vec2(0);
@ -10,17 +11,15 @@ void F0(out vec2 l0) {
vec2 l7 = vec2(0); vec2 l7 = vec2(0);
vec2 l8 = vec2(0); vec2 l8 = vec2(0);
vec2 l9 = vec2(0); vec2 l9 = vec2(0);
vec2 l10 = vec2(0); l2 = l1;
l3 = l2; l0 = l2;
l3 = l0;
l1 = l3; l1 = l3;
l4 = l1; l7 = l5;
l2 = l4; l4 = l7;
l8 = l6; l8 = l6;
l5 = l8; l5 = l8;
l9 = l7; l9 = l4;
l6 = l9; l6 = l9;
l10 = l5; return l0;
l7 = l10;
l0 = l1;
return;
} }

View File

@ -1,8 +1,7 @@
void F0(in float l0, out int l1); int F0(in float l0);
void F0(in float l0, out int l1) { int F0(in float l0) {
int l2 = 0; int l1 = 0;
l2 = int(l0); l1 = int(l0);
l1 = l2; return l1;
return;
} }

View File

@ -1,11 +1,10 @@
void F0(out int l0); int F0(void);
void F0(out int l0) { int F0(void) {
int l1 = 0; int l0 = 0;
l1 = 1; l0 = 1;
l1 = (l1) * (2); l0 = (l0) * (2);
l1 = (l1) + (2); l0 = (l0) + (2);
l1 = (2) - (l1); l0 = (2) - (l0);
l0 = l1; return l0;
return;
} }

View File

@ -1,6 +1,5 @@
void F0(out float l0); float F0(void);
void F0(out float l0) { float F0(void) {
l0 = (sin(1.0000000000e-01)) + (cos(2.0000000000e-01)); return (sin(1.0000000000e-01)) + (cos(2.0000000000e-01));
return;
} }

View File

@ -1,12 +1,10 @@
void F0(out float l0); float F0(void);
void F1(out int l0); int F1(void);
void F0(out float l0) { float F0(void) {
l0 = 1.0; return 1.0;
return;
} }
void F1(out int l0) { int F1(void) {
l0 = 2; return 2;
return;
} }

View File

@ -1,19 +1,17 @@
void F0(in vec2 l0, out int l1); int F0(in vec2 l0);
void F1(in vec2 l0, out int l1); int F1(in vec2 l0);
void F0(in vec2 l0, out int l1) { int F0(in vec2 l0) {
int l2[2]; int l1[2];
l2[0] = 0; l1[0] = 0;
l2[1] = 0; l1[1] = 0;
l1 = 2; return 2;
return;
} }
void F1(in vec2 l0, out int l1) { int F1(in vec2 l0) {
int l2[3]; int l1[3];
l2[0] = 0; l1[0] = 0;
l2[1] = 0; l1[1] = 0;
l2[2] = 0; l1[2] = 0;
l1 = 3; return 3;
return;
} }

View File

@ -1,39 +1,36 @@
void F0(out vec2 l0); vec2 F0(void);
void F1(out vec2 l0); vec2 F1(void);
void F2(out float l0); float F2(void);
void F3(in float l0); void F3(in float l0);
void F4(in int l0); void F4(in int l0);
void F5(void); void F5(void);
void F0(out vec2 l0) { vec2 F0(void) {
float l0 = float(0);
float l1 = float(0); float l1 = float(0);
float l2 = float(0); float l2 = float(0);
float l3 = float(0); float l3 = float(0);
float l4 = float(0); l0 = F2();
F2(l1); l1 = (l0) * (1.0);
l2 = (l1) * (1.0); l2 = F2();
F2(l3); l3 = (1.0) * (l2);
l4 = (1.0) * (l3); return vec2(l1, l3);
l0 = vec2(l2, l4);
return;
} }
void F1(out vec2 l0) { vec2 F1(void) {
float l0 = float(0);
float l1 = float(0); float l1 = float(0);
float l2 = float(0); float l2 = float(0);
float l3 = float(0); float l3 = float(0);
float l4 = float(0); l0 = F2();
F2(l1); l1 = (l0) * (1.0);
l2 = (l1) * (1.0); l2 = F2();
F2(l3); l3 = (1.0) * (l2);
l4 = (1.0) * (l3); return vec2(l1, l3);
l0 = vec2(l2, l4);
return;
} }
void F2(out float l0) { float F2(void) {
l0 = 1.0; return 1.0;
return;
} }
void F3(in float l0) { void F3(in float l0) {

View File

@ -1,28 +1,26 @@
void F0(out vec4 l0); vec4 F0(void);
void F1(out vec4 l0); vec4 F1(void);
void F0(out vec4 l0) { vec4 F0(void) {
int l1 = 0; int l0 = 0;
float l1 = float(0);
float l2 = float(0); float l2 = float(0);
float l3 = float(0); float l3 = float(0);
float l4 = float(0); l0 = 2;
l1 = 2; l1 = 2.5000000000e+00;
l2 = 2.5000000000e+00; l2 = 2.5000000000e+00;
l3 = 2.5000000000e+00; l3 = 2.5000000000e+00;
l4 = 2.5000000000e+00; return vec4(l0, l1, l2, l3);
l0 = vec4(l1, l2, l3, l4);
return;
} }
void F1(out vec4 l0) { vec4 F1(void) {
int l1 = 0; int l0 = 0;
float l1 = float(0);
float l2 = float(0); float l2 = float(0);
float l3 = float(0); float l3 = float(0);
float l4 = float(0); l0 = 2;
l1 = 2; l1 = 2.5000000000e+00;
l2 = 2.5000000000e+00; l2 = 2.5000000000e+00;
l3 = 2.5000000000e+00; l3 = 2.5000000000e+00;
l4 = 2.5000000000e+00; return vec4(l0, l1, l2, l3);
l0 = vec4(l1, l2, l3, l4);
return;
} }

View File

@ -1,44 +1,42 @@
void F0(out vec4 l0); vec4 F0(void);
void F1(out vec4 l0); vec4 F1(void);
void F0(out vec4 l0) { vec4 F0(void) {
int l0 = 0;
int l1 = 0; int l1 = 0;
int l2 = 0; int l2 = 0;
int l3 = 0; int l3 = 0;
int l4 = 0; float l4 = float(0);
float l5 = float(0); float l5 = float(0);
float l6 = float(0); float l6 = float(0);
float l7 = float(0); float l7 = float(0);
float l8 = float(0); l0 = 5;
l1 = 5; l1 = -5;
l2 = -5; l2 = -5;
l3 = -5; l3 = 5;
l4 = 5; l4 = 5.0;
l5 = 5.0; l5 = -5.0;
l6 = -5.0; l6 = -5.0;
l7 = -5.0; l7 = 5.0;
l8 = 5.0; return (vec4(l0, l1, l2, l3)) + (vec4(l4, l5, l6, l7));
l0 = (vec4(l1, l2, l3, l4)) + (vec4(l5, l6, l7, l8));
return;
} }
void F1(out vec4 l0) { vec4 F1(void) {
int l0 = 0;
int l1 = 0; int l1 = 0;
int l2 = 0; int l2 = 0;
int l3 = 0; int l3 = 0;
int l4 = 0; float l4 = float(0);
float l5 = float(0); float l5 = float(0);
float l6 = float(0); float l6 = float(0);
float l7 = float(0); float l7 = float(0);
float l8 = float(0); l0 = 5;
l1 = 5; l1 = -5;
l2 = -5; l2 = -5;
l3 = -5; l3 = 5;
l4 = 5; l4 = 5.0;
l5 = 5.0; l5 = -5.0;
l6 = -5.0; l6 = -5.0;
l7 = -5.0; l7 = 5.0;
l8 = 5.0; return (vec4(l0, l1, l2, l3)) + (vec4(l4, l5, l6, l7));
l0 = (vec4(l1, l2, l3, l4)) + (vec4(l5, l6, l7, l8));
return;
} }

View File

@ -1,8 +1,7 @@
void F0(in vec2 l0, out vec4 l1); vec4 F0(in vec2 l0);
void F0(in vec2 l0, out vec4 l1) { vec4 F0(in vec2 l0) {
vec4 l2 = vec4(0); vec4 l1 = vec4(0);
l2 = vec4(l0, 0.0, 1.0); l1 = vec4(l0, 0.0, 1.0);
l1 = l2; return l1;
return;
} }

View File

@ -1,11 +1,10 @@
void F0(in vec2 l0, out vec4 l1); vec4 F0(in vec2 l0);
void F0(in vec2 l0, out vec4 l1) { vec4 F0(in vec2 l0) {
vec4 l1 = vec4(0);
vec4 l2 = vec4(0); vec4 l2 = vec4(0);
vec4 l3 = vec4(0); l1 = vec4(l0, 0.0, 1.0);
l2 = vec4(l0, 0.0, 1.0); (l1).x = (l1).x;
(l2).x = (l2).x; l2 = l1;
l3 = l2; return l2;
l1 = l3;
return;
} }

View File

@ -1,26 +1,24 @@
void F0(in vec2 l0, out vec4 l1); vec4 F0(in vec2 l0);
void F1(in vec2 l0, out vec4 l1); vec4 F1(in vec2 l0);
void F2(out vec2 l0, out vec2 l1); void F2(out vec2 l0, out vec2 l1);
void F0(in vec2 l0, out vec4 l1) { vec4 F0(in vec2 l0) {
vec2 l1 = vec2(0);
vec2 l2 = vec2(0); vec2 l2 = vec2(0);
vec2 l3 = vec2(0); l1 = l0;
l2 = l0; l2 = l0;
l3 = l0; return vec4(l1, l2);
l1 = vec4(l2, l3);
return;
} }
void F1(in vec2 l0, out vec4 l1) { vec4 F1(in vec2 l0) {
vec2 l1 = vec2(0);
vec2 l2 = vec2(0); vec2 l2 = vec2(0);
vec2 l3 = vec2(0); vec2 l3 = vec2(0);
vec2 l4 = vec2(0); vec2 l4 = vec2(0);
vec2 l5 = vec2(0); F2(l1, l2);
F2(l2, l3); l3 = l1;
l4 = l2; l4 = l2;
l5 = l3; return vec4(l3, l4);
l1 = vec4(l4, l5);
return;
} }
void F2(out vec2 l0, out vec2 l1) { void F2(out vec2 l0, out vec2 l1) {