mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-compiler: Add an option to list the supported target types.
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
72db9eb19d
commit
67173a0021
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2017 Józef Kucia for CodeWeavers
|
||||
* Copyright 2020 Henri Verbeet for CodeWeavers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -35,6 +36,7 @@ enum
|
||||
OPTION_BUFFER_UAV,
|
||||
OPTION_OUTPUT,
|
||||
OPTION_PRINT_SOURCE_TYPES,
|
||||
OPTION_PRINT_TARGET_TYPES,
|
||||
OPTION_STRIP_DEBUG,
|
||||
OPTION_VERSION,
|
||||
};
|
||||
@ -52,6 +54,19 @@ source_type_info[] =
|
||||
" This is the format used for Direct3D shader model 4 and 5 shaders."},
|
||||
};
|
||||
|
||||
static const struct
|
||||
{
|
||||
enum vkd3d_shader_target_type type;
|
||||
const char *name;
|
||||
const char *description;
|
||||
}
|
||||
target_type_info[] =
|
||||
{
|
||||
{VKD3D_SHADER_TARGET_SPIRV_BINARY,
|
||||
"spirv-binary", "A SPIR-V shader in binary form.\n"
|
||||
" This is the format used for Vulkan shaders.\n"},
|
||||
};
|
||||
|
||||
static bool read_shader(struct vkd3d_shader_code *shader, const char *filename)
|
||||
{
|
||||
struct stat st;
|
||||
@ -121,6 +136,8 @@ static void print_usage(const char *program_name)
|
||||
" 'storage-buffer'.\n"
|
||||
" -o, --output=<file> Write the output to <file>.\n"
|
||||
" --print-source-types Display the supported source types and exit.\n"
|
||||
" --print-target-types Display the supported target types for the specified\n"
|
||||
" source type and exit.\n"
|
||||
" --strip-debug Strip debug information from the output.\n"
|
||||
" -V, --version Display version information and exit.\n"
|
||||
" -x <type> Specify the type of the source. Valid values are\n"
|
||||
@ -138,6 +155,7 @@ struct options
|
||||
enum vkd3d_shader_source_type source_type;
|
||||
bool print_version;
|
||||
bool print_source_types;
|
||||
bool print_target_types;
|
||||
|
||||
struct vkd3d_shader_compile_option compile_options[MAX_COMPILE_OPTIONS];
|
||||
unsigned int compile_option_count;
|
||||
@ -215,6 +233,7 @@ static bool parse_command_line(int argc, char **argv, struct options *options)
|
||||
{"buffer-uav", required_argument, NULL, OPTION_BUFFER_UAV},
|
||||
{"output", required_argument, NULL, OPTION_OUTPUT},
|
||||
{"print-source-types", no_argument, NULL, OPTION_PRINT_SOURCE_TYPES},
|
||||
{"print-target-types", no_argument, NULL, OPTION_PRINT_TARGET_TYPES},
|
||||
{"strip-debug", no_argument, NULL, OPTION_STRIP_DEBUG},
|
||||
{"version", no_argument, NULL, OPTION_VERSION},
|
||||
{NULL, 0, NULL, 0},
|
||||
@ -248,6 +267,10 @@ static bool parse_command_line(int argc, char **argv, struct options *options)
|
||||
options->print_source_types = true;
|
||||
return true;
|
||||
|
||||
case OPTION_PRINT_TARGET_TYPES:
|
||||
options->print_target_types = true;
|
||||
break;
|
||||
|
||||
case OPTION_STRIP_DEBUG:
|
||||
add_compile_option(options, VKD3D_SHADER_COMPILE_OPTION_STRIP_DEBUG, 1);
|
||||
break;
|
||||
@ -270,6 +293,9 @@ static bool parse_command_line(int argc, char **argv, struct options *options)
|
||||
}
|
||||
}
|
||||
|
||||
if (options->print_target_types)
|
||||
return true;
|
||||
|
||||
if (optind >= argc)
|
||||
return false;
|
||||
|
||||
@ -298,6 +324,36 @@ static void print_source_types(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void print_target_types(enum vkd3d_shader_source_type source_type)
|
||||
{
|
||||
const enum vkd3d_shader_target_type *target_types;
|
||||
const char *source_type_name;
|
||||
unsigned int count, i, j;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(source_type_info); ++i)
|
||||
{
|
||||
if (source_type == source_type_info[i].type)
|
||||
{
|
||||
source_type_name = source_type_info[i].name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
target_types = vkd3d_shader_get_supported_target_types(source_type, &count);
|
||||
fprintf(stdout, "Supported target types for source type '%s':\n", source_type_name);
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
for (j = 0; j < ARRAY_SIZE(target_type_info); ++j)
|
||||
{
|
||||
if (target_types[i] == target_type_info[j].type)
|
||||
{
|
||||
fprintf(stdout, " %s %s", target_type_info[j].name, target_type_info[j].description);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct vkd3d_shader_compile_info info;
|
||||
@ -326,6 +382,12 @@ int main(int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (options.print_target_types)
|
||||
{
|
||||
print_target_types(options.source_type);
|
||||
return 0;
|
||||
}
|
||||
|
||||
info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO;
|
||||
info.next = NULL;
|
||||
info.source_type = options.source_type;
|
||||
|
Loading…
x
Reference in New Issue
Block a user