summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2010-08-06 13:07:25 -0700
committerEric Anholt <[email protected]>2010-08-06 13:22:31 -0700
commit925b49ff310bf0b307add7c34627cddf87e6a554 (patch)
tree07301c8745a5171a4b4ff0511a87ed505043262b /src/mesa
parentc234d0b25f622a7bdd3c40bc72fdbd59d8494c7c (diff)
glsl2: Move gl_program->InputsRead/OutputsWritten setting to an ir pass.
This lets us handle arrays much better than trying to work backwards from assembly. Fixes fbo-drawbuffers-maxtargets on swrast (i965 needs loop unrolling)
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/program/ir_to_mesa.cpp71
1 files changed, 4 insertions, 67 deletions
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index d8a13220ae2..c6856eb5a40 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2324,80 +2324,14 @@ print_program(struct prog_instruction *mesa_instructions,
}
static void
-mark_input(struct gl_program *prog,
- int index,
- GLboolean reladdr)
-{
- prog->InputsRead |= BITFIELD64_BIT(index);
- int i;
-
- if (reladdr) {
- if (index >= FRAG_ATTRIB_TEX0 && index <= FRAG_ATTRIB_TEX7) {
- for (i = 0; i < 8; i++) {
- prog->InputsRead |= BITFIELD64_BIT(FRAG_ATTRIB_TEX0 + i);
- }
- } else {
- assert(!"FINISHME: Mark InputsRead for varying arrays");
- }
- }
-}
-
-static void
-mark_output(struct gl_program *prog,
- int index,
- GLboolean reladdr)
-{
- prog->OutputsWritten |= BITFIELD64_BIT(index);
- int i;
-
- if (reladdr) {
- if (index >= VERT_RESULT_TEX0 && index <= VERT_RESULT_TEX7) {
- for (i = 0; i < 8; i++) {
- prog->OutputsWritten |= BITFIELD64_BIT(FRAG_ATTRIB_TEX0 + i);
- }
- } else {
- assert(!"FINISHME: Mark OutputsWritten for varying arrays");
- }
- }
-}
-
-static void
count_resources(struct gl_program *prog)
{
unsigned int i;
- prog->InputsRead = 0;
- prog->OutputsWritten = 0;
prog->SamplersUsed = 0;
for (i = 0; i < prog->NumInstructions; i++) {
struct prog_instruction *inst = &prog->Instructions[i];
- unsigned int reg;
-
- switch (inst->DstReg.File) {
- case PROGRAM_OUTPUT:
- mark_output(prog, inst->DstReg.Index, inst->DstReg.RelAddr);
- break;
- case PROGRAM_INPUT:
- mark_input(prog, inst->DstReg.Index, inst->DstReg.RelAddr);
- break;
- default:
- break;
- }
-
- for (reg = 0; reg < _mesa_num_inst_src_regs(inst->Opcode); reg++) {
- switch (inst->SrcReg[reg].File) {
- case PROGRAM_OUTPUT:
- mark_output(prog, inst->SrcReg[reg].Index,
- inst->SrcReg[reg].RelAddr);
- break;
- case PROGRAM_INPUT:
- mark_input(prog, inst->SrcReg[reg].Index, inst->SrcReg[reg].RelAddr);
- break;
- default:
- break;
- }
- }
/* Instead of just using the uniform's value to map to a
* sampler, Mesa first allocates a separate number for the
@@ -2578,6 +2512,7 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program,
}
set_branchtargets(&v, mesa_instructions, num_instructions);
+
if (ctx->Shader.Flags & GLSL_DUMP) {
printf("\n");
printf("GLSL IR for linked %s program %d:\n", target_string,
@@ -2594,6 +2529,9 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program,
prog->Instructions = mesa_instructions;
prog->NumInstructions = num_instructions;
+ do_set_program_inouts(shader->ir, prog);
+ count_resources(prog);
+
_mesa_reference_program(ctx, &shader->Program, prog);
if ((ctx->Shader.Flags & GLSL_NO_OPT) == 0) {
@@ -2731,7 +2669,6 @@ _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog)
linked_prog = get_mesa_program(ctx, prog,
prog->_LinkedShaders[i]);
- count_resources(linked_prog);
link_uniforms_to_shared_uniform_list(prog->Uniforms, linked_prog);