- *final_assembly_size = c->qpu_inst_count * sizeof(uint64_t);
-
- uint64_t *qpu_insts = malloc(*final_assembly_size);
- if (!qpu_insts)
- return NULL;
-
- memcpy(qpu_insts, c->qpu_insts, *final_assembly_size);
-
- char *shaderdb;
- int ret = asprintf(&shaderdb,
- "%s shader: %d inst, %d threads, %d loops, "
- "%d uniforms, %d:%d spills:fills",
- vir_get_stage_name(c),
- c->qpu_inst_count,
- c->threads,
- c->loops,
- c->num_uniforms,
- c->spills,
- c->fills);
- if (ret >= 0) {
- c->debug_output(shaderdb, c->debug_output_data);
- free(shaderdb);
- }
-
- vir_compile_destroy(c);
-
- return qpu_insts;
-}
-
-uint64_t *v3d_compile_vs(const struct v3d_compiler *compiler,
- struct v3d_vs_key *key,
- struct v3d_vs_prog_data *prog_data,
- nir_shader *s,
- void (*debug_output)(const char *msg,
- void *debug_output_data),
- void *debug_output_data,
- int program_id, int variant_id,
- uint32_t *final_assembly_size)
-{
- struct v3d_compile *c = vir_compile_init(compiler, &key->base, s,
- debug_output, debug_output_data,
- program_id, variant_id);
-
- c->vs_key = key;
-
- /* Split our I/O vars and dead code eliminate the unused
- * components.
- */
- NIR_PASS_V(c->s, nir_lower_io_to_scalar_early,
- nir_var_shader_in | nir_var_shader_out);
- uint64_t used_outputs[4] = {0};
- for (int i = 0; i < c->vs_key->num_fs_inputs; i++) {
- int slot = v3d_slot_get_slot(c->vs_key->fs_inputs[i]);
- int comp = v3d_slot_get_component(c->vs_key->fs_inputs[i]);
- used_outputs[comp] |= 1ull << slot;
- }
- NIR_PASS_V(c->s, nir_remove_unused_io_vars,
- &c->s->outputs, used_outputs, NULL); /* demotes to globals */
- NIR_PASS_V(c->s, nir_lower_global_vars_to_local);
- v3d_optimize_nir(c->s);
- NIR_PASS_V(c->s, nir_remove_dead_variables, nir_var_shader_in);
- NIR_PASS_V(c->s, nir_lower_io, nir_var_shader_in | nir_var_shader_out,
- type_size_vec4,
- (nir_lower_io_options)0);
-
- v3d_lower_nir(c);
-
- if (key->clamp_color)
- NIR_PASS_V(c->s, nir_lower_clamp_color_outputs);
-
- if (key->base.ucp_enables) {
- NIR_PASS_V(c->s, nir_lower_clip_vs, key->base.ucp_enables,
- false);
- NIR_PASS_V(c->s, nir_lower_io_to_scalar,
- nir_var_shader_out);
- }
-
- /* Note: VS output scalarizing must happen after nir_lower_clip_vs. */
- NIR_PASS_V(c->s, nir_lower_io_to_scalar, nir_var_shader_out);
-
- v3d_lower_nir_late(c);
- v3d_optimize_nir(c->s);
- NIR_PASS_V(c->s, nir_lower_bool_to_int32);
- NIR_PASS_V(c->s, nir_convert_from_ssa, true);
-
- v3d_nir_to_vir(c);
-
- v3d_set_prog_data(c, &prog_data->base);
-