[PATCH vkd3d 6/8] vkd3d-compiler: Validate target type.
Isabella Bosia
ibosia at codeweavers.com
Mon Sep 7 06:35:45 CDT 2020
Signed-off-by: Isabella Bosia <ibosia at codeweavers.com>
---
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;
--
2.25.1
More information about the wine-devel
mailing list