diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 0d0515de..417cdc92 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -9577,7 +9577,7 @@ static bool is_dcl_instruction(enum vkd3d_shader_opcode handler_idx) || handler_idx == VKD3DSIH_HS_DECLS; } -int spirv_compiler_handle_instruction(struct spirv_compiler *compiler, +static int spirv_compiler_handle_instruction(struct spirv_compiler *compiler, const struct vkd3d_shader_instruction *instruction) { int ret = VKD3D_OK; @@ -9934,12 +9934,22 @@ int spirv_compiler_handle_instruction(struct spirv_compiler *compiler, } int spirv_compiler_generate_spirv(struct spirv_compiler *compiler, - const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *spirv) + const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_parser *parser, + struct vkd3d_shader_code *spirv) { + const struct vkd3d_shader_instruction_array *instructions = &parser->instructions; const struct vkd3d_shader_spirv_target_info *info = compiler->spirv_target_info; const struct vkd3d_shader_spirv_domain_shader_target_info *ds_info; struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; const struct vkd3d_shader_phase *phase; + enum vkd3d_result result = VKD3D_OK; + unsigned int i; + + for (i = 0; i < instructions->count; ++i) + { + if ((result = spirv_compiler_handle_instruction(compiler, &instructions->elements[i])) < 0) + return result; + } if ((phase = spirv_compiler_get_current_shader_phase(compiler))) spirv_compiler_leave_shader_phase(compiler, phase); diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index 012b3eb6..f5038eb7 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -1176,7 +1176,6 @@ static int compile_dxbc_tpf(const struct vkd3d_shader_compile_info *compile_info struct vkd3d_shader_compile_info scan_info; struct spirv_compiler *spirv_compiler; struct vkd3d_shader_parser *parser; - unsigned int i; int ret; scan_info = *compile_info; @@ -1234,13 +1233,7 @@ static int compile_dxbc_tpf(const struct vkd3d_shader_compile_info *compile_info return VKD3D_ERROR; } - for (i = 0; i < parser->instructions.count && ret >= 0; ++i) - { - ret = spirv_compiler_handle_instruction(spirv_compiler, &parser->instructions.elements[i]); - } - - if (ret >= 0) - ret = spirv_compiler_generate_spirv(spirv_compiler, compile_info, out); + ret = spirv_compiler_generate_spirv(spirv_compiler, compile_info, parser, out); spirv_compiler_destroy(spirv_compiler); vkd3d_shader_parser_destroy(parser); diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index b5f45834..6c5a1917 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -1144,10 +1144,9 @@ struct spirv_compiler *spirv_compiler_create(const struct vkd3d_shader_version * const struct vkd3d_shader_desc *shader_desc, const struct vkd3d_shader_compile_info *compile_info, const struct vkd3d_shader_scan_descriptor_info *scan_descriptor_info, struct vkd3d_shader_message_context *message_context, const struct vkd3d_shader_location *location); -int spirv_compiler_handle_instruction(struct spirv_compiler *compiler, - const struct vkd3d_shader_instruction *instruction); int spirv_compiler_generate_spirv(struct spirv_compiler *compiler, - const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *spirv); + const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_parser *parser, + struct vkd3d_shader_code *spirv); void spirv_compiler_destroy(struct spirv_compiler *compiler); void vkd3d_compute_dxbc_checksum(const void *dxbc, size_t size, uint32_t checksum[4]);