vkd3d-shader/sm4: Set an error state when shader_sm4_error() is called.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2021-10-06 17:11:45 +02:00 committed by Alexandre Julliard
parent 8543a1741e
commit a0c2e52b4b
5 changed files with 13 additions and 3 deletions

View File

@ -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,

View File

@ -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");

View File

@ -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);

View File

@ -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);

View File

@ -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;