[PATCH vkd3d v3 17/17] vkd3d-shader/hlsl: Replace register offsets with index paths in split copies.

Matteo Bruni matteo.mystral at gmail.com
Thu Jul 28 16:00:11 CDT 2022


On Wed, Jul 20, 2022 at 3:24 PM Francisco Casas <fcasas at codeweavers.com> wrote:
>
> hlsl_new_store() and hlsl_new_load() are deleted, so now there are no more
> direct ways to create derefs with offsets in hlsl.c and hlsl.h.
>
> Signed-off-by: Francisco Casas <fcasas at codeweavers.com>
> ---
>
> v3:
> * No changes.
>
> Signed-off-by: Francisco Casas <fcasas at codeweavers.com>
> ---
>  libs/vkd3d-shader/hlsl.c         | 32 -------------------------
>  libs/vkd3d-shader/hlsl.h         |  4 ----
>  libs/vkd3d-shader/hlsl_codegen.c | 40 +++++++++-----------------------
>  3 files changed, 11 insertions(+), 65 deletions(-)
>
> diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c
> index 20dcd9af..6b187e7d 100644
> --- a/libs/vkd3d-shader/hlsl.c
> +++ b/libs/vkd3d-shader/hlsl.c
> @@ -795,25 +795,6 @@ void hlsl_cleanup_deref(struct hlsl_deref *deref)
>      hlsl_src_remove(&deref->offset);
>  }
>
> -struct hlsl_ir_store *hlsl_new_store(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, struct hlsl_ir_node *offset,
> -        struct hlsl_ir_node *rhs, unsigned int writemask, struct vkd3d_shader_location loc)
> -{
> -    struct hlsl_ir_store *store;
> -
> -    if (!writemask && type_is_single_reg(rhs->data_type))
> -        writemask = (1 << rhs->data_type->dimx) - 1;
> -
> -    if (!(store = hlsl_alloc(ctx, sizeof(*store))))
> -        return NULL;
> -
> -    init_node(&store->node, HLSL_IR_STORE, NULL, loc);
> -    init_deref(ctx, &store->lhs, var, 0);
> -    hlsl_src_from_node(&store->lhs.offset, offset);
> -    hlsl_src_from_node(&store->rhs, rhs);
> -    store->writemask = writemask;
> -    return store;
> -}
> -
>  /* Initializes a simple variable derefence, so that it can be passed to load/store functions. */
>  void hlsl_init_simple_deref_from_var(struct hlsl_deref *deref, struct hlsl_ir_var *var)
>  {
> @@ -969,19 +950,6 @@ struct hlsl_ir_if *hlsl_new_if(struct hlsl_ctx *ctx, struct hlsl_ir_node *condit
>      return iff;
>  }
>
> -struct hlsl_ir_load *hlsl_new_load(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, struct hlsl_ir_node *offset,
> -        struct hlsl_type *type, const struct vkd3d_shader_location loc)
> -{
> -    struct hlsl_ir_load *load;
> -
> -    if (!(load = hlsl_alloc(ctx, sizeof(*load))))
> -        return NULL;
> -    init_node(&load->node, HLSL_IR_LOAD, type, loc);
> -    init_deref(ctx, &load->src, var, 0);
> -    hlsl_src_from_node(&load->src.offset, offset);
> -    return load;
> -}
> -
>  struct hlsl_ir_load *hlsl_new_load_index(struct hlsl_ctx *ctx, const struct hlsl_deref *deref,
>          struct hlsl_ir_node *idx, const struct vkd3d_shader_location *loc)
>  {
> diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h
> index e1ddd0cf..77005407 100644
> --- a/libs/vkd3d-shader/hlsl.h
> +++ b/libs/vkd3d-shader/hlsl.h
> @@ -774,11 +774,7 @@ struct hlsl_ir_resource_load *hlsl_new_resource_load(struct hlsl_ctx *ctx, struc
>          enum hlsl_resource_load_type type, struct hlsl_deref *resource, struct hlsl_deref *sampler,
>          struct hlsl_ir_node *coords, struct hlsl_ir_node *texel_offset, const struct vkd3d_shader_location *loc);
>
> -struct hlsl_ir_load *hlsl_new_load(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, struct hlsl_ir_node *offset,
> -        struct hlsl_type *type, struct vkd3d_shader_location loc);
>  struct hlsl_ir_loop *hlsl_new_loop(struct hlsl_ctx *ctx, struct vkd3d_shader_location loc);
> -struct hlsl_ir_store *hlsl_new_store(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, struct hlsl_ir_node *offset,
> -        struct hlsl_ir_node *rhs, unsigned int writemask, struct vkd3d_shader_location loc);
>  struct hlsl_type *hlsl_new_struct_type(struct hlsl_ctx *ctx, const char *name,
>          struct hlsl_struct_field *fields, size_t field_count);
>  struct hlsl_ir_swizzle *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned int components,
> diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c
> index 7a245007..08029361 100644
> --- a/libs/vkd3d-shader/hlsl_codegen.c
> +++ b/libs/vkd3d-shader/hlsl_codegen.c
> @@ -950,39 +950,21 @@ static bool fold_redundant_casts(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst
>   * split_matrix_copies(). Inserts new instructions right before
>   * "store". */
>  static bool split_copy(struct hlsl_ctx *ctx, struct hlsl_ir_store *store,
> -        const struct hlsl_ir_load *load, const unsigned int offset, struct hlsl_type *type)
> +        const struct hlsl_ir_load *load, const unsigned int indx, struct hlsl_type *type)

Why "indx" now?



More information about the wine-devel mailing list