From 5df81049aa80b2960d6fb7b84876b289ad31e90e Mon Sep 17 00:00:00 2001 From: Feifan He Date: Thu, 29 Aug 2024 01:21:39 +0800 Subject: [PATCH] vkd3d-shader/msl: Call vsir_program_transform() before generating code. --- libs/vkd3d-shader/ir.c | 3 ++- libs/vkd3d-shader/msl.c | 6 +++++- libs/vkd3d-shader/vkd3d_shader_main.c | 2 +- libs/vkd3d-shader/vkd3d_shader_private.h | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/libs/vkd3d-shader/ir.c b/libs/vkd3d-shader/ir.c index 6cef85fd..4b7b1a47 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -6685,7 +6685,8 @@ enum vkd3d_result vsir_program_transform(struct vsir_program *program, uint64_t vsir_transform(&ctx, vsir_program_remove_dead_code); vsir_transform(&ctx, vsir_program_normalise_combined_samplers); - if (compile_info->target_type != VKD3D_SHADER_TARGET_GLSL) + if (compile_info->target_type != VKD3D_SHADER_TARGET_GLSL + && compile_info->target_type != VKD3D_SHADER_TARGET_MSL) vsir_transform(&ctx, vsir_program_flatten_control_flow_constructs); } diff --git a/libs/vkd3d-shader/msl.c b/libs/vkd3d-shader/msl.c index 82619ca1..5178604e 100644 --- a/libs/vkd3d-shader/msl.c +++ b/libs/vkd3d-shader/msl.c @@ -88,11 +88,15 @@ static int msl_generator_init(struct msl_generator *gen, struct vsir_program *pr return VKD3D_OK; } -int msl_compile(struct vsir_program *program, struct vkd3d_shader_message_context *message_context) +int msl_compile(struct vsir_program *program, uint64_t config_flags, + const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_message_context *message_context) { struct msl_generator generator; int ret; + if ((ret = vsir_program_transform(program, config_flags, compile_info, message_context)) < 0) + return ret; + if ((ret = msl_generator_init(&generator, program, message_context)) < 0) return ret; msl_generator_generate(&generator); diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index ad924599..4444f4bc 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -1649,7 +1649,7 @@ int vsir_program_compile(struct vsir_program *program, uint64_t config_flags, break; case VKD3D_SHADER_TARGET_MSL: - ret = msl_compile(program, message_context); + ret = msl_compile(program, config_flags, compile_info, message_context); break; default: diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 248eac2f..72f46456 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -1595,7 +1595,8 @@ int spirv_compile(struct vsir_program *program, uint64_t config_flags, const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context); -int msl_compile(struct vsir_program *program, struct vkd3d_shader_message_context *message_context); +int msl_compile(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_md5_variant {