diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index e9b89547..527f69b8 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -183,6 +183,8 @@ static void VKD3D_PRINTF_FUNC(3, 4) shader_sm4_error(struct vkd3d_shader_sm4_par va_start(args, format); vkd3d_shader_verror(sm4->p.message_context, &sm4->p.location, error, format, args); va_end(args); + + sm4->p.failed = true; } static bool shader_sm4_read_src_param(struct vkd3d_shader_sm4_parser *priv, const uint32_t **ptr, @@ -1665,6 +1667,7 @@ void shader_sm4_reset(struct vkd3d_shader_parser *parser) struct vkd3d_shader_sm4_parser *sm4 = vkd3d_shader_sm4_parser(parser); parser->ptr = sm4->start; + parser->failed = false; } int vkd3d_shader_sm4_parser_create(const struct vkd3d_shader_compile_info *compile_info, diff --git a/libs/vkd3d-shader/glsl.c b/libs/vkd3d-shader/glsl.c index 9858098b..b90a5d91 100644 --- a/libs/vkd3d-shader/glsl.c +++ b/libs/vkd3d-shader/glsl.c @@ -114,8 +114,8 @@ int vkd3d_glsl_generator_generate(struct vkd3d_glsl_generator *generator, vkd3d_glsl_handle_instruction(generator, &ins); } - if (generator->failed) - return VKD3D_ERROR; + if (parser->failed || generator->failed) + return VKD3D_ERROR_INVALID_SHADER; vkd3d_string_buffer_printf(&generator->buffer, "}\n"); diff --git a/libs/vkd3d-shader/trace.c b/libs/vkd3d-shader/trace.c index 2858c7f9..57104246 100644 --- a/libs/vkd3d-shader/trace.c +++ b/libs/vkd3d-shader/trace.c @@ -1937,6 +1937,9 @@ enum vkd3d_result vkd3d_dxbc_binary_to_text(struct vkd3d_shader_parser *parser, } } + if (parser->failed) + result = VKD3D_ERROR_INVALID_SHADER; + if ((code = vkd3d_malloc(buffer->content_size))) { memcpy(code, buffer->buffer, buffer->content_size); diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index f02514b1..696c332f 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -958,7 +958,7 @@ static int scan_dxbc(const struct vkd3d_shader_compile_info *compile_info, } } - ret = VKD3D_OK; + ret = parser->failed ? VKD3D_ERROR_INVALID_SHADER : VKD3D_OK; done: vkd3d_shader_scan_context_cleanup(&context); @@ -1084,6 +1084,9 @@ static int compile_dxbc_tpf(const struct vkd3d_shader_compile_info *compile_info break; } + if (parser->failed) + ret = VKD3D_ERROR_INVALID_SHADER; + if (ret >= 0) ret = vkd3d_dxbc_compiler_generate_spirv(spirv_compiler, compile_info, out); diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index f937ff54..ba17d296 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -897,6 +897,7 @@ struct vkd3d_shader_parser { struct vkd3d_shader_message_context *message_context; struct vkd3d_shader_location location; + bool failed; struct vkd3d_shader_desc shader_desc; struct vkd3d_shader_version shader_version;