mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Fold constant integral max().
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
0ddaa80616
commit
8cb865d65a
@ -369,6 +369,35 @@ static bool fold_mod(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool fold_max(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst,
|
||||||
|
struct hlsl_ir_constant *src1, struct hlsl_ir_constant *src2)
|
||||||
|
{
|
||||||
|
enum hlsl_base_type type = dst->node.data_type->base_type;
|
||||||
|
unsigned int k;
|
||||||
|
|
||||||
|
assert(type == src1->node.data_type->base_type);
|
||||||
|
assert(type == src2->node.data_type->base_type);
|
||||||
|
|
||||||
|
for (k = 0; k < dst->node.data_type->dimx; ++k)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case HLSL_TYPE_INT:
|
||||||
|
dst->value[k].i = max(src1->value[k].i, src2->value[k].i);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HLSL_TYPE_UINT:
|
||||||
|
dst->value[k].u = max(src1->value[k].u, src2->value[k].u);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
FIXME("Fold max for type %s.\n", debug_hlsl_type(ctx, dst->node.data_type));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool hlsl_fold_constant_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
|
bool hlsl_fold_constant_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
|
||||||
{
|
{
|
||||||
struct hlsl_ir_constant *arg1, *arg2 = NULL, *res;
|
struct hlsl_ir_constant *arg1, *arg2 = NULL, *res;
|
||||||
@ -430,6 +459,10 @@ bool hlsl_fold_constant_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
|
|||||||
success = fold_mod(ctx, res, arg1, arg2);
|
success = fold_mod(ctx, res, arg1, arg2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case HLSL_OP2_MAX:
|
||||||
|
success = fold_max(ctx, res, arg1, arg2);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
FIXME("Fold \"%s\" expression.\n", debug_hlsl_expr_op(expr->op));
|
FIXME("Fold \"%s\" expression.\n", debug_hlsl_expr_op(expr->op));
|
||||||
success = false;
|
success = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user