vkd3d-shader/hlsl: Write SM4 swizzle instructions.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-08-24 01:18:10 -05:00 committed by Alexandre Julliard
parent 51b8c46b9d
commit 32fd18837b

View File

@ -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));
}