gallivm: Separate freeing LLVM intermediate data from freeing final code.
[mesa.git] / src / gallium / auxiliary / gallivm / lp_bld_tgsi_aos.c
index dbd9ccb3b62231b9261ced74cca05c9af286d8dc..4dee9bb4dd41e0d3c8c3495803282c5c7d6dbeb9 100644 (file)
@@ -363,7 +363,7 @@ emit_tex(struct lp_build_tgsi_aos_context *bld,
    unsigned target;
    unsigned unit;
    LLVMValueRef coords;
-   struct lp_derivatives derivs;
+   struct lp_derivatives derivs = { {NULL}, {NULL} };
 
    if (!bld->sampler) {
       _debug_printf("warning: found texture instruction but no sampler generator supplied\n");
@@ -374,22 +374,15 @@ emit_tex(struct lp_build_tgsi_aos_context *bld,
 
    coords = lp_build_emit_fetch( &bld->bld_base, inst, 0 , LP_CHAN_ALL);
 
-   if (0 && modifier == LP_BLD_TEX_MODIFIER_EXPLICIT_DERIV) {
-      lp_build_emit_fetch( &bld->bld_base, inst, 1 , LP_CHAN_ALL);
-      lp_build_emit_fetch( &bld->bld_base, inst, 2 , LP_CHAN_ALL);
+   if (modifier == LP_BLD_TEX_MODIFIER_EXPLICIT_DERIV) {
+      /* probably not going to work */
+      derivs.ddx[0] = lp_build_emit_fetch( &bld->bld_base, inst, 1 , LP_CHAN_ALL);
+      derivs.ddy[0] = lp_build_emit_fetch( &bld->bld_base, inst, 2 , LP_CHAN_ALL);
       unit = inst->Src[3].Register.Index;
-   }  else {
-#if 0
-      ddx = lp_build_ddx( &bld->bld_base.base, coords );
-      ddy = lp_build_ddy( &bld->bld_base.base, coords );
-#else
-      /* TODO */
-      derivs.ddx_ddy[0] = bld->bld_base.base.one;
-      derivs.ddx_ddy[1] = bld->bld_base.base.one;
-#endif
+   }
+   else {
       unit = inst->Src[1].Register.Index;
    }
-
    return bld->sampler->emit_fetch_texel(bld->sampler,
                                          &bld->bld_base.base,
                                          target, unit,
@@ -413,7 +406,7 @@ lp_emit_declaration_aos(
    for (idx = first; idx <= last; ++idx) {
       switch (decl->Declaration.File) {
       case TGSI_FILE_TEMPORARY:
-         assert(idx < LP_MAX_TGSI_TEMPS);
+         assert(idx < LP_MAX_INLINED_TEMPS);
          if (bld->indirect_files & (1 << TGSI_FILE_TEMPORARY)) {
             LLVMValueRef array_size = lp_build_const_int32(gallivm, last + 1);
             bld->temps_array = lp_build_array_alloca(bld->bld_base.base.gallivm,
@@ -536,7 +529,7 @@ lp_emit_instruction_aos(
    case TGSI_OPCODE_MIN:
       src0 = lp_build_emit_fetch(&bld->bld_base, inst, 0, LP_CHAN_ALL);
       src1 = lp_build_emit_fetch(&bld->bld_base, inst, 1, LP_CHAN_ALL);
-      dst0 = lp_build_max(&bld->bld_base.base, src0, src1);
+      dst0 = lp_build_min(&bld->bld_base.base, src0, src1);
       break;
 
    case TGSI_OPCODE_MAX:
@@ -664,12 +657,10 @@ lp_emit_instruction_aos(
    case TGSI_OPCODE_DDY:
       return FALSE;
 
-   case TGSI_OPCODE_KILP:
-      /* predicated kill */
+   case TGSI_OPCODE_KILL:
       return FALSE;
 
-   case TGSI_OPCODE_KIL:
-      /* conditional kill */
+   case TGSI_OPCODE_KILL_IF:
       return FALSE;
 
    case TGSI_OPCODE_PK2H:
@@ -844,6 +835,7 @@ lp_emit_instruction_aos(
       return FALSE;
 
    case TGSI_OPCODE_IF:
+   case TGSI_OPCODE_UIF:
       return FALSE;
 
    case TGSI_OPCODE_BGNLOOP:
@@ -1050,7 +1042,7 @@ lp_build_tgsi_aos(struct gallivm_state *gallivm,
             const uint size = parse.FullToken.FullImmediate.Immediate.NrTokens - 1;
             float imm[4];
             assert(size <= 4);
-            assert(num_immediates < LP_MAX_TGSI_IMMEDIATES);
+            assert(num_immediates < LP_MAX_INLINED_IMMEDIATES);
             for (chan = 0; chan < 4; ++chan) {
                imm[chan] = 0.0f;
             }