Skip to content

Commit

Permalink
internal/shader: reduce ConstType usages
Browse files Browse the repository at this point in the history
Updates #2550
  • Loading branch information
hajimehoshi committed Jul 29, 2023
1 parent e225f11 commit 7549f4f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/shader/stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
}
case shaderir.Float:
if rhs[0].Const != nil &&
rhs[0].ConstType != shaderir.ConstTypeInt &&
(rts[0].Main == shaderir.None || rts[0].Main == shaderir.Float) &&
gconstant.ToFloat(rhs[0].Const).Kind() != gconstant.Unknown {
rhs[0].Const = gconstant.ToFloat(rhs[0].Const)
rhs[0].ConstType = shaderir.ConstTypeFloat
Expand All @@ -133,7 +133,7 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
if (op == shaderir.MatrixMul || op == shaderir.Div) &&
(rts[0].Main == shaderir.Float ||
(rhs[0].Const != nil &&
rhs[0].ConstType != shaderir.ConstTypeInt &&
(rts[0].Main == shaderir.None || rts[0].Main == shaderir.Float) &&
gconstant.ToFloat(rhs[0].Const).Kind() != gconstant.Unknown)) {
if rhs[0].Const != nil {
rhs[0].Const = gconstant.ToFloat(rhs[0].Const)
Expand All @@ -146,7 +146,7 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
} else if (op == shaderir.MatrixMul || op == shaderir.ComponentWiseMul || lts[0].IsFloatVector()) &&
(rts[0].Main == shaderir.Float ||
(rhs[0].Const != nil &&
rhs[0].ConstType != shaderir.ConstTypeInt &&
(rts[0].Main == shaderir.None || rts[0].Main == shaderir.Float) &&
gconstant.ToFloat(rhs[0].Const).Kind() != gconstant.Unknown)) {
if rhs[0].Const != nil {
rhs[0].Const = gconstant.ToFloat(rhs[0].Const)
Expand Down

0 comments on commit 7549f4f

Please sign in to comment.