From 32e6a1bb4d0f5f06c5b7ce99dabb68eac5397528 Mon Sep 17 00:00:00 2001 From: Elizabeth Figura Date: Fri, 4 Oct 2024 18:09:05 -0500 Subject: [PATCH] vkd3d-shader: Validate the parsed shader in vsir_parse(). --- libs/vkd3d-shader/d3dbc.c | 12 ------------ libs/vkd3d-shader/dxil.c | 15 --------------- libs/vkd3d-shader/tpf.c | 12 ------------ libs/vkd3d-shader/vkd3d_shader_main.c | 13 +++++++++++++ libs/vkd3d-shader/vkd3d_shader_private.h | 6 ------ 5 files changed, 13 insertions(+), 45 deletions(-) diff --git a/libs/vkd3d-shader/d3dbc.c b/libs/vkd3d-shader/d3dbc.c index bbebf86e..9e2eacbc 100644 --- a/libs/vkd3d-shader/d3dbc.c +++ b/libs/vkd3d-shader/d3dbc.c @@ -1391,18 +1391,6 @@ int d3dbc_parse(const struct vkd3d_shader_compile_info *compile_info, uint64_t c if (ret < 0) { - WARN("Failed to parse shader.\n"); - vsir_program_cleanup(program); - return ret; - } - - if ((ret = vkd3d_shader_parser_validate(&sm1.p, config_flags)) < 0) - { - WARN("Failed to validate shader after parsing, ret %d.\n", ret); - - if (TRACE_ON()) - vsir_program_trace(program); - vsir_program_cleanup(program); return ret; } diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index 570af5ec..3235a278 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -10603,22 +10603,7 @@ int dxil_parse(const struct vkd3d_shader_compile_info *compile_info, uint64_t co vkd3d_free(byte_code); if (ret < 0) - { - WARN("Failed to parse shader.\n"); return ret; - } - - if ((ret = vkd3d_shader_parser_validate(&sm6.p, config_flags)) < 0) - { - WARN("Failed to validate shader after parsing, ret %d.\n", ret); - - if (TRACE_ON()) - vsir_program_trace(program); - - sm6_parser_cleanup(&sm6); - vsir_program_cleanup(program); - return ret; - } sm6_parser_cleanup(&sm6); diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index 67ae3247..5c1b1763 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -2964,22 +2964,10 @@ int tpf_parse(const struct vkd3d_shader_compile_info *compile_info, uint64_t con if (sm4.p.failed) { - WARN("Failed to parse shader.\n"); vsir_program_cleanup(program); return VKD3D_ERROR_INVALID_SHADER; } - if ((ret = vkd3d_shader_parser_validate(&sm4.p, config_flags)) < 0) - { - WARN("Failed to validate shader after parsing, ret %d.\n", ret); - - if (TRACE_ON()) - vsir_program_trace(program); - - vsir_program_cleanup(program); - return ret; - } - return VKD3D_OK; } diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index a5992c4f..0d577cf1 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -706,7 +706,20 @@ static enum vkd3d_result vsir_parse(const struct vkd3d_shader_compile_info *comp } if (ret < 0) + { WARN("Failed to parse shader.\n"); + return ret; + } + + if ((ret = vsir_program_validate(program, config_flags, compile_info->source_name, message_context)) < 0) + { + WARN("Failed to validate shader after parsing, ret %d.\n", ret); + + if (TRACE_ON()) + vsir_program_trace(program); + + vsir_program_cleanup(program); + } return ret; } diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 00d1d858..b7a153cb 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -1477,12 +1477,6 @@ void vkd3d_shader_parser_init(struct vkd3d_shader_parser *parser, struct vsir_pr void vkd3d_shader_parser_warning(struct vkd3d_shader_parser *parser, enum vkd3d_shader_error error, const char *format, ...) VKD3D_PRINTF_FUNC(3, 4); -static inline enum vkd3d_result vkd3d_shader_parser_validate(struct vkd3d_shader_parser *parser, uint64_t config_flags) -{ - return vsir_program_validate(parser->program, config_flags, - parser->location.source_name, parser->message_context); -} - struct vkd3d_shader_descriptor_info1 { enum vkd3d_shader_descriptor_type type;