r300/fragprog: No longer rely on hardcoded FRAG_RESULT_xxx constants
authorNicolai Hähnle <nhaehnle@gmail.com>
Sun, 26 Jul 2009 09:52:17 +0000 (11:52 +0200)
committerNicolai Hähnle <nhaehnle@gmail.com>
Mon, 27 Jul 2009 20:51:38 +0000 (22:51 +0200)
Also, this makes radeon_program_pair depend on the r300 fragment program
compiler. Since we now know that r600+ no longer use the same pairing
style in their ALU, we can stop pretending that program_pair is useful
for anything but r300-r500 fragment programs.

Signed-off-by: Nicolai Hähnle <nhaehnle@gmail.com>
src/mesa/drivers/dri/r300/compiler/r300_fragprog_emit.c
src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c
src/mesa/drivers/dri/r300/compiler/radeon_program_pair.c
src/mesa/drivers/dri/r300/compiler/radeon_program_pair.h

index 674d1f8cd35a023b43583113643e8d268fe8d774..80b569ade67f3bc8742037a7beb89aa2b122eb6a 100644 (file)
@@ -308,7 +308,7 @@ void r300BuildFragmentProgramHwCode(struct r300_fragment_program_compiler *compi
        code->node[0].alu_end = -1;
        code->node[0].tex_end = -1;
 
-       radeonPairProgram(&compiler->Base, &pair_handler, compiler);
+       radeonPairProgram(compiler, &pair_handler, compiler);
        if (compiler->Base.Error)
                return;
 
index 21d6b9bba71f11e6f06c831929b4accf883f6e95..3a527210c171bd091b01d93f773ef14e9df7a05b 100644 (file)
@@ -282,7 +282,7 @@ void r500BuildFragmentProgramHwCode(struct r300_fragment_program_compiler *compi
        code->inst_offset = 0;
        code->inst_end = -1;
 
-       radeonPairProgram(&compiler->Base, &pair_handler, compiler);
+       radeonPairProgram(compiler, &pair_handler, compiler);
        if (compiler->Base.Error)
                return;
 
index 57a364c78b6d6734629b113ec073e176d04929a0..84d0831cfc21fc1cbc75214c8a1a2e93b1e4ed10 100644 (file)
@@ -40,7 +40,7 @@
 #include "shader/prog_print.h"
 
 #define error(fmt, args...) do { \
-       rc_error(s->Compiler, "%s::%s(): " fmt "\n",    \
+       rc_error(&s->Compiler->Base, "%s::%s(): " fmt "\n",     \
                __FILE__, __FUNCTION__, ##args);        \
 } while(0)
 
@@ -118,7 +118,7 @@ struct pair_register_translation {
 };
 
 struct pair_state {
-       struct radeon_compiler * Compiler;
+       struct r300_fragment_program_compiler * Compiler;
        const struct radeon_pair_handler *Handler;
        GLboolean Verbose;
        void *UserData;
@@ -335,10 +335,10 @@ static void scan_instructions(struct pair_state *s)
        struct rc_instruction *source;
        GLuint ip;
 
-       for(source = s->Compiler->Program.Instructions.Next, ip = 0;
-           source != &s->Compiler->Program.Instructions;
+       for(source = s->Compiler->Base.Program.Instructions.Next, ip = 0;
+           source != &s->Compiler->Base.Program.Instructions;
            source = source->Next, ++ip) {
-               struct pair_state_instruction *pairinst = memory_pool_malloc(&s->Compiler->Pool, sizeof(*pairinst));
+               struct pair_state_instruction *pairinst = memory_pool_malloc(&s->Compiler->Base.Pool, sizeof(*pairinst));
                memset(pairinst, 0, sizeof(struct pair_state_instruction));
 
                pairinst->Instruction = source->I;
@@ -374,7 +374,7 @@ static void scan_instructions(struct pair_state *s)
                                            GET_BIT(pairinst->Instruction.DstReg.WriteMask, swz))
                                                continue;
 
-                                       struct reg_value_reader* r = memory_pool_malloc(&s->Compiler->Pool, sizeof(*r));
+                                       struct reg_value_reader* r = memory_pool_malloc(&s->Compiler->Base.Pool, sizeof(*r));
                                        pairinst->NumDependencies++;
                                        t->Value[swz]->NumReaders++;
                                        r->Reader = pairinst;
@@ -397,7 +397,7 @@ static void scan_instructions(struct pair_state *s)
                                                if (!GET_BIT(pairinst->Instruction.DstReg.WriteMask, j))
                                                        continue;
 
-                                               struct reg_value* v = memory_pool_malloc(&s->Compiler->Pool, sizeof(*v));
+                                               struct reg_value* v = memory_pool_malloc(&s->Compiler->Base.Pool, sizeof(*v));
                                                memset(v, 0, sizeof(struct reg_value));
                                                v->Writer = pairinst;
                                                if (t->Value[j]) {
@@ -435,7 +435,7 @@ static void scan_instructions(struct pair_state *s)
  */
 static void allocate_input_registers(struct pair_state *s)
 {
-       GLuint InputsRead = s->Compiler->Program.InputsRead;
+       GLuint InputsRead = s->Compiler->Base.Program.InputsRead;
        int i;
        GLuint hwindex = 0;
 
@@ -577,11 +577,11 @@ static void emit_all_tex(struct pair_state *s)
                        get_hw_reg(s, inst->DstReg.File, inst->DstReg.Index);
        }
 
-       if (s->Compiler->Debug)
+       if (s->Compiler->Base.Debug)
                _mesa_printf(" BEGIN_TEX\n");
 
        if (s->Handler->BeginTexBlock)
-               s->Compiler->Error = s->Compiler->Error || !s->Handler->BeginTexBlock(s->UserData);
+               s->Compiler->Base.Error = s->Compiler->Base.Error || !s->Handler->BeginTexBlock(s->UserData);
 
        for(pairinst = readytex; pairinst; pairinst = pairinst->NextReady) {
                struct prog_instruction *inst = &pairinst->Instruction;
@@ -591,7 +591,7 @@ static void emit_all_tex(struct pair_state *s)
                        inst->DstReg.Index = get_hw_reg(s, inst->DstReg.File, inst->DstReg.Index);
                inst->SrcReg[0].Index = get_hw_reg(s, inst->SrcReg[0].File, inst->SrcReg[0].Index);
 
-               if (s->Compiler->Debug) {
+               if (s->Compiler->Base.Debug) {
                        _mesa_printf("   ");
                        _mesa_print_instruction(inst);
                        fflush(stdout);
@@ -614,10 +614,10 @@ static void emit_all_tex(struct pair_state *s)
                rpti.SrcIndex = inst->SrcReg[0].Index;
                rpti.SrcSwizzle = inst->SrcReg[0].Swizzle;
 
-               s->Compiler->Error = s->Compiler->Error || !s->Handler->EmitTex(s->UserData, &rpti);
+               s->Compiler->Base.Error = s->Compiler->Base.Error || !s->Handler->EmitTex(s->UserData, &rpti);
        }
 
-       if (s->Compiler->Debug)
+       if (s->Compiler->Base.Debug)
                _mesa_printf(" END_TEX\n");
 }
 
@@ -781,10 +781,10 @@ static void fill_dest_into_pair(
        struct prog_instruction *inst = &pairinst->Instruction;
 
        if (inst->DstReg.File == PROGRAM_OUTPUT) {
-               if (inst->DstReg.Index == FRAG_RESULT_COLOR) {
+               if (inst->DstReg.Index == s->Compiler->OutputColor) {
                        pair->RGB.OutputWriteMask |= inst->DstReg.WriteMask & WRITEMASK_XYZ;
                        pair->Alpha.OutputWriteMask |= GET_BIT(inst->DstReg.WriteMask, 3);
-               } else if (inst->DstReg.Index == FRAG_RESULT_DEPTH) {
+               } else if (inst->DstReg.Index == s->Compiler->OutputDepth) {
                        pair->Alpha.DepthWriteMask |= GET_BIT(inst->DstReg.WriteMask, 3);
                }
        } else {
@@ -864,15 +864,15 @@ static void emit_alu(struct pair_state *s)
        success: ;
        }
 
-       if (s->Compiler->Debug)
+       if (s->Compiler->Base.Debug)
                radeonPrintPairInstruction(&pair);
 
-       s->Compiler->Error = s->Compiler->Error || !s->Handler->EmitPaired(s->UserData, &pair);
+       s->Compiler->Base.Error = s->Compiler->Base.Error || !s->Handler->EmitPaired(s->UserData, &pair);
 }
 
 
 void radeonPairProgram(
-       struct radeon_compiler * compiler,
+       struct r300_fragment_program_compiler * compiler,
        const struct radeon_pair_handler* handler, void *userdata)
 {
        struct pair_state s;
@@ -881,15 +881,15 @@ void radeonPairProgram(
        s.Compiler = compiler;
        s.Handler = handler;
        s.UserData = userdata;
-       s.Verbose = GL_FALSE && s.Compiler->Debug;
+       s.Verbose = GL_FALSE && s.Compiler->Base.Debug;
 
-       if (s.Compiler->Debug)
+       if (s.Compiler->Base.Debug)
                _mesa_printf("Emit paired program\n");
 
        scan_instructions(&s);
        allocate_input_registers(&s);
 
-       while(!s.Compiler->Error &&
+       while(!s.Compiler->Base.Error &&
              (s.ReadyTEX || s.ReadyRGB || s.ReadyAlpha || s.ReadyFullALU)) {
                if (s.ReadyTEX)
                        emit_all_tex(&s);
@@ -898,7 +898,7 @@ void radeonPairProgram(
                        emit_alu(&s);
        }
 
-       if (s.Compiler->Debug)
+       if (s.Compiler->Base.Debug)
                _mesa_printf(" END\n");
 }
 
index 9d4d7dd3c93a0ef277c4e3465b99862b53517a99..ff76178551881a21c9174fc11d0c6966468419af 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "radeon_program.h"
 
-struct radeon_compiler;
+struct r300_fragment_program_compiler;
 
 
 /**
@@ -131,11 +131,11 @@ struct radeon_pair_handler {
         */
        GLboolean (*BeginTexBlock)(void*);
 
-       GLuint MaxHwTemps;
+       unsigned MaxHwTemps;
 };
 
 void radeonPairProgram(
-       struct radeon_compiler * compiler,
+       struct r300_fragment_program_compiler * compiler,
        const struct radeon_pair_handler*, void *userdata);
 
 void radeonPrintPairInstruction(struct radeon_pair_instruction *inst);