[PATCH vkd3d 06/12] vkd3d-shader/hlsl: Split matrix copies.

Matteo Bruni matteo.mystral at gmail.com
Wed Apr 20 16:00:01 CDT 2022


On Wed, Apr 20, 2022 at 8:09 PM Zebediah Figura <zfigura at codeweavers.com> wrote:
>
> On 4/18/22 01:34, Giovanni Mascellani wrote:
> > Signed-off-by: Giovanni Mascellani <gmascellani at 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?

Speaking of which, let me attach my local changes when I reviewed this patch...
-------------- next part --------------
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c
index 73e3b73f..ad456dc5 100644
--- a/libs/vkd3d-shader/hlsl_codegen.c
+++ b/libs/vkd3d-shader/hlsl_codegen.c
@@ -672,17 +672,17 @@ 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)
+static unsigned int vector_count(const struct hlsl_type *type)
 {
-    if (type->type == HLSL_CLASS_VECTOR || type->modifiers & HLSL_MODIFIER_ROW_MAJOR)
+    if (type->modifiers & HLSL_MODIFIER_ROW_MAJOR)
         return type->dimx;
     else
         return type->dimy;
 }
 
-static unsigned int major_size(const struct hlsl_type *type)
+static unsigned int vector_size(const struct hlsl_type *type)
 {
-    if (type->type == HLSL_CLASS_VECTOR || type->modifiers & HLSL_MODIFIER_ROW_MAJOR)
+    if (type->modifiers & HLSL_MODIFIER_ROW_MAJOR)
         return type->dimy;
     else
         return type->dimx;
@@ -704,7 +704,7 @@ static bool split_matrix_copies(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr
     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));
+    element_type = hlsl_get_vector_type(ctx, type->base_type, vector_size(type));
 
     if (rhs->type != HLSL_IR_LOAD)
     {
@@ -712,7 +712,7 @@ static bool split_matrix_copies(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr
         return false;
     }
 
-    for (i = 0; i < major_size(type); ++i)
+    for (i = 0; i < vector_count(type); ++i)
     {
         if (!split_copy(ctx, store, hlsl_ir_load(rhs), 4 * i, element_type))
             return false;


More information about the wine-devel mailing list