mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
Revert "internal/shader: bug fix: an index must be a constant for vectors"
This reverts commit 7c4f532b83
.
Updates #3011
Reason: Dynamic indices should be allowed with WebGL 2.
This commit is contained in:
parent
b17ae6135e
commit
d46c677327
@ -1150,11 +1150,6 @@ func (cs *compileState) parseExpr(block *block, fname string, expr ast.Expr, mar
|
||||
x := exprs[0]
|
||||
t := ts[0]
|
||||
|
||||
if (t.IsFloatVector() || t.IsIntVector()) && idx.Const == nil {
|
||||
cs.addError(e.Pos(), fmt.Sprintf("index must be a constant for the type %s", t.String()))
|
||||
return nil, nil, nil, false
|
||||
}
|
||||
|
||||
var typ shaderir.Type
|
||||
switch t.Main {
|
||||
case shaderir.Vec2, shaderir.Vec3, shaderir.Vec4:
|
||||
|
@ -4363,67 +4363,3 @@ func Foo() int {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSyntaxIndex(t *testing.T) {
|
||||
// Issue #3011
|
||||
if _, err := compileToIR([]byte(`package main
|
||||
|
||||
func Foo() float {
|
||||
var a int
|
||||
var b vec4
|
||||
return b[a]
|
||||
}
|
||||
`)); err == nil {
|
||||
t.Error("compileToIR must return an error but did not")
|
||||
}
|
||||
if _, err := compileToIR([]byte(`package main
|
||||
|
||||
func Foo() int {
|
||||
var a int
|
||||
var b ivec4
|
||||
return b[a]
|
||||
}
|
||||
`)); err == nil {
|
||||
t.Error("compileToIR must return an error but did not")
|
||||
}
|
||||
if _, err := compileToIR([]byte(`package main
|
||||
|
||||
func Foo() float {
|
||||
var a int
|
||||
var b mat4
|
||||
return b[a][0]
|
||||
}
|
||||
`)); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err := compileToIR([]byte(`package main
|
||||
|
||||
func Foo() float {
|
||||
const a = 0
|
||||
var b vec4
|
||||
return b[a]
|
||||
}
|
||||
`)); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err := compileToIR([]byte(`package main
|
||||
|
||||
func Foo() int {
|
||||
const a = 0
|
||||
var b ivec4
|
||||
return b[a]
|
||||
}
|
||||
`)); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, err := compileToIR([]byte(`package main
|
||||
|
||||
func Foo() float {
|
||||
const a = 0
|
||||
var b mat4
|
||||
return b[a][0]
|
||||
}
|
||||
`)); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user