[PATCH vkd3d 3/4] vkd3d-compiler: Add support for running the HLSL preprocessor.
Zebediah Figura
zfigura at codeweavers.com
Thu Nov 26 11:54:35 CST 2020
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
programs/vkd3d-compiler/main.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/programs/vkd3d-compiler/main.c b/programs/vkd3d-compiler/main.c
index 3eee4bd2..cec2ebb1 100644
--- a/programs/vkd3d-compiler/main.c
+++ b/programs/vkd3d-compiler/main.c
@@ -163,6 +163,7 @@ static void print_usage(const char *program_name)
" Valid values are 'buffer-texture' (default) and\n"
" 'storage-buffer'.\n"
" -e, --entry=<name> Use <name> as the entry point (default is \"main\").\n"
+ " -E Preprocess the source code instead of compiling it.\n"
" -o, --output=<file> Write the output to <file>. If <file> is '-' or no\n"
" output file is specified, output will be written to\n"
" standard output.\n"
@@ -196,6 +197,7 @@ struct options
const char *profile;
enum vkd3d_shader_source_type source_type;
enum vkd3d_shader_target_type target_type;
+ bool preprocess_only;
bool print_version;
bool print_source_types;
bool print_target_types;
@@ -402,7 +404,7 @@ static bool parse_command_line(int argc, char **argv, struct options *options)
for (;;)
{
- if ((option = getopt_long(argc, argv, "b:e:ho:p:Vx:", long_options, NULL)) == -1)
+ if ((option = getopt_long(argc, argv, "b:e:Eho:p:Vx:", long_options, NULL)) == -1)
break;
switch (option)
@@ -429,6 +431,10 @@ static bool parse_command_line(int argc, char **argv, struct options *options)
options->entry_point = optarg;
break;
+ case 'E':
+ options->preprocess_only = true;
+ break;
+
case OPTION_OUTPUT:
case 'o':
options->output_filename = optarg;
@@ -669,7 +675,11 @@ int main(int argc, char **argv)
goto done;
}
- ret = vkd3d_shader_compile(&info, &output_code, &messages);
+ if (options.preprocess_only)
+ ret = vkd3d_shader_preprocess(&info, &output_code, &messages);
+ else
+ ret = vkd3d_shader_compile(&info, &output_code, &messages);
+
if (messages)
fputs(messages, stderr);
vkd3d_shader_free_messages(messages);
--
2.29.2
More information about the wine-devel
mailing list