Zebediah Figura : d3dcompiler: Cache vector types.

Alexandre Julliard julliard at winehq.org
Thu Jun 11 15:26:47 CDT 2020


Module: wine
Branch: master
Commit: 10601d9ac5af89d55462a220524afd02d741eae2
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=10601d9ac5af89d55462a220524afd02d741eae2

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Thu Jun 11 21:44:10 2020 +0200

d3dcompiler: Cache vector types.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/d3dcompiler_43/d3dcompiler_private.h |  1 +
 dlls/d3dcompiler_43/hlsl.y                |  1 +
 dlls/d3dcompiler_43/utils.c               | 12 +++---------
 3 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h
index a61b84d6b5..970150bbc5 100644
--- a/dlls/d3dcompiler_43/d3dcompiler_private.h
+++ b/dlls/d3dcompiler_43/d3dcompiler_private.h
@@ -988,6 +988,7 @@ struct hlsl_parse_ctx
     struct
     {
         struct hlsl_type *scalar[HLSL_TYPE_LAST_SCALAR + 1];
+        struct hlsl_type *vector[HLSL_TYPE_LAST_SCALAR + 1][4];
         struct hlsl_type *sampler[HLSL_SAMPLER_DIM_MAX + 1];
         struct hlsl_type *Void;
     } builtin_types;
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y
index 436b731fd1..83aa95b54f 100644
--- a/dlls/d3dcompiler_43/hlsl.y
+++ b/dlls/d3dcompiler_43/hlsl.y
@@ -237,6 +237,7 @@ static void declare_predefined_types(struct hlsl_scope *scope)
                     sprintf(name, "%s%u", names[bt], x);
                     type = new_hlsl_type(d3dcompiler_strdup(name), HLSL_CLASS_VECTOR, bt, x, y);
                     add_type_to_scope(scope, type);
+                    hlsl_ctx.builtin_types.vector[bt][x - 1] = type;
 
                     if (x == 1)
                     {
diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c
index 97e3cdf1a3..c3dbd505f2 100644
--- a/dlls/d3dcompiler_43/utils.c
+++ b/dlls/d3dcompiler_43/utils.c
@@ -1296,6 +1296,8 @@ static struct hlsl_type *expr_common_type(struct hlsl_type *t1, struct hlsl_type
 
     if (type == HLSL_CLASS_SCALAR)
         return hlsl_ctx.builtin_types.scalar[base];
+    if (type == HLSL_CLASS_VECTOR)
+        return hlsl_ctx.builtin_types.vector[base][dimx - 1];
     return new_hlsl_type(NULL, type, base, dimx, dimy);
 }
 
@@ -1495,15 +1497,7 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *lhs, enum parse_assign
             }
             assert(swizzle_type->type == HLSL_CLASS_VECTOR);
             if (swizzle_type->dimx != width)
-            {
-                struct hlsl_type *type;
-                if (!(type = new_hlsl_type(NULL, HLSL_CLASS_VECTOR, swizzle_type->base_type, width, 1)))
-                {
-                    d3dcompiler_free(assign);
-                    return NULL;
-                }
-                swizzle->node.data_type = type;
-            }
+                swizzle->node.data_type = hlsl_ctx.builtin_types.vector[swizzle_type->base_type][width - 1];
             rhs = &swizzle->node;
         }
         else




More information about the wine-cvs mailing list