From ffc845a50a69b48446f5e25e7b4485089231bbe7 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 25 Jun 2010 12:52:01 -0700 Subject: glsl2: Set InputsRead and OutputsWritten on the generated programs. --- src/mesa/shader/ir_to_mesa.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 02d3f7e2eeb..465d5529f82 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1172,6 +1172,43 @@ print_program(struct prog_instruction *mesa_instructions, } } +static void +count_resources(struct gl_program *prog) +{ + prog->InputsRead = 0; + prog->OutputsWritten = 0; + unsigned int i; + + for (i = 0; i < prog->NumInstructions; i++) { + struct prog_instruction *inst = &prog->Instructions[i]; + unsigned int reg; + + switch (inst->DstReg.File) { + case PROGRAM_OUTPUT: + prog->OutputsWritten |= BITFIELD64_BIT(inst->DstReg.Index); + break; + case PROGRAM_INPUT: + prog->InputsRead |= BITFIELD64_BIT(inst->DstReg.Index); + break; + default: + break; + } + + for (reg = 0; reg < _mesa_num_inst_src_regs(inst->Opcode); reg++) { + switch (inst->SrcReg[reg].File) { + case PROGRAM_OUTPUT: + prog->OutputsWritten |= BITFIELD64_BIT(inst->DstReg.Index); + break; + case PROGRAM_INPUT: + prog->InputsRead |= BITFIELD64_BIT(inst->DstReg.Index); + break; + default: + break; + } + } + } +} + struct gl_program * get_mesa_program(GLcontext *ctx, void *mem_ctx, struct glsl_shader *shader) { @@ -1372,6 +1409,7 @@ _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog) linked_prog = get_mesa_program(ctx, whole_program, whole_program->Shaders[i]); + count_resources(linked_prog); switch (whole_program->Shaders[i]->Type) { case GL_VERTEX_SHADER: -- cgit v1.2.3