From 0f16b8ec789c653c131928158efbf5860fa5a0d1 Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Tue, 16 Nov 2021 19:54:58 +0100 Subject: [PATCH] vkd3d-shader/hlsl: Write the else block only if it isn't empty. Signed-off-by: Giovanni Mascellani Signed-off-by: Zebediah Figura Signed-off-by: Henri Verbeet Signed-off-by: Matteo Bruni Signed-off-by: Alexandre Julliard --- libs/vkd3d-shader/hlsl_sm4.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index e597425a..c56a74d4 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1446,11 +1446,14 @@ static void write_sm4_if(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buf write_sm4_block(ctx, buffer, &iff->then_instrs); - instr.opcode = VKD3D_SM4_OP_ELSE; - instr.src_count = 0; - write_sm4_instruction(buffer, &instr); + if (!list_empty(&iff->else_instrs.instrs)) + { + instr.opcode = VKD3D_SM4_OP_ELSE; + instr.src_count = 0; + write_sm4_instruction(buffer, &instr); - write_sm4_block(ctx, buffer, &iff->else_instrs); + write_sm4_block(ctx, buffer, &iff->else_instrs); + } instr.opcode = VKD3D_SM4_OP_ENDIF; write_sm4_instruction(buffer, &instr);