From 32fd18837b37aac1a3fedc3d0ade91559ccedfae Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Tue, 24 Aug 2021 01:18:10 -0500 Subject: [PATCH] vkd3d-shader/hlsl: Write SM4 swizzle instructions. 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 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 723b6005..73bac7b7 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -925,6 +925,26 @@ static void write_sm4_store(struct hlsl_ctx *ctx, write_sm4_instruction(buffer, &instr); } +static void write_sm4_swizzle(struct hlsl_ctx *ctx, + struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_swizzle *swizzle) +{ + struct sm4_instruction instr; + unsigned int writemask; + + memset(&instr, 0, sizeof(instr)); + instr.opcode = VKD3D_SM4_OP_MOV; + + sm4_register_from_node(&instr.dst.reg, &instr.dst.writemask, &swizzle->node); + instr.has_dst = 1; + + sm4_register_from_node(&instr.srcs[0].reg, &writemask, swizzle->val.node); + instr.srcs[0].swizzle = hlsl_map_swizzle(hlsl_combine_swizzles(hlsl_swizzle_from_writemask(writemask), + swizzle->swizzle, swizzle->node.data_type->dimx), instr.dst.writemask); + instr.src_count = 1; + + write_sm4_instruction(buffer, &instr); +} + static void write_sm4_shdr(struct hlsl_ctx *ctx, const struct hlsl_ir_function_decl *entry_func, struct dxbc_writer *dxbc) { @@ -989,6 +1009,10 @@ static void write_sm4_shdr(struct hlsl_ctx *ctx, write_sm4_store(ctx, &buffer, hlsl_ir_store(instr)); break; + case HLSL_IR_SWIZZLE: + write_sm4_swizzle(ctx, &buffer, hlsl_ir_swizzle(instr)); + break; + default: FIXME("Unhandled instruction type %s.\n", hlsl_node_type_to_string(instr->type)); }