mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/hlsl: Implement constant folding of 'reinterpret' expressions.
As encountered in tests/hlsl/frexp.shader_test.
This commit is contained in:
Notes:
Henri Verbeet
2025-09-09 15:10:32 +02:00
Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1716
@@ -508,6 +508,19 @@ static bool fold_rcp(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, cons
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool fold_reinterpret(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
|
||||
const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src)
|
||||
{
|
||||
unsigned int k;
|
||||
|
||||
for (k = 0; k < dst_type->e.numeric.dimx; ++k)
|
||||
{
|
||||
dst->u[k] = src->value.u[k];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool fold_rsq(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)
|
||||
{
|
||||
@@ -1393,6 +1406,10 @@ bool hlsl_fold_constant_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
|
||||
success = fold_rcp(ctx, &res, instr->data_type, arg1, &instr->loc);
|
||||
break;
|
||||
|
||||
case HLSL_OP1_REINTERPRET:
|
||||
success = fold_reinterpret(ctx, &res, instr->data_type, arg1);
|
||||
break;
|
||||
|
||||
case HLSL_OP1_RSQ:
|
||||
success = fold_rsq(ctx, &res, instr->data_type, arg1, &instr->loc);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user