summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2010-06-25 12:52:01 -0700
committerEric Anholt <[email protected]>2010-06-25 12:52:01 -0700
commitffc845a50a69b48446f5e25e7b4485089231bbe7 (patch)
tree5091361a395467548f47d050bda02e994e838fc2 /src/mesa/shader
parent364fcd8ee1af39e215338fba59306a14dd81c2b2 (diff)
glsl2: Set InputsRead and OutputsWritten on the generated programs.
Diffstat (limited to 'src/mesa/shader')
-rw-r--r--src/mesa/shader/ir_to_mesa.cpp38
1 files changed, 38 insertions, 0 deletions
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: