diff options
author | Brian <[email protected]> | 2007-01-04 17:30:30 -0700 |
---|---|---|
committer | Brian <[email protected]> | 2007-01-04 17:30:30 -0700 |
commit | 64f78dd6a8596700a3cb5e657164775ebbc2e8db (patch) | |
tree | 22a9146a7fa3e31e5b1837b14b463bad47a8c962 | |
parent | c9db223f902ce9d7e9f3038e6baac6da7f231b34 (diff) |
compute InputsRead/OutputsWritten with slang_update_inputs_outputs()
-rw-r--r-- | src/mesa/shader/slang/slang_emit.c | 20 | ||||
-rw-r--r-- | src/mesa/shader/slang/slang_link2.c | 31 |
2 files changed, 31 insertions, 20 deletions
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index 4e1606be318..c5be1699699 100644 --- a/src/mesa/shader/slang/slang_emit.c +++ b/src/mesa/shader/slang/slang_emit.c @@ -625,24 +625,6 @@ static GLint 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; } @@ -746,7 +728,6 @@ slang_resolve_storage(slang_gen_context *gc, slang_ir_node *n, n->Store->File = PROGRAM_INPUT; n->Store->Index = i; assert(n->Store->Size > 0); - prog->InputsRead |= (1 << i); return; } @@ -754,7 +735,6 @@ slang_resolve_storage(slang_gen_context *gc, slang_ir_node *n, if (i >= 0) { n->Store->File = PROGRAM_OUTPUT; n->Store->Index = i; - prog->OutputsWritten |= (1 << i); return; } diff --git a/src/mesa/shader/slang/slang_link2.c b/src/mesa/shader/slang/slang_link2.c index 81a18755481..f68eaca167c 100644 --- a/src/mesa/shader/slang/slang_link2.c +++ b/src/mesa/shader/slang/slang_link2.c @@ -293,6 +293,34 @@ slang_resolve_branches(struct gl_program *prog) } +/** + * 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) @@ -390,6 +418,9 @@ _slang_link2(GLcontext *ctx, 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); |