[PATCH vkd3d v4 4/7] vkd3d-shader/hlsl: Simplify flow in add_array_load().
Giovanni Mascellani
gmascellani at codeweavers.com
Tue Apr 26 05:26:15 CDT 2022
Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
---
v4:
* Generate a multiplication only in the array branch.
---
libs/vkd3d-shader/hlsl.y | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index 291f8392..968f36ae 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -587,13 +587,18 @@ static bool add_array_load(struct hlsl_ctx *ctx, struct list *instrs, struct hls
const struct hlsl_type *expr_type = array->data_type;
struct hlsl_type *data_type;
struct hlsl_ir_constant *c;
- struct hlsl_ir_node *mul;
if (expr_type->type == HLSL_CLASS_ARRAY)
{
data_type = expr_type->e.array.type;
+
if (!(c = hlsl_new_uint_constant(ctx, hlsl_type_get_array_element_reg_size(data_type), &loc)))
return false;
+ list_add_tail(instrs, &c->node.entry);
+
+ if (!(index = hlsl_new_binary_expr(ctx, HLSL_OP2_MUL, index, &c->node)))
+ return false;
+ list_add_tail(instrs, &index->entry);
}
else if (expr_type->type == HLSL_CLASS_MATRIX)
{
@@ -604,8 +609,6 @@ static bool add_array_load(struct hlsl_ctx *ctx, struct list *instrs, struct hls
else if (expr_type->type == HLSL_CLASS_VECTOR)
{
data_type = hlsl_get_scalar_type(ctx, expr_type->base_type);
- if (!(c = hlsl_new_uint_constant(ctx, 1, &loc)))
- return false;
}
else
{
@@ -616,12 +619,6 @@ static bool add_array_load(struct hlsl_ctx *ctx, struct list *instrs, struct hls
return false;
}
- list_add_tail(instrs, &c->node.entry);
- if (!(mul = hlsl_new_binary_expr(ctx, HLSL_OP2_MUL, index, &c->node)))
- return false;
- list_add_tail(instrs, &mul->entry);
- index = mul;
-
return !!add_load(ctx, instrs, array, index, data_type, loc);
}
--
2.35.2
More information about the wine-devel
mailing list