From: "Zebediah Figura (she/her)" Subject: Re: [PATCH vkd3d 3/6] vkd3d-shader/hlsl: Write SM4 unsigned multiplication instructions. Message-Id: <4aa2945e-be6c-52f4-e130-94c7848f93c4@codeweavers.com> Date: Tue, 25 Jan 2022 13:06:32 -0600 In-Reply-To: <20220125110753.1358613-3-gmascellani@codeweavers.com> References: <20220125110753.1358613-1-gmascellani@codeweavers.com> <20220125110753.1358613-3-gmascellani@codeweavers.com> On 1/25/22 05:07, Giovanni Mascellani wrote: > +static void write_sm4_binary_op_with_null(struct vkd3d_bytecode_buffer *buffer, enum vkd3d_sm4_opcode opcode, > + const struct hlsl_ir_node *dst, unsigned dst_idx, const struct hlsl_ir_node *src1, > + const struct hlsl_ir_node *src2) > +{ > + struct sm4_instruction instr; > + unsigned int writemask; > + > + memset(&instr, 0, sizeof(instr)); > + instr.opcode = opcode; > + > + instr.dsts[1 - dst_idx].reg.type = VKD3D_SM4_RT_NULL; > + instr.dsts[1 - dst_idx].reg.dim = VKD3D_SM4_DIMENSION_NONE; > + instr.dsts[1 - dst_idx].reg.idx_count = 0; > + sm4_register_from_node(&instr.dsts[dst_idx].reg, &instr.dsts[dst_idx].writemask, NULL, dst); > + instr.dst_count = 2; > + > + sm4_register_from_node(&instr.srcs[0].reg, &writemask, &instr.srcs[0].swizzle_type, src1); > + instr.srcs[0].swizzle = hlsl_map_swizzle(hlsl_swizzle_from_writemask(writemask), instr.dsts[1].writemask); > + sm4_register_from_node(&instr.srcs[1].reg, &writemask, &instr.srcs[1].swizzle_type, src2); > + instr.srcs[1].swizzle = hlsl_map_swizzle(hlsl_swizzle_from_writemask(writemask), instr.dsts[1].writemask); > + instr.src_count = 2; > + > + write_sm4_instruction(buffer, &instr); > +} I want to find some way to put "2 dsts" in the function name, because as it is I can't tell just from reading. I'd also suggest specifying both dsts as optional hlsl_ir_node pointers, where NULL translates to SM4_RT_NULL. That would allow you to use this helper even if both dsts are used.