From e2c25dbc6d68c54692fcb7a9eda035d3399aabaa Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Thu, 3 Nov 2022 17:14:49 +0900 Subject: [PATCH] internal/shaderir: rename functions --- internal/shaderir/glsl/glsl.go | 4 ++-- internal/shaderir/program.go | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/internal/shaderir/glsl/glsl.go b/internal/shaderir/glsl/glsl.go index 2f6595fca..18b148615 100644 --- a/internal/shaderir/glsl/glsl.go +++ b/internal/shaderir/glsl/glsl.go @@ -136,7 +136,7 @@ func Compile(p *shaderir.Program, version GLSLVersion) (vertexShader, fragmentSh var funcs []*shaderir.Func if p.VertexFunc.Block != nil { - indices := p.ReferredFuncIndicesInVertexShader() + indices := p.ReachableFuncIndicesFromVertexShader() sort.Ints(indices) funcs = make([]*shaderir.Func, 0, len(indices)) for _, idx := range indices { @@ -234,7 +234,7 @@ func Compile(p *shaderir.Program, version GLSLVersion) (vertexShader, fragmentSh var funcs []*shaderir.Func if p.VertexFunc.Block != nil { - indices := p.ReferredFuncIndicesInFragmentShader() + indices := p.ReachableFuncIndicesFromFragmentShader() sort.Ints(indices) funcs = make([]*shaderir.Func, 0, len(indices)) for _, idx := range indices { diff --git a/internal/shaderir/program.go b/internal/shaderir/program.go index 60e97b32a..b0745a2f2 100644 --- a/internal/shaderir/program.go +++ b/internal/shaderir/program.go @@ -363,25 +363,25 @@ func IsValidSwizzling(s string) bool { return false } -func (p *Program) ReferredFuncIndicesInVertexShader() []int { - return p.referredFuncIndicesInBlockEntryPoint(p.VertexFunc.Block) +func (p *Program) ReachableFuncIndicesFromVertexShader() []int { + return p.reachableFuncIndicesFromBlockEntryPoint(p.VertexFunc.Block) } -func (p *Program) ReferredFuncIndicesInFragmentShader() []int { - return p.referredFuncIndicesInBlockEntryPoint(p.FragmentFunc.Block) +func (p *Program) ReachableFuncIndicesFromFragmentShader() []int { + return p.reachableFuncIndicesFromBlockEntryPoint(p.FragmentFunc.Block) } -func (p *Program) referredFuncIndicesInBlockEntryPoint(b *Block) []int { +func (p *Program) reachableFuncIndicesFromBlockEntryPoint(b *Block) []int { indexToFunc := map[int]*Func{} for _, f := range p.Funcs { f := f indexToFunc[f.Index] = &f } visited := map[int]struct{}{} - return referredFuncIndicesInBlock(b, indexToFunc, visited) + return reachableFuncIndicesFromBlock(b, indexToFunc, visited) } -func referredFuncIndicesInBlock(b *Block, indexToFunc map[int]*Func, visited map[int]struct{}) []int { +func reachableFuncIndicesFromBlock(b *Block, indexToFunc map[int]*Func, visited map[int]struct{}) []int { if b == nil { return nil } @@ -390,27 +390,27 @@ func referredFuncIndicesInBlock(b *Block, indexToFunc map[int]*Func, visited map for _, s := range b.Stmts { for _, e := range s.Exprs { - fs = append(fs, referredFuncIndicesInExpr(&e, indexToFunc, visited)...) + fs = append(fs, reachableFuncIndicesFromExpr(&e, indexToFunc, visited)...) } for _, bb := range s.Blocks { - fs = append(fs, referredFuncIndicesInBlock(bb, indexToFunc, visited)...) + fs = append(fs, reachableFuncIndicesFromBlock(bb, indexToFunc, visited)...) } } return fs } -func referredFuncIndicesInExpr(e *Expr, indexToFunc map[int]*Func, visited map[int]struct{}) []int { +func reachableFuncIndicesFromExpr(e *Expr, indexToFunc map[int]*Func, visited map[int]struct{}) []int { var fs []int if e.Type == FunctionExpr { if _, ok := visited[e.Index]; !ok { fs = append(fs, e.Index) visited[e.Index] = struct{}{} - fs = append(fs, referredFuncIndicesInBlock(indexToFunc[e.Index].Block, indexToFunc, visited)...) + fs = append(fs, reachableFuncIndicesFromBlock(indexToFunc[e.Index].Block, indexToFunc, visited)...) } } for _, ee := range e.Exprs { - fs = append(fs, referredFuncIndicesInExpr(&ee, indexToFunc, visited)...) + fs = append(fs, reachableFuncIndicesFromExpr(&ee, indexToFunc, visited)...) } return fs }