vkd3d-shader/hlsl: Pass the target block to hlsl_new_store_component().

This commit is contained in:
Elizabeth Figura
2024-12-09 13:46:33 -06:00
committed by Henri Verbeet
parent 5ab5a721a1
commit 9e3ac35669
Notes: Henri Verbeet 2025-03-05 14:16:50 +01:00
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Francisco Casas (@fcasas)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1401
4 changed files with 14 additions and 33 deletions

View File

@@ -1550,14 +1550,12 @@ 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_new_store_component(struct hlsl_ctx *ctx, struct hlsl_block *block,
bool 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;
hlsl_block_init(block);
if (!(store = hlsl_alloc(ctx, sizeof(*store))))
return false;
init_node(&store->node, HLSL_IR_STORE, NULL, &rhs->loc);

View File

@@ -1520,6 +1520,8 @@ 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,
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,
unsigned int writemask, const struct vkd3d_shader_location *loc);
@@ -1624,8 +1626,6 @@ struct hlsl_ir_node *hlsl_add_load_component(struct hlsl_ctx *ctx, struct hlsl_b
struct hlsl_ir_node *hlsl_new_simple_store(struct hlsl_ctx *ctx, struct hlsl_ir_var *lhs, struct hlsl_ir_node *rhs);
struct hlsl_ir_node *hlsl_new_store_index(struct hlsl_ctx *ctx, const struct hlsl_deref *lhs,
struct hlsl_ir_node *idx, struct hlsl_ir_node *rhs, unsigned int writemask, const struct vkd3d_shader_location *loc);
bool hlsl_new_store_component(struct hlsl_ctx *ctx, struct hlsl_block *block,
const struct hlsl_deref *lhs, unsigned int comp, struct hlsl_ir_node *rhs);
bool hlsl_index_is_noncontiguous(struct hlsl_ir_index *index);
bool hlsl_index_is_resource_access(struct hlsl_ir_index *index);

View File

@@ -1595,7 +1595,6 @@ static struct hlsl_ir_node *add_expr(struct hlsl_ctx *ctx, struct hlsl_block *bl
for (i = 0; i < type->e.numeric.dimy * type->e.numeric.dimx; ++i)
{
struct hlsl_ir_node *value, *cell_operands[HLSL_MAX_OPERANDS] = { NULL };
struct hlsl_block store_block;
unsigned int j;
for (j = 0; j < HLSL_MAX_OPERANDS; j++)
@@ -1612,9 +1611,8 @@ 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_new_store_component(ctx, &store_block, &var_deref, i, value))
if (!hlsl_block_add_store_component(ctx, block, &var_deref, i, value))
return NULL;
hlsl_block_add_block(block, &store_block);
}
if (!(var_load = hlsl_new_var_load(ctx, var, loc)))
@@ -2206,7 +2204,6 @@ static bool add_assignment(struct hlsl_ctx *ctx, struct hlsl_block *block, struc
for (j = 0; j < lhs->data_type->e.numeric.dimx; ++j)
{
struct hlsl_ir_node *load;
struct hlsl_block store_block;
const unsigned int idx = i * 4 + j;
const unsigned int component = i * lhs->data_type->e.numeric.dimx + j;
@@ -2219,12 +2216,11 @@ static bool add_assignment(struct hlsl_ctx *ctx, struct hlsl_block *block, struc
return false;
}
if (!hlsl_new_store_component(ctx, &store_block, &deref, component, load))
if (!hlsl_block_add_store_component(ctx, block, &deref, component, load))
{
hlsl_cleanup_deref(&deref);
return false;
}
hlsl_block_add_block(block, &store_block);
}
}
@@ -2397,9 +2393,8 @@ 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_new_store_component(ctx, &block, &dst_deref, *store_index, conv))
if (!hlsl_block_add_store_component(ctx, instrs, &dst_deref, *store_index, conv))
return;
hlsl_block_add_block(instrs, &block);
}
}
@@ -3135,7 +3130,6 @@ static struct hlsl_ir_node *add_user_call(struct hlsl_ctx *ctx,
struct hlsl_type *type = hlsl_type_get_component_type(ctx, param->data_type, j);
struct hlsl_constant_value value;
struct hlsl_ir_node *comp;
struct hlsl_block store_block;
if (!param->default_values[j].string)
{
@@ -3144,9 +3138,8 @@ static struct hlsl_ir_node *add_user_call(struct hlsl_ctx *ctx,
return NULL;
hlsl_block_add_instr(args->instrs, comp);
if (!hlsl_new_store_component(ctx, &store_block, &param_deref, j, comp))
if (!hlsl_block_add_store_component(ctx, args->instrs, &param_deref, j, comp))
return NULL;
hlsl_block_add_block(args->instrs, &store_block);
}
}
}
@@ -4434,7 +4427,6 @@ static bool intrinsic_mul(struct hlsl_ctx *ctx,
for (j = 0; j < matrix_type->e.numeric.dimy; ++j)
{
struct hlsl_ir_node *instr = NULL;
struct hlsl_block block;
for (k = 0; k < cast_type1->e.numeric.dimx && k < cast_type2->e.numeric.dimy; ++k)
{
@@ -4462,9 +4454,9 @@ static bool intrinsic_mul(struct hlsl_ctx *ctx,
}
}
if (!hlsl_new_store_component(ctx, &block, &var_deref, j * matrix_type->e.numeric.dimx + i, instr))
if (!hlsl_block_add_store_component(ctx, params->instrs, &var_deref,
j * matrix_type->e.numeric.dimx + i, instr))
return false;
hlsl_block_add_block(params->instrs, &block);
}
}
@@ -5116,15 +5108,13 @@ static bool intrinsic_transpose(struct hlsl_ctx *ctx,
{
for (j = 0; j < arg_type->e.numeric.dimy; ++j)
{
struct hlsl_block block;
if (!(load = hlsl_add_load_component(ctx, params->instrs, arg,
j * arg->data_type->e.numeric.dimx + i, loc)))
return false;
if (!hlsl_new_store_component(ctx, &block, &var_deref, i * var->data_type->e.numeric.dimx + j, load))
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_block(params->instrs, &block);
}
}

View File

@@ -1135,7 +1135,6 @@ static bool lower_complex_casts(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr
{
struct hlsl_ir_node *component_load, *cast;
struct hlsl_type *dst_comp_type;
struct hlsl_block store_block;
unsigned int src_idx;
if (broadcast)
@@ -1160,9 +1159,8 @@ 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_new_store_component(ctx, &store_block, &var_deref, dst_idx, cast))
if (!hlsl_block_add_store_component(ctx, block, &var_deref, dst_idx, cast))
return false;
hlsl_block_add_block(block, &store_block);
}
if (!(load = hlsl_new_var_load(ctx, var, &instr->loc)))
@@ -1199,7 +1197,6 @@ static bool lower_matrix_swizzles(struct hlsl_ctx *ctx, struct hlsl_ir_node *ins
for (i = 0; i < instr->data_type->e.numeric.dimx; ++i)
{
struct hlsl_block store_block;
struct hlsl_ir_node *load;
k = swizzle->u.matrix.components[i].y * matrix_type->e.numeric.dimx + swizzle->u.matrix.components[i].x;
@@ -1207,9 +1204,8 @@ 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_new_store_component(ctx, &store_block, &var_deref, i, load))
if (!hlsl_block_add_store_component(ctx, block, &var_deref, i, load))
return false;
hlsl_block_add_block(block, &store_block);
}
if (!(var_load = hlsl_new_var_load(ctx, var, &instr->loc)))
@@ -3564,13 +3560,10 @@ static bool lower_trig(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct
for (i = 0; i < type->e.numeric.dimx; ++i)
{
struct hlsl_block store_block;
sincos = hlsl_block_add_unary_expr(ctx, block, op, comps[i], &instr->loc);
if (!hlsl_new_store_component(ctx, &store_block, &var_deref, i, sincos))
if (!hlsl_block_add_store_component(ctx, block, &var_deref, i, sincos))
return false;
hlsl_block_add_block(block, &store_block);
}
if (!(var_load = hlsl_new_load_index(ctx, &var_deref, NULL, &instr->loc)))