struct lp_tgsi_info *info;
unsigned num_imms;
- float imm[128][4];
+ float imm[LP_MAX_TGSI_IMMEDIATES][4];
+ unsigned sample_target[PIPE_MAX_SHADER_SAMPLER_VIEWS];
struct lp_tgsi_channel_info temp[32][4];
};
case TGSI_TEXTURE_SHADOW2D:
case TGSI_TEXTURE_SHADOWRECT:
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_SHADOW2D_ARRAY:
case TGSI_TEXTURE_SHADOWCUBE:
+ case TGSI_TEXTURE_2D_ARRAY_MSAA:
+ case TGSI_TEXTURE_CUBE_ARRAY:
readmask = TGSI_WRITEMASK_XYZW;
+ /* modifier would be in another not analyzed reg so just say indirect */
+ if (modifier != LP_BLD_TEX_MODIFIER_NONE) {
+ indirect = TRUE;
+ }
+ break;
+ case TGSI_TEXTURE_SHADOWCUBE_ARRAY:
+ readmask = TGSI_WRITEMASK_XYZW;
+ indirect = TRUE;
break;
default:
assert(0);
static void
analyse_sample(struct analysis_context *ctx,
const struct tgsi_full_instruction *inst,
- enum lp_build_tex_modifier modifier)
+ enum lp_build_tex_modifier modifier,
+ boolean shadow)
{
struct lp_tgsi_info *info = ctx->info;
unsigned chan;
if (info->num_texs < Elements(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 = 0;
+ unsigned readmask;
- tex_info->target = inst->Texture.Texture;
- switch (inst->Texture.Texture) {
- case TGSI_TEXTURE_SHADOW1D:
- shadow = TRUE;
- /* Fallthrough */
+ switch (target) {
+ /* note no shadow targets here */
+ case TGSI_TEXTURE_BUFFER:
case TGSI_TEXTURE_1D:
readmask = TGSI_WRITEMASK_X;
break;
- case TGSI_TEXTURE_SHADOW1D_ARRAY:
- case TGSI_TEXTURE_SHADOW2D:
- case TGSI_TEXTURE_SHADOWRECT:
- shadow = TRUE;
- /* Fallthrough */
case TGSI_TEXTURE_1D_ARRAY:
case TGSI_TEXTURE_2D:
case TGSI_TEXTURE_RECT:
readmask = TGSI_WRITEMASK_XY;
break;
- case TGSI_TEXTURE_SHADOW2D_ARRAY:
- case TGSI_TEXTURE_SHADOWCUBE:
- shadow = TRUE;
- /* Fallthrough */
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_SHADOWCUBE_ARRAY:
- shadow = TRUE;
- /* Fallthrough */
case TGSI_TEXTURE_CUBE_ARRAY:
+ case TGSI_TEXTURE_2D_ARRAY_MSAA:
readmask = TGSI_WRITEMASK_XYZW;
break;
default:
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) {
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;
case TGSI_OPCODE_SAMPLE_C:
- analyse_sample(ctx, inst, LP_BLD_TEX_MODIFIER_NONE);
+ analyse_sample(ctx, inst, LP_BLD_TEX_MODIFIER_NONE, TRUE);
break;
case TGSI_OPCODE_SAMPLE_C_LZ:
- analyse_sample(ctx, inst, LP_BLD_TEX_MODIFIER_LOD_ZERO);
+ analyse_sample(ctx, inst, LP_BLD_TEX_MODIFIER_LOD_ZERO, TRUE);
break;
case TGSI_OPCODE_SAMPLE_D:
- analyse_sample(ctx, inst, LP_BLD_TEX_MODIFIER_EXPLICIT_DERIV);
+ analyse_sample(ctx, inst, LP_BLD_TEX_MODIFIER_EXPLICIT_DERIV, FALSE);
break;
case TGSI_OPCODE_SAMPLE_B:
- analyse_sample(ctx, inst, LP_BLD_TEX_MODIFIER_LOD_BIAS);
+ analyse_sample(ctx, inst, LP_BLD_TEX_MODIFIER_LOD_BIAS, FALSE);
break;
case TGSI_OPCODE_SAMPLE_L:
- analyse_sample(ctx, inst, LP_BLD_TEX_MODIFIER_EXPLICIT_LOD);
+ analyse_sample(ctx, inst, LP_BLD_TEX_MODIFIER_EXPLICIT_LOD, FALSE);
break;
default:
break;
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:
}
-static INLINE void
+static inline void
dump_info(const struct tgsi_token *tokens,
struct lp_tgsi_info *info)
{
&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 {
struct lp_tgsi_info *info)
{
struct tgsi_parse_context parse;
- struct analysis_context ctx;
+ struct analysis_context *ctx;
unsigned index;
unsigned chan;
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);
tgsi_parse_token(&parse);
switch (parse.FullToken.Token.Type) {
- case TGSI_TOKEN_TYPE_DECLARATION:
+ case TGSI_TOKEN_TYPE_DECLARATION: {
+ struct tgsi_full_declaration *decl = &parse.FullToken.FullDeclaration;
+ if (decl->Declaration.File == TGSI_FILE_SAMPLER_VIEW) {
+ for (index = decl->Range.First; index <= decl->Range.Last; index++) {
+ ctx->sample_target[index] = decl->SamplerView.Resource;
+ }
+ }
+ }
break;
case TGSI_TOKEN_TYPE_INSTRUCTION:
goto finished;
}
- analyse_instruction(&ctx, inst);
+ analyse_instruction(ctx, inst);
}
break;
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;
finished:
tgsi_parse_free(&parse);
+ FREE(ctx);
/*