draw: hack around weird primitive id input in gs
[mesa.git] / src / gallium / auxiliary / gallivm / lp_bld_tgsi_info.c
index a4caf788ec735099d2aca9b232fef110ad0b41ab..3bbf2603a688bd43a6272859e901488e9e7e22b0 100644 (file)
@@ -47,7 +47,7 @@ struct analysis_context
    struct lp_tgsi_info *info;
 
    unsigned num_imms;
-   float imm[128][4];
+   float imm[LP_MAX_TGSI_IMMEDIATES][4];
 
    struct lp_tgsi_channel_info temp[32][4];
 };
@@ -137,10 +137,21 @@ analyse_tex(struct analysis_context *ctx,
       case TGSI_TEXTURE_SHADOWCUBE:
          readmask = TGSI_WRITEMASK_XYZW;
          break;
+      case TGSI_TEXTURE_CUBE_ARRAY:
+         readmask = TGSI_WRITEMASK_XYZW;
+         break;
+      case TGSI_TEXTURE_SHADOWCUBE_ARRAY:
+         readmask = TGSI_WRITEMASK_XYZW;
+         break;
       default:
          assert(0);
          return;
       }
+      /* XXX
+       * For cube map arrays, this will not analyze lod or shadow argument.
+       * For shadow cube, this will not analyze lod bias argument.
+       * "Indirect" really has no meaning for such textures anyway though.
+       */
 
       if (modifier == LP_BLD_TEX_MODIFIER_EXPLICIT_DERIV) {
          /* We don't track explicit derivatives, although we could */
@@ -296,6 +307,15 @@ analyse_instruction(struct analysis_context *ctx,
       case TGSI_OPCODE_TXP:
          analyse_tex(ctx, inst, LP_BLD_TEX_MODIFIER_PROJECTED);
          break;
+      case TGSI_OPCODE_TEX2:
+         analyse_tex(ctx, inst, LP_BLD_TEX_MODIFIER_NONE);
+         break;
+      case TGSI_OPCODE_TXB2:
+         analyse_tex(ctx, inst, LP_BLD_TEX_MODIFIER_LOD_BIAS);
+         break;
+      case TGSI_OPCODE_TXL2:
+         analyse_tex(ctx, inst, LP_BLD_TEX_MODIFIER_EXPLICIT_LOD);
+         break;
       case TGSI_OPCODE_SAMPLE:
          analyse_sample(ctx, inst, LP_BLD_TEX_MODIFIER_NONE, FALSE);
          break;
@@ -389,7 +409,7 @@ analyse_instruction(struct analysis_context *ctx,
 
    switch (inst->Instruction.Opcode) {
    case TGSI_OPCODE_IF:
-   case TGSI_OPCODE_IFC:
+   case TGSI_OPCODE_UIF:
    case TGSI_OPCODE_ELSE:
    case TGSI_OPCODE_ENDIF:
    case TGSI_OPCODE_BGNLOOP:
@@ -433,7 +453,7 @@ dump_info(const struct tgsi_token *tokens,
                &tex_info->coord[chan];
          if (chan_info->file != TGSI_FILE_NULL) {
             debug_printf(" %s[%u].%c",
-                         tgsi_file_names[chan_info->file],
+                         tgsi_file_name(chan_info->file),
                          chan_info->u.index,
                          "xyzw01"[chan_info->swizzle]);
          } else {
@@ -487,7 +507,7 @@ lp_build_tgsi_info(const struct tgsi_token *tokens,
                    struct lp_tgsi_info *info)
 {
    struct tgsi_parse_context parse;
-   struct analysis_context ctx;
+   struct analysis_context *ctx;
    unsigned index;
    unsigned chan;
 
@@ -495,8 +515,8 @@ lp_build_tgsi_info(const struct tgsi_token *tokens,
 
    tgsi_scan_shader(tokens, &info->base);
 
-   memset(&ctx, 0, sizeof ctx);
-   ctx.info = info;
+   ctx = CALLOC(1, sizeof(struct analysis_context));
+   ctx->info = info;
 
    tgsi_parse_init(&parse, tokens);
 
@@ -518,7 +538,7 @@ lp_build_tgsi_info(const struct tgsi_token *tokens,
                goto finished;
             }
 
-            analyse_instruction(&ctx, inst);
+            analyse_instruction(ctx, inst);
          }
          break;
 
@@ -527,16 +547,16 @@ lp_build_tgsi_info(const struct tgsi_token *tokens,
             const unsigned size =
                   parse.FullToken.FullImmediate.Immediate.NrTokens - 1;
             assert(size <= 4);
-            if (ctx.num_imms < Elements(ctx.imm)) {
+            if (ctx->num_imms < Elements(ctx->imm)) {
                for (chan = 0; chan < size; ++chan) {
                   float value = parse.FullToken.FullImmediate.u[chan].Float;
-                  ctx.imm[ctx.num_imms][chan] = value;
+                  ctx->imm[ctx->num_imms][chan] = value;
 
                   if (value < 0.0f || value > 1.0f) {
                      info->unclamped_immediates = TRUE;
                   }
                }
-               ++ctx.num_imms;
+               ++ctx->num_imms;
             }
          }
          break;
@@ -551,6 +571,7 @@ lp_build_tgsi_info(const struct tgsi_token *tokens,
 finished:
 
    tgsi_parse_free(&parse);
+   FREE(ctx);
 
 
    /*