Hi, the patch looks mostly fine, but... On 23/11/21 17:36, Francisco Casas wrote:
+static void write_sm4_gather(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, + const struct hlsl_type *resource_type, const struct hlsl_ir_node *dst, + const struct hlsl_deref *resource, const struct hlsl_deref *sampler, const struct hlsl_ir_node *coords, + unsigned int swizzle) +{ + struct sm4_instruction instr; + unsigned int writemask; + + assert(sampler->var); + + memset(&instr, 0, sizeof(instr)); + instr.opcode = VKD3D_SM4_OP_GATHER4; + + sm4_register_from_node(&instr.dsts[0].reg, &instr.dsts[0].writemask, NULL, dst); + instr.dst_count = 1; + + sm4_register_from_node(&instr.srcs[0].reg, &writemask, &instr.srcs[0].swizzle_type, coords); + instr.srcs[0].swizzle = hlsl_swizzle_from_writemask(writemask); + + sm4_register_from_deref(ctx, &instr.srcs[1].reg, &writemask, &instr.srcs[1].swizzle_type, + resource, resource_type); + instr.srcs[1].swizzle = hlsl_map_swizzle(hlsl_swizzle_from_writemask(writemask), instr.dsts[0].writemask); + + sm4_register_from_deref(ctx, &instr.srcs[2].reg, &writemask, NULL, + sampler, sampler->var->data_type); + instr.srcs[2].reg.type = VKD3D_SM4_RT_SAMPLER; + instr.srcs[2].reg.dim = VKD3D_SM4_DIMENSION_VEC4; + instr.srcs[2].swizzle_type = VKD3D_SM4_SWIZZLE_SCALAR; + instr.srcs[2].swizzle = swizzle; + + instr.src_count = 3; + + write_sm4_instruction(buffer, &instr); +}
Zebediah has already submitted a patch (220300 should be the last revision) that adds support for samplers in sm4_register_from_deref. I think you should wait for that patch to be accepted and then rebase on it (of course using the swizzle_type override mechanism you introduced, because Zeb's code defaults to _SWIZZLE_NONE). If Matteo hasn't done that yet by then, you might also add another commit to fix the swizzle_type thing in the texture branch. Thanks, Giovanni.