summaryrefslogtreecommitdiff
path: root/src/mesa/shader/slang/slang_vartable.c
diff options
context:
space:
mode:
authorBen Skeggs <skeggsb@gmail.com>2008-07-23 14:05:22 +1000
committerBen Skeggs <skeggsb@gmail.com>2008-07-23 14:05:22 +1000
commit704dca40c4e0e983c07d84c3a32f8f9dc78a5543 (patch)
treebdcc585315d88274ec795b7206a143d562f54a76 /src/mesa/shader/slang/slang_vartable.c
parent0c25ac52425e6d6eb037b99ab90f41b47e3f4491 (diff)
parent7f3d6e74817e8880a0712c85f2b41fd88cf6a347 (diff)
Merge remote branch 'upstream/gallium-0.1' into nouveau-gallium-0.1
Diffstat (limited to 'src/mesa/shader/slang/slang_vartable.c')
-rw-r--r--src/mesa/shader/slang/slang_vartable.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/mesa/shader/slang/slang_vartable.c b/src/mesa/shader/slang/slang_vartable.c
index bb4d2d656c..68b4e00be0 100644
--- a/src/mesa/shader/slang/slang_vartable.c
+++ b/src/mesa/shader/slang/slang_vartable.c
@@ -1,6 +1,7 @@
#include "main/imports.h"
-#include "shader/prog_instruction.h"
+#include "shader/program.h"
+#include "shader/prog_print.h"
#include "slang_compile.h"
#include "slang_compile_variable.h"
#include "slang_mem.h"
@@ -129,7 +130,7 @@ _slang_pop_var_table(slang_var_table *vt)
/* just verify that any remaining allocations in this scope
* were for temps
*/
- for (i = 0; i < vt->MaxRegisters * 4; i++) {
+ for (i = 0; i < (int) vt->MaxRegisters * 4; i++) {
if (t->Temps[i] != FREE && t->Parent->Temps[i] == FREE) {
if (dbg) printf(" Free reg %d\n", i/4);
assert(t->Temps[i] == TEMP);
@@ -206,7 +207,7 @@ alloc_reg(slang_var_table *vt, GLint size, GLboolean isTemp)
for (i = 0; i <= vt->MaxRegisters * 4 - size; i += step) {
GLuint found = 0;
- for (j = 0; j < size; j++) {
+ for (j = 0; j < (GLuint) size; j++) {
if (i + j < vt->MaxRegisters * 4 && t->Temps[i + j] == FREE) {
found++;
}
@@ -218,7 +219,7 @@ alloc_reg(slang_var_table *vt, GLint size, GLboolean isTemp)
/* found block of size free regs */
if (size > 1)
assert(i % 4 == 0);
- for (j = 0; j < size; j++)
+ for (j = 0; j < (GLuint) size; j++)
t->Temps[i + j] = isTemp ? TEMP : VAR;
assert(i < MAX_PROGRAM_TEMPS * 4);
t->ValSize[i] = size;
@@ -247,14 +248,25 @@ _slang_alloc_var(slang_var_table *vt, slang_ir_storage *store)
if (store->Size == 1) {
const GLuint comp = i % 4;
store->Swizzle = MAKE_SWIZZLE4(comp, comp, comp, comp);
- if (dbg) printf("Alloc var sz %d at %d.%c (level %d)\n",
- store->Size, store->Index, "xyzw"[comp], t->Level);
+ }
+ else if (store->Size == 2) {
+ store->Swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y,
+ SWIZZLE_NIL, SWIZZLE_NIL);
+ }
+ else if (store->Size == 3) {
+ store->Swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y,
+ SWIZZLE_Z, SWIZZLE_NIL);
}
else {
store->Swizzle = SWIZZLE_NOOP;
- if (dbg) printf("Alloc var sz %d at %d.xyzw (level %d)\n",
- store->Size, store->Index, t->Level);
}
+
+ if (dbg)
+ printf("Alloc var sz %d at %d.%s (level %d)\n",
+ store->Size, store->Index,
+ _mesa_swizzle_string(store->Swizzle, 0, 0),
+ t->Level);
+
return GL_TRUE;
}
@@ -279,6 +291,7 @@ _slang_alloc_temp(slang_var_table *vt, slang_ir_storage *store)
store->Size, store->Index, "xyzw"[comp], t->Level);
}
else {
+ /* XXX improve swizzled for size=2/3, use for writemask... */
store->Swizzle = SWIZZLE_NOOP;
if (dbg) printf("Alloc temp sz %d at %d.xyzw (level %d)\n",
store->Size, store->Index, t->Level);
@@ -313,7 +326,7 @@ _slang_free_temp(slang_var_table *vt, slang_ir_storage *store)
else {
/*assert(store->Swizzle == SWIZZLE_NOOP);*/
assert(t->ValSize[r*4] == store->Size);
- for (i = 0; i < store->Size; i++) {
+ for (i = 0; i < (GLuint) store->Size; i++) {
assert(t->Temps[r * 4 + i] == TEMP);
t->Temps[r * 4 + i] = FREE;
}
@@ -327,7 +340,7 @@ _slang_is_temp(const slang_var_table *vt, const slang_ir_storage *store)
struct table *t = vt->Top;
GLuint comp;
assert(store->Index >= 0);
- assert(store->Index < vt->MaxRegisters);
+ assert(store->Index < (int) vt->MaxRegisters);
if (store->Swizzle == SWIZZLE_NOOP)
comp = 0;
else