mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
shader: Bug fix: Wrong local variable index in a block in the fragment entry point
This commit is contained in:
parent
9b6b306ca3
commit
ee049a19ac
@ -685,6 +685,7 @@ func (cs *compileState) parseBlock(outer *block, fname string, stmts []ast.Stmt,
|
||||
if fname == cs.fragmentEntry {
|
||||
offset-- // position
|
||||
offset -= len(cs.ir.Varyings)
|
||||
offset-- // color
|
||||
}
|
||||
}
|
||||
|
||||
|
34
internal/shader/testdata/for5.expected.fs
vendored
Normal file
34
internal/shader/testdata/for5.expected.fs
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
uniform float U0;
|
||||
uniform float U1;
|
||||
uniform float U2;
|
||||
|
||||
void F0(in int l0, out int l1);
|
||||
|
||||
void F0(in int l0, out int l1) {
|
||||
l1 = l0;
|
||||
return;
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
int l0 = 0;
|
||||
int l2 = 0;
|
||||
l0 = 0;
|
||||
for (int l1 = 0; l1 < 10; l1++) {
|
||||
int l2 = 0;
|
||||
int l3 = 0;
|
||||
F0(l1, l2);
|
||||
l3 = l2;
|
||||
l0 = (l0) + (l3);
|
||||
for (int l4 = 0; l4 < 10; l4++) {
|
||||
int l5 = 0;
|
||||
int l6 = 0;
|
||||
F0(l4, l5);
|
||||
l6 = l5;
|
||||
l0 = (l0) + (l6);
|
||||
}
|
||||
}
|
||||
l2 = 0;
|
||||
l0 = (l0) + (l2);
|
||||
gl_FragColor = vec4(l0);
|
||||
return;
|
||||
}
|
15
internal/shader/testdata/for5.go
vendored
15
internal/shader/testdata/for5.go
vendored
@ -24,3 +24,18 @@ func Vertex(pos vec2) vec4 {
|
||||
sum += y
|
||||
return vec4(sum)
|
||||
}
|
||||
|
||||
func Fragment(pos vec4) vec4 {
|
||||
sum := 0
|
||||
for i := 0; i < 10; i++ {
|
||||
x := Ident(i)
|
||||
sum += x
|
||||
for j := 0; j < 10; j++ {
|
||||
x := Ident(j)
|
||||
sum += x
|
||||
}
|
||||
}
|
||||
y := 0
|
||||
sum += y
|
||||
return vec4(sum)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user