From 009f5765df36fac3dbafb9a81102f85a76cc51b2 Mon Sep 17 00:00:00 2001 From: Elizabeth Figura Date: Mon, 9 Dec 2024 13:48:57 -0600 Subject: [PATCH] vkd3d-shader/hlsl: Return void from hlsl_block_add_store_component(). --- libs/vkd3d-shader/hlsl.c | 8 +++----- libs/vkd3d-shader/hlsl.h | 2 +- libs/vkd3d-shader/hlsl.y | 25 ++++++++----------------- libs/vkd3d-shader/hlsl_codegen.c | 10 +++------- 4 files changed, 15 insertions(+), 30 deletions(-) diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index a494e990..9cfee702 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -1550,20 +1550,20 @@ void hlsl_block_add_simple_store(struct hlsl_ctx *ctx, struct hlsl_block *block, hlsl_block_add_store_index(ctx, block, &lhs_deref, NULL, rhs, 0, &rhs->loc); } -bool hlsl_block_add_store_component(struct hlsl_ctx *ctx, struct hlsl_block *block, +void hlsl_block_add_store_component(struct hlsl_ctx *ctx, struct hlsl_block *block, const struct hlsl_deref *lhs, unsigned int comp, struct hlsl_ir_node *rhs) { struct hlsl_block comp_path_block; struct hlsl_ir_store *store; if (!(store = hlsl_alloc(ctx, sizeof(*store)))) - return false; + return; init_node(&store->node, HLSL_IR_STORE, NULL, &rhs->loc); if (!init_deref_from_component_index(ctx, &comp_path_block, &store->lhs, lhs, comp, &rhs->loc)) { vkd3d_free(store); - return false; + return; } hlsl_block_add_block(block, &comp_path_block); hlsl_src_from_node(&store->rhs, rhs); @@ -1572,8 +1572,6 @@ bool hlsl_block_add_store_component(struct hlsl_ctx *ctx, struct hlsl_block *blo store->writemask = (1 << rhs->data_type->e.numeric.dimx) - 1; hlsl_block_add_instr(block, &store->node); - - return true; } struct hlsl_ir_node *hlsl_new_call(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *decl, diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index ec225268..8e0b8c41 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -1520,7 +1520,7 @@ struct hlsl_ir_node *hlsl_block_add_load_component(struct hlsl_ctx *ctx, struct const struct hlsl_deref *deref, unsigned int comp, const struct vkd3d_shader_location *loc); void hlsl_block_add_simple_store(struct hlsl_ctx *ctx, struct hlsl_block *block, struct hlsl_ir_var *lhs, struct hlsl_ir_node *rhs); -bool hlsl_block_add_store_component(struct hlsl_ctx *ctx, struct hlsl_block *block, +void hlsl_block_add_store_component(struct hlsl_ctx *ctx, struct hlsl_block *block, const struct hlsl_deref *lhs, unsigned int comp, struct hlsl_ir_node *rhs); void hlsl_block_add_store_index(struct hlsl_ctx *ctx, struct hlsl_block *block, const struct hlsl_deref *lhs, struct hlsl_ir_node *idx, struct hlsl_ir_node *rhs, diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 5bf42e56..1f191fb8 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1611,8 +1611,7 @@ static struct hlsl_ir_node *add_expr(struct hlsl_ctx *ctx, struct hlsl_block *bl if (!(value = add_expr(ctx, block, op, cell_operands, scalar_type, loc))) return NULL; - if (!hlsl_block_add_store_component(ctx, block, &var_deref, i, value)) - return NULL; + hlsl_block_add_store_component(ctx, block, &var_deref, i, value); } if (!(var_load = hlsl_new_var_load(ctx, var, loc))) @@ -2216,11 +2215,7 @@ static bool add_assignment(struct hlsl_ctx *ctx, struct hlsl_block *block, struc return false; } - if (!hlsl_block_add_store_component(ctx, block, &deref, component, load)) - { - hlsl_cleanup_deref(&deref); - return false; - } + hlsl_block_add_store_component(ctx, block, &deref, component, load); } } @@ -2393,8 +2388,7 @@ static void initialize_var_components(struct hlsl_ctx *ctx, struct hlsl_block *i if (!(conv = add_implicit_conversion(ctx, instrs, load, dst_comp_type, &src->loc))) return; - if (!hlsl_block_add_store_component(ctx, instrs, &dst_deref, *store_index, conv)) - return; + hlsl_block_add_store_component(ctx, instrs, &dst_deref, *store_index, conv); } } @@ -3138,8 +3132,7 @@ static struct hlsl_ir_node *add_user_call(struct hlsl_ctx *ctx, return NULL; hlsl_block_add_instr(args->instrs, comp); - if (!hlsl_block_add_store_component(ctx, args->instrs, ¶m_deref, j, comp)) - return NULL; + hlsl_block_add_store_component(ctx, args->instrs, ¶m_deref, j, comp); } } } @@ -4454,9 +4447,8 @@ static bool intrinsic_mul(struct hlsl_ctx *ctx, } } - if (!hlsl_block_add_store_component(ctx, params->instrs, &var_deref, - j * matrix_type->e.numeric.dimx + i, instr)) - return false; + hlsl_block_add_store_component(ctx, params->instrs, &var_deref, + j * matrix_type->e.numeric.dimx + i, instr); } } @@ -5112,9 +5104,8 @@ static bool intrinsic_transpose(struct hlsl_ctx *ctx, j * arg->data_type->e.numeric.dimx + i, loc))) return false; - if (!hlsl_block_add_store_component(ctx, params->instrs, &var_deref, - i * var->data_type->e.numeric.dimx + j, load)) - return false; + hlsl_block_add_store_component(ctx, params->instrs, &var_deref, + i * var->data_type->e.numeric.dimx + j, load); } } diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index de7d965b..86d946a4 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -1159,8 +1159,7 @@ static bool lower_complex_casts(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr cast = hlsl_block_add_cast(ctx, block, component_load, dst_comp_type, &arg->loc); - if (!hlsl_block_add_store_component(ctx, block, &var_deref, dst_idx, cast)) - return false; + hlsl_block_add_store_component(ctx, block, &var_deref, dst_idx, cast); } if (!(load = hlsl_new_var_load(ctx, var, &instr->loc))) @@ -1204,8 +1203,7 @@ static bool lower_matrix_swizzles(struct hlsl_ctx *ctx, struct hlsl_ir_node *ins if (!(load = hlsl_add_load_component(ctx, block, swizzle->val.node, k, &instr->loc))) return false; - if (!hlsl_block_add_store_component(ctx, block, &var_deref, i, load)) - return false; + hlsl_block_add_store_component(ctx, block, &var_deref, i, load); } if (!(var_load = hlsl_new_var_load(ctx, var, &instr->loc))) @@ -3561,9 +3559,7 @@ static bool lower_trig(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct for (i = 0; i < type->e.numeric.dimx; ++i) { sincos = hlsl_block_add_unary_expr(ctx, block, op, comps[i], &instr->loc); - - if (!hlsl_block_add_store_component(ctx, block, &var_deref, i, sincos)) - return false; + hlsl_block_add_store_component(ctx, block, &var_deref, i, sincos); } if (!(var_load = hlsl_new_load_index(ctx, &var_deref, NULL, &instr->loc)))