slang_alloc_varying(struct gl_program *prog, const char *name)
{
GLint i = _mesa_add_varying(prog->Varying, name, 4); /* XXX fix size */
-#if 0
- if (prog->Target == GL_VERTEX_PROGRAM_ARB) {
-#ifdef OLD_LINK
- i += VERT_RESULT_VAR0;
- prog->OutputsWritten |= (1 << i);
-#else
- prog->OutputsWritten |= (1 << (i + VERT_RESULT_VAR0));
-#endif
- }
- else {
-#ifdef OLD_LINK
- i += FRAG_ATTRIB_VAR0;
- prog->InputsRead |= (1 << i);
-#else
- prog->InputsRead |= (1 << (i + FRAG_ATTRIB_VAR0));
-#endif
- }
-#endif
return i;
}
n->Store->File = PROGRAM_INPUT;
n->Store->Index = i;
assert(n->Store->Size > 0);
- prog->InputsRead |= (1 << i);
return;
}
if (i >= 0) {
n->Store->File = PROGRAM_OUTPUT;
n->Store->Index = i;
- prog->OutputsWritten |= (1 << i);
return;
}
}
+/**
+ * Scan program instructions to update the program's InputsRead and
+ * OutputsWritten fields.
+ */
+static void
+slang_update_inputs_outputs(struct gl_program *prog)
+{
+ GLuint i, j;
+
+ prog->InputsRead = 0x0;
+ prog->OutputsWritten = 0x0;
+
+ for (i = 0; i < prog->NumInstructions; i++) {
+ const struct prog_instruction *inst = prog->Instructions + i;
+ const GLuint numSrc = _mesa_num_inst_src_regs(inst->Opcode);
+ for (j = 0; j < numSrc; j++) {
+ if (inst->SrcReg[j].File == PROGRAM_INPUT) {
+ prog->InputsRead |= 1 << inst->SrcReg[j].Index;
+ }
+ }
+ if (inst->DstReg.File == PROGRAM_OUTPUT) {
+ prog->OutputsWritten |= 1 << inst->DstReg.Index;
+ }
+ }
+}
+
+
+
/** cast wrapper */
static struct gl_vertex_program *
vertex_program(struct gl_program *prog)
slang_resolve_branches(&shProg->VertexProgram->Base);
slang_resolve_branches(&shProg->FragmentProgram->Base);
+ slang_update_inputs_outputs(&shProg->VertexProgram->Base);
+ slang_update_inputs_outputs(&shProg->FragmentProgram->Base);
+
#if 1
printf("************** original fragment program\n");
_mesa_print_program(&fragProg->Base);