On 4/18/22 01:34, Giovanni Mascellani wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
libs/vkd3d-shader/hlsl_codegen.c | 52 ++++++++++++++++++++++++++ tests/hlsl-matrix-indexing.shader_test | 17 +++++++++ 2 files changed, 69 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 72c00430..73e3b73f 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -672,6 +672,57 @@ static bool split_struct_copies(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr return true; }
+static unsigned int minor_size(const struct hlsl_type *type) +{
- if (type->type == HLSL_CLASS_VECTOR || type->modifiers & HLSL_MODIFIER_ROW_MAJOR)
return type->dimx;
- else
return type->dimy;
+}
+static unsigned int major_size(const struct hlsl_type *type) +{
- if (type->type == HLSL_CLASS_VECTOR || type->modifiers & HLSL_MODIFIER_ROW_MAJOR)
return type->dimy;
- else
return type->dimx;
+}
Why handle HLSL_CLASS_VECTOR in these?
+static bool split_matrix_copies(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) +{
- const struct hlsl_ir_node *rhs;
- struct hlsl_type *element_type;
- const struct hlsl_type *type;
- unsigned int i;
- struct hlsl_ir_store *store;
- if (instr->type != HLSL_IR_STORE)
return false;
- store = hlsl_ir_store(instr);
- rhs = store->rhs.node;
- type = rhs->data_type;
- if (type->type != HLSL_CLASS_MATRIX)
return false;
- element_type = hlsl_get_vector_type(ctx, type->base_type, minor_size(type));
- if (rhs->type != HLSL_IR_LOAD)
- {
hlsl_fixme(ctx, &instr->loc, "Copying from unsupported node type.\n");
return false;
- }
- for (i = 0; i < major_size(type); ++i)
- {
if (!split_copy(ctx, store, hlsl_ir_load(rhs), 4 * i, element_type))
return false;
- }
- list_remove(&store->node.entry);
- hlsl_free_instr(&store->node);
- return true;
+}