mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Add constant folding for 'fract'.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
parent
c69562128a
commit
c16c5caad8
Notes:
Alexandre Julliard
2023-09-22 22:47:14 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Zebediah Figura (@zfigura) Approved-by: Francisco Casas (@fcasas) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/341
@ -202,6 +202,33 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool fold_fract(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
|
||||||
|
const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src)
|
||||||
|
{
|
||||||
|
enum hlsl_base_type type = dst_type->base_type;
|
||||||
|
unsigned int k;
|
||||||
|
float i;
|
||||||
|
|
||||||
|
assert(type == src->node.data_type->base_type);
|
||||||
|
|
||||||
|
for (k = 0; k < dst_type->dimx; ++k)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case HLSL_TYPE_FLOAT:
|
||||||
|
case HLSL_TYPE_HALF:
|
||||||
|
dst->u[k].f = modff(src->value.u[k].f, &i);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
FIXME("Fold 'fract' for type %s.\n", debug_hlsl_type(ctx, dst_type));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool fold_log2(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type,
|
static bool fold_log2(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type,
|
||||||
const struct hlsl_ir_constant *src, const struct vkd3d_shader_location *loc)
|
const struct hlsl_ir_constant *src, const struct vkd3d_shader_location *loc)
|
||||||
{
|
{
|
||||||
@ -996,6 +1023,10 @@ bool hlsl_fold_constant_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
|
|||||||
success = fold_cast(ctx, &res, instr->data_type, arg1);
|
success = fold_cast(ctx, &res, instr->data_type, arg1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case HLSL_OP1_FRACT:
|
||||||
|
success = fold_fract(ctx, &res, instr->data_type, arg1);
|
||||||
|
break;
|
||||||
|
|
||||||
case HLSL_OP1_LOG2:
|
case HLSL_OP1_LOG2:
|
||||||
success = fold_log2(ctx, &res, instr->data_type, arg1, &instr->loc);
|
success = fold_log2(ctx, &res, instr->data_type, arg1, &instr->loc);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user