From b6a340a96f0f1c23b67625499a9c9dedee57d42b Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 10 Jul 2022 15:45:28 +0900 Subject: [PATCH] internal/shader: optimization: use a regular return for a function with one output parameter Updates #2034 Updates #2188 --- internal/shader/shader.go | 43 ++++++++---- internal/shader/stmt.go | 65 ++++++++++++------- internal/shader/testdata/array.expected.vs | 40 +++++------- .../shader/testdata/array2.expected.metal | 15 ++--- internal/shader/testdata/array2.expected.vs | 29 ++++----- internal/shader/testdata/assign.expected.vs | 13 ++-- .../testdata/assign_multiple.expected.vs | 13 ++-- .../testdata/assign_multiple2.expected.vs | 17 +++-- internal/shader/testdata/atan.expected.metal | 13 ++-- internal/shader/testdata/atan.expected.vs | 13 ++-- internal/shader/testdata/blocks.expected.vs | 25 ++++--- internal/shader/testdata/blocks2.expected.vs | 18 +++-- internal/shader/testdata/blocks3.expected.vs | 27 ++++---- internal/shader/testdata/bool.expected.vs | 7 +- internal/shader/testdata/call.expected.vs | 18 +++-- .../shader/testdata/call_multiple.expected.vs | 13 ++-- internal/shader/testdata/const.expected.vs | 7 +- internal/shader/testdata/const2.expected.vs | 7 +- internal/shader/testdata/const4.expected.vs | 36 +++++----- internal/shader/testdata/define.expected.vs | 11 ++-- internal/shader/testdata/define2.expected.vs | 24 ++++--- .../testdata/define_multiple.expected.vs | 13 ++-- .../shader/testdata/define_type.expected.vs | 11 ++-- internal/shader/testdata/for.expected.vs | 23 ++++--- internal/shader/testdata/for2.expected.vs | 27 ++++---- internal/shader/testdata/for3.expected.vs | 31 +++++---- internal/shader/testdata/for4.expected.vs | 34 +++++----- internal/shader/testdata/for5.expected.fs | 11 ++-- internal/shader/testdata/for5.expected.vs | 11 ++-- internal/shader/testdata/func.expected.vs | 7 +- .../shader/testdata/func_body.expected.vs | 7 +- internal/shader/testdata/if.expected.vs | 16 ++--- internal/shader/testdata/if_else.expected.vs | 16 ++--- internal/shader/testdata/if_init.expected.vs | 20 +++--- internal/shader/testdata/inc.expected.vs | 17 +++-- .../shader/testdata/issue1236.expected.hlsl | 11 ++-- .../shader/testdata/issue1236.expected.vs | 11 ++-- .../shader/testdata/issue1248.expected.vs | 21 +++--- .../shader/testdata/issue1298.expected.vs | 11 ++-- .../shader/testdata/issue1299.expected.vs | 17 +++-- .../shader/testdata/issue1874.expected.vs | 7 +- .../shader/testdata/issue2011.expected.vs | 14 ++-- internal/shader/testdata/len.expected.vs | 28 ++++---- internal/shader/testdata/number.expected.vs | 41 ++++++------ .../shader/testdata/number_binary.expected.vs | 30 ++++----- .../shader/testdata/number_unary.expected.vs | 46 +++++++------ internal/shader/testdata/var.expected.vs | 11 ++-- internal/shader/testdata/var2.expected.vs | 15 ++--- .../shader/testdata/var_multiple.expected.vs | 24 ++++--- 49 files changed, 474 insertions(+), 511 deletions(-) diff --git a/internal/shader/shader.go b/internal/shader/shader.go index 1b5059ecd..7af7f868f 100644 --- a/internal/shader/shader.go +++ b/internal/shader/shader.go @@ -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 for _, v := range inParams { inT = append(inT, v.typ) @@ -276,6 +276,7 @@ func (cs *compileState) parse(f *ast.File) { Index: len(cs.funcs), InParams: inT, OutParams: outT, + Return: ret, Block: &shaderir.Block{}, }, }) @@ -620,7 +621,7 @@ func (s *compileState) parseConstant(block *block, vs *ast.ValueSpec) ([]constan 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 { t, ok := cs.parseType(block, f.Type) 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 } @@ -674,7 +681,7 @@ func (cs *compileState) parseFunc(block *block, d *ast.FuncDecl) (function, bool return function{}, false } - inParams, outParams := cs.parseFuncParams(block, d) + inParams, outParams, returnType := cs.parseFuncParams(block, d) checkVaryings := func(vs []variable) { 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) } - // 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 { - cs.addError(d.Pos(), fmt.Sprintf("vertex entry point must have at least one returning vec4 value for a position")) - return function{}, false + outParams = append(outParams, variable{ + typ: shaderir.Type{Main: shaderir.Vec4}, + }) } + + // The first out-param is treated as gl_Position in GLSL. 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")) return function{}, false @@ -724,11 +735,14 @@ func (cs *compileState) parseFunc(block *block, d *ast.FuncDecl) (function, bool return function{}, false } - if len(outParams) != 1 { - cs.addError(d.Pos(), fmt.Sprintf("fragment entry point must have one returning vec4 value for a color")) - return function{}, false + // For the fragment entry, a parameter (variable) is used as a returning value. + // For example, GLSL doesn't treat gl_FragColor as a returning value. + 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")) 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 { return function{}, false } - if len(outParams) > 0 { + if len(outParams) > 0 || returnType.Main != shaderir.None { var hasReturn func(stmts []shaderir.Stmt) bool hasReturn = func(stmts []shaderir.Stmt) bool { for _, stmt := range stmts { @@ -785,12 +799,13 @@ func (cs *compileState) parseFunc(block *block, d *ast.FuncDecl) (function, bool ir: shaderir.Func{ InParams: inT, OutParams: outT, + Return: returnType, Block: b.ir, }, }, 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 if outer == &cs.global { 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 { - ss, ok := cs.parseStmt(block, fname, stmt, inParams, outParams) + ss, ok := cs.parseStmt(block, fname, stmt, inParams, outParams, returnType) if !ok { return nil, false } diff --git a/internal/shader/stmt.go b/internal/shader/stmt.go index 9bfbca85b..47a965a8f 100644 --- a/internal/shader/stmt.go +++ b/internal/shader/stmt.go @@ -34,7 +34,7 @@ func (cs *compileState) forceToInt(node ast.Node, expr *shaderir.Expr) bool { 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 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)) } 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 { 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 // new pseudo block for each for-loop. Without this, the samely named counter variables in different // 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 { 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 - postSs, ok := cs.parseStmt(pseudoBlock, fname, stmt.Post, inParams, outParams) + postSs, ok := cs.parseStmt(pseudoBlock, fname, stmt.Post, inParams, outParams, returnType) if !ok { return nil, false } @@ -313,7 +313,7 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP 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 { return nil, false } @@ -344,7 +344,7 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP if stmt.Init != nil { init := stmt.Init 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 { return nil, false } @@ -371,7 +371,7 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP stmts = append(stmts, ss...) 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 { return nil, false } @@ -380,13 +380,13 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP if stmt.Else != nil { switch s := stmt.Else.(type) { 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 { return nil, false } bs = append(bs, b.ir) 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 { return nil, false } @@ -473,8 +473,14 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP for i, t := range types { expr := exprs[i] + var outT shaderir.Type + if len(outParams) == 0 { + outT = returnType + } else { + outT = outParams[i].typ + } if expr.Type == shaderir.NumberExpr { - switch outParams[i].typ.Main { + switch outT.Main { case shaderir.Int: if !cs.forceToInt(stmt, &expr) { 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) { - cs.addError(stmt.Pos(), fmt.Sprintf("cannot use type %s as type %s in return argument", t.String(), &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(), &outT)) return nil, false } - stmts = append(stmts, shaderir.Stmt{ - Type: shaderir.Assign, - Exprs: []shaderir.Expr{ - { - Type: shaderir.LocalVariable, - Index: len(inParams) + i, + if len(outParams) > 0 { + stmts = append(stmts, shaderir.Stmt{ + Type: shaderir.Assign, + Exprs: []shaderir.Expr{ + { + 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{ - Type: shaderir.Return, - }) + if len(outParams) > 0 { + stmts = append(stmts, shaderir.Stmt{ + Type: shaderir.Return, + }) + } case *ast.BranchStmt: switch stmt.Tok { diff --git a/internal/shader/testdata/array.expected.vs b/internal/shader/testdata/array.expected.vs index 0b1cf4699..c098256b1 100644 --- a/internal/shader/testdata/array.expected.vs +++ b/internal/shader/testdata/array.expected.vs @@ -1,29 +1,25 @@ uniform vec2 U0[4]; -void F0(out vec2 l0[2]); -void F1(out vec2 l0[2]); +vec2[2] F0(void); +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]; l1[0] = vec2(0); l1[1] = vec2(0); - l0[0] = l1[0]; - l0[1] = l1[1]; - return; -} - -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; + (l0)[0] = vec2(1.0); + l1[0] = l0[0]; + l1[1] = l0[1]; + (l1)[1] = vec2(2.0); + return l1; } diff --git a/internal/shader/testdata/array2.expected.metal b/internal/shader/testdata/array2.expected.metal index 1ef317379..8173104d1 100644 --- a/internal/shader/testdata/array2.expected.metal +++ b/internal/shader/testdata/array2.expected.metal @@ -1,12 +1,11 @@ -void F0(thread array& l0); +array F0(void); -void F0(thread array& l0) { - array l1 = {}; - array l2 = {}; +array F0(void) { + array l0 = {}; + array l1 = {}; { - array l2 = {}; - l2 = l1; + array l1 = {}; + l1 = l0; } - l0 = l2; - return; + return l1; } diff --git a/internal/shader/testdata/array2.expected.vs b/internal/shader/testdata/array2.expected.vs index 1c89be5ea..9d8837dbb 100644 --- a/internal/shader/testdata/array2.expected.vs +++ b/internal/shader/testdata/array2.expected.vs @@ -1,22 +1,19 @@ -void F0(out vec2 l0[3]); +vec2[3] F0(void); -void F0(out vec2 l0[3]) { - vec2 l1[2]; +vec2[3] F0(void) { + vec2 l0[2]; + l0[0] = vec2(0); + l0[1] = vec2(0); + vec2 l1[3]; l1[0] = vec2(0); l1[1] = vec2(0); - vec2 l2[3]; - l2[0] = vec2(0); - l2[1] = vec2(0); - l2[2] = vec2(0); + l1[2] = vec2(0); { - vec2 l2[2]; - l2[0] = vec2(0); - l2[1] = vec2(0); - l2[0] = l1[0]; - l2[1] = l1[1]; + vec2 l1[2]; + l1[0] = vec2(0); + l1[1] = vec2(0); + l1[0] = l0[0]; + l1[1] = l0[1]; } - l0[0] = l2[0]; - l0[1] = l2[1]; - l0[2] = l2[2]; - return; + return l1; } diff --git a/internal/shader/testdata/assign.expected.vs b/internal/shader/testdata/assign.expected.vs index 9efbf9885..d2a67969f 100644 --- a/internal/shader/testdata/assign.expected.vs +++ b/internal/shader/testdata/assign.expected.vs @@ -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) { - float l2 = float(0); - l2 = 0.0; - l2 = (l2) + (1.0); - l1 = vec4(l0, l2, l2); - return; +vec4 F0(in vec2 l0) { + float l1 = float(0); + l1 = 0.0; + l1 = (l1) + (1.0); + return vec4(l0, l1, l1); } diff --git a/internal/shader/testdata/assign_multiple.expected.vs b/internal/shader/testdata/assign_multiple.expected.vs index 35f03727a..6621cb946 100644 --- a/internal/shader/testdata/assign_multiple.expected.vs +++ b/internal/shader/testdata/assign_multiple.expected.vs @@ -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 F0(in vec2 l0, out vec4 l1) { +vec4 F0(in vec2 l0) { + float l1 = float(0); float l2 = float(0); float l3 = float(0); float l4 = float(0); - float l5 = float(0); - F1(l4, l5); + F1(l3, l4); + l1 = l3; l2 = l4; - l3 = l5; - l1 = vec4(l0, l2, l3); - return; + return vec4(l0, l1, l2); } void F1(out float l0, out float l1) { diff --git a/internal/shader/testdata/assign_multiple2.expected.vs b/internal/shader/testdata/assign_multiple2.expected.vs index 5af7e3172..01857766a 100644 --- a/internal/shader/testdata/assign_multiple2.expected.vs +++ b/internal/shader/testdata/assign_multiple2.expected.vs @@ -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 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; + l1 = 1.0; + l0 = l1; + l3 = 2.0; + l2 = l3; + return vec2(l0, l2); } diff --git a/internal/shader/testdata/atan.expected.metal b/internal/shader/testdata/atan.expected.metal index 495173a08..3735dd154 100644 --- a/internal/shader/testdata/atan.expected.metal +++ b/internal/shader/testdata/atan.expected.metal @@ -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 l4 = float(0); - l3 = atan((l1) / (l0)); - l4 = atan2(l1, l0); - l2 = (l3) == (l4); - return; + l2 = atan((l1) / (l0)); + l3 = atan2(l1, l0); + return (l2) == (l3); } diff --git a/internal/shader/testdata/atan.expected.vs b/internal/shader/testdata/atan.expected.vs index e23edef1d..b4d17289e 100644 --- a/internal/shader/testdata/atan.expected.vs +++ b/internal/shader/testdata/atan.expected.vs @@ -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 l4 = float(0); - l3 = atan((l1) / (l0)); - l4 = atan(l1, l0); - l2 = (l3) == (l4); - return; + l2 = atan((l1) / (l0)); + l3 = atan(l1, l0); + return (l2) == (l3); } diff --git a/internal/shader/testdata/blocks.expected.vs b/internal/shader/testdata/blocks.expected.vs index b0c11bfe0..c1ff4a919 100644 --- a/internal/shader/testdata/blocks.expected.vs +++ b/internal/shader/testdata/blocks.expected.vs @@ -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 l2 = vec4(0); +vec4 F0(in vec2 l0) { + vec4 l1 = vec4(0); { - vec3 l3 = vec3(0); - (l2).x = (l0).x; + vec3 l2 = vec3(0); + (l1).x = (l0).x; { - vec4 l4 = vec4(0); - (l2).y = (l3).y; - (l2).z = (l4).z; + vec4 l3 = vec4(0); + (l1).y = (l2).y; + (l1).z = (l3).z; } { - vec4 l4 = vec4(0); - (l2).y = (l3).y; - (l2).z = (l4).z; + vec4 l3 = vec4(0); + (l1).y = (l2).y; + (l1).z = (l3).z; } } - l1 = l2; - return; + return l1; } diff --git a/internal/shader/testdata/blocks2.expected.vs b/internal/shader/testdata/blocks2.expected.vs index 1e1dbd57e..e37be50b9 100644 --- a/internal/shader/testdata/blocks2.expected.vs +++ b/internal/shader/testdata/blocks2.expected.vs @@ -1,14 +1,12 @@ -void F0(out vec2 l0); +vec2 F0(void); -void F0(out vec2 l0) { - bool l1 = false; - l1 = true; +vec2 F0(void) { + bool l0 = false; + l0 = true; { - int l2 = 0; - l2 = 0; - l0 = vec2(l2); - return; + int l1 = 0; + l1 = 0; + return vec2(l1); } - l0 = vec2(1.0); - return; + return vec2(1.0); } diff --git a/internal/shader/testdata/blocks3.expected.vs b/internal/shader/testdata/blocks3.expected.vs index fb240c57d..3ba769281 100644 --- a/internal/shader/testdata/blocks3.expected.vs +++ b/internal/shader/testdata/blocks3.expected.vs @@ -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 l2 = vec4(0); +vec4 F0(in vec2 l0) { + vec4 l1 = vec4(0); { + vec3 l2 = vec3(0); vec3 l3 = vec3(0); - vec3 l4 = vec3(0); - (l2).x = (l0).x; + (l1).x = (l0).x; + { + vec4 l3 = vec4(0); + (l1).y = (l2).y; + (l1).z = (l3).z; + } { vec4 l4 = vec4(0); - (l2).y = (l3).y; - (l2).z = (l4).z; - } - { - vec4 l5 = vec4(0); - (l2).y = (l3).y; - (l2).z = (l4).z; + (l1).y = (l2).y; + (l1).z = (l3).z; } } - l1 = l2; - return; + return l1; } diff --git a/internal/shader/testdata/bool.expected.vs b/internal/shader/testdata/bool.expected.vs index 886c85177..37caa3991 100644 --- a/internal/shader/testdata/bool.expected.vs +++ b/internal/shader/testdata/bool.expected.vs @@ -1,6 +1,5 @@ -void F0(out bool l0); +bool F0(void); -void F0(out bool l0) { - l0 = true; - return; +bool F0(void) { + return true; } diff --git a/internal/shader/testdata/call.expected.vs b/internal/shader/testdata/call.expected.vs index e0fe54104..1fdda1a64 100644 --- a/internal/shader/testdata/call.expected.vs +++ b/internal/shader/testdata/call.expected.vs @@ -1,14 +1,12 @@ -void F0(in vec2 l0, out vec2 l1); -void F1(in vec2 l0, out vec2 l1); +vec2 F0(in vec2 l0); +vec2 F1(in vec2 l0); -void F0(in vec2 l0, out vec2 l1) { - vec2 l2 = vec2(0); - F1(l0, l2); - l1 = l2; - return; +vec2 F0(in vec2 l0) { + vec2 l1 = vec2(0); + l1 = F1(l0); + return l1; } -void F1(in vec2 l0, out vec2 l1) { - l1 = l0; - return; +vec2 F1(in vec2 l0) { + return l0; } diff --git a/internal/shader/testdata/call_multiple.expected.vs b/internal/shader/testdata/call_multiple.expected.vs index 6026d888c..5055f6637 100644 --- a/internal/shader/testdata/call_multiple.expected.vs +++ b/internal/shader/testdata/call_multiple.expected.vs @@ -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 F0(in vec2 l0, out vec2 l1) { +vec2 F0(in vec2 l0) { + float l1 = float(0); float l2 = float(0); float l3 = float(0); float l4 = float(0); - float l5 = float(0); - F1((l0).x, l2, l3); + F1((l0).x, l1, l2); + l3 = l1; l4 = l2; - l5 = l3; - l1 = vec2(l4, l5); - return; + return vec2(l3, l4); } void F1(in float l0, out float l1, out float l2) { diff --git a/internal/shader/testdata/const.expected.vs b/internal/shader/testdata/const.expected.vs index d6ea47afe..559a2809d 100644 --- a/internal/shader/testdata/const.expected.vs +++ b/internal/shader/testdata/const.expected.vs @@ -1,6 +1,5 @@ -void F0(out vec2 l0); +vec2 F0(void); -void F0(out vec2 l0) { - l0 = vec2(3.5000000000e+00); - return; +vec2 F0(void) { + return vec2(3.5000000000e+00); } diff --git a/internal/shader/testdata/const2.expected.vs b/internal/shader/testdata/const2.expected.vs index d6ea47afe..559a2809d 100644 --- a/internal/shader/testdata/const2.expected.vs +++ b/internal/shader/testdata/const2.expected.vs @@ -1,6 +1,5 @@ -void F0(out vec2 l0); +vec2 F0(void); -void F0(out vec2 l0) { - l0 = vec2(3.5000000000e+00); - return; +vec2 F0(void) { + return vec2(3.5000000000e+00); } diff --git a/internal/shader/testdata/const4.expected.vs b/internal/shader/testdata/const4.expected.vs index 935eaf9ef..d57267baa 100644 --- a/internal/shader/testdata/const4.expected.vs +++ b/internal/shader/testdata/const4.expected.vs @@ -1,28 +1,24 @@ -void F0(in int l0, out int l1); -void F1(in float l0, out float l1); -void F2(out int l0); -void F3(out float l0); +int F0(in int l0); +float F1(in float l0); +int F2(void); +float F3(void); -void F0(in int l0, out int l1) { - l1 = (1) + (l0); - return; +int F0(in int l0) { + return (1) + (l0); } -void F1(in float l0, out float l1) { - l1 = (1.0) + (l0); - return; +float F1(in float l0) { + return (1.0) + (l0); } -void F2(out int l0) { - int l1 = 0; - F0(1, l1); - l0 = l1; - return; +int F2(void) { + int l0 = 0; + l0 = F0(1); + return l0; } -void F3(out float l0) { - float l1 = float(0); - F1(1.0, l1); - l0 = l1; - return; +float F3(void) { + float l0 = float(0); + l0 = F1(1.0); + return l0; } diff --git a/internal/shader/testdata/define.expected.vs b/internal/shader/testdata/define.expected.vs index 7e48ae6d4..2831f7e4d 100644 --- a/internal/shader/testdata/define.expected.vs +++ b/internal/shader/testdata/define.expected.vs @@ -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 l2 = vec4(0); - l2 = vec4(l0, 0.0, 1.0); - l1 = l2; - return; +vec4 F0(in vec2 l0) { + vec4 l1 = vec4(0); + l1 = vec4(l0, 0.0, 1.0); + return l1; } diff --git a/internal/shader/testdata/define2.expected.vs b/internal/shader/testdata/define2.expected.vs index c0980aafb..ec18f9138 100644 --- a/internal/shader/testdata/define2.expected.vs +++ b/internal/shader/testdata/define2.expected.vs @@ -1,20 +1,18 @@ -void F0(out vec2 l0); -void F1(out vec2 l0); +vec2 F0(void); +vec2 F1(void); -void F0(out vec2 l0) { +vec2 F0(void) { + vec2 l0 = vec2(0); vec2 l1 = vec2(0); vec2 l2 = vec2(0); vec2 l3 = vec2(0); - vec2 l4 = vec2(0); - F1(l1); - l2 = (1.0) * (l1); - F1(l3); - l4 = (l3) * (1.0); - l0 = l2; - return; + l0 = F1(); + l1 = (1.0) * (l0); + l2 = F1(); + l3 = (l2) * (1.0); + return l1; } -void F1(out vec2 l0) { - l0 = vec2(0.0); - return; +vec2 F1(void) { + return vec2(0.0); } diff --git a/internal/shader/testdata/define_multiple.expected.vs b/internal/shader/testdata/define_multiple.expected.vs index c7d936ac0..78f55ce45 100644 --- a/internal/shader/testdata/define_multiple.expected.vs +++ b/internal/shader/testdata/define_multiple.expected.vs @@ -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 F0(in vec2 l0, out vec4 l1) { +vec4 F0(in vec2 l0) { + float l1 = float(0); float l2 = float(0); float l3 = float(0); float l4 = float(0); - float l5 = float(0); - F1(l2, l3); + F1(l1, l2); + l3 = l1; l4 = l2; - l5 = l3; - l1 = vec4(l0, l4, l4); - return; + return vec4(l0, l3, l3); } void F1(out float l0, out float l1) { diff --git a/internal/shader/testdata/define_type.expected.vs b/internal/shader/testdata/define_type.expected.vs index ce6eb64e4..96a2d7f46 100644 --- a/internal/shader/testdata/define_type.expected.vs +++ b/internal/shader/testdata/define_type.expected.vs @@ -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 l2 = vec4(0); - l2 = (vec4(0.0)) * (vec4(0.0)); - l1 = l2; - return; +vec4 F0(in vec2 l0) { + vec4 l1 = vec4(0); + l1 = (vec4(0.0)) * (vec4(0.0)); + return l1; } diff --git a/internal/shader/testdata/for.expected.vs b/internal/shader/testdata/for.expected.vs index b57a48444..34623ae7f 100644 --- a/internal/shader/testdata/for.expected.vs +++ b/internal/shader/testdata/for.expected.vs @@ -1,16 +1,15 @@ -void F0(out vec2 l0); +vec2 F0(void); -void F0(out vec2 l0) { - vec2 l1 = vec2(0); - vec2 l3 = vec2(0); - l1 = vec2(0.0); - for (int l2 = 0; l2 < 100; l2++) { - (l1).x = ((l1).x) + (float(l2)); +vec2 F0(void) { + vec2 l0 = vec2(0); + vec2 l2 = vec2(0); + l0 = vec2(0.0); + for (int l1 = 0; l1 < 100; l1++) { + (l0).x = ((l0).x) + (float(l1)); } - l3 = vec2(0.0); - for (float l4 = 10.0; l4 >= 0.0; l4 -= 2.0) { - (l3).x = ((l3).x) + (float(l4)); + l2 = vec2(0.0); + for (float l3 = 10.0; l3 >= 0.0; l3 -= 2.0) { + (l2).x = ((l2).x) + (float(l3)); } - l0 = l1; - return; + return l0; } diff --git a/internal/shader/testdata/for2.expected.vs b/internal/shader/testdata/for2.expected.vs index 252bca9fa..aded6db49 100644 --- a/internal/shader/testdata/for2.expected.vs +++ b/internal/shader/testdata/for2.expected.vs @@ -1,22 +1,21 @@ -void F0(out vec2 l0); +vec2 F0(void); -void F0(out vec2 l0) { - vec2 l1 = vec2(0); - vec2 l3 = vec2(0); - l1 = vec2(0.0); - for (int l2 = 0; l2 < 100; l2++) { - (l1).x = ((l1).x) + (float(l2)); - if (((l1).x) >= (100.0)) { +vec2 F0(void) { + vec2 l0 = vec2(0); + vec2 l2 = vec2(0); + l0 = vec2(0.0); + for (int l1 = 0; l1 < 100; l1++) { + (l0).x = ((l0).x) + (float(l1)); + if (((l0).x) >= (100.0)) { break; } } - l3 = vec2(0.0); - for (float l4 = 10.0; l4 >= 0.0; l4 -= 2.0) { - if (((l3).x) < (100.0)) { + l2 = vec2(0.0); + for (float l3 = 10.0; l3 >= 0.0; l3 -= 2.0) { + if (((l2).x) < (100.0)) { continue; } - (l3).x = ((l3).x) + (l4); + (l2).x = ((l2).x) + (l3); } - l0 = l1; - return; + return l0; } diff --git a/internal/shader/testdata/for3.expected.vs b/internal/shader/testdata/for3.expected.vs index af635c742..58800443c 100644 --- a/internal/shader/testdata/for3.expected.vs +++ b/internal/shader/testdata/for3.expected.vs @@ -1,20 +1,19 @@ -void F0(out vec2 l0); +vec2 F0(void); -void F0(out vec2 l0) { - vec2 l1 = vec2(0); - vec2 l3 = vec2(0); - l1 = vec2(0.0); - for (int l2 = 0; l2 < 100; l2++) { - vec2 l3 = vec2(0); - l3 = vec2(0.0); - l1 = l3; +vec2 F0(void) { + vec2 l0 = vec2(0); + vec2 l2 = vec2(0); + l0 = vec2(0.0); + for (int l1 = 0; l1 < 100; l1++) { + vec2 l2 = vec2(0); + l2 = vec2(0.0); + l0 = l2; } - l3 = vec2(0.0); - for (int l4 = 0; l4 < 100; l4++) { - vec2 l5 = vec2(0); - l5 = vec2(0.0); - l3 = l5; + l2 = vec2(0.0); + for (int l3 = 0; l3 < 100; l3++) { + vec2 l4 = vec2(0); + l4 = vec2(0.0); + l2 = l4; } - l0 = l1; - return; + return l0; } diff --git a/internal/shader/testdata/for4.expected.vs b/internal/shader/testdata/for4.expected.vs index 0d489c79b..74ce5eed2 100644 --- a/internal/shader/testdata/for4.expected.vs +++ b/internal/shader/testdata/for4.expected.vs @@ -1,24 +1,22 @@ -void F0(in int l0, out int l1); -void F1(out int l0); +int F0(in int l0); +int F1(void); -void F0(in int l0, out int l1) { - l1 = l0; - return; +int F0(in int l0) { + return l0; } -void F1(out int l0) { - int l1 = 0; - int l3 = 0; - l1 = 0; - for (int l2 = 0; l2 < 10; l2++) { +int F1(void) { + int l0 = 0; + int l2 = 0; + l0 = 0; + for (int l1 = 0; l1 < 10; l1++) { + int l2 = 0; int l3 = 0; - int l4 = 0; - F0(l2, l3); - l4 = l3; - l1 = (l1) + (l4); + l2 = F0(l1); + l3 = l2; + l0 = (l0) + (l3); } - l3 = 0; - l1 = (l1) + (l3); - l0 = l1; - return; + l2 = 0; + l0 = (l0) + (l2); + return l0; } diff --git a/internal/shader/testdata/for5.expected.fs b/internal/shader/testdata/for5.expected.fs index 440fe11b6..db4180056 100644 --- a/internal/shader/testdata/for5.expected.fs +++ b/internal/shader/testdata/for5.expected.fs @@ -2,11 +2,10 @@ uniform float U0; uniform float U1; uniform float U2; -void F0(in int l0, out int l1); +int F0(in int l0); -void F0(in int l0, out int l1) { - l1 = l0; - return; +int F0(in int l0) { + return l0; } void main(void) { @@ -16,13 +15,13 @@ void main(void) { for (int l1 = 0; l1 < 10; l1++) { int l2 = 0; int l3 = 0; - F0(l1, l2); + l2 = F0(l1); l3 = l2; l0 = (l0) + (l3); for (int l4 = 0; l4 < 10; l4++) { int l5 = 0; int l6 = 0; - F0(l4, l5); + l5 = F0(l4); l6 = l5; l0 = (l0) + (l6); } diff --git a/internal/shader/testdata/for5.expected.vs b/internal/shader/testdata/for5.expected.vs index 4025d0369..d2c70c5d9 100644 --- a/internal/shader/testdata/for5.expected.vs +++ b/internal/shader/testdata/for5.expected.vs @@ -3,11 +3,10 @@ uniform float U1; uniform float U2; attribute vec2 A0; -void F0(in int l0, out int l1); +int F0(in int l0); -void F0(in int l0, out int l1) { - l1 = l0; - return; +int F0(in int l0) { + return l0; } void main(void) { @@ -17,13 +16,13 @@ void main(void) { for (int l1 = 0; l1 < 10; l1++) { int l2 = 0; int l3 = 0; - F0(l1, l2); + l2 = F0(l1); l3 = l2; l0 = (l0) + (l3); for (int l4 = 0; l4 < 10; l4++) { int l5 = 0; int l6 = 0; - F0(l4, l5); + l5 = F0(l4); l6 = l5; l0 = (l0) + (l6); } diff --git a/internal/shader/testdata/func.expected.vs b/internal/shader/testdata/func.expected.vs index 89950bb0e..eb9189d67 100644 --- a/internal/shader/testdata/func.expected.vs +++ b/internal/shader/testdata/func.expected.vs @@ -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) { - l1 = vec4(0.0); - return; +vec4 F0(in vec2 l0) { + return vec4(0.0); } diff --git a/internal/shader/testdata/func_body.expected.vs b/internal/shader/testdata/func_body.expected.vs index 9a9a0a32f..5291ae73e 100644 --- a/internal/shader/testdata/func_body.expected.vs +++ b/internal/shader/testdata/func_body.expected.vs @@ -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) { - l1 = vec4(l0, 0.0, 1.0); - return; +vec4 F0(in vec2 l0) { + return vec4(l0, 0.0, 1.0); } diff --git a/internal/shader/testdata/if.expected.vs b/internal/shader/testdata/if.expected.vs index d91f6cea8..aee3e8130 100644 --- a/internal/shader/testdata/if.expected.vs +++ b/internal/shader/testdata/if.expected.vs @@ -1,12 +1,10 @@ -void F0(out vec2 l0); +vec2 F0(void); -void F0(out vec2 l0) { - bool l1 = false; - l1 = true; - if (l1) { - l0 = vec2(0.0); - return; +vec2 F0(void) { + bool l0 = false; + l0 = true; + if (l0) { + return vec2(0.0); } - l0 = vec2(1.0); - return; + return vec2(1.0); } diff --git a/internal/shader/testdata/if_else.expected.vs b/internal/shader/testdata/if_else.expected.vs index e3cc97175..ef14022b9 100644 --- a/internal/shader/testdata/if_else.expected.vs +++ b/internal/shader/testdata/if_else.expected.vs @@ -1,13 +1,11 @@ -void F0(out vec2 l0); +vec2 F0(void); -void F0(out vec2 l0) { - bool l1 = false; - l1 = true; - if (l1) { - l0 = vec2(0.0); - return; +vec2 F0(void) { + bool l0 = false; + l0 = true; + if (l0) { + return vec2(0.0); } else { - l0 = vec2(1.0); - return; + return vec2(1.0); } } diff --git a/internal/shader/testdata/if_init.expected.vs b/internal/shader/testdata/if_init.expected.vs index ff15f6c8d..99a94d5a0 100644 --- a/internal/shader/testdata/if_init.expected.vs +++ b/internal/shader/testdata/if_init.expected.vs @@ -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 l2 = vec2(0); - l2 = vec2(0.0); +vec2 F0(in vec2 l0) { + vec2 l1 = vec2(0); + l1 = vec2(0.0); { - vec2 l3 = vec2(0); - l3 = vec2(1.0); - if (((l3).x) == (1.0)) { - l1 = l3; - return; + vec2 l2 = vec2(0); + l2 = vec2(1.0); + if (((l2).x) == (1.0)) { + return l2; } } - l1 = l2; - return; + return l1; } diff --git a/internal/shader/testdata/inc.expected.vs b/internal/shader/testdata/inc.expected.vs index ecd439d66..5c6c3d4a1 100644 --- a/internal/shader/testdata/inc.expected.vs +++ b/internal/shader/testdata/inc.expected.vs @@ -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 l2 = 0; - l1 = 0; - l1 = (l1) + (1); - l2 = 1; - l2 = (l2) - (1); - l0 = vec2(l1, l2); - return; + l0 = 0; + l0 = (l0) + (1); + l1 = 1; + l1 = (l1) - (1); + return vec2(l0, l1); } diff --git a/internal/shader/testdata/issue1236.expected.hlsl b/internal/shader/testdata/issue1236.expected.hlsl index cf356f3e9..11ebb137a 100644 --- a/internal/shader/testdata/issue1236.expected.hlsl +++ b/internal/shader/testdata/issue1236.expected.hlsl @@ -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 l2 = 0.0; - l2 = mul(l0, float4x4FromScalar(1.0)); - l1 = l2; - return; +float4 F0(in float4 l0) { + float4 l1 = 0.0; + l1 = mul(l0, float4x4FromScalar(1.0)); + return l1; } diff --git a/internal/shader/testdata/issue1236.expected.vs b/internal/shader/testdata/issue1236.expected.vs index 39e0c3a6e..af009fc95 100644 --- a/internal/shader/testdata/issue1236.expected.vs +++ b/internal/shader/testdata/issue1236.expected.vs @@ -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 l2 = vec4(0); - l2 = (mat4(1.0)) * (l0); - l1 = l2; - return; +vec4 F0(in vec4 l0) { + vec4 l1 = vec4(0); + l1 = (mat4(1.0)) * (l0); + return l1; } diff --git a/internal/shader/testdata/issue1248.expected.vs b/internal/shader/testdata/issue1248.expected.vs index 33d56c435..5533a3ffc 100644 --- a/internal/shader/testdata/issue1248.expected.vs +++ b/internal/shader/testdata/issue1248.expected.vs @@ -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 l2 = vec2(0); vec2 l3 = vec2(0); @@ -10,17 +11,15 @@ void F0(out vec2 l0) { vec2 l7 = vec2(0); vec2 l8 = vec2(0); vec2 l9 = vec2(0); - vec2 l10 = vec2(0); - l3 = l2; + l2 = l1; + l0 = l2; + l3 = l0; l1 = l3; - l4 = l1; - l2 = l4; + l7 = l5; + l4 = l7; l8 = l6; l5 = l8; - l9 = l7; + l9 = l4; l6 = l9; - l10 = l5; - l7 = l10; - l0 = l1; - return; + return l0; } diff --git a/internal/shader/testdata/issue1298.expected.vs b/internal/shader/testdata/issue1298.expected.vs index ad94195e5..c5411f0f2 100644 --- a/internal/shader/testdata/issue1298.expected.vs +++ b/internal/shader/testdata/issue1298.expected.vs @@ -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 l2 = 0; - l2 = int(l0); - l1 = l2; - return; +int F0(in float l0) { + int l1 = 0; + l1 = int(l0); + return l1; } diff --git a/internal/shader/testdata/issue1299.expected.vs b/internal/shader/testdata/issue1299.expected.vs index 054cdb520..cba637c7e 100644 --- a/internal/shader/testdata/issue1299.expected.vs +++ b/internal/shader/testdata/issue1299.expected.vs @@ -1,11 +1,10 @@ -void F0(out int l0); +int F0(void); -void F0(out int l0) { - int l1 = 0; - l1 = 1; - l1 = (l1) * (2); - l1 = (l1) + (2); - l1 = (2) - (l1); - l0 = l1; - return; +int F0(void) { + int l0 = 0; + l0 = 1; + l0 = (l0) * (2); + l0 = (l0) + (2); + l0 = (2) - (l0); + return l0; } diff --git a/internal/shader/testdata/issue1874.expected.vs b/internal/shader/testdata/issue1874.expected.vs index 68cca2991..9f1358148 100644 --- a/internal/shader/testdata/issue1874.expected.vs +++ b/internal/shader/testdata/issue1874.expected.vs @@ -1,6 +1,5 @@ -void F0(out float l0); +float F0(void); -void F0(out float l0) { - l0 = (sin(1.0000000000e-01)) + (cos(2.0000000000e-01)); - return; +float F0(void) { + return (sin(1.0000000000e-01)) + (cos(2.0000000000e-01)); } diff --git a/internal/shader/testdata/issue2011.expected.vs b/internal/shader/testdata/issue2011.expected.vs index df1bf74fc..4da367171 100644 --- a/internal/shader/testdata/issue2011.expected.vs +++ b/internal/shader/testdata/issue2011.expected.vs @@ -1,12 +1,10 @@ -void F0(out float l0); -void F1(out int l0); +float F0(void); +int F1(void); -void F0(out float l0) { - l0 = 1.0; - return; +float F0(void) { + return 1.0; } -void F1(out int l0) { - l0 = 2; - return; +int F1(void) { + return 2; } diff --git a/internal/shader/testdata/len.expected.vs b/internal/shader/testdata/len.expected.vs index 3028fe4d3..0ed940cd7 100644 --- a/internal/shader/testdata/len.expected.vs +++ b/internal/shader/testdata/len.expected.vs @@ -1,19 +1,17 @@ -void F0(in vec2 l0, out int l1); -void F1(in vec2 l0, out int l1); +int F0(in vec2 l0); +int F1(in vec2 l0); -void F0(in vec2 l0, out int l1) { - int l2[2]; - l2[0] = 0; - l2[1] = 0; - l1 = 2; - return; +int F0(in vec2 l0) { + int l1[2]; + l1[0] = 0; + l1[1] = 0; + return 2; } -void F1(in vec2 l0, out int l1) { - int l2[3]; - l2[0] = 0; - l2[1] = 0; - l2[2] = 0; - l1 = 3; - return; +int F1(in vec2 l0) { + int l1[3]; + l1[0] = 0; + l1[1] = 0; + l1[2] = 0; + return 3; } diff --git a/internal/shader/testdata/number.expected.vs b/internal/shader/testdata/number.expected.vs index 9eb3b21d6..23dbfac2c 100644 --- a/internal/shader/testdata/number.expected.vs +++ b/internal/shader/testdata/number.expected.vs @@ -1,39 +1,36 @@ -void F0(out vec2 l0); -void F1(out vec2 l0); -void F2(out float l0); +vec2 F0(void); +vec2 F1(void); +float F2(void); void F3(in float l0); void F4(in int l0); void F5(void); -void F0(out vec2 l0) { +vec2 F0(void) { + float l0 = float(0); float l1 = float(0); float l2 = float(0); float l3 = float(0); - float l4 = float(0); - F2(l1); - l2 = (l1) * (1.0); - F2(l3); - l4 = (1.0) * (l3); - l0 = vec2(l2, l4); - return; + l0 = F2(); + l1 = (l0) * (1.0); + l2 = F2(); + l3 = (1.0) * (l2); + return vec2(l1, l3); } -void F1(out vec2 l0) { +vec2 F1(void) { + float l0 = float(0); float l1 = float(0); float l2 = float(0); float l3 = float(0); - float l4 = float(0); - F2(l1); - l2 = (l1) * (1.0); - F2(l3); - l4 = (1.0) * (l3); - l0 = vec2(l2, l4); - return; + l0 = F2(); + l1 = (l0) * (1.0); + l2 = F2(); + l3 = (1.0) * (l2); + return vec2(l1, l3); } -void F2(out float l0) { - l0 = 1.0; - return; +float F2(void) { + return 1.0; } void F3(in float l0) { diff --git a/internal/shader/testdata/number_binary.expected.vs b/internal/shader/testdata/number_binary.expected.vs index 8747b73be..58f567ae1 100644 --- a/internal/shader/testdata/number_binary.expected.vs +++ b/internal/shader/testdata/number_binary.expected.vs @@ -1,28 +1,26 @@ -void F0(out vec4 l0); -void F1(out vec4 l0); +vec4 F0(void); +vec4 F1(void); -void F0(out vec4 l0) { - int l1 = 0; +vec4 F0(void) { + int l0 = 0; + float l1 = float(0); float l2 = float(0); float l3 = float(0); - float l4 = float(0); - l1 = 2; + l0 = 2; + l1 = 2.5000000000e+00; l2 = 2.5000000000e+00; l3 = 2.5000000000e+00; - l4 = 2.5000000000e+00; - l0 = vec4(l1, l2, l3, l4); - return; + return vec4(l0, l1, l2, l3); } -void F1(out vec4 l0) { - int l1 = 0; +vec4 F1(void) { + int l0 = 0; + float l1 = float(0); float l2 = float(0); float l3 = float(0); - float l4 = float(0); - l1 = 2; + l0 = 2; + l1 = 2.5000000000e+00; l2 = 2.5000000000e+00; l3 = 2.5000000000e+00; - l4 = 2.5000000000e+00; - l0 = vec4(l1, l2, l3, l4); - return; + return vec4(l0, l1, l2, l3); } diff --git a/internal/shader/testdata/number_unary.expected.vs b/internal/shader/testdata/number_unary.expected.vs index 43ac16eb0..50186ae37 100644 --- a/internal/shader/testdata/number_unary.expected.vs +++ b/internal/shader/testdata/number_unary.expected.vs @@ -1,44 +1,42 @@ -void F0(out vec4 l0); -void F1(out vec4 l0); +vec4 F0(void); +vec4 F1(void); -void F0(out vec4 l0) { +vec4 F0(void) { + int l0 = 0; int l1 = 0; int l2 = 0; int l3 = 0; - int l4 = 0; + float l4 = float(0); float l5 = float(0); float l6 = float(0); float l7 = float(0); - float l8 = float(0); - l1 = 5; + l0 = 5; + l1 = -5; l2 = -5; - l3 = -5; - l4 = 5; - l5 = 5.0; + l3 = 5; + l4 = 5.0; + l5 = -5.0; l6 = -5.0; - l7 = -5.0; - l8 = 5.0; - l0 = (vec4(l1, l2, l3, l4)) + (vec4(l5, l6, l7, l8)); - return; + l7 = 5.0; + return (vec4(l0, l1, l2, l3)) + (vec4(l4, l5, l6, l7)); } -void F1(out vec4 l0) { +vec4 F1(void) { + int l0 = 0; int l1 = 0; int l2 = 0; int l3 = 0; - int l4 = 0; + float l4 = float(0); float l5 = float(0); float l6 = float(0); float l7 = float(0); - float l8 = float(0); - l1 = 5; + l0 = 5; + l1 = -5; l2 = -5; - l3 = -5; - l4 = 5; - l5 = 5.0; + l3 = 5; + l4 = 5.0; + l5 = -5.0; l6 = -5.0; - l7 = -5.0; - l8 = 5.0; - l0 = (vec4(l1, l2, l3, l4)) + (vec4(l5, l6, l7, l8)); - return; + l7 = 5.0; + return (vec4(l0, l1, l2, l3)) + (vec4(l4, l5, l6, l7)); } diff --git a/internal/shader/testdata/var.expected.vs b/internal/shader/testdata/var.expected.vs index 7e48ae6d4..2831f7e4d 100644 --- a/internal/shader/testdata/var.expected.vs +++ b/internal/shader/testdata/var.expected.vs @@ -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 l2 = vec4(0); - l2 = vec4(l0, 0.0, 1.0); - l1 = l2; - return; +vec4 F0(in vec2 l0) { + vec4 l1 = vec4(0); + l1 = vec4(l0, 0.0, 1.0); + return l1; } diff --git a/internal/shader/testdata/var2.expected.vs b/internal/shader/testdata/var2.expected.vs index db5a2a0e3..b87d450a7 100644 --- a/internal/shader/testdata/var2.expected.vs +++ b/internal/shader/testdata/var2.expected.vs @@ -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 l3 = vec4(0); - l2 = vec4(l0, 0.0, 1.0); - (l2).x = (l2).x; - l3 = l2; - l1 = l3; - return; + l1 = vec4(l0, 0.0, 1.0); + (l1).x = (l1).x; + l2 = l1; + return l2; } diff --git a/internal/shader/testdata/var_multiple.expected.vs b/internal/shader/testdata/var_multiple.expected.vs index b3db596e0..be3b96862 100644 --- a/internal/shader/testdata/var_multiple.expected.vs +++ b/internal/shader/testdata/var_multiple.expected.vs @@ -1,26 +1,24 @@ -void F0(in vec2 l0, out vec4 l1); -void F1(in vec2 l0, out vec4 l1); +vec4 F0(in vec2 l0); +vec4 F1(in vec2 l0); 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 l3 = vec2(0); + l1 = l0; l2 = l0; - l3 = l0; - l1 = vec4(l2, l3); - return; + return vec4(l1, l2); } -void F1(in vec2 l0, out vec4 l1) { +vec4 F1(in vec2 l0) { + vec2 l1 = vec2(0); vec2 l2 = vec2(0); vec2 l3 = vec2(0); vec2 l4 = vec2(0); - vec2 l5 = vec2(0); - F2(l2, l3); + F2(l1, l2); + l3 = l1; l4 = l2; - l5 = l3; - l1 = vec4(l4, l5); - return; + return vec4(l3, l4); } void F2(out vec2 l0, out vec2 l1) {