Signed-off-by: Isabella Bosia ibosia@codeweavers.com --- libs/vkd3d-shader/spirv.c | 46 ++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 10 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index bb251a4..6a6d187 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -50,36 +50,62 @@ static spv_target_env spv_target_env_from_vkd3d(enum vkd3d_shader_spirv_environm } }
-static void vkd3d_spirv_dump(const struct vkd3d_shader_code *spirv, enum vkd3d_shader_spirv_environment environment) +static enum vkd3d_result vkd3d_spirv_binary_to_text(const struct vkd3d_shader_code *spirv, + enum vkd3d_shader_spirv_environment environment, uint32_t options, struct vkd3d_shader_code *out) { - const static uint32_t options - = SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES | SPV_BINARY_TO_TEXT_OPTION_INDENT; spv_diagnostic diagnostic = NULL; spv_text text = NULL; spv_context context; - spv_result_t ret; + spv_result_t spvret; + enum vkd3d_result result = VKD3D_OK;
context = spvContextCreate(spv_target_env_from_vkd3d(environment));
- if (!(ret = spvBinaryToText(context, spirv->code, spirv->size / sizeof(uint32_t), + if (!(spvret = spvBinaryToText(context, spirv->code, spirv->size / sizeof(uint32_t), options, &text, &diagnostic))) { - const char *str, *current = text->str; - while ((str = strchr(current, '\n'))) + void *code = vkd3d_malloc(text->length); + if (code) { - TRACE("%.*s\n", (int)(str - current), current); - current = str + 1; + memcpy(code, text->str, text->length); + out->size = text->length; + out->code = code; } + else + result = VKD3D_ERROR_OUT_OF_MEMORY; } else { - FIXME("Failed to convert SPIR-V binary to text, ret %d.\n", ret); + FIXME("Failed to convert SPIR-V binary to text, ret %d.\n", spvret); FIXME("Diagnostic message: %s.\n", debugstr_a(diagnostic->error)); + result = VKD3D_ERROR; }
spvTextDestroy(text); spvDiagnosticDestroy(diagnostic); spvContextDestroy(context); + + return result; +} + +static void vkd3d_spirv_dump(const struct vkd3d_shader_code *spirv, + enum vkd3d_shader_spirv_environment environment) +{ + const static uint32_t options + = SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES | SPV_BINARY_TO_TEXT_OPTION_INDENT; + struct vkd3d_shader_code text; + + if (!vkd3d_spirv_binary_to_text(spirv, environment, options, &text)) + { + const char *str, *current = text.code; + while ((str = strchr(current, '\n'))) + { + TRACE("%.*s\n", (int)(str - current), current); + current = str + 1; + } + + vkd3d_shader_free_shader_code(&text); + } }
static void vkd3d_spirv_validate(const struct vkd3d_shader_code *spirv,
Signed-off-by: Isabella Bosia ibosia@codeweavers.com --- include/vkd3d_shader.h | 13 ++++++++ libs/vkd3d-shader/spirv.c | 47 +++++++++++++++++++++++++++ libs/vkd3d-shader/vkd3d_shader_main.c | 3 ++ 3 files changed, 63 insertions(+)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index 3752540..4c57f61 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -73,6 +73,18 @@ enum vkd3d_shader_compile_option_buffer_uav VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_BUFFER_UAV), };
+enum vkd3d_shader_compile_option_formatting_flags +{ + VKD3D_SHADER_COMPILE_OPTION_FORMATTING_NONE = 0x00000000, + VKD3D_SHADER_COMPILE_OPTION_FORMATTING_COLOUR = 0x00000001, + VKD3D_SHADER_COMPILE_OPTION_FORMATTING_INDENT = 0x00000002, + VKD3D_SHADER_COMPILE_OPTION_FORMATTING_SHOW_BYTE_OFFSET = 0x00000004, + VKD3D_SHADER_COMPILE_OPTION_FORMATTING_NO_HEADER = 0x00000008, + VKD3D_SHADER_COMPILE_OPTION_FORMATTING_FRIENDLY_NAMES = 0x00000010, + + VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_FORMATTING_FLAGS), +}; + enum vkd3d_shader_compile_option_name { /** @@ -451,6 +463,7 @@ enum vkd3d_shader_target_type * shaders. */ VKD3D_SHADER_TARGET_SPIRV_BINARY, + VKD3D_SHADER_TARGET_SPIRV_TEXT,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_TARGET_TYPE), }; diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 6a6d187..530e802 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -50,6 +50,32 @@ static spv_target_env spv_target_env_from_vkd3d(enum vkd3d_shader_spirv_environm } }
+static uint32_t get_binary_to_text_options(enum vkd3d_shader_compile_option_formatting_flags formatting) +{ + uint32_t out = 0; + unsigned int i; + + static const struct + { + enum vkd3d_shader_compile_option_formatting_flags vkd3d; + uint32_t spv; + } + valuemap[] = + { + {VKD3D_SHADER_COMPILE_OPTION_FORMATTING_COLOUR, SPV_BINARY_TO_TEXT_OPTION_COLOR }, + {VKD3D_SHADER_COMPILE_OPTION_FORMATTING_INDENT, SPV_BINARY_TO_TEXT_OPTION_INDENT }, + {VKD3D_SHADER_COMPILE_OPTION_FORMATTING_SHOW_BYTE_OFFSET, SPV_BINARY_TO_TEXT_OPTION_SHOW_BYTE_OFFSET}, + {VKD3D_SHADER_COMPILE_OPTION_FORMATTING_NO_HEADER, SPV_BINARY_TO_TEXT_OPTION_NO_HEADER }, + {VKD3D_SHADER_COMPILE_OPTION_FORMATTING_FRIENDLY_NAMES, SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES }, + }; + + for (i = 0; i < ARRAY_SIZE(valuemap); i++) + if (formatting & valuemap[i].vkd3d) + out |= valuemap[i].spv; + + return out; +} + static enum vkd3d_result vkd3d_spirv_binary_to_text(const struct vkd3d_shader_code *spirv, enum vkd3d_shader_spirv_environment environment, uint32_t options, struct vkd3d_shader_code *out) { @@ -130,6 +156,15 @@ static void vkd3d_spirv_validate(const struct vkd3d_shader_code *spirv,
#else
+static uint32_t get_binary_to_text_options(enum vkd3d_shader_compile_option_formatting_flags formatting) +{ + return 0; +} +static enum vkd3d_result vkd3d_spirv_binary_to_text(const struct vkd3d_shader_code *spirv, + enum vkd3d_shader_spirv_environment environment, uint32_t options, struct vkd3d_shader_code *out) +{ + return VKD3D_ERROR; +} static void vkd3d_spirv_dump(const struct vkd3d_shader_code *spirv, enum vkd3d_shader_spirv_environment environment) {} static void vkd3d_spirv_validate(const struct vkd3d_shader_code *spirv, @@ -9187,6 +9222,18 @@ int vkd3d_dxbc_compiler_generate_spirv(struct vkd3d_dxbc_compiler *compiler, if (compiler->failed) return VKD3D_ERROR_INVALID_SHADER;
+ if (compile_info->target_type == VKD3D_SHADER_TARGET_SPIRV_TEXT) + { + struct vkd3d_shader_code text; + enum vkd3d_shader_spirv_environment environment = vkd3d_dxbc_compiler_get_target_environment(compiler); + if (vkd3d_spirv_binary_to_text(spirv, environment, + get_binary_to_text_options(VKD3D_SHADER_COMPILE_OPTION_FORMATTING_FRIENDLY_NAMES | + VKD3D_SHADER_COMPILE_OPTION_FORMATTING_INDENT), + &text) != VKD3D_OK) + return VKD3D_ERROR; + *spirv = text; + } + return VKD3D_OK; }
diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c index e3abaf7..6984843 100644 --- a/libs/vkd3d-shader/vkd3d_shader_main.c +++ b/libs/vkd3d-shader/vkd3d_shader_main.c @@ -1063,6 +1063,9 @@ const enum vkd3d_shader_target_type *vkd3d_shader_get_supported_target_types( static const enum vkd3d_shader_target_type dxbc_tpf_types[] = { VKD3D_SHADER_TARGET_SPIRV_BINARY, +#ifdef HAVE_SPIRV_TOOLS + VKD3D_SHADER_TARGET_SPIRV_TEXT, +#endif };
TRACE("source_type %#x, count %p.\n", source_type, count);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Isabella Bosia ibosia@codeweavers.com --- include/vkd3d_shader.h | 2 ++ libs/vkd3d-shader/spirv.c | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index 4c57f61..2309c7c 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -97,6 +97,8 @@ enum vkd3d_shader_compile_option_name VKD3D_SHADER_COMPILE_OPTION_STRIP_DEBUG = 0x00000001, /** \a value is a member of enum vkd3d_shader_compile_option_buffer_uav. */ VKD3D_SHADER_COMPILE_OPTION_BUFFER_UAV = 0x00000002, + /** \a value is a member of enum vkd3d_shader_compile_option_formatting_flags. */ + VKD3D_SHADER_COMPILE_OPTION_FORMATTING = 0x00000003,
VKD3D_FORCE_32_BIT_ENUM(VKD3D_SHADER_COMPILE_OPTION_NAME), }; diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 530e802..913b017 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -2207,6 +2207,7 @@ struct vkd3d_dxbc_compiler unsigned int spec_constant_count; struct vkd3d_shader_spec_constant *spec_constants; size_t spec_constants_size; + enum vkd3d_shader_compile_option_formatting_flags formatting; };
static bool is_control_point_phase(const struct vkd3d_shader_phase *phase) @@ -2267,6 +2268,9 @@ struct vkd3d_dxbc_compiler *vkd3d_dxbc_compiler_create(const struct vkd3d_shader
vkd3d_spirv_builder_init(&compiler->spirv_builder, vkd3d_dxbc_compiler_get_entry_point_name(compiler));
+ compiler->formatting = VKD3D_SHADER_COMPILE_OPTION_FORMATTING_FRIENDLY_NAMES | + VKD3D_SHADER_COMPILE_OPTION_FORMATTING_INDENT; + for (i = 0; i < compile_info->option_count; ++i) { const struct vkd3d_shader_compile_option *option = &compile_info->options[i]; @@ -2286,6 +2290,10 @@ struct vkd3d_dxbc_compiler *vkd3d_dxbc_compiler_create(const struct vkd3d_shader WARN("Ignoring unrecognised value %#x for option %#x.\n", option->value, option->name); break;
+ case VKD3D_SHADER_COMPILE_OPTION_FORMATTING: + compiler->formatting = option->value; + break; + default: WARN("Ignoring unrecognised option %#x with value %#x.\n", option->name, option->value); break; @@ -9227,9 +9235,7 @@ int vkd3d_dxbc_compiler_generate_spirv(struct vkd3d_dxbc_compiler *compiler, struct vkd3d_shader_code text; enum vkd3d_shader_spirv_environment environment = vkd3d_dxbc_compiler_get_target_environment(compiler); if (vkd3d_spirv_binary_to_text(spirv, environment, - get_binary_to_text_options(VKD3D_SHADER_COMPILE_OPTION_FORMATTING_FRIENDLY_NAMES | - VKD3D_SHADER_COMPILE_OPTION_FORMATTING_INDENT), - &text) != VKD3D_OK) + get_binary_to_text_options(compiler->formatting), &text) != VKD3D_OK) return VKD3D_ERROR; *spirv = text; }
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Isabella Bosia ibosia@codeweavers.com --- programs/vkd3d-compiler/main.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/programs/vkd3d-compiler/main.c b/programs/vkd3d-compiler/main.c index a6c935c..0461f4a 100644 --- a/programs/vkd3d-compiler/main.c +++ b/programs/vkd3d-compiler/main.c @@ -55,7 +55,7 @@ source_type_info[] = " This is the format used for Direct3D shader model 4 and 5 shaders."}, };
-static const struct +static const struct target_type_info { enum vkd3d_shader_target_type type; const char *name; @@ -246,6 +246,17 @@ static enum vkd3d_shader_target_type parse_target_type(const char *target) return VKD3D_SHADER_TARGET_NONE; }
+static const struct target_type_info *get_target_type_info(enum vkd3d_shader_target_type type) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(target_type_info); ++i) + if (type == target_type_info[i].type) + return &target_type_info[i]; + + return NULL; +} + static bool parse_command_line(int argc, char **argv, struct options *options) { enum vkd3d_shader_compile_option_buffer_uav buffer_uav; @@ -359,7 +370,7 @@ 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; + unsigned int count, i;
for (i = 0; i < ARRAY_SIZE(source_type_info); ++i) { @@ -374,14 +385,9 @@ static void print_target_types(enum vkd3d_shader_source_type source_type) 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; - } - } + const struct target_type_info *type = get_target_type_info(target_types[i]); + if (type) + fprintf(stdout, " %s %s", type->name, type->description); } }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=78199
Your paranoid android.
=== debiant (build log) ===
Task: Patch failed to apply
=== debiant (build log) ===
Task: Patch failed to apply
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Isabella Bosia ibosia@codeweavers.com --- programs/vkd3d-compiler/main.c | 38 ++++++++++++++++------------------ 1 file changed, 18 insertions(+), 20 deletions(-)
diff --git a/programs/vkd3d-compiler/main.c b/programs/vkd3d-compiler/main.c index 0461f4a..a5cf031 100644 --- a/programs/vkd3d-compiler/main.c +++ b/programs/vkd3d-compiler/main.c @@ -42,7 +42,7 @@ enum OPTION_VERSION, };
-static const struct +static const struct source_type_info { enum vkd3d_shader_source_type type; const char *name; @@ -246,6 +246,17 @@ static enum vkd3d_shader_target_type parse_target_type(const char *target) return VKD3D_SHADER_TARGET_NONE; }
+static const struct source_type_info *get_source_type_info(enum vkd3d_shader_source_type type) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(source_type_info); ++i) + if (type == source_type_info[i].type) + return &source_type_info[i]; + + return NULL; +} + static const struct target_type_info *get_target_type_info(enum vkd3d_shader_target_type type) { unsigned int i; @@ -349,38 +360,25 @@ static bool parse_command_line(int argc, char **argv, struct options *options) static void print_source_types(void) { const enum vkd3d_shader_source_type *source_types; - unsigned int count, i, j; + unsigned int count, i;
source_types = vkd3d_shader_get_supported_source_types(&count); fputs("Supported source types:\n", stdout); for (i = 0; i < count; ++i) { - for (j = 0; j < ARRAY_SIZE(source_type_info); ++j) - { - if (source_types[i] == source_type_info[j].type) - { - fprintf(stdout, " %s %s\n", source_type_info[j].name, source_type_info[j].description); - break; - } - } + const struct source_type_info *type = get_source_type_info(source_types[i]); + if (type) + fprintf(stdout, " %s %s", type->name, type->description); } + }
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; + const char *source_type_name = get_source_type_info(source_type)->name; unsigned int count, i;
- 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)
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=78200
Your paranoid android.
=== debiant (build log) ===
Task: Patch failed to apply
=== debiant (build log) ===
Task: Patch failed to apply
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Isabella Bosia ibosia@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;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=78201
Your paranoid android.
=== debiant (build log) ===
Task: Patch failed to apply
=== debiant (build log) ===
Task: Patch failed to apply
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Also allow outputting non-binary formats to tty.
Signed-off-by: Isabella Bosia ibosia@codeweavers.com --- programs/vkd3d-compiler/main.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/programs/vkd3d-compiler/main.c b/programs/vkd3d-compiler/main.c index cb23b81..c05ec6a 100644 --- a/programs/vkd3d-compiler/main.c +++ b/programs/vkd3d-compiler/main.c @@ -51,8 +51,8 @@ static const struct source_type_info source_type_info[] = { {VKD3D_SHADER_SOURCE_DXBC_TPF, - "dxbc-tpf", "A 'Tokenized Program Format' shader embedded in a DXBC container.\n" - " This is the format used for Direct3D shader model 4 and 5 shaders."}, + "dxbc-tpf", "A 'Tokenized Program Format' shader embedded in a DXBC container.\n" + " This is the format used for Direct3D shader model 4 and 5 shaders.\n"}, };
static const struct target_type_info @@ -60,12 +60,17 @@ static const struct target_type_info enum vkd3d_shader_target_type type; const char *name; const char *description; + bool is_binary; } 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"}, + " This is the format used for Vulkan shaders.\n", + true}, + {VKD3D_SHADER_TARGET_SPIRV_TEXT, + "spirv-text", "A SPIR-V shader in text form.\n", + false}, };
static bool read_shader(struct vkd3d_shader_code *shader, FILE *f) @@ -134,8 +139,7 @@ static void print_usage(const char *program_name) "[options...] [file]\n" "Options:\n" " -h, --help Display this information and exit.\n" - " -b <type> Specify the target type. Currently the only valid value\n" - " is 'spirv-binary'.\n" + " -b <type> Specify the target type.\n" " --buffer-uav=<type> Specify the buffer type to use for buffer UAV bindings.\n" " Valid values are 'buffer-texture' (default) and\n" " 'storage-buffer'.\n" @@ -393,7 +397,7 @@ static void print_source_types(void) { const struct source_type_info *type = get_source_type_info(source_types[i]); if (type) - fprintf(stdout, " %s %s", type->name, type->description); + fprintf(stdout, " %-12s %s", type->name, type->description); }
} @@ -410,7 +414,7 @@ static void print_target_types(enum vkd3d_shader_source_type source_type) { const struct target_type_info *type = get_target_type_info(target_types[i]); if (type) - fprintf(stdout, " %s %s", type->name, type->description); + fprintf(stdout, " %-12s %s", type->name, type->description); } }
@@ -502,7 +506,8 @@ int main(int argc, char **argv) if (!(output = open_output(options.output_filename, &close_output))) goto done;
- if (!options.output_filename && isatty(fileno(output))) + if (!options.output_filename && get_target_type_info(options.target_type)->is_binary + && isatty(fileno(output))) { fprintf(stderr, "Output is a tty and output format is binary, exiting.\n" "If this is really what you intended, specify the output explicitly.\n");
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=78202
Your paranoid android.
=== debiant (build log) ===
Task: Patch failed to apply
=== debiant (build log) ===
Task: Patch failed to apply
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Isabella Bosia ibosia@codeweavers.com --- programs/vkd3d-compiler/main.c | 54 +++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-)
diff --git a/programs/vkd3d-compiler/main.c b/programs/vkd3d-compiler/main.c index c05ec6a..4812d47 100644 --- a/programs/vkd3d-compiler/main.c +++ b/programs/vkd3d-compiler/main.c @@ -29,7 +29,7 @@ #include "vkd3d_common.h" #include "vkd3d_shader.h"
-#define MAX_COMPILE_OPTIONS 2 +#define MAX_COMPILE_OPTIONS 3
enum { @@ -40,6 +40,7 @@ enum OPTION_PRINT_TARGET_TYPES, OPTION_STRIP_DEBUG, OPTION_VERSION, + OPTION_TEXT_FORMATTING, };
static const struct source_type_info @@ -146,6 +147,10 @@ static void print_usage(const char *program_name) " -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" + " --formatting=<type> Specify the formatting options for text output.\n" + " Valid values are 'none', 'print', 'colour', 'indent',\n" + " 'show-byte-offset', 'no-header', and 'friendly-names'.\n" + " Default is --formatting=friendly-names,indent.\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" @@ -221,6 +226,45 @@ static bool parse_buffer_uav(enum vkd3d_shader_compile_option_buffer_uav *buffer return false; }
+static bool parse_formatting(uint32_t *formatting, char *arg) +{ + static const struct formatting_option + { + char *name; + enum vkd3d_shader_compile_option_formatting_flags value; + } + opts[] = + { + {"none", VKD3D_SHADER_COMPILE_OPTION_FORMATTING_NONE }, + {"colour", VKD3D_SHADER_COMPILE_OPTION_FORMATTING_COLOUR }, + {"indent", VKD3D_SHADER_COMPILE_OPTION_FORMATTING_INDENT }, + {"show-byte-offset", VKD3D_SHADER_COMPILE_OPTION_FORMATTING_SHOW_BYTE_OFFSET}, + {"no-header", VKD3D_SHADER_COMPILE_OPTION_FORMATTING_NO_HEADER }, + {"friendly-names", VKD3D_SHADER_COMPILE_OPTION_FORMATTING_FRIENDLY_NAMES }, + }; + char *tok; + + for (tok = strtok(arg, ","); tok; tok = strtok(NULL, ",")) + { + unsigned int i; + for (i = 0; i < ARRAY_SIZE(opts); ++i) + { + if (!strcmp(tok, opts[i].name)) + { + *formatting |= opts[i].value; + break; + } + } + if (i == ARRAY_SIZE(opts)) + { + fprintf(stderr, "Invalid formatting '%s' specified.\n", tok); + return false; + } + } + + return true; +} + static enum vkd3d_shader_source_type parse_source_type(const char *source) { unsigned int i; @@ -292,6 +336,7 @@ static bool validate_target_type( static bool parse_command_line(int argc, char **argv, struct options *options) { enum vkd3d_shader_compile_option_buffer_uav buffer_uav; + enum vkd3d_shader_compile_option_formatting_flags formatting = 0; int option;
static struct option long_options[] = @@ -299,6 +344,7 @@ static bool parse_command_line(int argc, char **argv, struct options *options) {"help", no_argument, NULL, OPTION_HELP}, {"buffer-uav", required_argument, NULL, OPTION_BUFFER_UAV}, {"output", required_argument, NULL, OPTION_OUTPUT}, + {"formatting", required_argument, NULL, OPTION_TEXT_FORMATTING}, {"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}, @@ -339,6 +385,12 @@ static bool parse_command_line(int argc, char **argv, struct options *options) options->output_filename = optarg; break;
+ case OPTION_TEXT_FORMATTING: + if (!parse_formatting(&formatting, optarg)) + return false; + add_compile_option(options, VKD3D_SHADER_COMPILE_OPTION_FORMATTING, formatting); + break; + case OPTION_PRINT_SOURCE_TYPES: options->print_source_types = true; return true;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=78203
Your paranoid android.
=== debiant (build log) ===
Task: Patch failed to apply
=== debiant (build log) ===
Task: Patch failed to apply
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com