Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- libs/vkd3d-shader/hlsl_sm4.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 2458018f..37a51125 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1489,6 +1489,39 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, break; }
+ case HLSL_TYPE_BOOL: + { + switch (expr->op) + { + case HLSL_OP2_EQUAL: + { + const struct hlsl_type *src_type = arg1->data_type; + + switch (src_type->base_type) + { + case HLSL_TYPE_FLOAT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_EQ, &expr->node, arg1, arg2); + break; + + case HLSL_TYPE_BOOL: + case HLSL_TYPE_INT: + case HLSL_TYPE_UINT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_IEQ, &expr->node, arg1, arg2); + break; + + default: + break; + } + break; + } + + default: + hlsl_fixme(ctx, &expr->node.loc, "SM4 bool "%s" expression.\n", debug_hlsl_expr_op(expr->op)); + break; + } + break; + } + default: { struct vkd3d_string_buffer *string;
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- libs/vkd3d-shader/hlsl_sm4.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 37a51125..efc5969f 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1515,6 +1515,28 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, break; }
+ case HLSL_OP2_NEQUAL: + { + const struct hlsl_type *src_type = arg1->data_type; + + switch (src_type->base_type) + { + case HLSL_TYPE_FLOAT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_NE, &expr->node, arg1, arg2); + break; + + case HLSL_TYPE_BOOL: + case HLSL_TYPE_INT: + case HLSL_TYPE_UINT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_INE, &expr->node, arg1, arg2); + break; + + default: + break; + } + break; + } + default: hlsl_fixme(ctx, &expr->node.loc, "SM4 bool "%s" expression.\n", debug_hlsl_expr_op(expr->op)); break;
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- libs/vkd3d-shader/hlsl_sm4.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index efc5969f..8bb3dc2e 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1537,6 +1537,31 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, break; }
+ case HLSL_OP2_LESS: + { + const struct hlsl_type *src_type = arg1->data_type; + + switch (src_type->base_type) + { + case HLSL_TYPE_FLOAT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_LT, &expr->node, arg1, arg2); + break; + + case HLSL_TYPE_BOOL: + case HLSL_TYPE_INT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_ILT, &expr->node, arg1, arg2); + break; + + case HLSL_TYPE_UINT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_ULT, &expr->node, arg1, arg2); + break; + + default: + break; + } + break; + } + default: hlsl_fixme(ctx, &expr->node.loc, "SM4 bool "%s" expression.\n", debug_hlsl_expr_op(expr->op)); break;
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- Makefile.am | 1 - libs/vkd3d-shader/hlsl_sm4.c | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am index 20fee06d..cfff09eb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -287,7 +287,6 @@ XFAIL_TESTS = \ tests/cast-to-half.shader_test \ tests/cast-to-int.shader_test \ tests/cast-to-uint.shader_test \ - tests/conditional.shader_test \ tests/hlsl-array-dimension.shader_test \ tests/hlsl-bool-cast.shader_test \ tests/hlsl-duplicate-modifiers.shader_test \ diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 8bb3dc2e..f0aa5dbf 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1562,6 +1562,31 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, break; }
+ case HLSL_OP2_GREATER: + { + const struct hlsl_type *src_type = arg1->data_type; + + switch (src_type->base_type) + { + case HLSL_TYPE_FLOAT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_LT, &expr->node, arg2, arg1); + break; + + case HLSL_TYPE_BOOL: + case HLSL_TYPE_INT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_ILT, &expr->node, arg2, arg1); + break; + + case HLSL_TYPE_UINT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_ULT, &expr->node, arg2, arg1); + break; + + default: + break; + } + break; + } + default: hlsl_fixme(ctx, &expr->node.loc, "SM4 bool "%s" expression.\n", debug_hlsl_expr_op(expr->op)); break;
Should we lower these at parse time instead?
Same for LE -> GE.
Hi,
On 17/12/21 19:07, Zebediah Figura (she/her) wrote:
Should we lower these at parse time instead?
Same for LE -> GE.
Don't know. I have to say that I was genuinely surprised that we allowed so much redundancy in the IR, but certainly it won't be me the one who complains about having an expressive IR. So, given that it had already been accepted, I didn't protest.
My feeling is that when your compiler isn't able to handle most trivial arithmetic operators it is a bit early to enter fine discussions about how to best trim the IR so that optimization phases that do not exist yet might be a little bit better or not.
Giovanni.
On 12/17/21 14:40, Giovanni Mascellani wrote:
Hi,
On 17/12/21 19:07, Zebediah Figura (she/her) wrote:
Should we lower these at parse time instead?
Same for LE -> GE.
Don't know. I have to say that I was genuinely surprised that we allowed so much redundancy in the IR, but certainly it won't be me the one who complains about having an expressive IR. So, given that it had already been accepted, I didn't protest.
Well, that code is old, and a lot of the old code doesn't really reflect current preferred design principles.
My feeling is that when your compiler isn't able to handle most trivial arithmetic operators it is a bit early to enter fine discussions about how to best trim the IR so that optimization phases that do not exist yet might be a little bit better or not.
I don't think it's really about optimization in this case. Rather, if we just do something as simple as
- $$ = add_binary_comparison_expr_merge(ctx, $1, $3, HLSL_OP2_GREATER, @2); + $$ = add_binary_comparison_expr_merge(ctx, $3, $1, HLSL_OP2_LESS, @2);
then this patch suddenly doesn't become necessary anymore.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- libs/vkd3d-shader/hlsl_sm4.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index f0aa5dbf..ada1878f 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1587,6 +1587,31 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, break; }
+ case HLSL_OP2_LEQUAL: + { + const struct hlsl_type *src_type = arg1->data_type; + + switch (src_type->base_type) + { + case HLSL_TYPE_FLOAT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_GE, &expr->node, arg2, arg1); + break; + + case HLSL_TYPE_BOOL: + case HLSL_TYPE_INT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_IGE, &expr->node, arg2, arg1); + break; + + case HLSL_TYPE_UINT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_UGE, &expr->node, arg2, arg1); + break; + + default: + break; + } + break; + } + default: hlsl_fixme(ctx, &expr->node.loc, "SM4 bool "%s" expression.\n", debug_hlsl_expr_op(expr->op)); break;
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- libs/vkd3d-shader/hlsl_sm4.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index ada1878f..c5544a99 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1612,6 +1612,31 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, break; }
+ case HLSL_OP2_GEQUAL: + { + const struct hlsl_type *src_type = arg1->data_type; + + switch (src_type->base_type) + { + case HLSL_TYPE_FLOAT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_GE, &expr->node, arg1, arg2); + break; + + case HLSL_TYPE_BOOL: + case HLSL_TYPE_INT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_IGE, &expr->node, arg1, arg2); + break; + + case HLSL_TYPE_UINT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_UGE, &expr->node, arg1, arg2); + break; + + default: + break; + } + break; + } + default: hlsl_fixme(ctx, &expr->node.loc, "SM4 bool "%s" expression.\n", debug_hlsl_expr_op(expr->op)); break;
On 12/17/21 03:42, Giovanni Mascellani wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
libs/vkd3d-shader/hlsl_sm4.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 2458018f..37a51125 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1489,6 +1489,39 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, break; }
case HLSL_TYPE_BOOL:
{
switch (expr->op)
{
case HLSL_OP2_EQUAL:
{
const struct hlsl_type *src_type = arg1->data_type;
switch (src_type->base_type)
{
case HLSL_TYPE_FLOAT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_EQ, &expr->node, arg1, arg2);
break;
case HLSL_TYPE_BOOL:
case HLSL_TYPE_INT:
case HLSL_TYPE_UINT:
write_sm4_binary_op(buffer, VKD3D_SM4_OP_IEQ, &expr->node, arg1, arg2);
break;
default:
break;
This needs a hlsl_fixme().
}
break;
}
default:
hlsl_fixme(ctx, &expr->node.loc, "SM4 bool \"%s\" expression.\n", debug_hlsl_expr_op(expr->op));
break;
}
break;
}
default: { struct vkd3d_string_buffer *string;