Zebediah Figura : vkd3d-shader: Generate the synthetic name for the temp variable instead of the uniform.
Alexandre Julliard
julliard at winehq.org
Tue Apr 20 16:26:15 CDT 2021
Module: vkd3d
Branch: master
Commit: f0d2a6d38470e178feb4ad13e99cc4d43a81e9bf
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=f0d2a6d38470e178feb4ad13e99cc4d43a81e9bf
Author: Zebediah Figura <zfigura at codeweavers.com>
Date: Thu Apr 15 19:03:45 2021 -0500
vkd3d-shader: Generate the synthetic name for the temp variable instead of the uniform.
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
libs/vkd3d-shader/hlsl_codegen.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c
index 12d5988..2522705 100644
--- a/libs/vkd3d-shader/hlsl_codegen.c
+++ b/libs/vkd3d-shader/hlsl_codegen.c
@@ -25,39 +25,43 @@
/* Split uniforms into two variables representing the constant and temp
* registers, and copy the former to the latter, so that writes to uniforms
* work. */
-static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_var *var)
+static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_var *temp)
{
struct vkd3d_string_buffer *name;
- struct hlsl_ir_var *const_var;
+ struct hlsl_ir_var *uniform;
struct hlsl_ir_store *store;
struct hlsl_ir_load *load;
- if (!(name = vkd3d_string_buffer_get(&ctx->string_buffers)))
+ /* Use the synthetic name for the temp, rather than the uniform, so that we
+ * can write the uniform name into the shader reflection data. */
+
+ if (!(uniform = hlsl_new_var(temp->name, temp->data_type, temp->loc, NULL, temp->reg_reservation)))
{
ctx->failed = true;
return;
}
- vkd3d_string_buffer_printf(name, "<uniform-%s>", var->name);
- if (!(const_var = hlsl_new_var(vkd3d_strdup(name->buffer), var->data_type, var->loc, NULL, var->reg_reservation)))
+ list_add_before(&temp->scope_entry, &uniform->scope_entry);
+ list_add_tail(&ctx->extern_vars, &uniform->extern_entry);
+ temp->is_uniform = 0;
+ uniform->is_uniform = 1;
+
+ if (!(name = vkd3d_string_buffer_get(&ctx->string_buffers)))
{
- vkd3d_string_buffer_release(&ctx->string_buffers, name);
ctx->failed = true;
return;
}
+ vkd3d_string_buffer_printf(name, "<temp-%s>", temp->name);
+ temp->name = vkd3d_strdup(name->buffer);
vkd3d_string_buffer_release(&ctx->string_buffers, name);
- list_add_before(&var->scope_entry, &const_var->scope_entry);
- list_add_tail(&ctx->extern_vars, &const_var->extern_entry);
- var->is_uniform = 0;
- const_var->is_uniform = 1;
- if (!(load = hlsl_new_var_load(const_var, var->loc)))
+ if (!(load = hlsl_new_var_load(uniform, temp->loc)))
{
ctx->failed = true;
return;
}
list_add_head(instrs, &load->node.entry);
- if (!(store = hlsl_new_simple_store(var, &load->node)))
+ if (!(store = hlsl_new_simple_store(temp, &load->node)))
{
ctx->failed = true;
return;
More information about the wine-cvs
mailing list