mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader: Lower SUB to NEG + ADD at parse time.
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:
parent
ed7cdb3940
commit
6e3bdb17dc
@ -1062,7 +1062,6 @@ static const char *debug_expr_op(const struct hlsl_ir_expr *expr)
|
|||||||
"sat",
|
"sat",
|
||||||
|
|
||||||
"+",
|
"+",
|
||||||
"-",
|
|
||||||
"*",
|
"*",
|
||||||
"/",
|
"/",
|
||||||
|
|
||||||
|
@ -302,7 +302,6 @@ enum hlsl_ir_expr_op
|
|||||||
HLSL_IR_UNOP_SAT,
|
HLSL_IR_UNOP_SAT,
|
||||||
|
|
||||||
HLSL_IR_BINOP_ADD,
|
HLSL_IR_BINOP_ADD,
|
||||||
HLSL_IR_BINOP_SUB,
|
|
||||||
HLSL_IR_BINOP_MUL,
|
HLSL_IR_BINOP_MUL,
|
||||||
HLSL_IR_BINOP_DIV,
|
HLSL_IR_BINOP_DIV,
|
||||||
|
|
||||||
|
@ -1118,7 +1118,7 @@ static enum hlsl_ir_expr_op op_from_assignment(enum parse_assign_op op)
|
|||||||
{
|
{
|
||||||
0,
|
0,
|
||||||
HLSL_IR_BINOP_ADD,
|
HLSL_IR_BINOP_ADD,
|
||||||
HLSL_IR_BINOP_SUB,
|
0,
|
||||||
HLSL_IR_BINOP_MUL,
|
HLSL_IR_BINOP_MUL,
|
||||||
HLSL_IR_BINOP_DIV,
|
HLSL_IR_BINOP_DIV,
|
||||||
HLSL_IR_BINOP_MOD,
|
HLSL_IR_BINOP_MOD,
|
||||||
@ -1176,12 +1176,23 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
|
|||||||
struct hlsl_ir_expr *copy;
|
struct hlsl_ir_expr *copy;
|
||||||
DWORD writemask = 0;
|
DWORD writemask = 0;
|
||||||
|
|
||||||
|
if (assign_op == ASSIGN_OP_SUB)
|
||||||
|
{
|
||||||
|
struct hlsl_ir_node *args[3] = {rhs};
|
||||||
|
struct hlsl_ir_expr *expr;
|
||||||
|
|
||||||
|
if (!(expr = add_expr(ctx, instrs, HLSL_IR_UNOP_NEG, args, &rhs->loc)))
|
||||||
|
return NULL;
|
||||||
|
rhs = &expr->node;
|
||||||
|
assign_op = ASSIGN_OP_ADD;
|
||||||
|
}
|
||||||
if (assign_op != ASSIGN_OP_ASSIGN)
|
if (assign_op != ASSIGN_OP_ASSIGN)
|
||||||
{
|
{
|
||||||
enum hlsl_ir_expr_op op = op_from_assignment(assign_op);
|
enum hlsl_ir_expr_op op = op_from_assignment(assign_op);
|
||||||
struct hlsl_ir_node *args[3] = {lhs, rhs};
|
struct hlsl_ir_node *args[3] = {lhs, rhs};
|
||||||
struct hlsl_ir_expr *expr;
|
struct hlsl_ir_expr *expr;
|
||||||
|
|
||||||
|
assert(op);
|
||||||
if (!(expr = add_expr(ctx, instrs, op, args, &rhs->loc)))
|
if (!(expr = add_expr(ctx, instrs, op, args, &rhs->loc)))
|
||||||
return NULL;
|
return NULL;
|
||||||
rhs = &expr->node;
|
rhs = &expr->node;
|
||||||
@ -2909,7 +2920,12 @@ add_expr:
|
|||||||
}
|
}
|
||||||
| add_expr '-' mul_expr
|
| add_expr '-' mul_expr
|
||||||
{
|
{
|
||||||
$$ = add_binary_expr(ctx, $1, $3, HLSL_IR_BINOP_SUB, @2);
|
struct hlsl_ir_node *neg;
|
||||||
|
|
||||||
|
if (!(neg = hlsl_new_unary_expr(ctx, HLSL_IR_UNOP_NEG, node_from_list($3), @2)))
|
||||||
|
YYABORT;
|
||||||
|
list_add_tail($3, &neg->entry);
|
||||||
|
$$ = add_binary_expr(ctx, $1, $3, HLSL_IR_BINOP_ADD, @2);
|
||||||
}
|
}
|
||||||
|
|
||||||
shift_expr:
|
shift_expr:
|
||||||
|
@ -620,10 +620,6 @@ static void write_sm1_expr(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *b
|
|||||||
write_sm1_binary_op(ctx, buffer, D3DSIO_MUL, &instr->reg, &arg1->reg, &arg2->reg);
|
write_sm1_binary_op(ctx, buffer, D3DSIO_MUL, &instr->reg, &arg1->reg, &arg2->reg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HLSL_IR_BINOP_SUB:
|
|
||||||
write_sm1_binary_op(ctx, buffer, D3DSIO_SUB, &instr->reg, &arg1->reg, &arg2->reg);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HLSL_IR_UNOP_NEG:
|
case HLSL_IR_UNOP_NEG:
|
||||||
write_sm1_unary_op(ctx, buffer, D3DSIO_MOV, &instr->reg, &arg1->reg, D3DSPSM_NEG);
|
write_sm1_unary_op(ctx, buffer, D3DSIO_MOV, &instr->reg, &arg1->reg, D3DSPSM_NEG);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user