diff --git a/src/panfrost/bifrost/bi_schedule.c b/src/panfrost/bifrost/bi_schedule.c index e30b10fb8ad..bf3eb5ee9f0 100644 --- a/src/panfrost/bifrost/bi_schedule.c +++ b/src/panfrost/bifrost/bi_schedule.c @@ -2015,6 +2015,14 @@ bi_lower_fau(bi_context *ctx) if (ins->op == BI_OPCODE_ATEST) fau = ins->src[2]; + /* Dual texturing requires the texture operation descriptor + * encoded as an immediate so we can fix up. + */ + if (ins->op == BI_OPCODE_TEXC) { + assert(ins->src[3].type == BI_INDEX_CONSTANT); + constants[cwords++] = ins->src[3].value; + } + bi_foreach_src(ins, s) { if (bi_check_fau_src(ins, s, constants, &cwords, &fau)) continue; diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 6cb728ed4e9..c8b54462c65 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -5107,16 +5107,6 @@ bi_compile_variant_nir(nir_shader *nir, if (bifrost_debug & BIFROST_DBG_SHADERS && !skip_internal) bi_print_shader(ctx, stdout); - if (ctx->arch <= 8) { - bi_lower_fau(ctx); - } - - /* Lowering FAU can create redundant moves. Run CSE+DCE to clean up. */ - if (likely(optimize)) { - bi_opt_cse(ctx); - bi_opt_dead_code_eliminate(ctx); - } - /* Analyze before register allocation to avoid false dependencies. The * skip bit is a function of only the data flow graph and is invariant * under valid scheduling. Helpers are only defined for fragment @@ -5131,6 +5121,19 @@ bi_compile_variant_nir(nir_shader *nir, bi_opt_fuse_dual_texture(ctx); } + /* Lower FAU after fusing dual texture, because fusing dual texture + * creates new immediates that themselves may need lowering. + */ + if (ctx->arch <= 8) { + bi_lower_fau(ctx); + } + + /* Lowering FAU can create redundant moves. Run CSE+DCE to clean up. */ + if (likely(optimize)) { + bi_opt_cse(ctx); + bi_opt_dead_code_eliminate(ctx); + } + if (likely(!(bifrost_debug & BIFROST_DBG_NOPSCHED))) bi_pressure_schedule(ctx);