vkd3d-shader/hlsl: Store static initialization instructions in a block.

This commit is contained in:
Nikolay Sivov 2023-06-09 15:28:06 +02:00 committed by Alexandre Julliard
parent 5dee6561c2
commit 99314b6340
Notes: Alexandre Julliard 2023-06-12 23:10:20 +02:00
Approved-by: Zebediah Figura (@zfigura)
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/228
4 changed files with 8 additions and 9 deletions

View File

@ -3236,7 +3236,7 @@ static bool hlsl_ctx_init(struct hlsl_ctx *ctx, const char *source_name,
rb_init(&ctx->functions, compare_function_rb);
list_init(&ctx->static_initializers);
hlsl_block_init(&ctx->static_initializers);
list_init(&ctx->extern_vars);
list_init(&ctx->buffers);

View File

@ -796,9 +796,8 @@ struct hlsl_ctx
struct hlsl_type *Void;
} builtin_types;
/* List of the instruction nodes for initializing static variables; linked by the
* hlsl_ir_node.entry fields. */
struct list static_initializers;
/* List of the instruction nodes for initializing static variables. */
struct hlsl_block static_initializers;
/* Dynamic array of constant values that appear in the shader, associated to the 'c' registers.
* Only used for SM1 profiles. */

View File

@ -2159,7 +2159,7 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
}
if (modifiers & HLSL_STORAGE_STATIC)
list_move_tail(&ctx->static_initializers, v->initializer.instrs);
list_move_tail(&ctx->static_initializers.instrs, v->initializer.instrs);
else
list_move_tail(statements_list, v->initializer.instrs);
vkd3d_free(v->initializer.args);
@ -2182,9 +2182,9 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
vkd3d_free(v);
continue;
}
list_add_tail(&ctx->static_initializers, &zero->entry);
hlsl_block_add_instr(&ctx->static_initializers, zero);
if (!(cast = add_cast(ctx, &ctx->static_initializers, zero, var->data_type, &var->loc)))
if (!(cast = add_cast(ctx, &ctx->static_initializers.instrs, zero, var->data_type, &var->loc)))
{
vkd3d_free(v);
continue;
@ -2195,7 +2195,7 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
vkd3d_free(v);
continue;
}
list_add_tail(&ctx->static_initializers, &store->entry);
hlsl_block_add_instr(&ctx->static_initializers, store);
}
vkd3d_free(v);
}

View File

@ -3977,7 +3977,7 @@ int hlsl_emit_bytecode(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry
unsigned int i;
bool progress;
list_move_head(&body->instrs, &ctx->static_initializers);
list_move_head(&body->instrs, &ctx->static_initializers.instrs);
memset(&recursive_call_ctx, 0, sizeof(recursive_call_ctx));
hlsl_transform_ir(ctx, find_recursive_calls, body, &recursive_call_ctx);