winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
August 2023
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
1 participants
667 discussions
Start a n
N
ew thread
Zebediah Figura : vkd3d-shader/hlsl: Define smoothstep() in HLSL.
by Alexandre Julliard
30 Aug '23
30 Aug '23
Module: vkd3d Branch: master Commit: 9ab77658f25260fc0316a87d4e79a8e2abd99cdb URL:
https://gitlab.winehq.org/wine/vkd3d/-/commit/9ab77658f25260fc0316a87d4e79a…
Author: Zebediah Figura <zfigura(a)codeweavers.com> Date: Mon Aug 7 17:20:10 2023 -0500 vkd3d-shader/hlsl: Define smoothstep() in HLSL. --- libs/vkd3d-shader/hlsl.c | 51 ++++++++++++++++++++++++++++++++++++++++ libs/vkd3d-shader/hlsl.h | 8 +++++++ libs/vkd3d-shader/hlsl.y | 61 +++++++++++++----------------------------------- 3 files changed, 75 insertions(+), 45 deletions(-) diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index be5b4052..b8cf6813 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -2988,6 +2988,16 @@ void hlsl_add_function(struct hlsl_ctx *ctx, char *name, struct hlsl_ir_function struct hlsl_ir_function *func; struct rb_entry *func_entry; + if (ctx->internal_func_name) + { + char *internal_name; + + if (!(internal_name = hlsl_strdup(ctx, ctx->internal_func_name))) + return; + vkd3d_free(name); + name = internal_name; + } + func_entry = rb_get(&ctx->functions, name); if (func_entry) { @@ -3519,3 +3529,44 @@ int hlsl_compile_shader(const struct vkd3d_shader_code *hlsl, const struct vkd3d hlsl_ctx_cleanup(&ctx); return ret; } + +struct hlsl_ir_function_decl *hlsl_compile_internal_function(struct hlsl_ctx *ctx, const char *name, const char *hlsl) +{ + const struct hlsl_ir_function_decl *saved_cur_function = ctx->cur_function; + struct vkd3d_shader_code code = {.code = hlsl, .size = strlen(hlsl)}; + const char *saved_internal_func_name = ctx->internal_func_name; + struct vkd3d_string_buffer *internal_name; + struct hlsl_ir_function_decl *func; + void *saved_scanner = ctx->scanner; + int ret; + + TRACE("name %s, hlsl %s.\n", debugstr_a(name), debugstr_a(hlsl)); + + /* The actual name of the function is mangled with a unique prefix, both to + * allow defining multiple variants of a function with the same name, and to + * avoid polluting the user name space. */ + + if (!(internal_name = hlsl_get_string_buffer(ctx))) + return NULL; + vkd3d_string_buffer_printf(internal_name, "<%s-%u>", name, ctx->internal_name_counter++); + + /* Save and restore everything that matters. + * Note that saving the scope stack is hard, and shouldn't be necessary. */ + + ctx->scanner = NULL; + ctx->internal_func_name = internal_name->buffer; + ctx->cur_function = NULL; + ret = hlsl_lexer_compile(ctx, &code); + ctx->scanner = saved_scanner; + ctx->internal_func_name = saved_internal_func_name; + ctx->cur_function = saved_cur_function; + if (ret) + { + ERR("Failed to compile intrinsic, error %u.\n", ret); + hlsl_release_string_buffer(ctx, internal_name); + return NULL; + } + func = hlsl_get_func_decl(ctx, internal_name->buffer); + hlsl_release_string_buffer(ctx, internal_name); + return func; +} diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index d1fd6fef..e1faa03a 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -837,6 +837,12 @@ struct hlsl_ctx * compute shader profiles. It is set using the numthreads() attribute in the entry point. */ uint32_t thread_count[3]; + /* In some cases we generate opcodes by parsing an HLSL function and then + * invoking it. If not NULL, this field is the name of the function that we + * are currently parsing, "mangled" with an internal prefix to avoid + * polluting the user namespace. */ + const char *internal_func_name; + /* Whether the parser is inside a state block (effects' metadata) inside a variable declaration. */ uint32_t in_state_block : 1; /* Whether the numthreads() attribute has been provided in the entry-point function. */ @@ -1263,6 +1269,8 @@ bool hlsl_sm4_register_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_sem bool output, enum vkd3d_shader_register_type *type, enum vkd3d_sm4_swizzle_type *swizzle_type, bool *has_idx); int hlsl_sm4_write(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func, struct vkd3d_shader_code *out); +struct hlsl_ir_function_decl *hlsl_compile_internal_function(struct hlsl_ctx *ctx, const char *name, const char *hlsl); + int hlsl_lexer_compile(struct hlsl_ctx *ctx, const struct vkd3d_shader_code *hlsl); #endif diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index ee387fe9..7ce0340c 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -3422,58 +3422,29 @@ static bool intrinsic_sin(struct hlsl_ctx *ctx, static bool intrinsic_smoothstep(struct hlsl_ctx *ctx, const struct parse_initializer *params, const struct vkd3d_shader_location *loc) { - struct hlsl_ir_node *min_arg, *max_arg, *x_arg, *p, *p_num, *p_denom, *res, *one, *minus_two, *three; - - if (!elementwise_intrinsic_float_convert_args(ctx, params, loc)) - return false; - - min_arg = params->args[0]; - max_arg = params->args[1]; - x_arg = params->args[2]; - - if (!(min_arg = add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_NEG, min_arg, loc))) - return false; - - if (!(p_num = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_ADD, x_arg, min_arg, loc))) - return false; - - if (!(p_denom = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_ADD, max_arg, min_arg, loc))) - return false; - - if (!(one = hlsl_new_float_constant(ctx, 1.0, loc))) - return false; - hlsl_block_add_instr(params->instrs, one); - - if (!(p_denom = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_DIV, one, p_denom, loc))) - return false; - - if (!(p = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, p_num, p_denom, loc))) - return false; - - if (!(p = add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_SAT, p, loc))) - return false; - - if (!(minus_two = hlsl_new_float_constant(ctx, -2.0, loc))) - return false; - hlsl_block_add_instr(params->instrs, minus_two); - - if (!(three = hlsl_new_float_constant(ctx, 3.0, loc))) - return false; - hlsl_block_add_instr(params->instrs, three); + struct hlsl_ir_function_decl *func; + struct hlsl_type *type; + char *body; - if (!(res = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, minus_two, p, loc))) - return false; + static const char template[] = + "%s smoothstep(%s low, %s high, %s x)\n" + "{\n" + " %s p = saturate((x - low) / (high - low));\n" + " return (p * p) * (3 - 2 * p);\n" + "}"; - if (!(res = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_ADD, three, res, loc))) + if (!(type = elementwise_intrinsic_get_common_type(ctx, params, loc))) return false; + type = hlsl_get_numeric_type(ctx, type->class, HLSL_TYPE_FLOAT, type->dimx, type->dimy); - if (!(p = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, p, p, loc))) + if (!(body = hlsl_sprintf_alloc(ctx, template, type->name, type->name, type->name, type->name, type->name))) return false; - - if (!(res = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, p, res, loc))) + func = hlsl_compile_internal_function(ctx, "smoothstep", body); + vkd3d_free(body); + if (!func) return false; - return true; + return add_user_call(ctx, func, params, loc); } static bool intrinsic_sqrt(struct hlsl_ctx *ctx,
1
0
0
0
Zebediah Figura : vkd3d-shader/hlsl: Store the internal name counter in struct hlsl_ctx.
by Alexandre Julliard
30 Aug '23
30 Aug '23
Module: vkd3d Branch: master Commit: d396c4ce27a343e9668046c964eea238ff9041f6 URL:
https://gitlab.winehq.org/wine/vkd3d/-/commit/d396c4ce27a343e9668046c964eea…
Author: Zebediah Figura <zfigura(a)codeweavers.com> Date: Tue Aug 29 16:50:13 2023 -0500 vkd3d-shader/hlsl: Store the internal name counter in struct hlsl_ctx. This is minutely more efficient than using a global variable and atomic instructions. --- libs/vkd3d-shader/hlsl.c | 3 +-- libs/vkd3d-shader/hlsl.h | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index a6747cd1..be5b4052 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -1060,11 +1060,10 @@ struct hlsl_ir_var *hlsl_new_synthetic_var(struct hlsl_ctx *ctx, const char *tem { struct vkd3d_string_buffer *string; struct hlsl_ir_var *var; - static LONG counter; if (!(string = hlsl_get_string_buffer(ctx))) return NULL; - vkd3d_string_buffer_printf(string, "<%s-%u>", template, InterlockedIncrement(&counter)); + vkd3d_string_buffer_printf(string, "<%s-%u>", template, ctx->internal_name_counter++); var = hlsl_new_synthetic_var_named(ctx, string->buffer, type, loc, true); hlsl_release_string_buffer(ctx, string); return var; diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 2f2f1f29..d1fd6fef 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -798,6 +798,9 @@ struct hlsl_ctx /* Pointer to the current function; changes as the parser reads the code. */ const struct hlsl_ir_function_decl *cur_function; + /* Counter for generating unique internal variable names. */ + unsigned int internal_name_counter; + /* Default matrix majority for matrix types. Can be set by a pragma within the HLSL source. */ unsigned int matrix_majority;
1
0
0
0
Zebediah Figura : vkd3d-shader/hlsl: Separate an add_user_call() helper.
by Alexandre Julliard
30 Aug '23
30 Aug '23
Module: vkd3d Branch: master Commit: f22e52f35886d05a50e6dfbaa42be269337a2258 URL:
https://gitlab.winehq.org/wine/vkd3d/-/commit/f22e52f35886d05a50e6dfbaa42be…
Author: Zebediah Figura <zfigura(a)codeweavers.com> Date: Mon Aug 7 16:48:20 2023 -0500 vkd3d-shader/hlsl: Separate an add_user_call() helper. --- libs/vkd3d-shader/hlsl.y | 165 +++++++++++++++++++++++++---------------------- 1 file changed, 87 insertions(+), 78 deletions(-) diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 73257b8e..ee387fe9 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -2330,6 +2330,92 @@ static struct hlsl_ir_function_decl *find_function_call(struct hlsl_ctx *ctx, return args.decl; } +static struct hlsl_ir_node *hlsl_new_void_expr(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc) +{ + struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS] = {0}; + + return hlsl_new_expr(ctx, HLSL_OP0_VOID, operands, ctx->builtin_types.Void, loc); +} + +static bool add_user_call(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *func, + const struct parse_initializer *args, const struct vkd3d_shader_location *loc) +{ + struct hlsl_ir_node *call; + unsigned int i; + + assert(args->args_count == func->parameters.count); + + for (i = 0; i < func->parameters.count; ++i) + { + struct hlsl_ir_var *param = func->parameters.vars[i]; + struct hlsl_ir_node *arg = args->args[i]; + + if (!hlsl_types_are_equal(arg->data_type, param->data_type)) + { + struct hlsl_ir_node *cast; + + if (!(cast = add_cast(ctx, args->instrs, arg, param->data_type, &arg->loc))) + return false; + args->args[i] = cast; + arg = cast; + } + + if (param->storage_modifiers & HLSL_STORAGE_IN) + { + struct hlsl_ir_node *store; + + if (!(store = hlsl_new_simple_store(ctx, param, arg))) + return false; + hlsl_block_add_instr(args->instrs, store); + } + } + + if (!(call = hlsl_new_call(ctx, func, loc))) + return false; + hlsl_block_add_instr(args->instrs, call); + + for (i = 0; i < func->parameters.count; ++i) + { + struct hlsl_ir_var *param = func->parameters.vars[i]; + struct hlsl_ir_node *arg = args->args[i]; + + if (param->storage_modifiers & HLSL_STORAGE_OUT) + { + struct hlsl_ir_load *load; + + if (arg->data_type->modifiers & HLSL_MODIFIER_CONST) + hlsl_error(ctx, &arg->loc, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, + "Output argument to \"%s\" is const.", func->func->name); + + if (!(load = hlsl_new_var_load(ctx, param, &arg->loc))) + return false; + hlsl_block_add_instr(args->instrs, &load->node); + + if (!add_assignment(ctx, args->instrs, arg, ASSIGN_OP_ASSIGN, &load->node)) + return false; + } + } + + if (func->return_var) + { + struct hlsl_ir_load *load; + + if (!(load = hlsl_new_var_load(ctx, func->return_var, loc))) + return false; + hlsl_block_add_instr(args->instrs, &load->node); + } + else + { + struct hlsl_ir_node *expr; + + if (!(expr = hlsl_new_void_expr(ctx, loc))) + return false; + hlsl_block_add_instr(args->instrs, expr); + } + + return true; +} + static struct hlsl_ir_node *intrinsic_float_convert_arg(struct hlsl_ctx *ctx, const struct parse_initializer *params, struct hlsl_ir_node *arg, const struct vkd3d_shader_location *loc) { @@ -3666,13 +3752,6 @@ static int intrinsic_function_name_compare(const void *a, const void *b) return strcmp(a, func->name); } -static struct hlsl_ir_node *hlsl_new_void_expr(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc) -{ - struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS] = {0}; - - return hlsl_new_expr(ctx, HLSL_OP0_VOID, operands, ctx->builtin_types.Void, loc); -} - static struct hlsl_block *add_call(struct hlsl_ctx *ctx, const char *name, struct parse_initializer *args, const struct vkd3d_shader_location *loc) { @@ -3681,78 +3760,8 @@ static struct hlsl_block *add_call(struct hlsl_ctx *ctx, const char *name, if ((decl = find_function_call(ctx, name, args, loc))) { - struct hlsl_ir_node *call; - unsigned int i; - - assert(args->args_count == decl->parameters.count); - - for (i = 0; i < decl->parameters.count; ++i) - { - struct hlsl_ir_var *param = decl->parameters.vars[i]; - struct hlsl_ir_node *arg = args->args[i]; - - if (!hlsl_types_are_equal(arg->data_type, param->data_type)) - { - struct hlsl_ir_node *cast; - - if (!(cast = add_cast(ctx, args->instrs, arg, param->data_type, &arg->loc))) - goto fail; - args->args[i] = cast; - arg = cast; - } - - if (param->storage_modifiers & HLSL_STORAGE_IN) - { - struct hlsl_ir_node *store; - - if (!(store = hlsl_new_simple_store(ctx, param, arg))) - goto fail; - hlsl_block_add_instr(args->instrs, store); - } - } - - if (!(call = hlsl_new_call(ctx, decl, loc))) + if (!add_user_call(ctx, decl, args, loc)) goto fail; - hlsl_block_add_instr(args->instrs, call); - - for (i = 0; i < decl->parameters.count; ++i) - { - struct hlsl_ir_var *param = decl->parameters.vars[i]; - struct hlsl_ir_node *arg = args->args[i]; - - if (param->storage_modifiers & HLSL_STORAGE_OUT) - { - struct hlsl_ir_load *load; - - if (arg->data_type->modifiers & HLSL_MODIFIER_CONST) - hlsl_error(ctx, &arg->loc, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, - "Output argument to \"%s\" is const.", decl->func->name); - - if (!(load = hlsl_new_var_load(ctx, param, &arg->loc))) - goto fail; - hlsl_block_add_instr(args->instrs, &load->node); - - if (!add_assignment(ctx, args->instrs, arg, ASSIGN_OP_ASSIGN, &load->node)) - goto fail; - } - } - - if (decl->return_var) - { - struct hlsl_ir_load *load; - - if (!(load = hlsl_new_var_load(ctx, decl->return_var, loc))) - goto fail; - hlsl_block_add_instr(args->instrs, &load->node); - } - else - { - struct hlsl_ir_node *expr; - - if (!(expr = hlsl_new_void_expr(ctx, loc))) - goto fail; - hlsl_block_add_instr(args->instrs, expr); - } } else if ((intrinsic = bsearch(name, intrinsic_functions, ARRAY_SIZE(intrinsic_functions), sizeof(*intrinsic_functions), intrinsic_function_name_compare)))
1
0
0
0
Zebediah Figura : vkd3d-shader/hlsl: Introduce an hlsl_sprintf_alloc() helper.
by Alexandre Julliard
30 Aug '23
30 Aug '23
Module: vkd3d Branch: master Commit: 63e056512d7a425384a7c22620e9fbec1df987d6 URL:
https://gitlab.winehq.org/wine/vkd3d/-/commit/63e056512d7a425384a7c22620e9f…
Author: Zebediah Figura <zfigura(a)codeweavers.com> Date: Mon Aug 7 16:45:31 2023 -0500 vkd3d-shader/hlsl: Introduce an hlsl_sprintf_alloc() helper. --- libs/vkd3d-shader/d3dbc.c | 11 +++-------- libs/vkd3d-shader/hlsl.c | 21 +++++++++++++++++++++ libs/vkd3d-shader/hlsl.h | 2 ++ libs/vkd3d-shader/hlsl_codegen.c | 25 ++++++++++--------------- 4 files changed, 36 insertions(+), 23 deletions(-) diff --git a/libs/vkd3d-shader/d3dbc.c b/libs/vkd3d-shader/d3dbc.c index 99a5bd7a..2b02d51f 100644 --- a/libs/vkd3d-shader/d3dbc.c +++ b/libs/vkd3d-shader/d3dbc.c @@ -1638,17 +1638,12 @@ static void write_sm1_uniforms(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffe if (var->is_param && var->is_uniform) { - struct vkd3d_string_buffer *name; + char *new_name; - if (!(name = hlsl_get_string_buffer(ctx))) - { - buffer->status = VKD3D_ERROR_OUT_OF_MEMORY; + if (!(new_name = hlsl_sprintf_alloc(ctx, "$%s", var->name))) return; - } - vkd3d_string_buffer_printf(name, "$%s", var->name); vkd3d_free((char *)var->name); - var->name = hlsl_strdup(ctx, name->buffer); - hlsl_release_string_buffer(ctx, name); + var->name = new_name; } } } diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 8b706e1e..a6747cd1 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -72,6 +72,27 @@ void hlsl_fixme(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc, c ctx->result = VKD3D_ERROR_NOT_IMPLEMENTED; } +char *hlsl_sprintf_alloc(struct hlsl_ctx *ctx, const char *fmt, ...) +{ + struct vkd3d_string_buffer *string; + va_list args; + char *ret; + + if (!(string = hlsl_get_string_buffer(ctx))) + return NULL; + va_start(args, fmt); + if (vkd3d_string_buffer_vprintf(string, fmt, args) < 0) + { + va_end(args); + hlsl_release_string_buffer(ctx, string); + return NULL; + } + va_end(args); + ret = hlsl_strdup(ctx, string->buffer); + hlsl_release_string_buffer(ctx, string); + return ret; +} + bool hlsl_add_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, bool local_var) { struct hlsl_scope *scope = ctx->cur_scope; diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 8bc72a8a..2f2f1f29 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -1069,6 +1069,8 @@ static inline unsigned int hlsl_sampler_dim_count(enum hlsl_sampler_dim dim) } } +char *hlsl_sprintf_alloc(struct hlsl_ctx *ctx, const char *fmt, ...) VKD3D_PRINTF_FUNC(2, 3); + const char *debug_hlsl_expr_op(enum hlsl_ir_expr_op op); const char *debug_hlsl_type(struct hlsl_ctx *ctx, const struct hlsl_type *type); const char *debug_hlsl_writemask(unsigned int writemask); diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index bae8e5f9..710d2908 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -163,10 +163,10 @@ static bool replace_deref_path_with_offset(struct hlsl_ctx *ctx, struct hlsl_der * work. */ static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct hlsl_block *block, struct hlsl_ir_var *temp) { - struct vkd3d_string_buffer *name; struct hlsl_ir_var *uniform; struct hlsl_ir_node *store; struct hlsl_ir_load *load; + char *new_name; /* Use the synthetic name for the temp, rather than the uniform, so that we * can write the uniform name into the shader reflection data. */ @@ -180,11 +180,9 @@ static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct hlsl_block *block, uniform->is_param = temp->is_param; uniform->buffer = temp->buffer; - if (!(name = hlsl_get_string_buffer(ctx))) + if (!(new_name = hlsl_sprintf_alloc(ctx, "<temp-%s>", temp->name))) return; - vkd3d_string_buffer_printf(name, "<temp-%s>", temp->name); - temp->name = hlsl_strdup(ctx, name->buffer); - hlsl_release_string_buffer(ctx, name); + temp->name = new_name; if (!(load = hlsl_new_var_load(ctx, uniform, &temp->loc))) return; @@ -235,16 +233,15 @@ static struct hlsl_ir_var *add_semantic_var(struct hlsl_ctx *ctx, struct hlsl_ir uint32_t index, bool output, const struct vkd3d_shader_location *loc) { struct hlsl_semantic new_semantic; - struct vkd3d_string_buffer *name; struct hlsl_ir_var *ext_var; + char *new_name; - if (!(name = hlsl_get_string_buffer(ctx))) + if (!(new_name = hlsl_sprintf_alloc(ctx, "<%s-%s%u>", output ? "output" : "input", semantic->name, index))) return NULL; - vkd3d_string_buffer_printf(name, "<%s-%s%u>", output ? "output" : "input", semantic->name, index); LIST_FOR_EACH_ENTRY(ext_var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry) { - if (!ascii_strcasecmp(ext_var->name, name->buffer)) + if (!ascii_strcasecmp(ext_var->name, new_name)) { if (output) { @@ -271,25 +268,23 @@ static struct hlsl_ir_var *add_semantic_var(struct hlsl_ctx *ctx, struct hlsl_ir } } - hlsl_release_string_buffer(ctx, name); + vkd3d_free(new_name); return ext_var; } } if (!(new_semantic.name = hlsl_strdup(ctx, semantic->name))) { - hlsl_release_string_buffer(ctx, name); + vkd3d_free(new_name); return NULL; } new_semantic.index = index; - if (!(ext_var = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer), type, loc, &new_semantic, - modifiers, NULL))) + if (!(ext_var = hlsl_new_var(ctx, new_name, type, loc, &new_semantic, modifiers, NULL))) { - hlsl_release_string_buffer(ctx, name); + vkd3d_free(new_name); hlsl_cleanup_semantic(&new_semantic); return NULL; } - hlsl_release_string_buffer(ctx, name); if (output) ext_var->is_output_semantic = 1; else
1
0
0
0
Gabriel Ivăncescu : winex11: Avoid querying GPU properties in get_host_primary_monitor_rect.
by Alexandre Julliard
30 Aug '23
30 Aug '23
Module: wine Branch: master Commit: 88c1ef974a2a776b80c7054e2452266b18f483dd URL:
https://gitlab.winehq.org/wine/wine/-/commit/88c1ef974a2a776b80c7054e245226…
Author: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> Date: Tue Aug 29 17:00:29 2023 +0300 winex11: Avoid querying GPU properties in get_host_primary_monitor_rect. Since we only need the id, and vkGetRandROutputDisplayEXT can be extremely expensive. Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=55500
Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> --- dlls/winex11.drv/display.c | 4 ++-- dlls/winex11.drv/x11drv.h | 2 +- dlls/winex11.drv/xinerama.c | 2 +- dlls/winex11.drv/xrandr.c | 9 ++------- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/dlls/winex11.drv/display.c b/dlls/winex11.drv/display.c index f46c320e89b..49475571f71 100644 --- a/dlls/winex11.drv/display.c +++ b/dlls/winex11.drv/display.c @@ -402,7 +402,7 @@ RECT get_host_primary_monitor_rect(void) RECT rect = {0}; /* The first monitor is always primary */ - if (host_handler.get_gpus(&gpus, &gpu_count) && gpu_count && + if (host_handler.get_gpus(&gpus, &gpu_count, FALSE) && gpu_count && host_handler.get_adapters(gpus[0].id, &adapters, &adapter_count) && adapter_count && host_handler.get_monitors(adapters[0].id, &monitors, &monitor_count) && monitor_count) rect = monitors[0].rc_monitor; @@ -529,7 +529,7 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage TRACE( "via %s\n", debugstr_a(host_handler.name) ); /* Initialize GPUs */ - if (!host_handler.get_gpus( &gpus, &gpu_count )) return FALSE; + if (!host_handler.get_gpus( &gpus, &gpu_count, TRUE )) return FALSE; TRACE("GPU count: %d\n", gpu_count); for (gpu = 0; gpu < gpu_count; gpu++) diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 9ee6498a02e..8e233a051f4 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -777,7 +777,7 @@ struct x11drv_display_device_handler /* get_gpus will be called to get a list of GPUs. First GPU has to be where the primary adapter is. * * Return FALSE on failure with parameters unchanged */ - BOOL (*get_gpus)(struct gdi_gpu **gpus, int *count); + BOOL (*get_gpus)(struct gdi_gpu **gpus, int *count, BOOL get_properties); /* get_adapters will be called to get a list of adapters in EnumDisplayDevices context under a GPU. * The first adapter has to be primary if GPU is primary. diff --git a/dlls/winex11.drv/xinerama.c b/dlls/winex11.drv/xinerama.c index a508141d8c4..f0f831cbc1d 100644 --- a/dlls/winex11.drv/xinerama.c +++ b/dlls/winex11.drv/xinerama.c @@ -190,7 +190,7 @@ done: return ret; } -static BOOL xinerama_get_gpus( struct gdi_gpu **new_gpus, int *count ) +static BOOL xinerama_get_gpus( struct gdi_gpu **new_gpus, int *count, BOOL get_properties ) { static const WCHAR wine_adapterW[] = {'W','i','n','e',' ','A','d','a','p','t','e','r',0}; struct gdi_gpu *gpus; diff --git a/dlls/winex11.drv/xrandr.c b/dlls/winex11.drv/xrandr.c index 23601b9e75e..cf3f911cf5b 100644 --- a/dlls/winex11.drv/xrandr.c +++ b/dlls/winex11.drv/xrandr.c @@ -752,7 +752,7 @@ done: /* Get a list of GPUs reported by XRandR 1.4. Set get_properties to FALSE if GPU properties are * not needed to avoid unnecessary querying */ -static BOOL xrandr14_get_gpus2( struct gdi_gpu **new_gpus, int *count, BOOL get_properties ) +static BOOL xrandr14_get_gpus( struct gdi_gpu **new_gpus, int *count, BOOL get_properties ) { static const WCHAR wine_adapterW[] = {'W','i','n','e',' ','A','d','a','p','t','e','r',0}; struct gdi_gpu *gpus = NULL; @@ -849,11 +849,6 @@ done: return ret; } -static BOOL xrandr14_get_gpus( struct gdi_gpu **new_gpus, int *count ) -{ - return xrandr14_get_gpus2( new_gpus, count, TRUE ); -} - static void xrandr14_free_gpus( struct gdi_gpu *gpus ) { free( gpus ); @@ -1233,7 +1228,7 @@ static BOOL xrandr14_get_id( const WCHAR *device_name, BOOL is_primary, x11drv_s pthread_mutex_lock( &xrandr_mutex ); if (!current_modes) { - if (!xrandr14_get_gpus2( &gpus, &gpu_count, FALSE )) + if (!xrandr14_get_gpus( &gpus, &gpu_count, FALSE )) { pthread_mutex_unlock( &xrandr_mutex ); return FALSE;
1
0
0
0
Alexis Murzeau : wpcap: Handle negative count for pcap_dispatch and pcap_loop.
by Alexandre Julliard
30 Aug '23
30 Aug '23
Module: wine Branch: master Commit: 2cc573aef98c082ce1c934750b4e448cd1070d9c URL:
https://gitlab.winehq.org/wine/wine/-/commit/2cc573aef98c082ce1c934750b4e44…
Author: Alexis Murzeau <amubtdx(a)gmail.com> Date: Wed Aug 30 09:51:29 2023 +0000 wpcap: Handle negative count for pcap_dispatch and pcap_loop. According to WinPcap documentation of `pcap_dispatch` (
https://www.winpcap.org/docs/docs_41b5/html/group__wpcapfunc.html#g60ce104c…
): > A cnt of -1 processes all the packets received in one buffer when > reading a live capture, or all the packets in the file when reading a > ``savefile'' Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=55487
Signed-off-by: Alexis Murzeau <amubtdx(a)gmail.com> --- dlls/wpcap/wpcap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/wpcap/wpcap.c b/dlls/wpcap/wpcap.c index 8c304ce66a4..f96e7098ae5 100644 --- a/dlls/wpcap/wpcap.c +++ b/dlls/wpcap/wpcap.c @@ -967,7 +967,7 @@ int CDECL pcap_dispatch( struct pcap *pcap, int count, TRACE( "%p, %d, %p, %p\n", pcap, count, callback, user ); - while (processed < count) + while (count <= 0 || processed < count) { struct pcap_pkthdr_win32 *hdr = NULL; const unsigned char *data = NULL; @@ -1000,7 +1000,7 @@ int CDECL pcap_loop( struct pcap *pcap, int count, TRACE( "%p, %d, %p, %p\n", pcap, count, callback, user ); - while (processed < count) + while (count <= 0 || processed < count) { struct pcap_pkthdr_win32 *hdr = NULL; const unsigned char *data = NULL;
1
0
0
0
Alexandre Julliard : wow64: Also send notifications for failed memory management calls.
by Alexandre Julliard
30 Aug '23
30 Aug '23
Module: wine Branch: master Commit: 1942cc30171c9f98abde65f3a0d8857c9ccd892a URL:
https://gitlab.winehq.org/wine/wine/-/commit/1942cc30171c9f98abde65f3a0d885…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Wed Aug 30 13:54:59 2023 +0200 wow64: Also send notifications for failed memory management calls. --- dlls/ntdll/tests/wow64.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ dlls/wow64/syscall.c | 1 + dlls/wow64/virtual.c | 38 ++++++++++++++++++-------------------- 3 files changed, 66 insertions(+), 20 deletions(-) diff --git a/dlls/ntdll/tests/wow64.c b/dlls/ntdll/tests/wow64.c index 6ca5ebd9b74..485b9006b14 100644 --- a/dlls/ntdll/tests/wow64.c +++ b/dlls/ntdll/tests/wow64.c @@ -392,6 +392,21 @@ static void test_cross_process_notifications( HANDLE process, void *ptr ) } ok( !entry, "not at end of list\n" ); + addr = (void *)0x123; + size = 0x321; + status = NtAllocateVirtualMemory( process, &addr, 0, &size, MEM_COMMIT, PAGE_EXECUTE_READ ); + ok( status == STATUS_CONFLICTING_ADDRESSES || status == STATUS_INVALID_PARAMETER, + "NtAllocateVirtualMemory failed %lx\n", status ); + entry = pop_from_work_list( &list->work_list ); + if (current_machine != IMAGE_FILE_MACHINE_ARM64) + { + entry = expect_cross_work_entry( list, entry, CrossProcessPreVirtualAlloc, addr, 0x321, + MEM_COMMIT, PAGE_EXECUTE_READ, 0, 0xcccccccc ); + entry = expect_cross_work_entry( list, entry, CrossProcessPostVirtualAlloc, addr, 0x321, + MEM_COMMIT, PAGE_EXECUTE_READ, status, 0xcccccccc ); + } + ok( !entry, "not at end of list\n" ); + addr = NULL; size = 0x4321; status = NtAllocateVirtualMemory( process, &addr, 0, &size, MEM_RESERVE, PAGE_EXECUTE_READWRITE ); @@ -433,6 +448,23 @@ static void test_cross_process_notifications( HANDLE process, void *ptr ) } ok( !entry, "not at end of list\n" ); + addr2 = (char *)addr + 0x222; + size = 34; + status = NtProtectVirtualMemory( process, &addr2, &size, PAGE_EXECUTE_WRITECOPY, &old_prot ); + ok( status == STATUS_INVALID_PARAMETER_4 || status == STATUS_INVALID_PAGE_PROTECTION, + "NtProtectVirtualMemory failed %lx\n", status ); + entry = pop_from_work_list( &list->work_list ); + if (current_machine != IMAGE_FILE_MACHINE_ARM64) + { + entry = expect_cross_work_entry( list, entry, CrossProcessPreVirtualProtect, + (char *)addr + 0x222, 34, + PAGE_EXECUTE_WRITECOPY, 0, 0xcccccccc, 0xcccccccc ); + entry = expect_cross_work_entry( list, entry, CrossProcessPostVirtualProtect, + (char *)addr + 0x222, 34, + PAGE_EXECUTE_WRITECOPY, status, 0xcccccccc, 0xcccccccc ); + } + ok( !entry, "not at end of list\n" ); + status = NtWriteVirtualMemory( process, (char *)addr + 0x1111, data, sizeof(data), &size ); ok( !status, "NtWriteVirtualMemory failed %lx\n", status ); entry = pop_from_work_list( &list->work_list ); @@ -465,6 +497,21 @@ static void test_cross_process_notifications( HANDLE process, void *ptr ) } ok( !entry, "not at end of list\n" ); + addr = (void *)0x123; + size = 0; + status = NtFreeVirtualMemory( process, &addr, &size, MEM_RELEASE ); + ok( status == STATUS_MEMORY_NOT_ALLOCATED || status == STATUS_INVALID_PARAMETER, + "NtFreeVirtualMemory failed %lx\n", status ); + entry = pop_from_work_list( &list->work_list ); + if (current_machine != IMAGE_FILE_MACHINE_ARM64) + { + entry = expect_cross_work_entry( list, entry, CrossProcessPreVirtualFree, addr, 0, + MEM_RELEASE, 0, 0xcccccccc, 0xcccccccc ); + entry = expect_cross_work_entry( list, entry, CrossProcessPostVirtualFree, addr, 0, + MEM_RELEASE, status, 0xcccccccc, 0xcccccccc ); + } + ok( !entry, "not at end of list\n" ); + file = CreateFileA( "c:\\windows\\syswow64\\version.dll", GENERIC_READ | GENERIC_EXECUTE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 ); ok( file != INVALID_HANDLE_VALUE, "Failed to open version.dll\n" ); mapping = CreateFileMappingA( file, NULL, PAGE_READONLY | SEC_IMAGE, 0, 0, NULL ); diff --git a/dlls/wow64/syscall.c b/dlls/wow64/syscall.c index 4b13fd9d3cd..3b8e479bcb2 100644 --- a/dlls/wow64/syscall.c +++ b/dlls/wow64/syscall.c @@ -1296,6 +1296,7 @@ void WINAPI Wow64ProcessPendingCrossProcessItems(void) break; case CrossProcessPostVirtualAlloc: if (!pBTCpuNotifyMemoryAlloc) break; + if (entry->args[2]) break; pBTCpuNotifyMemoryAlloc( (void *)entry->addr, entry->size, entry->args[0], entry->args[1] ); break; case CrossProcessPreVirtualFree: diff --git a/dlls/wow64/virtual.c b/dlls/wow64/virtual.c index 79b4e9c2288..e497f60210e 100644 --- a/dlls/wow64/virtual.c +++ b/dlls/wow64/virtual.c @@ -160,15 +160,14 @@ NTSTATUS WINAPI wow64_NtAllocateVirtualMemory( UINT *args ) addr, size, 3, type, protect, 0 ); status = NtAllocateVirtualMemory( process, &addr, get_zero_bits( zero_bits ), &size, type, protect ); + + if (!is_current) + send_cross_process_notification( process, CrossProcessPostVirtualAlloc, + addr, size, 3, type, protect, status ); + if (!status) { - if (is_current) - { - if (pBTCpuNotifyMemoryAlloc) pBTCpuNotifyMemoryAlloc( addr, size, type, protect ); - } - else send_cross_process_notification( process, CrossProcessPostVirtualAlloc, - addr, size, 3, type, protect, 0 ); - + if (is_current && pBTCpuNotifyMemoryAlloc) pBTCpuNotifyMemoryAlloc( addr, size, type, protect ); put_addr( addr32, addr ); put_size( size32, size ); } @@ -204,15 +203,13 @@ NTSTATUS WINAPI wow64_NtAllocateVirtualMemoryEx( UINT *args ) addr, size, 3, type, protect, 0 ); status = NtAllocateVirtualMemoryEx( process, &addr, &size, type, protect, params64, count ); + + if (!is_current) send_cross_process_notification( process, CrossProcessPostVirtualAlloc, + addr, size, 3, type, protect, status ); + if (!status) { - if (is_current) - { - if (pBTCpuNotifyMemoryAlloc) pBTCpuNotifyMemoryAlloc( addr, size, type, protect ); - } - else send_cross_process_notification( process, CrossProcessPostVirtualAlloc, - addr, size, 3, type, protect, 0 ); - + if (is_current && pBTCpuNotifyMemoryAlloc) pBTCpuNotifyMemoryAlloc( addr, size, type, protect ); put_addr( addr32, addr ); put_size( size32, size ); } @@ -299,11 +296,11 @@ NTSTATUS WINAPI wow64_NtFreeVirtualMemory( UINT *args ) addr, size, 2, type, 0 ); status = NtFreeVirtualMemory( process, &addr, &size, type ); + + if (!is_current) send_cross_process_notification( process, CrossProcessPostVirtualFree, + addr, size, 2, type, status ); if (!status) { - if (!is_current) - send_cross_process_notification( process, CrossProcessPostVirtualFree, - addr, size, 2, type, 0 ); put_addr( addr32, addr ); put_size( size32, size ); } @@ -517,11 +514,12 @@ NTSTATUS WINAPI wow64_NtProtectVirtualMemory( UINT *args ) addr, size, 2, new_prot, 0 ); status = NtProtectVirtualMemory( process, &addr, &size, new_prot, old_prot ); + + if (!is_current) send_cross_process_notification( process, CrossProcessPostVirtualProtect, + addr, size, 2, new_prot, status ); + if (!status) { - if (!is_current) - send_cross_process_notification( process, CrossProcessPostVirtualProtect, - addr, size, 2, new_prot, 0 ); put_addr( addr32, addr ); put_size( size32, size ); }
1
0
0
0
Rémi Bernon : include: Make general winetest helpers static inline.
by Alexandre Julliard
30 Aug '23
30 Aug '23
Module: wine Branch: master Commit: ef3e97dbc2176d8de5a078b50a8dd1ddfaa3cb2e URL:
https://gitlab.winehq.org/wine/wine/-/commit/ef3e97dbc2176d8de5a078b50a8dd1…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Tue Aug 29 21:59:17 2023 +0200 include: Make general winetest helpers static inline. --- include/wine/test.h | 366 ++++++++++++++++++++++++++-------------------------- 1 file changed, 184 insertions(+), 182 deletions(-)
1
0
0
0
Rémi Bernon : include: Prefix winetest color constants with winetest_.
by Alexandre Julliard
30 Aug '23
30 Aug '23
Module: wine Branch: master Commit: 4b9507d600c229d35709bb40791e5135c0f73d76 URL:
https://gitlab.winehq.org/wine/wine/-/commit/4b9507d600c229d35709bb40791e51…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Tue Aug 29 18:33:11 2023 +0200 include: Prefix winetest color constants with winetest_. --- include/wine/test.h | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/include/wine/test.h b/include/wine/test.h index 88884946e89..fd8b4619e8e 100644 --- a/include/wine/test.h +++ b/include/wine/test.h @@ -264,14 +264,14 @@ const char *winetest_elapsed(void) return wine_dbg_sprintf( "%.3f", (now - winetest_start_time) / 1000.0); } -static const char color_reset[] = "\x1b[0m"; -static const char color_dark_red[] = "\x1b[31m"; -static const char color_dark_purple[] = "\x1b[35m"; -static const char color_green[] = "\x1b[32m"; -static const char color_yellow[] = "\x1b[33m"; -static const char color_blue[] = "\x1b[34m"; -static const char color_bright_red[] = "\x1b[1;91m"; -static const char color_bright_purple[] = "\x1b[1;95m"; +static const char winetest_color_reset[] = "\x1b[0m"; +static const char winetest_color_dark_red[] = "\x1b[31m"; +static const char winetest_color_dark_purple[] = "\x1b[35m"; +static const char winetest_color_green[] = "\x1b[32m"; +static const char winetest_color_yellow[] = "\x1b[33m"; +static const char winetest_color_blue[] = "\x1b[34m"; +static const char winetest_color_bright_red[] = "\x1b[1;91m"; +static const char winetest_color_bright_purple[] = "\x1b[1;95m"; static void winetest_printf( const char *msg, ... ) __WINE_PRINTF_ATTR(1,2); static void winetest_printf( const char *msg, ... ) @@ -373,19 +373,19 @@ int winetest_vok( int condition, const char *msg, va_list args ) winetest_print_lock(); if (data->flaky_level) { - if (winetest_color) printf( color_dark_purple ); + if (winetest_color) printf( winetest_color_dark_purple ); winetest_print_context( "Test succeeded inside flaky todo block: " ); vprintf(msg, args); InterlockedIncrement( &winetest_flaky_failures ); } else { - if (winetest_color) printf( color_dark_red ); + if (winetest_color) printf( winetest_color_dark_red ); winetest_print_context( "Test succeeded inside todo block: " ); vprintf(msg, args); InterlockedIncrement( &winetest_todo_failures ); } - if (winetest_color) printf( color_reset ); + if (winetest_color) printf( winetest_color_reset ); winetest_print_unlock(); return 0; } @@ -397,10 +397,10 @@ int winetest_vok( int condition, const char *msg, va_list args ) if (winetest_debug > 0) { winetest_print_lock(); - if (winetest_color) printf( color_yellow ); + if (winetest_color) printf( winetest_color_yellow ); winetest_print_context( "Test marked todo: " ); vprintf(msg, args); - if (winetest_color) printf( color_reset ); + if (winetest_color) printf( winetest_color_reset ); winetest_print_unlock(); } InterlockedIncrement( &winetest_todo_successes ); @@ -416,19 +416,19 @@ int winetest_vok( int condition, const char *msg, va_list args ) winetest_print_lock(); if (data->flaky_level) { - if (winetest_color) printf( color_bright_purple ); + if (winetest_color) printf( winetest_color_bright_purple ); winetest_print_context( "Test marked flaky: " ); vprintf(msg, args); InterlockedIncrement( &winetest_flaky_failures ); } else { - if (winetest_color) printf( color_bright_red ); + if (winetest_color) printf( winetest_color_bright_red ); winetest_print_context( "Test failed: " ); vprintf(msg, args); InterlockedIncrement( &winetest_failures ); } - if (winetest_color) printf( color_reset ); + if (winetest_color) printf( winetest_color_reset ); winetest_print_unlock(); return 0; } @@ -438,9 +438,9 @@ int winetest_vok( int condition, const char *msg, va_list args ) (winetest_time && GetTickCount() >= winetest_last_time + 1000)) { winetest_print_lock(); - if (winetest_color) printf( color_green ); + if (winetest_color) printf( winetest_color_green ); winetest_printf("Test succeeded\n"); - if (winetest_color) printf( color_reset ); + if (winetest_color) printf( winetest_color_reset ); winetest_print_unlock(); } InterlockedIncrement( &winetest_successes ); @@ -481,10 +481,10 @@ void winetest_vskip( const char *msg, va_list args ) if (winetest_add_line() < winetest_mute_threshold) { winetest_print_lock(); - if (winetest_color) printf( color_blue ); + if (winetest_color) printf( winetest_color_blue ); winetest_print_context( "Tests skipped: " ); vprintf(msg, args); - if (winetest_color) printf( color_reset ); + if (winetest_color) printf( winetest_color_reset ); winetest_print_unlock(); InterlockedIncrement( &winetest_skipped ); } @@ -612,9 +612,9 @@ void winetest_wait_child_process( HANDLE process ) { DWORD pid = GetProcessId( process ); winetest_print_lock(); - if (winetest_color) printf( color_bright_red ); + if (winetest_color) printf( winetest_color_bright_red ); winetest_printf( "unhandled exception %08x in child process %04x\n", (UINT)exit_code, (UINT)pid ); - if (winetest_color) printf( color_reset ); + if (winetest_color) printf( winetest_color_reset ); winetest_print_unlock(); InterlockedIncrement( &winetest_failures ); } @@ -713,11 +713,11 @@ static LONG CALLBACK exc_filter( EXCEPTION_POINTERS *ptrs ) if (data->current_file) printf( "%s:%d: this is the last test seen before the exception\n", data->current_file, data->current_line ); - if (winetest_color) printf( color_bright_red ); + if (winetest_color) printf( winetest_color_bright_red ); printf( "%04x:%s:%s unhandled exception %08x at %p\n", (UINT)GetCurrentProcessId(), current_test->name, winetest_elapsed(), (UINT)ptrs->ExceptionRecord->ExceptionCode, ptrs->ExceptionRecord->ExceptionAddress ); - if (winetest_color) printf( color_reset ); + if (winetest_color) printf( winetest_color_reset ); fflush( stdout ); winetest_print_unlock(); return EXCEPTION_EXECUTE_HANDLER;
1
0
0
0
Rémi Bernon : include: Rename winetest thread data struct and getter.
by Alexandre Julliard
30 Aug '23
30 Aug '23
Module: wine Branch: master Commit: 615ceb3be3c52514d9c988378da6b9c8b6f7f251 URL:
https://gitlab.winehq.org/wine/wine/-/commit/615ceb3be3c52514d9c988378da6b9…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Tue Aug 29 21:57:05 2023 +0200 include: Rename winetest thread data struct and getter. --- include/wine/test.h | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/include/wine/test.h b/include/wine/test.h index 3bb50ad22cf..88884946e89 100644 --- a/include/wine/test.h +++ b/include/wine/test.h @@ -203,7 +203,7 @@ static LONG winetest_muted_todo_successes; /* same as todo_successes but silent static LONG line_counters[16384]; /* The following data must be kept track of on a per-thread basis */ -struct tls_data +struct winetest_thread_data { const char* current_file; /* file of current check */ int current_line; /* line of current check */ @@ -218,9 +218,9 @@ struct tls_data }; static DWORD tls_index; -static struct tls_data *get_tls_data(void) +static struct winetest_thread_data *winetest_get_thread_data(void) { - struct tls_data *data; + struct winetest_thread_data *data; DWORD last_error; last_error=GetLastError(); @@ -244,7 +244,7 @@ static void exit_process( int code ) void winetest_set_location( const char* file, int line ) { - struct tls_data *data = get_tls_data(); + struct winetest_thread_data *data = winetest_get_thread_data(); data->current_file=strrchr(file,'/'); if (data->current_file==NULL) data->current_file=strrchr(file,'\\'); @@ -276,7 +276,7 @@ static const char color_bright_purple[] = "\x1b[1;95m"; static void winetest_printf( const char *msg, ... ) __WINE_PRINTF_ATTR(1,2); static void winetest_printf( const char *msg, ... ) { - struct tls_data *data = get_tls_data(); + struct winetest_thread_data *data = winetest_get_thread_data(); va_list valist; printf( "%s:%d:%s ", data->current_file, data->current_line, winetest_elapsed() ); @@ -286,7 +286,7 @@ static void winetest_printf( const char *msg, ... ) } static void winetest_print_context( const char *msgtype ) { - struct tls_data *data = get_tls_data(); + struct winetest_thread_data *data = winetest_get_thread_data(); unsigned int i; winetest_printf( "%s", msgtype ); @@ -333,13 +333,13 @@ int broken( int condition ) static LONG winetest_add_line( void ) { - struct tls_data *data; + struct winetest_thread_data *data; int index, count; if (winetest_debug > 1) return 0; - data = get_tls_data(); + data = winetest_get_thread_data(); index = data->current_line % ARRAY_SIZE(line_counters); count = InterlockedIncrement(line_counters + index) - 1; if (count == winetest_mute_threshold) @@ -364,7 +364,7 @@ static LONG winetest_add_line( void ) */ int winetest_vok( int condition, const char *msg, va_list args ) { - struct tls_data *data = get_tls_data(); + struct winetest_thread_data *data = winetest_get_thread_data(); if (data->todo_level) { @@ -512,14 +512,14 @@ void winetest_win_skip( const char *msg, ... ) void winetest_start_flaky( int is_flaky ) { - struct tls_data *data = get_tls_data(); + struct winetest_thread_data *data = winetest_get_thread_data(); data->flaky_level = (data->flaky_level << 1) | (is_flaky != 0); data->flaky_do_loop = 1; } int winetest_loop_flaky(void) { - struct tls_data *data = get_tls_data(); + struct winetest_thread_data *data = winetest_get_thread_data(); int do_flaky = data->flaky_do_loop; data->flaky_do_loop = 0; return do_flaky; @@ -527,20 +527,20 @@ int winetest_loop_flaky(void) void winetest_end_flaky(void) { - struct tls_data *data = get_tls_data(); + struct winetest_thread_data *data = winetest_get_thread_data(); data->flaky_level >>= 1; } void winetest_start_todo( int is_todo ) { - struct tls_data *data = get_tls_data(); + struct winetest_thread_data *data = winetest_get_thread_data(); data->todo_level = (data->todo_level << 1) | (is_todo != 0); data->todo_do_loop=1; } int winetest_loop_todo(void) { - struct tls_data *data = get_tls_data(); + struct winetest_thread_data *data = winetest_get_thread_data(); int do_loop=data->todo_do_loop; data->todo_do_loop=0; return do_loop; @@ -548,13 +548,13 @@ int winetest_loop_todo(void) void winetest_end_todo(void) { - struct tls_data *data = get_tls_data(); + struct winetest_thread_data *data = winetest_get_thread_data(); data->todo_level >>= 1; } void winetest_push_context( const char *fmt, ... ) { - struct tls_data *data = get_tls_data(); + struct winetest_thread_data *data = winetest_get_thread_data(); va_list valist; if (data->context_count < ARRAY_SIZE(data->context)) @@ -569,7 +569,7 @@ void winetest_push_context( const char *fmt, ... ) void winetest_pop_context(void) { - struct tls_data *data = get_tls_data(); + struct winetest_thread_data *data = winetest_get_thread_data(); if (data->context_count) --data->context_count; @@ -707,7 +707,7 @@ static void usage( const char *argv0 ) /* trap unhandled exceptions */ static LONG CALLBACK exc_filter( EXCEPTION_POINTERS *ptrs ) { - struct tls_data *data = get_tls_data(); + struct winetest_thread_data *data = winetest_get_thread_data(); winetest_print_lock(); if (data->current_file)
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
...
67
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
Results per page:
10
25
50
100
200