internal/shaderir: refactoring

This commit is contained in:
Hajime Hoshi 2023-05-05 14:24:48 +09:00
parent ceb2bfc89c
commit befe990562

View File

@ -449,7 +449,11 @@ func (p *Program) appendReachableUniformVariablesFromBlock(indices []int, block
f = func(expr *Expr) { f = func(expr *Expr) {
switch expr.Type { switch expr.Type {
case UniformVariable: case UniformVariable:
if _, ok := indicesSet[expr.Index]; ok {
return
}
indicesSet[expr.Index] = struct{}{} indicesSet[expr.Index] = struct{}{}
indices = append(indices, expr.Index)
case FunctionExpr: case FunctionExpr:
if _, ok := visitedFuncs[expr.Index]; ok { if _, ok := visitedFuncs[expr.Index]; ok {
return return
@ -460,9 +464,6 @@ func (p *Program) appendReachableUniformVariablesFromBlock(indices []int, block
} }
walkExprs(f, block) walkExprs(f, block)
for i := range indicesSet {
indices = append(indices, i)
}
return indices return indices
} }