mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 02:42:02 +01:00
shaderir: Fix the test side: local variables for 'for' stmts must be reserved
This commit is contained in:
parent
b73fecae79
commit
646518f2e8
@ -440,9 +440,7 @@ func (c *compileContext) glslBlock(p *shaderir.Program, topBlock, block *shaderi
|
|||||||
end := constantToNumberLiteral(ct, s.ForEnd)
|
end := constantToNumberLiteral(ct, s.ForEnd)
|
||||||
t0, t1 := typeString(&t)
|
t0, t1 := typeString(&t)
|
||||||
lines = append(lines, fmt.Sprintf("%sfor (%s %s%s = %s; %s %s %s; %s) {", idt, t0, v, t1, init, v, op, end, delta))
|
lines = append(lines, fmt.Sprintf("%sfor (%s %s%s = %s; %s %s %s; %s) {", idt, t0, v, t1, init, v, op, end, delta))
|
||||||
// For's variable is special and defiend in the for statement.
|
lines = append(lines, c.glslBlock(p, topBlock, s.Blocks[0], level+1, localVarIndex)...)
|
||||||
// Add 1 to the number of the local variables.
|
|
||||||
lines = append(lines, c.glslBlock(p, topBlock, s.Blocks[0], level+1, localVarIndex+1)...)
|
|
||||||
lines = append(lines, fmt.Sprintf("%s}", idt))
|
lines = append(lines, fmt.Sprintf("%s}", idt))
|
||||||
case shaderir.Continue:
|
case shaderir.Continue:
|
||||||
lines = append(lines, idt+"continue;")
|
lines = append(lines, idt+"continue;")
|
||||||
|
@ -657,7 +657,9 @@ void F0(in float l0, in float l1, out float l2) {
|
|||||||
{Main: Float},
|
{Main: Float},
|
||||||
},
|
},
|
||||||
Block: block(
|
Block: block(
|
||||||
nil,
|
[]Type{
|
||||||
|
{},
|
||||||
|
},
|
||||||
forStmt(
|
forStmt(
|
||||||
Type{Main: Int},
|
Type{Main: Int},
|
||||||
3,
|
3,
|
||||||
@ -707,7 +709,9 @@ void F0(in float l0, in float l1, out float l2) {
|
|||||||
{Main: Float},
|
{Main: Float},
|
||||||
},
|
},
|
||||||
Block: block(
|
Block: block(
|
||||||
nil,
|
[]Type{
|
||||||
|
{},
|
||||||
|
},
|
||||||
forStmt(
|
forStmt(
|
||||||
Type{Main: Int},
|
Type{Main: Int},
|
||||||
3,
|
3,
|
||||||
@ -775,7 +779,10 @@ void F0(float l0, float l1, thread float& l2) {
|
|||||||
{Main: Float},
|
{Main: Float},
|
||||||
},
|
},
|
||||||
Block: block(
|
Block: block(
|
||||||
nil,
|
[]Type{
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
},
|
||||||
forStmt(
|
forStmt(
|
||||||
Type{Main: Int},
|
Type{Main: Int},
|
||||||
3,
|
3,
|
||||||
@ -789,13 +796,13 @@ void F0(float l0, float l1, thread float& l2) {
|
|||||||
},
|
},
|
||||||
assignStmt(
|
assignStmt(
|
||||||
localVariableExpr(2),
|
localVariableExpr(2),
|
||||||
localVariableExpr(4),
|
localVariableExpr(5),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
forStmt(
|
forStmt(
|
||||||
Type{Main: Float},
|
Type{Main: Float},
|
||||||
3,
|
4,
|
||||||
0,
|
0,
|
||||||
100,
|
100,
|
||||||
LessThanOp,
|
LessThanOp,
|
||||||
@ -806,7 +813,7 @@ void F0(float l0, float l1, thread float& l2) {
|
|||||||
},
|
},
|
||||||
assignStmt(
|
assignStmt(
|
||||||
localVariableExpr(2),
|
localVariableExpr(2),
|
||||||
localVariableExpr(4),
|
localVariableExpr(5),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -818,12 +825,12 @@ void F0(float l0, float l1, thread float& l2) {
|
|||||||
|
|
||||||
void F0(in float l0, in float l1, out float l2) {
|
void F0(in float l0, in float l1, out float l2) {
|
||||||
for (int l3 = 0; l3 < 100; l3++) {
|
for (int l3 = 0; l3 < 100; l3++) {
|
||||||
int l4 = 0;
|
int l5 = 0;
|
||||||
l2 = l4;
|
l2 = l5;
|
||||||
}
|
}
|
||||||
for (float l3 = 0.0; l3 < 100.0; l3++) {
|
for (float l4 = 0.0; l4 < 100.0; l4++) {
|
||||||
int l4 = 0;
|
int l5 = 0;
|
||||||
l2 = l4;
|
l2 = l5;
|
||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
GlslFS: glslPrelude + `
|
GlslFS: glslPrelude + `
|
||||||
@ -831,12 +838,12 @@ void F0(in float l0, in float l1, out float l2);
|
|||||||
|
|
||||||
void F0(in float l0, in float l1, out float l2) {
|
void F0(in float l0, in float l1, out float l2) {
|
||||||
for (int l3 = 0; l3 < 100; l3++) {
|
for (int l3 = 0; l3 < 100; l3++) {
|
||||||
int l4 = 0;
|
int l5 = 0;
|
||||||
l2 = l4;
|
l2 = l5;
|
||||||
}
|
}
|
||||||
for (float l3 = 0.0; l3 < 100.0; l3++) {
|
for (float l4 = 0.0; l4 < 100.0; l4++) {
|
||||||
int l4 = 0;
|
int l5 = 0;
|
||||||
l2 = l4;
|
l2 = l5;
|
||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
Metal: `#include <metal_stdlib>
|
Metal: `#include <metal_stdlib>
|
||||||
@ -849,12 +856,12 @@ void F0(float l0, float l1, thread float& l2);
|
|||||||
|
|
||||||
void F0(float l0, float l1, thread float& l2) {
|
void F0(float l0, float l1, thread float& l2) {
|
||||||
for (int l3 = 0; l3 < 100; l3++) {
|
for (int l3 = 0; l3 < 100; l3++) {
|
||||||
int l4 = 0;
|
int l5 = 0;
|
||||||
l2 = l4;
|
l2 = l5;
|
||||||
}
|
}
|
||||||
for (float l3 = 0.0; l3 < 100.0; l3++) {
|
for (float l4 = 0.0; l4 < 100.0; l4++) {
|
||||||
int l4 = 0;
|
int l5 = 0;
|
||||||
l2 = l4;
|
l2 = l5;
|
||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
},
|
},
|
||||||
|
@ -448,9 +448,7 @@ func (c *compileContext) metalBlock(p *shaderir.Program, topBlock, block *shader
|
|||||||
end := constantToNumberLiteral(ct, s.ForEnd)
|
end := constantToNumberLiteral(ct, s.ForEnd)
|
||||||
ts := typeString(&t, false, false)
|
ts := typeString(&t, false, false)
|
||||||
lines = append(lines, fmt.Sprintf("%sfor (%s %s = %s; %s %s %s; %s) {", idt, ts, v, init, v, op, end, delta))
|
lines = append(lines, fmt.Sprintf("%sfor (%s %s = %s; %s %s %s; %s) {", idt, ts, v, init, v, op, end, delta))
|
||||||
// For's variable is special and defiend in the for statement.
|
lines = append(lines, c.metalBlock(p, topBlock, s.Blocks[0], level+1, localVarIndex)...)
|
||||||
// Add 1 to the number of the local variables.
|
|
||||||
lines = append(lines, c.metalBlock(p, topBlock, s.Blocks[0], level+1, localVarIndex+1)...)
|
|
||||||
lines = append(lines, fmt.Sprintf("%s}", idt))
|
lines = append(lines, fmt.Sprintf("%s}", idt))
|
||||||
case shaderir.Continue:
|
case shaderir.Continue:
|
||||||
lines = append(lines, idt+"continue;")
|
lines = append(lines, idt+"continue;")
|
||||||
|
Loading…
Reference in New Issue
Block a user