vkd3d-shader/hlsl: Store SM4 DOT in the vsir program.

This commit is contained in:
Francisco Casas 2024-11-06 00:17:04 -03:00 committed by Henri Verbeet
parent e8b373e3ff
commit 30bc6965a2
Notes: Henri Verbeet 2024-11-06 23:02:23 +01:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1251
2 changed files with 31 additions and 48 deletions

View File

@ -8266,6 +8266,34 @@ static bool sm4_generate_vsir_instr_expr(struct hlsl_ctx *ctx,
return false; return false;
} }
case HLSL_OP2_DOT:
switch (dst_type->e.numeric.type)
{
case HLSL_TYPE_FLOAT:
switch (expr->operands[0].node->data_type->dimx)
{
case 4:
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_DP4, 0, 0, false);
return true;
case 3:
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_DP3, 0, 0, false);
return true;
case 2:
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_DP2, 0, 0, false);
return true;
case 1:
default:
vkd3d_unreachable();
}
default:
hlsl_fixme(ctx, &expr->node.loc, "SM4 %s dot expression.", dst_type_name);
return false;
}
case HLSL_OP2_EQUAL: case HLSL_OP2_EQUAL:
VKD3D_ASSERT(dst_type->e.numeric.type == HLSL_TYPE_BOOL); VKD3D_ASSERT(dst_type->e.numeric.type == HLSL_TYPE_BOOL);

View File

@ -5032,25 +5032,6 @@ static void write_sm4_ret(const struct tpf_compiler *tpf)
write_sm4_instruction(tpf, &instr); write_sm4_instruction(tpf, &instr);
} }
/* dp# instructions don't map the swizzle. */
static void write_sm4_binary_op_dot(const struct tpf_compiler *tpf, enum vkd3d_sm4_opcode opcode,
const struct hlsl_ir_node *dst, const struct hlsl_ir_node *src1, const struct hlsl_ir_node *src2)
{
struct sm4_instruction instr;
memset(&instr, 0, sizeof(instr));
instr.opcode = opcode;
sm4_dst_from_node(&instr.dsts[0], dst);
instr.dst_count = 1;
sm4_src_from_node(tpf, &instr.srcs[0], src1, VKD3DSP_WRITEMASK_ALL);
sm4_src_from_node(tpf, &instr.srcs[1], src2, VKD3DSP_WRITEMASK_ALL);
instr.src_count = 2;
write_sm4_instruction(tpf, &instr);
}
static void write_sm4_binary_op_with_two_destinations(const struct tpf_compiler *tpf, static void write_sm4_binary_op_with_two_destinations(const struct tpf_compiler *tpf,
enum vkd3d_sm4_opcode opcode, const struct hlsl_ir_node *dst, unsigned int dst_idx, enum vkd3d_sm4_opcode opcode, const struct hlsl_ir_node *dst, unsigned int dst_idx,
const struct hlsl_ir_node *src1, const struct hlsl_ir_node *src2) const struct hlsl_ir_node *src1, const struct hlsl_ir_node *src2)
@ -5302,35 +5283,6 @@ static void write_sm4_expr(const struct tpf_compiler *tpf, const struct hlsl_ir_
switch (expr->op) switch (expr->op)
{ {
case HLSL_OP2_DOT:
switch (dst_type->e.numeric.type)
{
case HLSL_TYPE_FLOAT:
switch (arg1->data_type->dimx)
{
case 4:
write_sm4_binary_op_dot(tpf, VKD3D_SM4_OP_DP4, &expr->node, arg1, arg2);
break;
case 3:
write_sm4_binary_op_dot(tpf, VKD3D_SM4_OP_DP3, &expr->node, arg1, arg2);
break;
case 2:
write_sm4_binary_op_dot(tpf, VKD3D_SM4_OP_DP2, &expr->node, arg1, arg2);
break;
case 1:
default:
vkd3d_unreachable();
}
break;
default:
hlsl_fixme(tpf->ctx, &expr->node.loc, "SM4 %s dot expression.", dst_type_string->buffer);
}
break;
case HLSL_OP2_MOD: case HLSL_OP2_MOD:
switch (dst_type->e.numeric.type) switch (dst_type->e.numeric.type)
{ {
@ -5809,6 +5761,9 @@ static void tpf_handle_instruction(struct tpf_compiler *tpf, const struct vkd3d_
case VKD3DSIH_ADD: case VKD3DSIH_ADD:
case VKD3DSIH_AND: case VKD3DSIH_AND:
case VKD3DSIH_DIV: case VKD3DSIH_DIV:
case VKD3DSIH_DP2:
case VKD3DSIH_DP3:
case VKD3DSIH_DP4:
case VKD3DSIH_DSX: case VKD3DSIH_DSX:
case VKD3DSIH_DSX_COARSE: case VKD3DSIH_DSX_COARSE:
case VKD3DSIH_DSX_FINE: case VKD3DSIH_DSX_FINE: