[PATCH vkd3d 1/6] vkd3d-shader: Correctly dump array types.

Zebediah Figura zfigura at codeweavers.com
Tue Feb 16 23:52:04 CST 2021


Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 libs/vkd3d-shader/hlsl.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c
index f181439c..342fe6af 100644
--- a/libs/vkd3d-shader/hlsl.c
+++ b/libs/vkd3d-shader/hlsl.c
@@ -693,10 +693,27 @@ char *hlsl_type_to_string(const struct hlsl_type *type)
             return string;
 
         case HLSL_CLASS_ARRAY:
-            name = hlsl_base_type_to_string(type->e.array.type);
-            if ((string = malloc(strlen(name) + 15)))
-                sprintf(string, "%s[%u]", name, type->e.array.elements_count);
+        {
+            const struct hlsl_type *t;
+            char *inner_string;
+            size_t len = 1;
+
+            for (t = type; t->type == HLSL_CLASS_ARRAY; t = t->e.array.type)
+                len += 14;
+            if (!(inner_string = hlsl_type_to_string(t)))
+                return NULL;
+            len += strlen(inner_string);
+
+            if ((string = malloc(len)))
+            {
+                strcpy(string, inner_string);
+                for (t = type; t->type == HLSL_CLASS_ARRAY; t = t->e.array.type)
+                    sprintf(string + strlen(string), "[%u]", t->e.array.elements_count);
+            }
+
+            vkd3d_free(inner_string);
             return string;
+        }
 
         case HLSL_CLASS_STRUCT:
             return vkd3d_strdup("<anonymous struct>");
-- 
2.30.1




More information about the wine-devel mailing list