vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_store_index().

This commit is contained in:
Zebediah Figura 2022-11-10 20:57:00 -06:00 committed by Alexandre Julliard
parent 29a2b87f54
commit 306ae40696
Notes: Alexandre Julliard 2023-05-09 22:25:23 +02:00
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/196
4 changed files with 19 additions and 25 deletions

View File

@ -1067,16 +1067,13 @@ static void init_node(struct hlsl_ir_node *node, enum hlsl_ir_node_type type,
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_simple_store(struct hlsl_ctx *ctx, struct hlsl_ir_var *lhs, struct hlsl_ir_node *rhs)
{ {
struct hlsl_ir_store *store;
struct hlsl_deref lhs_deref; struct hlsl_deref lhs_deref;
hlsl_init_simple_deref_from_var(&lhs_deref, lhs); hlsl_init_simple_deref_from_var(&lhs_deref, lhs);
if (!(store = hlsl_new_store_index(ctx, &lhs_deref, NULL, rhs, 0, &rhs->loc))) return hlsl_new_store_index(ctx, &lhs_deref, NULL, rhs, 0, &rhs->loc);
return NULL;
return &store->node;
} }
struct hlsl_ir_store *hlsl_new_store_index(struct hlsl_ctx *ctx, const struct hlsl_deref *lhs, 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) struct hlsl_ir_node *idx, struct hlsl_ir_node *rhs, unsigned int writemask, const struct vkd3d_shader_location *loc)
{ {
struct hlsl_ir_store *store; struct hlsl_ir_store *store;
@ -1105,7 +1102,7 @@ struct hlsl_ir_store *hlsl_new_store_index(struct hlsl_ctx *ctx, const struct hl
writemask = (1 << rhs->data_type->dimx) - 1; writemask = (1 << rhs->data_type->dimx) - 1;
store->writemask = writemask; store->writemask = writemask;
return store; return &store->node;
} }
bool hlsl_new_store_component(struct hlsl_ctx *ctx, struct hlsl_block *block, bool hlsl_new_store_component(struct hlsl_ctx *ctx, struct hlsl_block *block,

View File

@ -1123,7 +1123,7 @@ struct hlsl_ir_node *hlsl_new_load_component(struct hlsl_ctx *ctx, struct hlsl_b
const struct hlsl_deref *deref, unsigned int comp, const struct vkd3d_shader_location *loc); const struct hlsl_deref *deref, unsigned int comp, const struct vkd3d_shader_location *loc);
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_simple_store(struct hlsl_ctx *ctx, struct hlsl_ir_var *lhs, struct hlsl_ir_node *rhs);
struct hlsl_ir_store *hlsl_new_store_index(struct hlsl_ctx *ctx, const struct hlsl_deref *lhs, 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); 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, 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); const struct hlsl_deref *lhs, unsigned int comp, struct hlsl_ir_node *rhs);

View File

@ -1753,8 +1753,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
for (i = 0; i < mat->data_type->dimx; ++i) for (i = 0; i < mat->data_type->dimx; ++i)
{ {
struct hlsl_ir_node *cell, *load; struct hlsl_ir_node *cell, *load, *store;
struct hlsl_ir_store *store;
struct hlsl_ir_constant *c; struct hlsl_ir_constant *c;
struct hlsl_deref deref; struct hlsl_deref deref;
@ -1780,13 +1779,13 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
hlsl_cleanup_deref(&deref); hlsl_cleanup_deref(&deref);
return NULL; return NULL;
} }
list_add_tail(instrs, &store->node.entry); list_add_tail(instrs, &store->entry);
hlsl_cleanup_deref(&deref); hlsl_cleanup_deref(&deref);
} }
} }
else else
{ {
struct hlsl_ir_store *store; struct hlsl_ir_node *store;
struct hlsl_deref deref; struct hlsl_deref deref;
if (!hlsl_init_deref_from_index_chain(ctx, &deref, lhs)) if (!hlsl_init_deref_from_index_chain(ctx, &deref, lhs))
@ -1797,7 +1796,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
hlsl_cleanup_deref(&deref); hlsl_cleanup_deref(&deref);
return NULL; return NULL;
} }
list_add_tail(instrs, &store->node.entry); list_add_tail(instrs, &store->entry);
hlsl_cleanup_deref(&deref); hlsl_cleanup_deref(&deref);
} }

View File

@ -353,10 +353,9 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct
for (i = 0; i < hlsl_type_major_size(type); ++i) for (i = 0; i < hlsl_type_major_size(type); ++i)
{ {
struct hlsl_ir_store *store; struct hlsl_ir_node *store, *cast;
struct hlsl_ir_var *input; struct hlsl_ir_var *input;
struct hlsl_ir_load *load; struct hlsl_ir_load *load;
struct hlsl_ir_node *cast;
if (!(input = add_semantic_var(ctx, var, vector_type_src, modifiers, semantic, if (!(input = add_semantic_var(ctx, var, vector_type_src, modifiers, semantic,
semantic_index + i, false, loc))) semantic_index + i, false, loc)))
@ -378,7 +377,7 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct
if (!(store = hlsl_new_store_index(ctx, &lhs->src, &c->node, cast, 0, &var->loc))) if (!(store = hlsl_new_store_index(ctx, &lhs->src, &c->node, cast, 0, &var->loc)))
return; return;
list_add_after(&c->node.entry, &store->node.entry); list_add_after(&c->node.entry, &store->entry);
} }
else else
{ {
@ -386,7 +385,7 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct
if (!(store = hlsl_new_store_index(ctx, &lhs->src, NULL, cast, 0, &var->loc))) if (!(store = hlsl_new_store_index(ctx, &lhs->src, NULL, cast, 0, &var->loc)))
return; return;
list_add_after(&cast->entry, &store->node.entry); list_add_after(&cast->entry, &store->entry);
} }
} }
} }
@ -868,7 +867,7 @@ static struct hlsl_ir_node *add_zero_mipmap_level(struct hlsl_ctx *ctx, struct h
struct hlsl_ir_load *coords_load; struct hlsl_ir_load *coords_load;
struct hlsl_deref coords_deref; struct hlsl_deref coords_deref;
struct hlsl_ir_constant *zero; struct hlsl_ir_constant *zero;
struct hlsl_ir_store *store; struct hlsl_ir_node *store;
struct hlsl_ir_var *coords; struct hlsl_ir_var *coords;
assert(dim_count < 4); assert(dim_count < 4);
@ -880,19 +879,19 @@ static struct hlsl_ir_node *add_zero_mipmap_level(struct hlsl_ctx *ctx, struct h
hlsl_init_simple_deref_from_var(&coords_deref, coords); 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))) if (!(store = hlsl_new_store_index(ctx, &coords_deref, NULL, index, (1u << dim_count) - 1, loc)))
return NULL; return NULL;
list_add_after(&index->entry, &store->node.entry); list_add_after(&index->entry, &store->entry);
if (!(zero = hlsl_new_uint_constant(ctx, 0, loc))) if (!(zero = hlsl_new_uint_constant(ctx, 0, loc)))
return NULL; return NULL;
list_add_after(&store->node.entry, &zero->node.entry); list_add_after(&store->entry, &zero->node.entry);
if (!(store = hlsl_new_store_index(ctx, &coords_deref, NULL, &zero->node, 1u << dim_count, loc))) if (!(store = hlsl_new_store_index(ctx, &coords_deref, NULL, &zero->node, 1u << dim_count, loc)))
return NULL; return NULL;
list_add_after(&zero->node.entry, &store->node.entry); list_add_after(&zero->node.entry, &store->entry);
if (!(coords_load = hlsl_new_var_load(ctx, coords, loc))) if (!(coords_load = hlsl_new_var_load(ctx, coords, loc)))
return NULL; return NULL;
list_add_after(&store->node.entry, &coords_load->node.entry); list_add_after(&store->entry, &coords_load->node.entry);
return &coords_load->node; return &coords_load->node;
} }
@ -964,7 +963,6 @@ static bool lower_index_loads(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
for (i = 0; i < mat->data_type->dimx; ++i) for (i = 0; i < mat->data_type->dimx; ++i)
{ {
struct hlsl_ir_store *store;
struct hlsl_ir_constant *c; struct hlsl_ir_constant *c;
if (!(c = hlsl_new_uint_constant(ctx, i, &instr->loc))) if (!(c = hlsl_new_uint_constant(ctx, i, &instr->loc)))
@ -981,7 +979,7 @@ static bool lower_index_loads(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
if (!(store = hlsl_new_store_index(ctx, &row_deref, &c->node, &load->node, 0, &instr->loc))) if (!(store = hlsl_new_store_index(ctx, &row_deref, &c->node, &load->node, 0, &instr->loc)))
return false; return false;
list_add_before(&instr->entry, &store->node.entry); list_add_before(&instr->entry, &store->entry);
} }
if (!(load = hlsl_new_var_load(ctx, var, &instr->loc))) if (!(load = hlsl_new_var_load(ctx, var, &instr->loc)))
@ -1769,7 +1767,7 @@ static bool fold_redundant_casts(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst
static bool split_copy(struct hlsl_ctx *ctx, struct hlsl_ir_store *store, static bool split_copy(struct hlsl_ctx *ctx, struct hlsl_ir_store *store,
const struct hlsl_ir_load *load, const unsigned int idx, struct hlsl_type *type) const struct hlsl_ir_load *load, const unsigned int idx, struct hlsl_type *type)
{ {
struct hlsl_ir_store *split_store; struct hlsl_ir_node *split_store;
struct hlsl_ir_load *split_load; struct hlsl_ir_load *split_load;
struct hlsl_ir_constant *c; struct hlsl_ir_constant *c;
@ -1783,7 +1781,7 @@ static bool split_copy(struct hlsl_ctx *ctx, struct hlsl_ir_store *store,
if (!(split_store = hlsl_new_store_index(ctx, &store->lhs, &c->node, &split_load->node, 0, &store->node.loc))) if (!(split_store = hlsl_new_store_index(ctx, &store->lhs, &c->node, &split_load->node, 0, &store->node.loc)))
return false; return false;
list_add_before(&store->node.entry, &split_store->node.entry); list_add_before(&store->node.entry, &split_store->entry);
return true; return true;
} }