summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader/slang/slang_vartable.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2008-08-05 16:18:39 -0600
committerBrian Paul <[email protected]>2008-08-05 16:18:39 -0600
commit1308ca6d2168c5c2f81a8e675687e9d9a4db1a28 (patch)
tree43f2e21146f58870037442871b833ea447dd5551 /src/mesa/shader/slang/slang_vartable.c
parent749c1b9fbe4bd89e61dfc3657ad4f8adae20ff2b (diff)
mesa: glsl: re-org of intermediate/temp storage
Simplify the code for allocating storage for intermediate results. Use fewer temps in some cases. Also, use new asm vec4_move intrinsic instead of regular assigments in various constructors. For example: float f; vec3 v; v.xyz = f; is not legal GLSL, so do this instead: __asm vec4_move v.xyz, f; // note: f will auto-expand into f.xxxx Plus, fix assorted bugs in structure comparison.
Diffstat (limited to 'src/mesa/shader/slang/slang_vartable.c')
-rw-r--r--src/mesa/shader/slang/slang_vartable.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/mesa/shader/slang/slang_vartable.c b/src/mesa/shader/slang/slang_vartable.c
index 68b4e00be03..9b607e64037 100644
--- a/src/mesa/shader/slang/slang_vartable.c
+++ b/src/mesa/shader/slang/slang_vartable.c
@@ -110,9 +110,10 @@ _slang_pop_var_table(slang_var_table *vt)
slang_ir_storage *store = (slang_ir_storage *) t->Vars[i]->aux;
GLint j;
GLuint comp;
- if (dbg) printf(" Free var %s, size %d at %d\n",
+ if (dbg) printf(" Free var %s, size %d at %d.%s\n",
(char*) t->Vars[i]->a_name, store->Size,
- store->Index);
+ store->Index,
+ _mesa_swizzle_string(store->Swizzle, 0, 0));
if (store->Size == 1)
comp = GET_SWZ(store->Swizzle, 0);
@@ -159,7 +160,7 @@ _slang_add_variable(slang_var_table *vt, slang_variable *v)
assert(vt);
t = vt->Top;
assert(t);
- if (dbg) printf("Adding var %s\n", (char *) v->a_name);
+ if (dbg) printf("Adding var %s, store %p\n", (char *) v->a_name, v->aux);
t->Vars = (slang_variable **)
_slang_realloc(t->Vars,
t->NumVars * sizeof(slang_variable *),
@@ -262,10 +263,11 @@ _slang_alloc_var(slang_var_table *vt, slang_ir_storage *store)
}
if (dbg)
- printf("Alloc var sz %d at %d.%s (level %d)\n",
+ printf("Alloc var storage sz %d at %d.%s (level %d) store %p\n",
store->Size, store->Index,
_mesa_swizzle_string(store->Swizzle, 0, 0),
- t->Level);
+ t->Level,
+ (void*) store);
return GL_TRUE;
}
@@ -283,19 +285,29 @@ _slang_alloc_temp(slang_var_table *vt, slang_ir_storage *store)
if (i < 0)
return GL_FALSE;
+ assert(store->Index < 0);
+
store->Index = i / 4;
if (store->Size == 1) {
const GLuint comp = i % 4;
store->Swizzle = MAKE_SWIZZLE4(comp, comp, comp, comp);
- if (dbg) printf("Alloc temp sz %d at %d.%c (level %d)\n",
- store->Size, store->Index, "xyzw"[comp], t->Level);
}
else {
/* XXX improve swizzled for size=2/3, use for writemask... */
+#if 1
+ if (store->Size == 2) {
+ store->Swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y,
+ SWIZZLE_NIL, SWIZZLE_NIL);
+ }
+#endif
store->Swizzle = SWIZZLE_NOOP;
- if (dbg) printf("Alloc temp sz %d at %d.xyzw (level %d)\n",
- store->Size, store->Index, t->Level);
}
+
+ if (dbg) printf("Alloc temp sz %d at %d.%s (level %d) store %p\n",
+ store->Size, store->Index,
+ _mesa_swizzle_string(store->Swizzle, 0, 0), t->Level,
+ (void *) store);
+
return GL_TRUE;
}
@@ -309,7 +321,10 @@ _slang_free_temp(slang_var_table *vt, slang_ir_storage *store)
assert(store->Size > 0);
assert(r >= 0);
assert(r + store->Size <= vt->MaxRegisters * 4);
- if (dbg) printf("Free temp sz %d at %d (level %d)\n", store->Size, r, t->Level);
+ if (dbg) printf("Free temp sz %d at %d.%s (level %d) store %p\n",
+ store->Size, r,
+ _mesa_swizzle_string(store->Swizzle, 0, 0),
+ t->Level, (void *) store);
if (store->Size == 1) {
const GLuint comp = GET_SWZ(store->Swizzle, 0);
/* we can actually fail some of these assertions because of the
@@ -319,8 +334,8 @@ _slang_free_temp(slang_var_table *vt, slang_ir_storage *store)
assert(store->Swizzle == MAKE_SWIZZLE4(comp, comp, comp, comp));
assert(comp < 4);
assert(t->ValSize[r * 4 + comp] == 1);
- assert(t->Temps[r * 4 + comp] == TEMP);
#endif
+ assert(t->Temps[r * 4 + comp] == TEMP);
t->Temps[r * 4 + comp] = FREE;
}
else {