Józef Kucia : vkd3d-shader: Translate continue instructions.
Module: vkd3d Branch: master Commit: 79339d153a512c5f69204f05b7739aa30ff5e84e URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=79339d153a512c5f69204f05... Author: Józef Kucia <jkucia(a)codeweavers.com> Date: Mon Sep 24 10:25:19 2018 +0200 vkd3d-shader: Translate continue instructions. Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- libs/vkd3d-shader/spirv.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index d19d899..b96b69e 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -4850,6 +4850,20 @@ static void vkd3d_dxbc_compiler_pop_control_flow_level(struct vkd3d_dxbc_compile memset(cf_info, 0, sizeof(*cf_info)); } +static struct vkd3d_control_flow_info *vkd3d_dxbc_compiler_find_innermost_loop( + struct vkd3d_dxbc_compiler *compiler) +{ + int depth; + + for (depth = compiler->control_flow_depth - 1; depth >= 0; --depth) + { + if (compiler->control_flow_info[depth].current_block == VKD3D_BLOCK_LOOP) + return &compiler->control_flow_info[depth]; + } + + return NULL; +} + static struct vkd3d_control_flow_info *vkd3d_dxbc_compiler_find_innermost_breakable_cf_construct( struct vkd3d_dxbc_compiler *compiler) { @@ -5079,8 +5093,6 @@ static void vkd3d_dxbc_compiler_emit_control_flow_instruction(struct vkd3d_dxbc_ return; } - assert(compiler->control_flow_depth); - if (breakable_cf_info->current_block == VKD3D_BLOCK_LOOP) { vkd3d_spirv_build_op_branch(builder, breakable_cf_info->u.loop.merge_block_id); @@ -5102,6 +5114,22 @@ static void vkd3d_dxbc_compiler_emit_control_flow_instruction(struct vkd3d_dxbc_ vkd3d_dxbc_compiler_emit_breakc(compiler, instruction, cf_info->u.loop.merge_block_id); break; + case VKD3DSIH_CONTINUE: + { + struct vkd3d_control_flow_info *loop_cf_info; + + if (!(loop_cf_info = vkd3d_dxbc_compiler_find_innermost_loop(compiler))) + { + ERR("Invalid 'continue' instruction outside loop.\n"); + return; + } + + vkd3d_spirv_build_op_branch(builder, loop_cf_info->u.loop.continue_block_id); + + cf_info->inside_block = false; + break; + } + case VKD3DSIH_RET: vkd3d_dxbc_compiler_emit_return(compiler, instruction); @@ -6278,6 +6306,7 @@ void vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler case VKD3DSIH_BREAK: case VKD3DSIH_BREAKP: case VKD3DSIH_CASE: + case VKD3DSIH_CONTINUE: case VKD3DSIH_DEFAULT: case VKD3DSIH_ELSE: case VKD3DSIH_ENDIF:
participants (1)
-
Alexandre Julliard