vkd3d-shader/hlsl: Do not swallow compilation errors.

There are cases where compilation fails, but no error message is
recorded. They usually correspond to unimplemented features, but
still failure should be forwarded to the caller, otherwise it will
manifest itself later in more confusing ways (like not being able
to find a function even though it was apparently correctly compiled).

Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Giovanni Mascellani 2021-08-30 08:49:25 +02:00 committed by Alexandre Julliard
parent b5251b3350
commit 910aa4df01

View File

@ -1803,7 +1803,7 @@ int hlsl_compile_shader(const struct vkd3d_shader_code *hlsl, const struct vkd3d
if (!hlsl_ctx_init(&ctx, profile, message_context)) if (!hlsl_ctx_init(&ctx, profile, message_context))
return VKD3D_ERROR_OUT_OF_MEMORY; return VKD3D_ERROR_OUT_OF_MEMORY;
if (hlsl_lexer_compile(&ctx, hlsl) == 2) if ((ret = hlsl_lexer_compile(&ctx, hlsl)) == 2)
{ {
hlsl_ctx_cleanup(&ctx); hlsl_ctx_cleanup(&ctx);
return VKD3D_ERROR_OUT_OF_MEMORY; return VKD3D_ERROR_OUT_OF_MEMORY;
@ -1815,6 +1815,14 @@ int hlsl_compile_shader(const struct vkd3d_shader_code *hlsl, const struct vkd3d
return ctx.result; return ctx.result;
} }
/* If parsing failed without an error condition being recorded, we
* plausibly hit some unimplemented feature. */
if (ret)
{
hlsl_ctx_cleanup(&ctx);
return VKD3D_ERROR_NOT_IMPLEMENTED;
}
if (!(entry_func = hlsl_get_func_decl(&ctx, entry_point))) if (!(entry_func = hlsl_get_func_decl(&ctx, entry_point)))
{ {
const struct vkd3d_shader_location loc = {.source_name = compile_info->source_name}; const struct vkd3d_shader_location loc = {.source_name = compile_info->source_name};