[PATCH vkd3d v3 2/3] vkd3d-compiler: Move some argument validation out of parse_command_line().

Zebediah Figura zfigura at codeweavers.com
Sat Dec 25 22:43:13 CST 2021


Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 programs/vkd3d-compiler/main.c | 31 ++++++++++++++-----------------
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/programs/vkd3d-compiler/main.c b/programs/vkd3d-compiler/main.c
index 4e56e8fa5..5607c29d9 100644
--- a/programs/vkd3d-compiler/main.c
+++ b/programs/vkd3d-compiler/main.c
@@ -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;
 
-- 
2.34.1




More information about the wine-devel mailing list