Zebediah Figura : d3dcompiler: Check for missing return value semantics on the entry point.

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


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

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Mon Jun  8 16:49:38 2020 -0500

d3dcompiler: Check for missing return value semantics on the entry point.

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/hlsl.y            | 42 ++++++++++++++++++++---------------
 dlls/d3dcompiler_43/tests/hlsl_d3d9.c | 12 ++++++++++
 2 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y
index 79becca257..b5057db887 100644
--- a/dlls/d3dcompiler_43/hlsl.y
+++ b/dlls/d3dcompiler_43/hlsl.y
@@ -2971,24 +2971,6 @@ struct bwriter_shader *parse_hlsl(enum shader_type type, DWORD major, DWORD mino
 
     hlsl_parse();
 
-    TRACE("Compilation status = %d\n", hlsl_ctx.status);
-    if (messages)
-    {
-        if (hlsl_ctx.messages.size)
-            *messages = hlsl_ctx.messages.string;
-        else
-            *messages = NULL;
-    }
-    else
-    {
-        if (hlsl_ctx.messages.capacity)
-            d3dcompiler_free(hlsl_ctx.messages.string);
-    }
-
-    for (i = 0; i < hlsl_ctx.source_files_count; ++i)
-        d3dcompiler_free((void *)hlsl_ctx.source_files[i]);
-    d3dcompiler_free(hlsl_ctx.source_files);
-
     if (hlsl_ctx.status == PARSE_ERR)
         goto out;
 
@@ -2998,6 +2980,13 @@ struct bwriter_shader *parse_hlsl(enum shader_type type, DWORD major, DWORD mino
         goto out;
     }
 
+    if (!type_is_void(entry_func->return_type)
+            && entry_func->return_type->type != HLSL_CLASS_STRUCT && !entry_func->semantic)
+    {
+        hlsl_report_message(entry_func->loc, HLSL_LEVEL_ERROR,
+                "entry point \"%s\" is missing a return value semantic", entry_func->func->name);
+    }
+
     /* Index 0 means unused; index 1 means function entry, so start at 2. */
     index_instructions(entry_func->body, 2);
 
@@ -3010,6 +2999,23 @@ struct bwriter_shader *parse_hlsl(enum shader_type type, DWORD major, DWORD mino
     compute_liveness(entry_func);
 
 out:
+    if (messages)
+    {
+        if (hlsl_ctx.messages.size)
+            *messages = hlsl_ctx.messages.string;
+        else
+            *messages = NULL;
+    }
+    else
+    {
+        if (hlsl_ctx.messages.capacity)
+            d3dcompiler_free(hlsl_ctx.messages.string);
+    }
+
+    for (i = 0; i < hlsl_ctx.source_files_count; ++i)
+        d3dcompiler_free((void *)hlsl_ctx.source_files[i]);
+    d3dcompiler_free(hlsl_ctx.source_files);
+
     TRACE("Freeing functions IR.\n");
     wine_rb_destroy(&hlsl_ctx.functions, free_function_rb, NULL);
 
diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c
index fba8a638b5..e82b466de2 100644
--- a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c
+++ b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c
@@ -1133,6 +1133,18 @@ static void test_fail(void)
         "{\n"
         "    return float4(0, 0, 0, 0);\n"
         "}",
+
+        /* 15 */
+        "float4 test()\n"
+        "{\n"
+        "    return float4(0, 0, 0, 0);\n"
+        "}",
+
+        "float4 test(out float4 o : SV_TARGET)\n"
+        "{\n"
+        "    o = float4(1, 1, 1, 1);\n"
+        "    return float4(0, 0, 0, 0);\n"
+        "}",
     };
 
     static const char *targets[] = {"ps_2_0", "ps_3_0", "ps_4_0"};




More information about the wine-cvs mailing list