vkd3d-shader/ir: Move vsir_program_normalise() to the end of the file.

vsir_program_normalise() has function calls to basically everything in
ir.c, so it's useful to have it in an easily reachable place to
quickly jump to wherever you need using your favorite code editor's
features.
This commit is contained in:
Giovanni Mascellani 2024-04-02 10:01:13 +02:00 committed by Alexandre Julliard
parent 9047dad4bc
commit d10031911d
Notes: Alexandre Julliard 2024-04-03 00:22:21 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/752

View File

@ -4393,106 +4393,6 @@ fail:
return ret;
}
enum vkd3d_result vsir_program_normalise(struct vsir_program *program, uint64_t config_flags,
const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_message_context *message_context)
{
enum vkd3d_result result = VKD3D_OK;
remove_dcl_temps(program);
if ((result = vsir_program_lower_texkills(program)) < 0)
return result;
if (program->shader_version.major >= 6)
{
struct vsir_cfg cfg;
if ((result = lower_switch_to_if_ladder(program)) < 0)
return result;
if ((result = vsir_program_materialise_ssas_to_temps(program)) < 0)
return result;
if ((result = vsir_cfg_init(&cfg, program, message_context)) < 0)
return result;
vsir_cfg_compute_dominators(&cfg);
if ((result = vsir_cfg_compute_loops(&cfg)) < 0)
{
vsir_cfg_cleanup(&cfg);
return result;
}
if ((result = vsir_cfg_sort_nodes(&cfg)) < 0)
{
vsir_cfg_cleanup(&cfg);
return result;
}
if ((result = vsir_cfg_generate_synthetic_loop_intervals(&cfg)) < 0)
{
vsir_cfg_cleanup(&cfg);
return result;
}
if ((result = vsir_cfg_build_structured_program(&cfg)) < 0)
{
vsir_cfg_cleanup(&cfg);
return result;
}
if ((result = vsir_cfg_emit_structured_program(&cfg)) < 0)
{
vsir_cfg_cleanup(&cfg);
return result;
}
vsir_cfg_cleanup(&cfg);
}
else
{
if (program->shader_version.type != VKD3D_SHADER_TYPE_PIXEL)
{
if ((result = vsir_program_remap_output_signature(program, compile_info, message_context)) < 0)
return result;
}
if (program->shader_version.type == VKD3D_SHADER_TYPE_HULL)
{
if ((result = instruction_array_flatten_hull_shader_phases(&program->instructions)) < 0)
return result;
if ((result = instruction_array_normalise_hull_shader_control_point_io(&program->instructions,
&program->input_signature)) < 0)
return result;
}
if ((result = vsir_program_normalise_io_registers(program)) < 0)
return result;
if ((result = instruction_array_normalise_flat_constants(program)) < 0)
return result;
remove_dead_code(program);
if ((result = vsir_program_normalise_combined_samplers(program, message_context)) < 0)
return result;
}
if ((result = vsir_program_flatten_control_flow_constructs(program, message_context)) < 0)
return result;
if (TRACE_ON())
vkd3d_shader_trace(program);
if ((result = vsir_program_validate(program, config_flags,
compile_info->source_name, message_context)) < 0)
return result;
return result;
}
struct validation_context
{
struct vkd3d_shader_message_context *message_context;
@ -5357,3 +5257,103 @@ fail:
return VKD3D_ERROR_OUT_OF_MEMORY;
}
enum vkd3d_result vsir_program_normalise(struct vsir_program *program, uint64_t config_flags,
const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_message_context *message_context)
{
enum vkd3d_result result = VKD3D_OK;
remove_dcl_temps(program);
if ((result = vsir_program_lower_texkills(program)) < 0)
return result;
if (program->shader_version.major >= 6)
{
struct vsir_cfg cfg;
if ((result = lower_switch_to_if_ladder(program)) < 0)
return result;
if ((result = vsir_program_materialise_ssas_to_temps(program)) < 0)
return result;
if ((result = vsir_cfg_init(&cfg, program, message_context)) < 0)
return result;
vsir_cfg_compute_dominators(&cfg);
if ((result = vsir_cfg_compute_loops(&cfg)) < 0)
{
vsir_cfg_cleanup(&cfg);
return result;
}
if ((result = vsir_cfg_sort_nodes(&cfg)) < 0)
{
vsir_cfg_cleanup(&cfg);
return result;
}
if ((result = vsir_cfg_generate_synthetic_loop_intervals(&cfg)) < 0)
{
vsir_cfg_cleanup(&cfg);
return result;
}
if ((result = vsir_cfg_build_structured_program(&cfg)) < 0)
{
vsir_cfg_cleanup(&cfg);
return result;
}
if ((result = vsir_cfg_emit_structured_program(&cfg)) < 0)
{
vsir_cfg_cleanup(&cfg);
return result;
}
vsir_cfg_cleanup(&cfg);
}
else
{
if (program->shader_version.type != VKD3D_SHADER_TYPE_PIXEL)
{
if ((result = vsir_program_remap_output_signature(program, compile_info, message_context)) < 0)
return result;
}
if (program->shader_version.type == VKD3D_SHADER_TYPE_HULL)
{
if ((result = instruction_array_flatten_hull_shader_phases(&program->instructions)) < 0)
return result;
if ((result = instruction_array_normalise_hull_shader_control_point_io(&program->instructions,
&program->input_signature)) < 0)
return result;
}
if ((result = vsir_program_normalise_io_registers(program)) < 0)
return result;
if ((result = instruction_array_normalise_flat_constants(program)) < 0)
return result;
remove_dead_code(program);
if ((result = vsir_program_normalise_combined_samplers(program, message_context)) < 0)
return result;
}
if ((result = vsir_program_flatten_control_flow_constructs(program, message_context)) < 0)
return result;
if (TRACE_ON())
vkd3d_shader_trace(program);
if ((result = vsir_program_validate(program, config_flags,
compile_info->source_name, message_context)) < 0)
return result;
return result;
}