Incorporate per-lane offsets for varying data in the front-end.

Previously, it was only in the GatherScatterFlattenOpt optimization pass that
we added the per-lane offsets when we were indexing into varying data.
(Specifically, the case of float foo[]; int index; foo[index], where foo
is an array of varying elements rather than uniform elements.)  Now, this
is done in the front-end as we're first emitting code.

In addition to the basic ugliness of doing this in an optimization pass, 
it was also error-prone to do it there, since we no longer have access
to all of the type information that's around in the front-end.

No functionality or performance change.
This commit is contained in:
Matt Pharr
2011-11-03 13:15:07 -07:00
parent 6084d6aeaf
commit 43a2d510bf
7 changed files with 247 additions and 129 deletions

View File

@@ -6,15 +6,17 @@ struct Foo {
float x;
float f;
};
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
float a = aFOO[programIndex];
uniform Foo myFoo[3] = { { a, a }, {a, a}, {a, a} };
int i = 1;
uniform Foo myFoo[3] = { { -1, -2 }, {a, -3}, {-4, -5} };
int i = aFOO[0];
varying Foo barFoo = myFoo[i];
//CO print("% %\n", myFoo[i].x, barFoo.x);
RET[programIndex] = barFoo.x;
}
export void result(uniform float RET[4]) {
export void result(uniform float RET[]) {
RET[programIndex] = 1+programIndex;
}

View File

@@ -12,12 +12,12 @@ export void f_fi(uniform float RET[], uniform float a[], uniform int bFOO[]) {
uniform int i;
for (i = 0; i < 17; ++i) {
myFoo[i].x = i;
myFoo[i].f = 2*i;
myFoo[i].f = 17+2*i;
}
RET[programIndex] = myFoo[b/2].f;
}
export void result(uniform float RET[]) {
RET[programIndex] = 2 + 2 * programIndex;
RET[programIndex] = 19 + 2 * programIndex;
}