From 24f4308982e54371ea22ff0aee7ca5f0fea63416 Mon Sep 17 00:00:00 2001 From: Francisco Casas Date: Tue, 5 Nov 2024 22:23:41 -0300 Subject: [PATCH] vkd3d-shader/hlsl: Store SM4 MUL in the vsir program. --- libs/vkd3d-shader/hlsl_codegen.c | 19 +++++++++++++++++++ libs/vkd3d-shader/tpf.c | 21 ++------------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index fc69cccd..16b8df93 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -8392,6 +8392,25 @@ static bool sm4_generate_vsir_instr_expr(struct hlsl_ctx *ctx, return false; } + case HLSL_OP2_MUL: + switch (dst_type->e.numeric.type) + { + case HLSL_TYPE_FLOAT: + generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_MUL, 0, 0, true); + return true; + + case HLSL_TYPE_INT: + case HLSL_TYPE_UINT: + /* Using IMUL instead of UMUL because we're taking the low + * bits, and the native compiler generates IMUL. */ + sm4_generate_vsir_expr_with_two_destinations(ctx, program, VKD3DSIH_IMUL, expr, 1); + return true; + + default: + hlsl_fixme(ctx, &expr->node.loc, "SM4 %s multiplication expression.", dst_type_name); + return false; + } + case HLSL_OP2_NEQUAL: VKD3D_ASSERT(dst_type->e.numeric.type == HLSL_TYPE_BOOL); diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index 9a0431b2..31e196dc 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -5377,25 +5377,6 @@ static void write_sm4_expr(const struct tpf_compiler *tpf, const struct hlsl_ir_ } break; - case HLSL_OP2_MUL: - switch (dst_type->e.numeric.type) - { - case HLSL_TYPE_FLOAT: - write_sm4_binary_op(tpf, VKD3D_SM4_OP_MUL, &expr->node, arg1, arg2); - break; - - case HLSL_TYPE_INT: - case HLSL_TYPE_UINT: - /* Using IMUL instead of UMUL because we're taking the low - * bits, and the native compiler generates IMUL. */ - write_sm4_binary_op_with_two_destinations(tpf, VKD3D_SM4_OP_IMUL, &expr->node, 1, arg1, arg2); - break; - - default: - hlsl_fixme(tpf->ctx, &expr->node.loc, "SM4 %s multiplication expression.", dst_type_string->buffer); - } - break; - default: hlsl_fixme(tpf->ctx, &expr->node.loc, "SM4 %s expression.", debug_hlsl_expr_op(expr->op)); } @@ -5883,6 +5864,7 @@ static void tpf_handle_instruction(struct tpf_compiler *tpf, const struct vkd3d_ case VKD3DSIH_IMAD: case VKD3DSIH_IMAX: case VKD3DSIH_IMIN: + case VKD3DSIH_IMUL: case VKD3DSIH_INE: case VKD3DSIH_INEG: case VKD3DSIH_ISHL: @@ -5895,6 +5877,7 @@ static void tpf_handle_instruction(struct tpf_compiler *tpf, const struct vkd3d_ case VKD3DSIH_MIN: case VKD3DSIH_MOV: case VKD3DSIH_MOVC: + case VKD3DSIH_MUL: case VKD3DSIH_NEU: case VKD3DSIH_NOT: case VKD3DSIH_OR: