+ tex_info->sampler_unit = inst->Src[1].Register.Index;
+ tex_info->texture_unit = inst->Src[1].Register.Index;
+ }
+
+ for (chan = 0; chan < 4; ++chan) {
+ struct lp_tgsi_channel_info *chan_info = &tex_info->coord[chan];
+ if (readmask & (1 << chan)) {
+ analyse_src(ctx, chan_info, &inst->Src[0].Register, chan);
+ if (chan_info->file != TGSI_FILE_INPUT) {
+ indirect = TRUE;
+ }
+ } else {
+ memset(chan_info, 0, sizeof *chan_info);
+ }
+ }
+
+ if (indirect) {
+ info->indirect_textures = TRUE;
+ }
+
+ ++info->num_texs;
+ } else {
+ info->indirect_textures = TRUE;
+ }
+}
+
+
+/**
+ * Analyse properties of sample instructions, in particular used
+ * to figure out if a texture is considered indirect.
+ * Not actually used by much except the tgsi dumping code.
+ */
+static void
+analyse_sample(struct analysis_context *ctx,
+ const struct tgsi_full_instruction *inst,
+ enum lp_build_tex_modifier modifier,
+ boolean shadow)
+{
+ struct lp_tgsi_info *info = ctx->info;
+ unsigned chan;
+
+ if (info->num_texs < ARRAY_SIZE(info->tex)) {
+ struct lp_tgsi_texture_info *tex_info = &info->tex[info->num_texs];
+ unsigned target = ctx->sample_target[inst->Src[1].Register.Index];
+ boolean indirect = FALSE;
+ boolean shadow = FALSE;
+ unsigned readmask;
+
+ switch (target) {
+ /* note no shadow targets here */
+ case TGSI_TEXTURE_BUFFER:
+ case TGSI_TEXTURE_1D:
+ readmask = TGSI_WRITEMASK_X;
+ break;
+ case TGSI_TEXTURE_1D_ARRAY:
+ case TGSI_TEXTURE_2D:
+ case TGSI_TEXTURE_RECT:
+ readmask = TGSI_WRITEMASK_XY;
+ break;
+ case TGSI_TEXTURE_2D_ARRAY:
+ case TGSI_TEXTURE_2D_MSAA:
+ case TGSI_TEXTURE_3D:
+ case TGSI_TEXTURE_CUBE:
+ readmask = TGSI_WRITEMASK_XYZ;
+ break;
+ case TGSI_TEXTURE_CUBE_ARRAY:
+ case TGSI_TEXTURE_2D_ARRAY_MSAA:
+ readmask = TGSI_WRITEMASK_XYZW;
+ break;
+ default:
+ assert(0);
+ return;
+ }
+
+ tex_info->target = target;
+ tex_info->texture_unit = inst->Src[1].Register.Index;
+ tex_info->sampler_unit = inst->Src[2].Register.Index;
+
+ if (tex_info->texture_unit != tex_info->sampler_unit) {
+ info->sampler_texture_units_different = TRUE;
+ }
+
+ if (modifier == LP_BLD_TEX_MODIFIER_EXPLICIT_DERIV ||
+ modifier == LP_BLD_TEX_MODIFIER_EXPLICIT_LOD ||
+ modifier == LP_BLD_TEX_MODIFIER_LOD_BIAS || shadow) {
+ /* We don't track insts with additional regs, although we could */
+ indirect = TRUE;