[PATCH vkd3d v3 1/3] vkd3d-shader/hlsl: Move replace_node() to hlsl.c.
Giovanni Mascellani
gmascellani at codeweavers.com
Fri Feb 11 02:32:11 CST 2022
Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
Il 11/02/22 04:48, Zebediah Figura ha scritto:
> From: Francisco Casas <fcasas at codeweavers.com>
>
> Also rename it to hlsl_replace_node().
>
> Signed-off-by: Francisco Casas <fcasas at codeweavers.com>
> Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
> ---
> libs/vkd3d-shader/hlsl.c | 14 ++++++++++++++
> libs/vkd3d-shader/hlsl.h | 2 ++
> libs/vkd3d-shader/hlsl_codegen.c | 25 ++++++-------------------
> 3 files changed, 22 insertions(+), 19 deletions(-)
>
> diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c
> index 8a0f4b017..a9a427707 100644
> --- a/libs/vkd3d-shader/hlsl.c
> +++ b/libs/vkd3d-shader/hlsl.c
> @@ -1400,6 +1400,20 @@ void hlsl_dump_function(struct hlsl_ctx *ctx, const struct hlsl_ir_function_decl
> vkd3d_string_buffer_cleanup(&buffer);
> }
>
> +void hlsl_replace_node(struct hlsl_ir_node *old, struct hlsl_ir_node *new)
> +{
> + struct hlsl_src *src, *next;
> +
> + LIST_FOR_EACH_ENTRY_SAFE(src, next, &old->uses, struct hlsl_src, entry)
> + {
> + hlsl_src_remove(src);
> + hlsl_src_from_node(src, new);
> + }
> + list_remove(&old->entry);
> + hlsl_free_instr(old);
> +}
> +
> +
> void hlsl_free_type(struct hlsl_type *type)
> {
> struct hlsl_struct_field *field, *next_field;
> diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h
> index 3a69165e5..67fe1a8d5 100644
> --- a/libs/vkd3d-shader/hlsl.h
> +++ b/libs/vkd3d-shader/hlsl.h
> @@ -713,6 +713,8 @@ void hlsl_dump_function(struct hlsl_ctx *ctx, const struct hlsl_ir_function_decl
>
> int hlsl_emit_dxbc(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func, struct vkd3d_shader_code *out);
>
> +void hlsl_replace_node(struct hlsl_ir_node *old, struct hlsl_ir_node *new);
> +
> void hlsl_free_instr(struct hlsl_ir_node *node);
> void hlsl_free_instr_list(struct list *list);
> void hlsl_free_type(struct hlsl_type *type);
> diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c
> index eac3513c9..77ddd979a 100644
> --- a/libs/vkd3d-shader/hlsl_codegen.c
> +++ b/libs/vkd3d-shader/hlsl_codegen.c
> @@ -224,19 +224,6 @@ static bool transform_ir(struct hlsl_ctx *ctx, bool (*func)(struct hlsl_ctx *ctx
> return progress;
> }
>
> -static void replace_node(struct hlsl_ir_node *old, struct hlsl_ir_node *new)
> -{
> - struct hlsl_src *src, *next;
> -
> - LIST_FOR_EACH_ENTRY_SAFE(src, next, &old->uses, struct hlsl_src, entry)
> - {
> - hlsl_src_remove(src);
> - hlsl_src_from_node(src, new);
> - }
> - list_remove(&old->entry);
> - hlsl_free_instr(old);
> -}
> -
> /* Lower casts from vec1 to vecN to swizzles. */
> static bool lower_broadcasts(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
> {
> @@ -267,7 +254,7 @@ static bool lower_broadcasts(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, v
> return false;
> list_add_after(&new_cast->node.entry, &swizzle->node.entry);
>
> - replace_node(&cast->node, &swizzle->node);
> + hlsl_replace_node(&cast->node, &swizzle->node);
> return true;
> }
>
> @@ -437,7 +424,7 @@ static bool copy_propagation_transform_load(struct hlsl_ctx *ctx,
> list_add_before(&node->entry, &swizzle_node->node.entry);
> new_node = &swizzle_node->node;
> }
> - replace_node(node, new_node);
> + hlsl_replace_node(node, new_node);
> return true;
> }
>
> @@ -566,7 +553,7 @@ static bool fold_redundant_casts(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst
> if (hlsl_types_are_equal(src_type, dst_type)
> || (src_type->base_type == dst_type->base_type && is_vec1(src_type) && is_vec1(dst_type)))
> {
> - replace_node(&expr->node, expr->operands[0].node);
> + hlsl_replace_node(&expr->node, expr->operands[0].node);
> return true;
> }
> }
> @@ -708,7 +695,7 @@ static bool lower_narrowing_casts(struct hlsl_ctx *ctx, struct hlsl_ir_node *ins
> return false;
> list_add_after(&new_cast->node.entry, &swizzle->node.entry);
>
> - replace_node(&cast->node, &swizzle->node);
> + hlsl_replace_node(&cast->node, &swizzle->node);
> return true;
> }
>
> @@ -842,7 +829,7 @@ static bool fold_constants(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, voi
> }
>
> list_add_before(&expr->node.entry, &res->node.entry);
> - replace_node(&expr->node, &res->node);
> + hlsl_replace_node(&expr->node, &res->node);
> return true;
> }
>
> @@ -862,7 +849,7 @@ static bool remove_trivial_swizzles(struct hlsl_ctx *ctx, struct hlsl_ir_node *i
> if (((swizzle->swizzle >> (2 * i)) & 3) != i)
> return false;
>
> - replace_node(instr, swizzle->val.node);
> + hlsl_replace_node(instr, swizzle->val.node);
>
> return true;
> }
More information about the wine-devel
mailing list