mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
vkd3d-shader/hlsl: Add a hlsl_block_add_store_index() helper.
This commit is contained in:
committed by
Henri Verbeet
parent
eafc97bcb3
commit
fc4f440245
Notes:
Henri Verbeet
2025-03-03 18:05:08 +01:00
Approved-by: Francisco Casas (@fcasas) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1394
@@ -1534,6 +1534,13 @@ struct hlsl_ir_node *hlsl_new_store_index(struct hlsl_ctx *ctx, const struct hls
|
||||
return &store->node;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
append_new_instr(ctx, block, hlsl_new_store_index(ctx, lhs, idx, rhs, writemask, 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)
|
||||
{
|
||||
|
@@ -1518,6 +1518,9 @@ struct hlsl_ir_node *hlsl_block_add_int_constant(struct hlsl_ctx *ctx, struct hl
|
||||
int32_t n, const struct vkd3d_shader_location *loc);
|
||||
struct hlsl_ir_node *hlsl_block_add_load_component(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
||||
const struct hlsl_deref *deref, unsigned int comp, const struct vkd3d_shader_location *loc);
|
||||
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);
|
||||
struct hlsl_ir_node *hlsl_block_add_uint_constant(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
||||
unsigned int n, const struct vkd3d_shader_location *loc);
|
||||
struct hlsl_ir_node *hlsl_block_add_unary_expr(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
||||
|
@@ -2247,7 +2247,7 @@ static bool add_assignment(struct hlsl_ctx *ctx, struct hlsl_block *block, struc
|
||||
|
||||
for (i = 0; i < mat->data_type->e.numeric.dimx; ++i)
|
||||
{
|
||||
struct hlsl_ir_node *cell, *load, *store, *c;
|
||||
struct hlsl_ir_node *cell, *load, *c;
|
||||
struct hlsl_deref deref;
|
||||
|
||||
if (!(writemask & (1 << i)))
|
||||
@@ -2265,29 +2265,18 @@ static bool add_assignment(struct hlsl_ctx *ctx, struct hlsl_block *block, struc
|
||||
if (!hlsl_init_deref_from_index_chain(ctx, &deref, cell))
|
||||
return false;
|
||||
|
||||
if (!(store = hlsl_new_store_index(ctx, &deref, NULL, load, 0, &rhs->loc)))
|
||||
{
|
||||
hlsl_cleanup_deref(&deref);
|
||||
return false;
|
||||
}
|
||||
hlsl_block_add_instr(block, store);
|
||||
hlsl_block_add_store_index(ctx, block, &deref, NULL, load, 0, &rhs->loc);
|
||||
hlsl_cleanup_deref(&deref);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
struct hlsl_ir_node *store;
|
||||
struct hlsl_deref deref;
|
||||
|
||||
if (!hlsl_init_deref_from_index_chain(ctx, &deref, lhs))
|
||||
return false;
|
||||
|
||||
if (!(store = hlsl_new_store_index(ctx, &deref, NULL, rhs, writemask, &rhs->loc)))
|
||||
{
|
||||
hlsl_cleanup_deref(&deref);
|
||||
return false;
|
||||
}
|
||||
hlsl_block_add_instr(block, store);
|
||||
hlsl_block_add_store_index(ctx, block, &deref, NULL, rhs, writemask, &rhs->loc);
|
||||
hlsl_cleanup_deref(&deref);
|
||||
}
|
||||
|
||||
|
@@ -403,7 +403,7 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct hlsl_ir_function_dec
|
||||
|
||||
for (i = 0; i < hlsl_type_major_size(type); ++i)
|
||||
{
|
||||
struct hlsl_ir_node *store, *cast;
|
||||
struct hlsl_ir_node *cast;
|
||||
struct hlsl_ir_var *input;
|
||||
struct hlsl_ir_load *load;
|
||||
|
||||
@@ -446,17 +446,13 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct hlsl_ir_function_dec
|
||||
{
|
||||
c = hlsl_block_add_uint_constant(ctx, block, i, &var->loc);
|
||||
|
||||
if (!(store = hlsl_new_store_index(ctx, &lhs->src, c, cast, 0, &var->loc)))
|
||||
return;
|
||||
hlsl_block_add_instr(block, store);
|
||||
hlsl_block_add_store_index(ctx, block, &lhs->src, c, cast, 0, &var->loc);
|
||||
}
|
||||
else
|
||||
{
|
||||
VKD3D_ASSERT(i == 0);
|
||||
|
||||
if (!(store = hlsl_new_store_index(ctx, &lhs->src, NULL, cast, 0, &var->loc)))
|
||||
return;
|
||||
hlsl_block_add_instr(block, store);
|
||||
hlsl_block_add_store_index(ctx, block, &lhs->src, NULL, cast, 0, &var->loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1072,10 +1068,10 @@ static struct hlsl_ir_node *add_zero_mipmap_level(struct hlsl_ctx *ctx, struct h
|
||||
struct hlsl_ir_node *index, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
unsigned int dim_count = index->data_type->e.numeric.dimx;
|
||||
struct hlsl_ir_node *store, *zero;
|
||||
struct hlsl_ir_load *coords_load;
|
||||
struct hlsl_deref coords_deref;
|
||||
struct hlsl_ir_var *coords;
|
||||
struct hlsl_ir_node *zero;
|
||||
|
||||
VKD3D_ASSERT(dim_count < 4);
|
||||
|
||||
@@ -1084,15 +1080,11 @@ static struct hlsl_ir_node *add_zero_mipmap_level(struct hlsl_ctx *ctx, struct h
|
||||
return NULL;
|
||||
|
||||
hlsl_init_simple_deref_from_var(&coords_deref, coords);
|
||||
if (!(store = hlsl_new_store_index(ctx, &coords_deref, NULL, index, (1u << dim_count) - 1, loc)))
|
||||
return NULL;
|
||||
hlsl_block_add_instr(block, store);
|
||||
hlsl_block_add_store_index(ctx, block, &coords_deref, NULL, index, (1u << dim_count) - 1, loc);
|
||||
|
||||
zero = hlsl_block_add_uint_constant(ctx, block, 0, loc);
|
||||
|
||||
if (!(store = hlsl_new_store_index(ctx, &coords_deref, NULL, zero, 1u << dim_count, loc)))
|
||||
return NULL;
|
||||
hlsl_block_add_instr(block, store);
|
||||
hlsl_block_add_store_index(ctx, block, &coords_deref, NULL, zero, 1u << dim_count, loc);
|
||||
|
||||
if (!(coords_load = hlsl_new_var_load(ctx, coords, loc)))
|
||||
return NULL;
|
||||
@@ -1308,9 +1300,7 @@ static bool lower_index_loads(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
|
||||
return false;
|
||||
hlsl_block_add_instr(block, &load->node);
|
||||
|
||||
if (!(store = hlsl_new_store_index(ctx, &row_deref, c, &load->node, 0, &instr->loc)))
|
||||
return false;
|
||||
hlsl_block_add_instr(block, store);
|
||||
hlsl_block_add_store_index(ctx, block, &row_deref, c, &load->node, 0, &instr->loc);
|
||||
}
|
||||
|
||||
if (!(load = hlsl_new_var_load(ctx, var, &instr->loc)))
|
||||
|
Reference in New Issue
Block a user