mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader: Store variables with external linkage in a dedicated list.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
44816403f1
commit
8f26986615
@ -1578,6 +1578,7 @@ static bool hlsl_ctx_init(struct hlsl_ctx *ctx, const struct hlsl_profile_info *
|
||||
rb_init(&ctx->functions, compare_function_rb);
|
||||
|
||||
list_init(&ctx->static_initializers);
|
||||
list_init(&ctx->extern_vars);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ struct hlsl_ir_var
|
||||
const char *name;
|
||||
const char *semantic;
|
||||
const struct hlsl_reg_reservation *reg_reservation;
|
||||
struct list scope_entry, param_entry;
|
||||
struct list scope_entry, param_entry, extern_entry;
|
||||
|
||||
unsigned int first_write, last_read;
|
||||
struct hlsl_reg reg;
|
||||
@ -418,6 +418,7 @@ struct hlsl_ctx
|
||||
struct hlsl_scope *cur_scope;
|
||||
struct hlsl_scope *globals;
|
||||
struct list scopes;
|
||||
struct list extern_vars;
|
||||
|
||||
struct list types;
|
||||
struct rb_tree functions;
|
||||
|
@ -45,7 +45,8 @@ static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct list *instrs, stru
|
||||
return;
|
||||
}
|
||||
vkd3d_string_buffer_release(&ctx->string_buffers, name);
|
||||
list_add_head(&ctx->globals->vars, &const_var->scope_entry);
|
||||
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;
|
||||
|
||||
@ -87,7 +88,8 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct
|
||||
}
|
||||
vkd3d_string_buffer_release(&ctx->string_buffers, name);
|
||||
varying->is_input_varying = 1;
|
||||
list_add_head(&ctx->globals->vars, &varying->scope_entry);
|
||||
list_add_before(&var->scope_entry, &varying->scope_entry);
|
||||
list_add_tail(&ctx->extern_vars, &varying->extern_entry);
|
||||
|
||||
if (!(load = hlsl_new_var_load(varying, var->loc)))
|
||||
{
|
||||
@ -164,7 +166,8 @@ static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct
|
||||
}
|
||||
vkd3d_string_buffer_release(&ctx->string_buffers, name);
|
||||
varying->is_output_varying = 1;
|
||||
list_add_head(&ctx->globals->vars, &varying->scope_entry);
|
||||
list_add_before(&var->scope_entry, &varying->scope_entry);
|
||||
list_add_tail(&ctx->extern_vars, &varying->extern_entry);
|
||||
|
||||
if (!(offset = hlsl_new_uint_constant(ctx, field_offset * 4, var->loc)))
|
||||
{
|
||||
@ -593,7 +596,7 @@ static void compute_liveness(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl
|
||||
var->first_write = var->last_read = 0;
|
||||
}
|
||||
|
||||
LIST_FOR_EACH_ENTRY(var, &ctx->globals->vars, struct hlsl_ir_var, scope_entry)
|
||||
LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry)
|
||||
{
|
||||
if (var->is_uniform || var->is_input_varying)
|
||||
var->first_write = 1;
|
||||
@ -601,11 +604,6 @@ static void compute_liveness(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl
|
||||
var->last_read = UINT_MAX;
|
||||
}
|
||||
|
||||
LIST_FOR_EACH_ENTRY(var, entry_func->parameters, struct hlsl_ir_var, param_entry)
|
||||
{
|
||||
var->first_write = 1;
|
||||
}
|
||||
|
||||
if (entry_func->return_var)
|
||||
entry_func->return_var->last_read = UINT_MAX;
|
||||
|
||||
@ -846,7 +844,7 @@ static void allocate_const_registers(struct hlsl_ctx *ctx, struct hlsl_ir_functi
|
||||
struct liveness liveness = {0};
|
||||
struct hlsl_ir_var *var;
|
||||
|
||||
LIST_FOR_EACH_ENTRY(var, &ctx->globals->vars, struct hlsl_ir_var, scope_entry)
|
||||
LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry)
|
||||
{
|
||||
if (var->is_uniform && var->last_read)
|
||||
{
|
||||
@ -928,12 +926,16 @@ int hlsl_emit_dxbc(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_fun
|
||||
|
||||
LIST_FOR_EACH_ENTRY(var, &ctx->globals->vars, struct hlsl_ir_var, scope_entry)
|
||||
{
|
||||
if (var->data_type->type == HLSL_CLASS_OBJECT)
|
||||
list_add_tail(&ctx->extern_vars, &var->extern_entry);
|
||||
if (var->is_uniform)
|
||||
prepend_uniform_copy(ctx, entry_func->body, var);
|
||||
}
|
||||
|
||||
LIST_FOR_EACH_ENTRY(var, entry_func->parameters, struct hlsl_ir_var, param_entry)
|
||||
{
|
||||
if (var->data_type->type == HLSL_CLASS_OBJECT)
|
||||
list_add_tail(&ctx->extern_vars, &var->extern_entry);
|
||||
if (var->is_uniform)
|
||||
prepend_uniform_copy(ctx, entry_func->body, var);
|
||||
if (var->is_input_varying)
|
||||
|
Loading…
Reference in New Issue
Block a user