mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
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:
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
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user