summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader/slang/slang_emit.c
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-01-05 16:02:45 -0700
committerBrian <[email protected]>2007-01-05 16:02:45 -0700
commit5cf7326132a37f11357b5cb31bcc9238fef5b54c (patch)
tree8d92595241072e8aebba501c68b544ef8b4e13eb /src/mesa/shader/slang/slang_emit.c
parentb2ab693d68f2ba1358b9c3f8bab53b9ebfb586fe (diff)
Checkpoint glsl compiler work: sampler uniforms now implemented, linked properly.
Diffstat (limited to 'src/mesa/shader/slang/slang_emit.c')
-rw-r--r--src/mesa/shader/slang/slang_emit.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index a3d970694f9..3f1f1373c61 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -184,6 +184,7 @@ storage_string(const slang_ir_storage *st)
"UNIFORM",
"WRITE_ONLY",
"ADDRESS",
+ "SAMPLER",
"UNDEFINED"
};
static char s[100];
@@ -194,10 +195,8 @@ storage_string(const slang_ir_storage *st)
sprintf(s, "%s[%d..%d]", files[st->File], st->Index,
st->Index + st->Size - 1);
#endif
- if (st->File == 1000)
- sprintf(s, "sampler");
- else
- sprintf(s, "%s[%d]", files[st->File], st->Index);
+ assert(st->File < sizeof(files) / sizeof(files[0]));
+ sprintf(s, "%s[%d]", files[st->File], st->Index);
return s;
}
@@ -680,10 +679,12 @@ slang_resolve_storage(slang_gen_context *gc, slang_ir_node *n,
assert(n->Var);
if (is_sampler_type(&n->Var->type)) {
/* i.e. "uniform sampler2D tex;" */
-#define PROGRAM_SAMPLER 1000
n->Store->File = PROGRAM_SAMPLER;
n->Store->Size = 1; /* never used */
n->Store->Index = alloc_sampler(gc);
+ n->Store->Index = slang_alloc_uniform(prog, (char *) n->Var->a_name, 1);
+ printf("********** Alloc sampler uniform %d\n", n->Store->Index);
+ abort(); /* this is a locally-declared sampler */
}
else if (n->Store->Index < 0) { /* XXX assert this? */
assert(gc);
@@ -701,12 +702,18 @@ slang_resolve_storage(slang_gen_context *gc, slang_ir_node *n,
return;
}
+ /*
+ assert(!is_sampler_type(&n->Var->type));
+ */
+
if (n->Opcode == IR_VAR && n->Store->File == PROGRAM_UNDEFINED) {
/* try to determine the storage for this variable */
GLint i;
assert(n->Var);
+ /*if (is_sampler(*/
+
if (n->Store->Size < 0) {
/* determine var/storage size now */
n->Store->Size = sizeof_type(&n->Var->type);
@@ -766,14 +773,7 @@ slang_resolve_storage(slang_gen_context *gc, slang_ir_node *n,
else if (n->Var->type.qualifier == slang_qual_varying) {
i = slang_alloc_varying(prog, (char *) n->Var->a_name);
if (i >= 0) {
-#ifdef OLD_LINK
- if (prog->Target == GL_VERTEX_PROGRAM_ARB)
- n->Store->File = PROGRAM_OUTPUT;
- else
- n->Store->File = PROGRAM_INPUT;
-#else
n->Store->File = PROGRAM_VARYING;
-#endif
n->Store->Index = i;
return;
}
@@ -1023,14 +1023,24 @@ emit_tex(slang_gen_context *gc, slang_ir_node *n, struct gl_program *prog)
inst = new_instruction(prog, OPCODE_TXB);
}
+ if (!n->Store)
+ slang_alloc_temp_storage(gc, n, 4);
+
storage_to_dst_reg(&inst->DstReg, n->Store, n->Writemask);
- storage_to_src_reg(&inst->SrcReg[0], n->Children[0]->Store,
- n->Children[0]->Swizzle);
+ /* Child[1] is the coord */
+ storage_to_src_reg(&inst->SrcReg[0], n->Children[1]->Store,
+ n->Children[1]->Swizzle);
- inst->TexSrcTarget = n->TexTarget;
- inst->TexSrcUnit = 0; /* XXX temp */
+ /* Child[0] is the sampler (a uniform which'll indicate the texture unit) */
+ assert(n->Children[0]->Store);
+ assert(n->Children[0]->Store->Size >= TEXTURE_1D_INDEX);
+ inst->Sampler = n->Children[0]->Store->Index; /* i.e. uniform's index */
+ inst->TexSrcTarget = n->Children[0]->Store->Size;
+ inst->TexSrcUnit = 27; /* Dummy value; the TexSrcUnit will be computed at
+ * link time, using the sampler uniform's value.
+ */
return inst;
}