vkd3d-shader/hlsl: Don't create a temporary copy for a uniform if one already exists.

This can currently never happen, because we only ever process each uniform
once. However, this will change once we support compiling multiple shaders
in effects.
This commit is contained in:
Anna (navi) Figueiredo Gomes
2025-07-03 02:41:14 +02:00
committed by Henri Verbeet
parent f4d95af91d
commit db80f09c7a
Notes: Henri Verbeet 2025-07-23 17:30:00 +02:00
Approved-by: Francisco Casas (@fcasas)
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1471

View File

@@ -186,12 +186,15 @@ static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct hlsl_block *block,
{ {
struct hlsl_ir_node *store; struct hlsl_ir_node *store;
struct hlsl_ir_load *load; struct hlsl_ir_load *load;
struct hlsl_ir_var *temp;
char *new_name;
uniform->is_uniform = 1; uniform->is_uniform = 1;
list_add_tail(&ctx->extern_vars, &uniform->extern_entry); list_add_tail(&ctx->extern_vars, &uniform->extern_entry);
if (!uniform->temp_copy)
{
struct hlsl_ir_var *temp;
char *new_name;
if (!(new_name = hlsl_sprintf_alloc(ctx, "<temp-%s>", uniform->name))) if (!(new_name = hlsl_sprintf_alloc(ctx, "<temp-%s>", uniform->name)))
return; return;
@@ -204,12 +207,13 @@ static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct hlsl_block *block,
list_add_tail(&ctx->dummy_scope->vars, &temp->scope_entry); list_add_tail(&ctx->dummy_scope->vars, &temp->scope_entry);
uniform->temp_copy = temp; uniform->temp_copy = temp;
}
if (!(load = hlsl_new_var_load(ctx, uniform, &uniform->loc))) if (!(load = hlsl_new_var_load(ctx, uniform, &uniform->loc)))
return; return;
list_add_head(&block->instrs, &load->node.entry); list_add_head(&block->instrs, &load->node.entry);
if (!(store = hlsl_new_simple_store(ctx, temp, &load->node))) if (!(store = hlsl_new_simple_store(ctx, uniform->temp_copy, &load->node)))
return; return;
list_add_after(&load->node.entry, &store->entry); list_add_after(&load->node.entry, &store->entry);
} }