Commit fdb3db52 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

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

parent d5486b6b
......@@ -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);
......
......@@ -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"};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment