mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
shaderir/glsl: Bug fix: Calculate local variable indices correctly
Fixes #1339
This commit is contained in:
parent
4308bbbc31
commit
f61a916e4a
22
internal/shader/testdata/array2.expected.vs
vendored
Normal file
22
internal/shader/testdata/array2.expected.vs
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
void F0(out vec2 l0[3]);
|
||||
|
||||
void F0(out vec2 l0[3]) {
|
||||
vec2 l1[2];
|
||||
l1[0] = vec2(0);
|
||||
l1[1] = vec2(0);
|
||||
vec2 l2[3];
|
||||
l2[0] = vec2(0);
|
||||
l2[1] = vec2(0);
|
||||
l2[2] = vec2(0);
|
||||
{
|
||||
vec2 l2[2];
|
||||
l2[0] = vec2(0);
|
||||
l2[1] = vec2(0);
|
||||
l2[0] = l1[0];
|
||||
l2[1] = l1[1];
|
||||
}
|
||||
l0[0] = l2[0];
|
||||
l0[1] = l2[1];
|
||||
l0[2] = l2[2];
|
||||
return;
|
||||
}
|
11
internal/shader/testdata/array2.go
vendored
Normal file
11
internal/shader/testdata/array2.go
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
func Foo() [3]vec2 {
|
||||
var a [2]vec2
|
||||
{
|
||||
var b [2]vec2
|
||||
b = a
|
||||
}
|
||||
var c [3]vec2
|
||||
return c
|
||||
}
|
@ -282,7 +282,8 @@ func descendantLocalVars(block, target *shaderir.Block) ([]shaderir.Type, bool)
|
||||
for _, s := range block.Stmts {
|
||||
for _, b := range s.Blocks {
|
||||
if ts2, found := descendantLocalVars(b, target); found {
|
||||
ts = append(ts, block.LocalVars...)
|
||||
n := b.LocalVarIndexOffset - block.LocalVarIndexOffset
|
||||
ts = append(ts, block.LocalVars[:n]...)
|
||||
ts = append(ts, ts2...)
|
||||
return ts, true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user