Lines Matching defs:ctx
75 static bi_block *emit_cf_list(bi_context *ctx, struct exec_list *list);
463 bi_varying_base_bytes(bi_context *ctx, nir_intrinsic_instr *intr)
466 uint32_t mask = ctx->inputs->fixed_varying_mask;
483 bi_varying_offset(bi_context *ctx, nir_intrinsic_instr *intr)
488 return bi_varying_base_bytes(ctx, intr) + (nir_src_as_uint(*src) * 16);
817 bi_skip_atest(bi_context *ctx, bool emit_zs)
819 return (ctx->inputs->is_blit && !emit_zs) || ctx->inputs->is_blend;
1385 bi_context *ctx = b->shader;
1388 unsigned offset = (ctx->stage == MESA_SHADER_VERTEX) ?
1389 util_bitcount64(ctx->nir->info.inputs_read) : 0;
3899 create_empty_block(bi_context *ctx)
3901 bi_block *blk = rzalloc(ctx, bi_block);
3909 emit_block(bi_context *ctx, nir_block *block)
3911 if (ctx->after_block) {
3912 ctx->current_block = ctx->after_block;
3913 ctx->after_block = NULL;
3915 ctx->current_block = create_empty_block(ctx);
3918 list_addtail(&ctx->current_block->link, &ctx->blocks);
3919 list_inithead(&ctx->current_block->instructions);
3921 bi_builder _b = bi_init_builder(ctx, bi_after_block(ctx->current_block));
3925 ++ctx->instruction_count;
3928 return ctx->current_block;
3932 emit_if(bi_context *ctx, nir_if *nif)
3934 bi_block *before_block = ctx->current_block;
3937 bi_builder _b = bi_init_builder(ctx, bi_after_block(ctx->current_block));
3943 bi_block *then_block = emit_cf_list(ctx, &nif->then_list);
3944 bi_block *end_then_block = ctx->current_block;
3948 int count_in = ctx->instruction_count;
3949 bi_block *else_block = emit_cf_list(ctx, &nif->else_list);
3950 bi_block *end_else_block = ctx->current_block;
3951 ctx->after_block = create_empty_block(ctx);
3958 if (ctx->instruction_count == count_in) {
3959 then_branch->branch_target = ctx->after_block;
3960 bi_block_add_successor(end_then_block, ctx->after_block); /* fallthrough */
3967 then_exit->branch_target = ctx->after_block;
3970 bi_block_add_successor(end_else_block, ctx->after_block); /* fallthrough */
3978 emit_loop(bi_context *ctx, nir_loop *nloop)
3981 bi_block *start_block = ctx->current_block;
3983 bi_block *saved_break = ctx->break_block;
3984 bi_block *saved_continue = ctx->continue_block;
3986 ctx->continue_block = create_empty_block(ctx);
3987 ctx->break_block = create_empty_block(ctx);
3988 ctx->after_block = ctx->continue_block;
3991 emit_cf_list(ctx, &nloop->body);
3994 bi_builder _b = bi_init_builder(ctx, bi_after_block(ctx->current_block));
3996 I->branch_target = ctx->continue_block;
3997 bi_block_add_successor(start_block, ctx->continue_block);
3998 bi_block_add_successor(ctx->current_block, ctx->continue_block);
4000 ctx->after_block = ctx->break_block;
4003 ctx->break_block = saved_break;
4004 ctx->continue_block = saved_continue;
4005 ++ctx->loop_count;
4009 emit_cf_list(bi_context *ctx, struct exec_list *list)
4016 bi_block *block = emit_block(ctx, nir_cf_node_as_block(node));
4025 emit_if(ctx, nir_cf_node_as_if(node));
4029 emit_loop(ctx, nir_cf_node_as_loop(node));
4106 bi_count_preload_cost(bi_context *ctx)
4113 for (unsigned i = 0; i < ARRAY_SIZE(ctx->info.bifrost->messages); ++i) {
4114 struct bifrost_message_preload msg = ctx->info.bifrost->messages[i];
4128 bi_shader_stage_name(bi_context *ctx)
4130 if (ctx->idvs == BI_IDVS_VARYING)
4132 else if (ctx->idvs == BI_IDVS_POSITION)
4134 else if (ctx->inputs->is_blend)
4137 return gl_shader_stage_name(ctx->stage);
4141 bi_print_stats(bi_context *ctx, unsigned size, FILE *fp)
4157 bi_foreach_block(ctx, block) {
4176 bool full_threads = (ctx->arch == 7 && ctx->info.work_reg_count <= 32);
4184 ctx->nir->info.label ?: "",
4185 bi_shader_stage_name(ctx),
4191 if (ctx->arch == 7) {
4192 ralloc_asprintf_append(&str, ", %u preloads", bi_count_preload_cost(ctx));
4196 ctx->loop_count, ctx->spills, ctx->fills);
4203 va_print_stats(bi_context *ctx, unsigned size, FILE *fp)
4209 bi_foreach_instr_global(ctx, I) {
4238 unsigned nr_threads = (ctx->info.work_reg_count <= 32) ? 2 : 1;
4245 ctx->nir->info.label ?: "",
4246 bi_shader_stage_name(ctx),
4249 ctx->loop_count, ctx->spills, ctx->fills);
4640 bi_opt_post_ra(bi_context *ctx)
4642 bi_foreach_instr_global_safe(ctx, ins) {
4718 bi_lower_branch(bi_context *ctx, bi_block *block)
4720 bool cull_terminal = (ctx->arch <= 8);
4747 bi_pack_clauses(bi_context *ctx, struct util_dynarray *binary, unsigned offset)
4749 unsigned final_clause = bi_pack(ctx, binary);
4753 bi_block *first_block = list_first_entry(&ctx->blocks, bi_block, link);
4754 bi_clause *first_clause = bi_next_clause(ctx, first_block, NULL);
4757 ctx->info.bifrost->wait_6 = (first_deps & (1 << 6));
4758 ctx->info.bifrost->wait_7 = (first_deps & (1 << 7));
4939 bi_context *ctx = rzalloc(NULL, bi_context);
4944 ctx->sysval_to_id = sysval_to_id;
4945 ctx->inputs = inputs;
4946 ctx->nir = nir;
4947 ctx->stage = nir->info.stage;
4948 ctx->quirks = bifrost_get_quirks(inputs->gpu_id);
4949 ctx->arch = inputs->gpu_id >> 12;
4950 ctx->info = info;
4951 ctx->idvs = idvs;
4952 ctx->malloc_idvs = (ctx->arch >= 9) && !inputs->no_idvs;
4960 ctx->nir = nir = nir_shader_clone(ctx, nir);
4984 ctx->ubo_mask = ~0;
4986 list_inithead(&ctx->blocks);
4995 ctx->allocated_vec = _mesa_hash_table_u64_create(ctx);
5001 ctx->ssa_alloc += func->impl->ssa_alloc;
5002 ctx->reg_alloc += func->impl->reg_alloc;
5004 emit_cf_list(ctx, &func->impl->body);
5009 bi_foreach_block(ctx, block) {
5010 block->index = ctx->num_blocks++;
5013 bi_validate(ctx, "NIR -> BIR");
5018 (ctx->stage == MESA_SHADER_FRAGMENT) &&
5019 !ctx->emitted_atest &&
5020 !bi_skip_atest(ctx, false);
5023 bi_block *end = list_last_entry(&ctx->blocks, bi_block, link);
5024 bi_builder b = bi_init_builder(ctx, bi_after_block(end));
5031 bi_lower_swizzle(ctx);
5032 bi_validate(ctx, "Early lowering");
5035 if (optimize && !ctx->inputs->no_ubo_to_push) {
5036 bi_opt_push_ubo(ctx);
5040 bi_opt_copy_prop(ctx);
5042 while (bi_opt_constant_fold(ctx))
5043 bi_opt_copy_prop(ctx);
5045 bi_opt_mod_prop_forward(ctx);
5046 bi_opt_mod_prop_backward(ctx);
5050 if (ctx->arch == 7 && ctx->stage == MESA_SHADER_FRAGMENT &&
5052 bi_opt_dead_code_eliminate(ctx);
5053 bi_opt_message_preload(ctx);
5054 bi_opt_copy_prop(ctx);
5057 bi_opt_dead_code_eliminate(ctx);
5058 bi_opt_cse(ctx);
5059 bi_opt_dead_code_eliminate(ctx);
5060 if (!ctx->inputs->no_ubo_to_push)
5061 bi_opt_reorder_push(ctx);
5062 bi_validate(ctx, "Optimization passes");
5065 bi_foreach_instr_global(ctx, I) {
5069 if (ctx->arch >= 9) {
5070 va_optimize(ctx);
5072 bi_foreach_instr_global_safe(ctx, I) {
5074 va_lower_constants(ctx, I);
5076 bi_builder b = bi_init_builder(ctx, bi_before_instr(I));
5082 bi_opt_cse(ctx);
5083 bi_opt_dead_code_eliminate(ctx);
5086 bi_validate(ctx, "Valhall passes");
5089 bi_foreach_block(ctx, block) {
5090 bi_lower_branch(ctx, block);
5094 bi_print_shader(ctx, stdout);
5101 if (ctx->stage == MESA_SHADER_FRAGMENT)
5102 bi_analyze_helper_requirements(ctx);
5107 bi_opt_fuse_dual_texture(ctx);
5113 if (ctx->arch <= 8) {
5114 bi_lower_fau(ctx);
5119 bi_opt_cse(ctx);
5120 bi_opt_dead_code_eliminate(ctx);
5124 bi_pressure_schedule(ctx);
5126 bi_validate(ctx, "Late lowering");
5128 bi_register_allocate(ctx);
5131 bi_opt_post_ra(ctx);
5134 bi_print_shader(ctx, stdout);
5136 if (ctx->arch >= 9) {
5137 va_assign_slots(ctx);
5138 va_insert_flow_control_nops(ctx);
5139 va_merge_flow(ctx);
5140 va_mark_last(ctx);
5142 bi_schedule(ctx);
5143 bi_assign_scoreboard(ctx);
5149 bi_analyze_helper_terminate(ctx);
5150 bi_mark_clauses_td(ctx);
5154 bi_print_shader(ctx, stdout);
5156 if (ctx->arch <= 8) {
5157 bi_pack_clauses(ctx, binary, offset);
5159 bi_pack_valhall(ctx, binary);
5163 if (ctx->arch <= 8) {
5178 if (ctx->arch >= 9) {
5179 va_print_stats(ctx, binary->size - offset, stderr);
5181 bi_print_stats(ctx, binary->size - offset, stderr);
5185 return ctx;
5218 bi_context *ctx = bi_compile_variant_nir(nir, inputs, binary, sysval_to_id, local_info, idvs);
5221 bi_block *first_block = list_first_entry(&ctx->blocks, bi_block, link);
5235 if (nir->info.stage == MESA_SHADER_FRAGMENT && ctx->arch >= 9)
5238 info->ubo_mask |= ctx->ubo_mask;
5239 info->tls_size = MAX2(info->tls_size, ctx->info.tls_size);
5245 info->vs.secondary_work_reg_count = ctx->info.work_reg_count;
5248 info->work_reg_count = ctx->info.work_reg_count;
5257 bi_foreach_instr_global(ctx, I) {
5268 bi_builder b = bi_init_builder(ctx, bi_before_instr(write));
5276 bi_pack_valhall(ctx, binary);
5279 ralloc_free(ctx);