internal/shader: bug fix: mat *= vec is not allowed

Updates #1971
This commit is contained in:
Hajime Hoshi 2022-01-21 02:03:46 +09:00
parent 0415773b94
commit 99f003a17a
2 changed files with 2 additions and 5 deletions

View File

@ -113,10 +113,7 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
// OK
} else if op == shaderir.Mul && ((lts[0].Main == shaderir.Vec2 && rts[0].Main == shaderir.Mat2) ||
(lts[0].Main == shaderir.Vec3 && rts[0].Main == shaderir.Mat3) ||
(lts[0].Main == shaderir.Vec4 && rts[0].Main == shaderir.Mat4) ||
(lts[0].Main == shaderir.Mat2 && rts[0].Main == shaderir.Vec2) ||
(lts[0].Main == shaderir.Mat3 && rts[0].Main == shaderir.Vec3) ||
(lts[0].Main == shaderir.Mat4 && rts[0].Main == shaderir.Vec4)) {
(lts[0].Main == shaderir.Vec4 && rts[0].Main == shaderir.Mat4)) {
// OK
} else if rhs[0].Const != nil && rhs[0].Const.Kind() == gconstant.Int {
rhs[0].Const = gconstant.ToFloat(rhs[0].Const)

View File

@ -1630,7 +1630,7 @@ func TestShaderOperatorMultiplyAssign(t *testing.T) {
{stmt: "a := mat2(1); a *= 2", err: false},
{stmt: "a := mat2(1); a *= 2.0", err: false},
{stmt: "a := mat2(1); a *= int(2)", err: true},
{stmt: "a := mat2(1); a *= vec2(2)", err: false},
{stmt: "a := mat2(1); a *= vec2(2)", err: true},
{stmt: "a := mat2(1); a += vec2(2)", err: true},
{stmt: "a := mat2(1); a *= vec3(2)", err: true},
{stmt: "a := mat2(1); a *= vec4(2)", err: true},