[PATCH vkd3d 11/12] vkd3d-shader/hlsl: Replace register offsets with index paths in input/output copies.
Giovanni Mascellani
gmascellani at codeweavers.com
Thu Jul 14 07:01:38 CDT 2022
Hi,
Il 01/07/22 23:24, Francisco Casas ha scritto:
> +static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_load *lhs,
> + struct hlsl_type *type, unsigned int modifiers, const struct hlsl_semantic *semantic)
> {
> - struct hlsl_ir_constant *offset;
> - struct hlsl_ir_store *store;
> - struct hlsl_ir_load *load;
> - struct hlsl_ir_var *input;
> + struct hlsl_type *vector_type = hlsl_get_vector_type(ctx, type->base_type, hlsl_type_minor_size(type));
> + struct hlsl_ir_var *var = lhs->src.var;
> + unsigned int i;
>
> - if (type->type == HLSL_CLASS_MATRIX)
> + for (i = 0; i < hlsl_type_major_size(type); ++i)
> {
> - struct hlsl_type *vector_type = hlsl_get_vector_type(ctx, type->base_type, hlsl_type_minor_size(type));
> - struct hlsl_semantic vector_semantic = *semantic;
> - unsigned int i;
> + struct hlsl_semantic semantic_copy = *semantic;
> + struct hlsl_ir_store *store;
> + struct hlsl_ir_constant *c;
> + struct hlsl_ir_var *input;
> + struct hlsl_ir_load *load;
>
> - for (i = 0; i < hlsl_type_major_size(type); ++i)
> - {
> - prepend_input_copy(ctx, instrs, var, vector_type, 4 * i, modifiers, &vector_semantic);
> - ++vector_semantic.index;
> - }
> -
> - return;
> - }
> + semantic_copy.index = semantic->index + i;
>
> - if (!(input = add_extern_var(ctx, var, type, modifiers, semantic, false)))
> - return;
> + if (!(input = add_extern_var(ctx, var, vector_type, modifiers, &semantic_copy, false)))
> + return;
>
> - if (!(load = hlsl_new_var_load(ctx, input, var->loc)))
> - return;
> - list_add_head(instrs, &load->node.entry);
> + if (!(load = hlsl_new_var_load(ctx, input, var->loc)))
> + return;
> + list_add_after(&lhs->node.entry, &load->node.entry);
>
> - if (!(offset = hlsl_new_uint_constant(ctx, field_offset, &var->loc)))
> - return;
> - list_add_after(&load->node.entry, &offset->node.entry);
> + if (type->type == HLSL_CLASS_MATRIX)
> + {
> + if (!(c = hlsl_new_uint_constant(ctx, i, &var->loc)))
> + return;
> + list_add_after(&load->node.entry, &c->node.entry);
>
> - if (!(store = hlsl_new_store(ctx, var, &offset->node, &load->node, 0, var->loc)))
> - return;
> - list_add_after(&offset->node.entry, &store->node.entry);
> + if (!(store = hlsl_new_store_index(ctx, &lhs->src, &c->node, &load->node, 0, var->loc)))
> + return;
> + list_add_after(&c->node.entry, &store->node.entry);
> + }
> + else
> + {
> + if (!(store = hlsl_new_store_index(ctx, &lhs->src, NULL, &load->node, 0, var->loc)))
> + return;
> + list_add_after(&load->node.entry, &store->node.entry);
This branch (i.e., not a matrix) can only happen when i == 0, right? In
this case, I'd put an "assert(i == 0);", just to give a little help to
the reader wandering around here.
Same thing for output variables.
> + }
> + }
> }
Thanks, Giovanni.
More information about the wine-devel
mailing list