From d9508558a90127ac477712b7ad29fe3c57e77861 Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Thu, 17 Oct 2024 14:21:21 +0200 Subject: [PATCH] vkd3d-shader: Keep track of whether programs have normalised hull shader control point I/O. --- libs/vkd3d-shader/glsl.c | 1 + libs/vkd3d-shader/ir.c | 16 +++++++++++++--- libs/vkd3d-shader/msl.c | 1 + libs/vkd3d-shader/spirv.c | 1 + libs/vkd3d-shader/vkd3d_shader_private.h | 1 + 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/libs/vkd3d-shader/glsl.c b/libs/vkd3d-shader/glsl.c index 3e570ee2..46515818 100644 --- a/libs/vkd3d-shader/glsl.c +++ b/libs/vkd3d-shader/glsl.c @@ -2214,6 +2214,7 @@ int glsl_compile(struct vsir_program *program, uint64_t config_flags, return ret; VKD3D_ASSERT(program->normalised_io); + VKD3D_ASSERT(program->normalised_hull_cp_io); vkd3d_glsl_generator_init(&generator, program, compile_info, descriptor_info, combined_sampler_info, message_context); diff --git a/libs/vkd3d-shader/ir.c b/libs/vkd3d-shader/ir.c index e80f0718..f7d9329c 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -99,6 +99,7 @@ bool vsir_program_init(struct vsir_program *program, const struct vkd3d_shader_c program->shader_version = *version; program->cf_type = cf_type; program->normalised_io = normalised_io; + program->normalised_hull_cp_io = normalised_io; return shader_instruction_array_init(&program->instructions, reserve); } @@ -1134,6 +1135,14 @@ static enum vkd3d_result instruction_array_normalise_hull_shader_control_point_i enum vkd3d_result ret; unsigned int i, j; + VKD3D_ASSERT(!program->normalised_hull_cp_io); + + if (program->shader_version.type != VKD3D_SHADER_TYPE_HULL) + { + program->normalised_hull_cp_io = true; + return VKD3D_OK; + } + if (!(normaliser.outpointid_param = vsir_program_create_outpointid_param(program))) { ERR("Failed to allocate src param.\n"); @@ -1177,6 +1186,7 @@ static enum vkd3d_result instruction_array_normalise_hull_shader_control_point_i break; case VKD3DSIH_HS_CONTROL_POINT_PHASE: program->instructions = normaliser.instructions; + program->normalised_hull_cp_io = true; return VKD3D_OK; case VKD3DSIH_HS_FORK_PHASE: case VKD3DSIH_HS_JOIN_PHASE: @@ -1185,6 +1195,7 @@ static enum vkd3d_result instruction_array_normalise_hull_shader_control_point_i ret = control_point_normaliser_emit_hs_input(&normaliser, &program->input_signature, input_control_point_count, i, &location); program->instructions = normaliser.instructions; + program->normalised_hull_cp_io = true; return ret; default: break; @@ -1192,6 +1203,7 @@ static enum vkd3d_result instruction_array_normalise_hull_shader_control_point_i } program->instructions = normaliser.instructions; + program->normalised_hull_cp_io = true; return VKD3D_OK; } @@ -7659,11 +7671,9 @@ enum vkd3d_result vsir_program_transform(struct vsir_program *program, uint64_t vsir_transform(&ctx, vsir_program_remap_output_signature); if (program->shader_version.type == VKD3D_SHADER_TYPE_HULL) - { vsir_transform(&ctx, vsir_program_flatten_hull_shader_phases); - vsir_transform(&ctx, instruction_array_normalise_hull_shader_control_point_io); - } + vsir_transform(&ctx, instruction_array_normalise_hull_shader_control_point_io); vsir_transform(&ctx, vsir_program_normalise_io_registers); vsir_transform(&ctx, vsir_program_normalise_flat_constants); vsir_transform(&ctx, vsir_program_remove_dead_code); diff --git a/libs/vkd3d-shader/msl.c b/libs/vkd3d-shader/msl.c index f3cf04b1..5baefbc1 100644 --- a/libs/vkd3d-shader/msl.c +++ b/libs/vkd3d-shader/msl.c @@ -870,6 +870,7 @@ int msl_compile(struct vsir_program *program, uint64_t config_flags, return ret; VKD3D_ASSERT(program->normalised_io); + VKD3D_ASSERT(program->normalised_hull_cp_io); if ((ret = msl_generator_init(&generator, program, compile_info, descriptor_info, message_context)) < 0) return ret; diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 94999177..252379f6 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -10651,6 +10651,7 @@ static int spirv_compiler_generate_spirv(struct spirv_compiler *compiler, struct return result; VKD3D_ASSERT(program->normalised_io); + VKD3D_ASSERT(program->normalised_hull_cp_io); max_element_count = max(program->output_signature.element_count, program->patch_constant_signature.element_count); if (!(compiler->output_info = vkd3d_calloc(max_element_count, sizeof(*compiler->output_info)))) diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 47d29e6f..1eb72722 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -1416,6 +1416,7 @@ struct vsir_program bool has_point_size; enum vsir_control_flow_type cf_type; bool normalised_io; + bool normalised_hull_cp_io; const char **block_names; size_t block_name_count;