Zebediah Figura : d3dcompiler: Allow hlsl_ir_constant to contain only scalar and vector constants.

Alexandre Julliard julliard at winehq.org
Wed Jul 8 15:34:35 CDT 2020


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

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Sun Jul  5 17:45:34 2020 -0500

d3dcompiler: Allow hlsl_ir_constant to contain only scalar and vector constants.

We only emit scalar constants at parse time, and while there's certainly an
advantage to vectorizing constant instructions, there's not much point in
having hlsl_ir_constant hold matrices. Matrices should be lowered to vector
operations first.

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 | 10 +++---
 dlls/d3dcompiler_43/utils.c               | 51 +++++++++++++------------------
 2 files changed, 27 insertions(+), 34 deletions(-)

diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h
index 23eff21094..3e91f74645 100644
--- a/dlls/d3dcompiler_43/d3dcompiler_private.h
+++ b/dlls/d3dcompiler_43/d3dcompiler_private.h
@@ -874,11 +874,11 @@ struct hlsl_ir_constant
     struct hlsl_ir_node node;
     union
     {
-        unsigned u[16];
-        int i[16];
-        float f[16];
-        double d[16];
-        BOOL b[16];
+        unsigned u[4];
+        int i[4];
+        float f[4];
+        double d[4];
+        BOOL b[4];
     } value;
 };
 
diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c
index 4bc3b9b0a6..7f0c451ce9 100644
--- a/dlls/d3dcompiler_43/utils.c
+++ b/dlls/d3dcompiler_43/utils.c
@@ -1823,41 +1823,34 @@ static void debug_dump_deref(const struct hlsl_deref *deref)
 static void debug_dump_ir_constant(const struct hlsl_ir_constant *constant)
 {
     struct hlsl_type *type = constant->node.data_type;
-    unsigned int x, y;
+    unsigned int x;
 
-    if (type->dimy != 1)
+    if (type->dimx != 1)
         wine_dbg_printf("{");
-    for (y = 0; y < type->dimy; ++y)
+    for (x = 0; x < type->dimx; ++x)
     {
-        if (type->dimx != 1)
-            wine_dbg_printf("{");
-        for (x = 0; x < type->dimx; ++x)
+        switch (type->base_type)
         {
-            switch (type->base_type)
-            {
-                case HLSL_TYPE_FLOAT:
-                    wine_dbg_printf("%.8e ", constant->value.f[y * type->dimx + x]);
-                    break;
-                case HLSL_TYPE_DOUBLE:
-                    wine_dbg_printf("%.16e ", constant->value.d[y * type->dimx + x]);
-                    break;
-                case HLSL_TYPE_INT:
-                    wine_dbg_printf("%d ", constant->value.i[y * type->dimx + x]);
-                    break;
-                case HLSL_TYPE_UINT:
-                    wine_dbg_printf("%u ", constant->value.u[y * type->dimx + x]);
-                    break;
-                case HLSL_TYPE_BOOL:
-                    wine_dbg_printf("%s ", constant->value.b[y * type->dimx + x] == FALSE ? "false" : "true");
-                    break;
-                default:
-                    wine_dbg_printf("Constants of type %s not supported\n", debug_base_type(type));
-            }
+            case HLSL_TYPE_FLOAT:
+                wine_dbg_printf("%.8e ", constant->value.f[x]);
+                break;
+            case HLSL_TYPE_DOUBLE:
+                wine_dbg_printf("%.16e ", constant->value.d[x]);
+                break;
+            case HLSL_TYPE_INT:
+                wine_dbg_printf("%d ", constant->value.i[x]);
+                break;
+            case HLSL_TYPE_UINT:
+                wine_dbg_printf("%u ", constant->value.u[x]);
+                break;
+            case HLSL_TYPE_BOOL:
+                wine_dbg_printf("%s ", constant->value.b[x] ? "true" : "false");
+                break;
+            default:
+                wine_dbg_printf("Constants of type %s not supported\n", debug_base_type(type));
         }
-        if (type->dimx != 1)
-            wine_dbg_printf("}");
     }
-    if (type->dimy != 1)
+    if (type->dimx != 1)
         wine_dbg_printf("}");
 }
 




More information about the wine-cvs mailing list