vkd3d-shader/hlsl: Introduce a compiler pass to vectorize stores.

This commit is contained in:
Elizabeth Figura
2024-10-30 11:51:07 -05:00
committed by Henri Verbeet
parent 1a999f74fc
commit f576ecc992
Notes: Henri Verbeet 2025-04-03 20:34:10 +02:00
Approved-by: Francisco Casas (@fcasas)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1443
3 changed files with 364 additions and 0 deletions

View File

@@ -1588,6 +1588,43 @@ 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);
}
static struct hlsl_ir_node *hlsl_new_store_parent(struct hlsl_ctx *ctx,
const struct hlsl_deref *lhs, unsigned int path_len, struct hlsl_ir_node *rhs,
unsigned int writemask, const struct vkd3d_shader_location *loc)
{
struct hlsl_ir_store *store;
VKD3D_ASSERT(!hlsl_deref_is_lowered(lhs));
VKD3D_ASSERT(lhs->path_len >= path_len);
if (!(store = hlsl_alloc(ctx, sizeof(*store))))
return NULL;
init_node(&store->node, HLSL_IR_STORE, NULL, loc);
if (!hlsl_init_deref(ctx, &store->lhs, lhs->var, path_len))
{
vkd3d_free(store);
return NULL;
}
for (unsigned int i = 0; i < path_len; ++i)
hlsl_src_from_node(&store->lhs.path[i], lhs->path[i].node);
hlsl_src_from_node(&store->rhs, rhs);
if (!writemask && type_is_single_reg(rhs->data_type))
writemask = (1 << rhs->data_type->e.numeric.dimx) - 1;
store->writemask = writemask;
return &store->node;
}
void hlsl_block_add_store_parent(struct hlsl_ctx *ctx, struct hlsl_block *block,
const struct hlsl_deref *lhs, unsigned int path_len, struct hlsl_ir_node *rhs,
unsigned int writemask, const struct vkd3d_shader_location *loc)
{
append_new_instr(ctx, block, hlsl_new_store_parent(ctx, lhs, path_len, rhs, writemask, loc));
}
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)
{