From 910aa4df01abfb2460d93e04cf398a946cc9f8e4 Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Mon, 30 Aug 2021 08:49:25 +0200 Subject: [PATCH] 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 Signed-off-by: Henri Verbeet Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- libs/vkd3d-shader/hlsl.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 0d9186ae..fc9b4256 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -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)) 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); 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; } + /* 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))) { const struct vkd3d_shader_location loc = {.source_name = compile_info->source_name};