diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 09ec2f8e..54f3292b 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -461,7 +461,7 @@ static bool init_deref_from_component_index(struct hlsl_ctx *ctx, struct hlsl_bl struct hlsl_type *path_type; struct hlsl_ir_constant *c; - list_init(&block->instrs); + hlsl_block_init(block); path_len = 0; path_type = hlsl_deref_get_type(ctx, prefix); @@ -1012,7 +1012,7 @@ struct hlsl_ir_store *hlsl_new_store_component(struct hlsl_ctx *ctx, struct hlsl struct hlsl_block comp_path_block; struct hlsl_ir_store *store; - list_init(&block->instrs); + hlsl_block_init(block); if (!(store = hlsl_alloc(ctx, sizeof(*store)))) return NULL; @@ -1150,8 +1150,8 @@ struct hlsl_ir_if *hlsl_new_if(struct hlsl_ctx *ctx, struct hlsl_ir_node *condit return NULL; init_node(&iff->node, HLSL_IR_IF, NULL, &loc); hlsl_src_from_node(&iff->condition, condition); - list_init(&iff->then_instrs.instrs); - list_init(&iff->else_instrs.instrs); + hlsl_block_init(&iff->then_instrs); + hlsl_block_init(&iff->else_instrs); return iff; } @@ -1201,7 +1201,7 @@ struct hlsl_ir_load *hlsl_new_load_component(struct hlsl_ctx *ctx, struct hlsl_b struct hlsl_block comp_path_block; struct hlsl_ir_load *load; - list_init(&block->instrs); + hlsl_block_init(block); if (!(load = hlsl_alloc(ctx, sizeof(*load)))) return NULL; @@ -1298,7 +1298,7 @@ struct hlsl_ir_loop *hlsl_new_loop(struct hlsl_ctx *ctx, struct vkd3d_shader_loc if (!(loop = hlsl_alloc(ctx, sizeof(*loop)))) return NULL; init_node(&loop->node, HLSL_IR_LOOP, NULL, &loc); - list_init(&loop->body.instrs); + hlsl_block_init(&loop->body); return loop; } @@ -1601,7 +1601,7 @@ struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, if (!(decl = hlsl_alloc(ctx, sizeof(*decl)))) return NULL; - list_init(&decl->body.instrs); + hlsl_block_init(&decl->body); decl->return_type = return_type; decl->parameters = *parameters; decl->loc = *loc; diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 6c8b8da3..3e631dd9 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -857,6 +857,11 @@ static inline struct hlsl_ir_swizzle *hlsl_ir_swizzle(const struct hlsl_ir_node return CONTAINING_RECORD(node, struct hlsl_ir_swizzle, node); } +static inline void hlsl_block_init(struct hlsl_block *block) +{ + list_init(&block->instrs); +} + static inline void hlsl_block_add_instr(struct hlsl_block *block, struct hlsl_ir_node *instr) { list_add_tail(&block->instrs, &instr->entry); diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index c95ce2d8..c8550b65 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -29,7 +29,7 @@ static struct hlsl_ir_node *new_offset_from_path_index(struct hlsl_ctx *ctx, str struct hlsl_ir_node *idx_offset = NULL; struct hlsl_ir_constant *c; - list_init(&block->instrs); + hlsl_block_init(block); switch (type->class) { @@ -101,7 +101,7 @@ static struct hlsl_ir_node *new_offset_instr_from_deref(struct hlsl_ctx *ctx, st struct hlsl_type *type; unsigned int i; - list_init(&block->instrs); + hlsl_block_init(block); assert(deref->var); type = deref->var->data_type; @@ -721,7 +721,7 @@ static bool lower_calls(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void * hlsl_error(ctx, &call->node.loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Function \"%s\" is not defined.", decl->func->name); - list_init(&block.instrs); + hlsl_block_init(&block); if (!hlsl_clone_block(ctx, &block, &decl->body)) return false; list_move_before(&call->node.entry, &block.instrs);