summaryrefslogtreecommitdiff
path: root/src/mesa/shader/slang/slang_codegen.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-07-22 18:27:56 -0600
committerBrian Paul <brian.paul@tungstengraphics.com>2008-07-22 18:27:56 -0600
commit7f3d6e74817e8880a0712c85f2b41fd88cf6a347 (patch)
tree7b058447c29d4040cf3ad83f027d897083ae3a45 /src/mesa/shader/slang/slang_codegen.c
parent0d1ed45cbfd555330c8746b0fc046bdb41d767d0 (diff)
mesa: glsl: rework swizzle storage handling
Build on the heirarchal approach implemented for arrays/structs.
Diffstat (limited to 'src/mesa/shader/slang/slang_codegen.c')
-rw-r--r--src/mesa/shader/slang/slang_codegen.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index 6e5a54773e..d4bf99f78f 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -2630,14 +2630,34 @@ _slang_gen_variable(slang_assemble_ctx * A, slang_operation *oper)
}
+
+/**
+ * Return the number of components actually named by the swizzle.
+ * Recall that swizzles may have undefined/don't-care values.
+ */
+static GLuint
+swizzle_size(GLuint swizzle)
+{
+ GLuint size = 0, i;
+ for (i = 0; i < 4; i++) {
+ GLuint swz = GET_SWZ(swizzle, i);
+ size += (swz >= 0 && swz <= 3);
+ }
+ return size;
+}
+
+
static slang_ir_node *
_slang_gen_swizzle(slang_ir_node *child, GLuint swizzle)
{
- /* XXX should rewrite this to use relative/Parent storage */
slang_ir_node *n = new_node1(IR_SWIZZLE, child);
assert(child);
if (n) {
- n->Store = _slang_new_ir_storage_swz(PROGRAM_UNDEFINED, -1, -1, swizzle);
+ assert(!n->Store);
+ n->Store = _slang_new_ir_storage_relative(0,
+ swizzle_size(swizzle),
+ child->Store);
+ n->Store->Swizzle = swizzle;
}
return n;
}