vkd3d-shader/hlsl: Use replace_ir() for hlsl_fold_constant_exprs().

This commit is contained in:
Elizabeth Figura
2025-08-20 17:50:53 -05:00
committed by Henri Verbeet
parent 6e8eeb8f7a
commit 1f40222a0d
Notes: Henri Verbeet 2025-10-28 16:58:15 +01:00
Approved-by: Francisco Casas (@fcasas)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1794
3 changed files with 9 additions and 12 deletions

View File

@@ -1835,7 +1835,8 @@ unsigned int hlsl_offset_from_deref_safe(struct hlsl_ctx *ctx, const struct hlsl
struct hlsl_reg hlsl_reg_from_deref(struct hlsl_ctx *ctx, const struct hlsl_deref *deref);
bool hlsl_copy_propagation_execute(struct hlsl_ctx *ctx, struct hlsl_block *block);
bool hlsl_fold_constant_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context);
struct hlsl_ir_node *hlsl_fold_constant_exprs(struct hlsl_ctx *ctx,
struct hlsl_ir_node *instr, struct hlsl_block *block);
struct hlsl_ir_node *hlsl_fold_constant_identities(struct hlsl_ctx *ctx,
struct hlsl_ir_node *instr, struct hlsl_block *block);
bool hlsl_normalize_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context);

View File

@@ -8470,7 +8470,7 @@ static bool simplify_exprs(struct hlsl_ctx *ctx, struct hlsl_block *block)
do
{
progress = hlsl_transform_ir(ctx, hlsl_fold_constant_exprs, block, NULL);
progress = replace_ir(ctx, hlsl_fold_constant_exprs, block);
progress |= hlsl_transform_ir(ctx, hlsl_normalize_binary_exprs, block, NULL);
progress |= hlsl_transform_ir(ctx, fold_unary_identities, block, NULL);
progress |= hlsl_transform_ir(ctx, fold_conditional_identities, block, NULL);
@@ -14849,7 +14849,7 @@ static void process_entry_function(struct hlsl_ctx *ctx, struct list *semantic_v
replace_ir(ctx, lower_int_modulus_sm1, body);
replace_ir(ctx, lower_division, body);
/* Constants casted to float must be folded, and new casts to bool also need to be lowered. */
hlsl_transform_ir(ctx, hlsl_fold_constant_exprs, body, NULL);
replace_ir(ctx, hlsl_fold_constant_exprs, body);
replace_ir(ctx, lower_casts_to_bool, body);
replace_ir(ctx, lower_casts_to_int, body);

View File

@@ -1434,11 +1434,11 @@ static bool fold_rshift(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, c
return true;
}
bool hlsl_fold_constant_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
struct hlsl_ir_node *hlsl_fold_constant_exprs(struct hlsl_ctx *ctx,
struct hlsl_ir_node *instr, struct hlsl_block *block)
{
struct hlsl_ir_constant *arg1, *arg2 = NULL, *arg3 = NULL;
struct hlsl_constant_value res = {0};
struct hlsl_ir_node *res_node;
struct hlsl_ir_expr *expr;
unsigned int i;
bool success;
@@ -1638,13 +1638,9 @@ bool hlsl_fold_constant_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
}
if (success)
{
if (!(res_node = hlsl_new_constant(ctx, instr->data_type, &res, &instr->loc)))
return false;
list_add_before(&expr->node.entry, &res_node->entry);
hlsl_replace_node(&expr->node, res_node);
}
return success;
return hlsl_block_add_constant(ctx, block, instr->data_type, &res, &instr->loc);
return NULL;
}
struct hlsl_ir_node *hlsl_fold_constant_identities(struct hlsl_ctx *ctx,