[PATCH vkd3d] vkd3d-shader/hlsl: Ensure that SM4 endif has 0 source registers.
Signed-off-by: Francisco Casas <fcasas(a)codeweavers.com> --- libs/vkd3d-shader/hlsl_sm4.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 872118c1..6a2b52cb 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1854,28 +1854,29 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, static void write_sm4_if(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_if *iff) { struct sm4_instruction instr = { .opcode = VKD3D_SM4_OP_IF | VKD3D_SM4_CONDITIONAL_NZ, .src_count = 1, }; assert(iff->condition.node->data_type->dimx == 1); sm4_src_from_node(&instr.srcs[0], iff->condition.node, VKD3DSP_WRITEMASK_ALL); write_sm4_instruction(buffer, &instr); write_sm4_block(ctx, buffer, &iff->then_instrs); 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); } instr.opcode = VKD3D_SM4_OP_ENDIF; + instr.src_count = 0; write_sm4_instruction(buffer, &instr); } -- 2.25.1
Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com> --- That's fine for me, but you could have added if "src_count = 0" thing just before the "if" that writes the "else" (confusing, isn't it?), and it would have covered both branches. Giovanni. Il 07/04/22 19:56, Francisco Casas ha scritto:
Signed-off-by: Francisco Casas <fcasas(a)codeweavers.com> --- libs/vkd3d-shader/hlsl_sm4.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 872118c1..6a2b52cb 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1854,28 +1854,29 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, static void write_sm4_if(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_if *iff) { struct sm4_instruction instr = { .opcode = VKD3D_SM4_OP_IF | VKD3D_SM4_CONDITIONAL_NZ, .src_count = 1, };
assert(iff->condition.node->data_type->dimx == 1);
sm4_src_from_node(&instr.srcs[0], iff->condition.node, VKD3DSP_WRITEMASK_ALL); write_sm4_instruction(buffer, &instr);
write_sm4_block(ctx, buffer, &iff->then_instrs);
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); }
instr.opcode = VKD3D_SM4_OP_ENDIF; + instr.src_count = 0; write_sm4_instruction(buffer, &instr); }
April 8, 2022 8:34 AM, "Giovanni Mascellani" <gmascellani(a)codeweavers.com> wrote:
Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com> --- That's fine for me, but you could have added if "src_count = 0" thing just before the "if" that writes the "else" (confusing, isn't it?), and it would have covered both branches.
Yes, but, just for the sake of discussing about trivialities, I prefer to keep instructions that are part of the same action close to each other. More so given that the code is our documentation. As I see it, there are 2 separate actions here: "Reuse the if instruction for making the else instruction" or "Reuse the if instruction for making the endif instruction". Granted that this inclination may introduce a little redundancy. Francisco.
participants (4)
-
Francisco Casas -
Giovanni Mascellani -
Henri Verbeet -
Matteo Bruni