Module: vkd3d
Branch: master
Commit: 910aa4df01abfb2460d93e04cf398a946cc9f8e4
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=910aa4df01abfb2460d93e0…
Author: Giovanni Mascellani <gmascellani(a)codeweavers.com>
Date: Mon Aug 30 08:49:25 2021 +0200
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(a)codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
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 0d9186a..fc9b425 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};