Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- v2: Add hlsl_fixme(). --- libs/vkd3d-shader/hlsl_sm4.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 2458018f..26ff019c 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1489,6 +1489,40 @@ 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: + hlsl_fixme(ctx, &expr->node.loc, "SM4 equality between "%s".\n", debug_hlsl_type(ctx, src_type)); + 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 --- v2: Add hlsl_fixme(). --- libs/vkd3d-shader/hlsl_sm4.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 26ff019c..d5ea5563 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1516,6 +1516,29 @@ 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: + hlsl_fixme(ctx, &expr->node.loc, "SM4 inequality between "%s".\n", debug_hlsl_type(ctx, src_type)); + break; + } + break; + } + default: hlsl_fixme(ctx, &expr->node.loc, "SM4 bool "%s" expression.\n", debug_hlsl_expr_op(expr->op)); break;
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- v2: Add hlsl_fixme(). --- libs/vkd3d-shader/hlsl_sm4.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index d5ea5563..70cf4e13 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1539,6 +1539,32 @@ 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: + hlsl_fixme(ctx, &expr->node.loc, "SM4 less-than between "%s".\n", debug_hlsl_type(ctx, src_type)); + break; + } + break; + } + default: hlsl_fixme(ctx, &expr->node.loc, "SM4 bool "%s" expression.\n", debug_hlsl_expr_op(expr->op)); break;
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
On Mon, Dec 20, 2021 at 10:25 AM Giovanni Mascellani gmascellani@codeweavers.com wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
v2: Add hlsl_fixme().
libs/vkd3d-shader/hlsl_sm4.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index d5ea5563..70cf4e13 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1539,6 +1539,32 @@ 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:
hlsl_fixme(ctx, &expr->node.loc, "SM4 less-than between \"%s\".\n", debug_hlsl_type(ctx, src_type));
break;
}
break;
}
According to some testing I did on the side, it looks like HLSL_TYPE_BOOL should use ULT / UGE instead (and I resent it with that change). Not the biggest deal, our bool handling needs a lot of work anyway...
Hi,
Il 19/01/22 13:10, Matteo Bruni ha scritto:
According to some testing I did on the side, it looks like HLSL_TYPE_BOOL should use ULT / UGE instead (and I resent it with that change). Not the biggest deal, our bool handling needs a lot of work anyway...
Agree, that's right. I probably wrote that patch before realizing that TRUE is encoded as ~0.
Thanks, Giovanni.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- v2: Add hlsl_fixme(). --- libs/vkd3d-shader/hlsl_sm4.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 70cf4e13..e2b768cb 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1565,6 +1565,32 @@ 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: + hlsl_fixme(ctx, &expr->node.loc, "SM4 greater-or-equal-than between "%s".\n", debug_hlsl_type(ctx, src_type)); + break; + } + break; + } + default: hlsl_fixme(ctx, &expr->node.loc, "SM4 bool "%s" expression.\n", debug_hlsl_expr_op(expr->op)); break;
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
They are replaced with HLSL_OP2_LESS and HLSL_OP2_GEQUAL after swapping the parameters.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- v2: Introduce patch. --- Makefile.am | 1 - libs/vkd3d-shader/hlsl.c | 2 -- libs/vkd3d-shader/hlsl.h | 2 -- libs/vkd3d-shader/hlsl.y | 4 ++-- 4 files changed, 2 insertions(+), 7 deletions(-)
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.c b/libs/vkd3d-shader/hlsl.c index d2ea4c34..8ae31306 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -1198,8 +1198,6 @@ const char *debug_hlsl_expr_op(enum hlsl_ir_expr_op op) [HLSL_OP2_DOT] = "dot", [HLSL_OP2_EQUAL] = "==", [HLSL_OP2_GEQUAL] = ">=", - [HLSL_OP2_GREATER] = ">", - [HLSL_OP2_LEQUAL] = "<=", [HLSL_OP2_LESS] = "<", [HLSL_OP2_LOGIC_AND] = "&&", [HLSL_OP2_LOGIC_OR] = "||", diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 57acf3a0..6aec0b08 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -316,8 +316,6 @@ enum hlsl_ir_expr_op HLSL_OP2_DOT, HLSL_OP2_EQUAL, HLSL_OP2_GEQUAL, - HLSL_OP2_GREATER, - HLSL_OP2_LEQUAL, HLSL_OP2_LESS, HLSL_OP2_LOGIC_AND, HLSL_OP2_LOGIC_OR, diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 636882c4..37556f8e 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -3422,11 +3422,11 @@ relational_expr: } | relational_expr '>' shift_expr { - $$ = add_binary_comparison_expr_merge(ctx, $1, $3, HLSL_OP2_GREATER, @2); + $$ = add_binary_comparison_expr_merge(ctx, $3, $1, HLSL_OP2_LESS, @2); } | relational_expr OP_LE shift_expr { - $$ = add_binary_comparison_expr_merge(ctx, $1, $3, HLSL_OP2_LEQUAL, @2); + $$ = add_binary_comparison_expr_merge(ctx, $3, $1, HLSL_OP2_GEQUAL, @2); } | relational_expr OP_GE shift_expr {
Signed-off-by: Zebediah Figura zfigura@codeweavers.com