llvmpipe: add compute debug option
[mesa.git] / src / gallium / drivers / r300 / compiler / r500_fragprog_emit.c
index c30cd753d15b692197d0f8c1a71c3030149473e7..a50b86798b6fb6c126ce6c9c8e0f439aa41ea72c 100644 (file)
@@ -41,7 +41,7 @@
 
 #include "r500_fragprog.h"
 
-#include "../r300_reg.h"
+#include "r300_reg.h"
 
 #include "radeon_program_pair.h"
 
@@ -210,6 +210,8 @@ static unsigned int use_source(struct r500_fragment_program_code* code, struct r
        } else if (src.File == RC_FILE_TEMPORARY || src.File == RC_FILE_INPUT) {
                use_temporary(code, src.Index);
                return src.Index;
+       } else if (src.File == RC_FILE_INLINE) {
+               return src.Index | (1 << 7);
        }
 
        return 0;
@@ -262,7 +264,7 @@ static void emit_paired(struct r300_fragment_program_compiler *c, struct rc_pair
        } else {
                code->inst[ip].inst0 = R500_INST_TYPE_ALU;
        }
-       code->inst[ip].inst0 |= R500_INST_TEX_SEM_WAIT;
+       code->inst[ip].inst0 |= (inst->SemWait << R500_INST_TEX_SEM_WAIT_SHIFT);
 
        code->inst[ip].inst0 |= (inst->RGB.WriteMask << 11);
        code->inst[ip].inst0 |= inst->Alpha.WriteMask ? 1 << 14 : 0;
@@ -319,6 +321,10 @@ static void emit_paired(struct r300_fragment_program_compiler *c, struct rc_pair
                        break;
        }
 
+       /* Set the output modifier */
+       code->inst[ip].inst3 |= inst->RGB.Omod << R500_ALU_RGB_OMOD_SHIFT;
+       code->inst[ip].inst4 |= inst->Alpha.Omod << R500_ALPHA_OMOD_SHIFT;
+
        code->inst[ip].inst1 |= R500_RGB_ADDR0(use_source(code, inst->RGB.Src[0]));
        code->inst[ip].inst1 |= R500_RGB_ADDR1(use_source(code, inst->RGB.Src[1]));
        code->inst[ip].inst1 |= R500_RGB_ADDR2(use_source(code, inst->RGB.Src[2]));
@@ -376,9 +382,9 @@ static int emit_tex(struct r300_fragment_program_compiler *c, struct rc_sub_inst
 
        code->inst[ip].inst0 = R500_INST_TYPE_TEX
                | (inst->DstReg.WriteMask << 11)
-               | R500_INST_TEX_SEM_WAIT;
+               | (inst->TexSemWait << R500_INST_TEX_SEM_WAIT_SHIFT);
        code->inst[ip].inst1 = R500_TEX_ID(inst->TexSrcUnit)
-               | R500_TEX_SEM_ACQUIRE;
+               | (inst->TexSemAcquire << R500_TEX_SEM_ACQUIRE_SHIFT);
 
        if (inst->TexSrcTarget == RC_TEXTURE_RECT)
                code->inst[ip].inst1 |= R500_TEX_UNSCALED;
@@ -667,6 +673,9 @@ void r500BuildFragmentProgramHwCode(struct radeon_compiler *c, void *user)
                code->inst[ip].inst0 = R500_INST_TYPE_OUT | R500_INST_TEX_SEM_WAIT;
        }
 
+       /* Make sure TEX_SEM_WAIT is set on the last instruction */
+       code->inst[code->inst_end].inst0 |= R500_INST_TEX_SEM_WAIT;
+
        /* Enable full flow control mode if we are using loops or have if
         * statements nested at least four deep. */
        if (s.MaxBranchDepth >= 4 || s.LoopsReserved > 0) {