vkd3d-compiler: Move some argument validation out of parse_command_line().

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-12-25 22:43:13 -06:00 committed by Alexandre Julliard
parent 1e2bcb0458
commit 47ea863535

View File

@ -502,23 +502,6 @@ static bool parse_command_line(int argc, char **argv, struct options *options)
if (options->target_type == VKD3D_SHADER_TARGET_NONE && !options->preprocess_only)
options->target_type = VKD3D_SHADER_TARGET_SPIRV_BINARY;
if (options->print_target_types)
return true;
if (!options->preprocess_only && !validate_target_type(options->source_type, options->target_type))
{
fprintf(stderr, "Target type '%s' is invalid for source type '%s'.\n",
get_target_type_info(options->target_type)->name,
get_source_type_info(options->source_type)->name);
return false;
}
if (!options->preprocess_only && options->source_type == VKD3D_SHADER_SOURCE_HLSL && !options->profile)
{
fprintf(stderr, "You need to specify a profile when compiling from HLSL source.\n");
return false;
}
if (optind < argc)
options->filename = argv[argc - 1];
@ -657,6 +640,20 @@ int main(int argc, char **argv)
return 0;
}
if (!options.preprocess_only && !validate_target_type(options.source_type, options.target_type))
{
fprintf(stderr, "Target type '%s' is invalid for source type '%s'.\n",
get_target_type_info(options.target_type)->name,
get_source_type_info(options.source_type)->name);
return 0;
}
if (!options.preprocess_only && options.source_type == VKD3D_SHADER_SOURCE_HLSL && !options.profile)
{
fprintf(stderr, "You need to specify a profile when compiling from HLSL source.\n");
return 0;
}
if (!(input = open_input(options.filename, &close_input)))
goto done;