Isabella Bosia : vkd3d-compiler: Validate target type.

Alexandre Julliard julliard at winehq.org
Mon Sep 7 16:07:10 CDT 2020


Module: vkd3d
Branch: master
Commit: 6d7bef1f8d406fd5563646888c4575b7143e7864
URL:    https://source.winehq.org/git/vkd3d.git/?a=commit;h=6d7bef1f8d406fd5563646888c4575b7143e7864

Author: Isabella Bosia <ibosia at codeweavers.com>
Date:   Mon Sep  7 12:35:45 2020 +0100

vkd3d-compiler: Validate target type.

Signed-off-by: Isabella Bosia <ibosia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/vkd3d-compiler/main.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/programs/vkd3d-compiler/main.c b/programs/vkd3d-compiler/main.c
index a5cf031..cb23b81 100644
--- a/programs/vkd3d-compiler/main.c
+++ b/programs/vkd3d-compiler/main.c
@@ -268,6 +268,23 @@ static const struct target_type_info *get_target_type_info(enum vkd3d_shader_tar
     return NULL;
 }
 
+static bool validate_target_type(
+        enum vkd3d_shader_source_type source_type,
+        enum vkd3d_shader_target_type target_type)
+{
+    unsigned int i, count;
+    const enum vkd3d_shader_target_type *supported_types =
+        vkd3d_shader_get_supported_target_types(source_type, &count);
+
+    for (i = 0; i < ARRAY_SIZE(target_type_info); ++i)
+    {
+        if (target_type == supported_types[i])
+            return true;
+    }
+
+    return false;
+}
+
 static bool parse_command_line(int argc, char **argv, struct options *options)
 {
     enum vkd3d_shader_compile_option_buffer_uav buffer_uav;
@@ -348,6 +365,14 @@ static bool parse_command_line(int argc, char **argv, struct options *options)
         }
     }
 
+    if (!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->print_target_types)
         return true;
 




More information about the wine-cvs mailing list