vkd3d-shader/hlsl: Write SM4 conditionals.

Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Giovanni Mascellani 2021-11-05 19:35:55 +01:00 committed by Alexandre Julliard
parent 09dfe62368
commit 10593ad653

View File

@ -1415,6 +1415,33 @@ 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,
};
unsigned int writemask;
assert(iff->condition.node->data_type->dimx == 1);
sm4_register_from_node(&instr.srcs[0].reg, &writemask, iff->condition.node);
instr.srcs[0].swizzle = hlsl_swizzle_from_writemask(writemask);
write_sm4_instruction(buffer, &instr);
write_sm4_block(ctx, buffer, &iff->then_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;
write_sm4_instruction(buffer, &instr);
}
static void write_sm4_load(struct hlsl_ctx *ctx, static void write_sm4_load(struct hlsl_ctx *ctx,
struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_load *load) struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_load *load)
{ {
@ -1554,6 +1581,10 @@ static void write_sm4_block(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *
write_sm4_expr(ctx, buffer, hlsl_ir_expr(instr)); write_sm4_expr(ctx, buffer, hlsl_ir_expr(instr));
break; break;
case HLSL_IR_IF:
write_sm4_if(ctx, buffer, hlsl_ir_if(instr));
break;
case HLSL_IR_LOAD: case HLSL_IR_LOAD:
write_sm4_load(ctx, buffer, hlsl_ir_load(instr)); write_sm4_load(ctx, buffer, hlsl_ir_load(instr));
break; break;