Giovanni Mascellani : vkd3d-shader/hlsl: Simplify flow in add_array_load().
Alexandre Julliard
julliard at winehq.org
Wed Apr 27 16:12:02 CDT 2022
Module: vkd3d
Branch: master
Commit: e2b4f01a9fa627d1fc533c27a93a8214c1466bc1
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=e2b4f01a9fa627d1fc533c27a93a8214c1466bc1
Author: Giovanni Mascellani <gmascellani at codeweavers.com>
Date: Wed Apr 27 10:56:23 2022 +0200
vkd3d-shader/hlsl: Simplify flow in add_array_load().
Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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);
}
More information about the wine-cvs
mailing list