vkd3d-shader/hlsl: Fold some general conditional identities.

The following conditional identities are applied:

  c ? x : x -> x
  false ? x : y -> y; true ? x : y -> x
  c ? true : false -> c; c ? false : true -> !c
  !c ? x : y -> c ? y : x

Lastly, for expression chains x, y in a conditional expression
  c ? x : y,
we evaluate all conditionals in the expression chains with the
condition c, assuming c is true (for x), or false (for y).
This commit is contained in:
Shaun Ren
2025-08-01 19:24:12 -04:00
committed by Henri Verbeet
parent 245430002a
commit 320c3c9652
Notes: Henri Verbeet 2025-08-21 16:34:35 +02:00
Approved-by: Francisco Casas (@fcasas)
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1648
5 changed files with 352 additions and 74 deletions

View File

@@ -1699,6 +1699,9 @@ struct hlsl_type *hlsl_new_stream_output_type(struct hlsl_ctx *ctx,
struct hlsl_ir_node *hlsl_new_ternary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op,
struct hlsl_ir_node *arg1, struct hlsl_ir_node *arg2, struct hlsl_ir_node *arg3);
bool hlsl_constant_is_zero(struct hlsl_ir_constant *c);
bool hlsl_constant_is_one(struct hlsl_ir_constant *c);
void hlsl_init_simple_deref_from_var(struct hlsl_deref *deref, struct hlsl_ir_var *var);
struct hlsl_ir_load *hlsl_new_var_load(struct hlsl_ctx *ctx, struct hlsl_ir_var *var,