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.
This commit is contained in:
Zebediah Figura 2023-08-29 16:50:13 -05:00 committed by Alexandre Julliard
parent f22e52f358
commit d396c4ce27
Notes: Alexandre Julliard 2023-08-30 23:19:43 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/310
2 changed files with 4 additions and 2 deletions

View File

@ -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;

View File

@ -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;