From: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- I'm sorry for the very late signoffs. For some reason, this year resuming work after vacation has been a real struggle. Then my usual workflow of going through all the pending stuff before sending replies didn't help at all.
I'm going to resend the first batch of pending patches (that look okay to me) because: - the oldest of the lot just fell out of the patch tracker - I want to make some trivial changes to a few more - it seems nice to clarify order (although the patches look mostly independent)
I'm also going to send a bunch of comments to various, more or less old, email threads. Most of which I had written at the time, but then see above. I'll make it a point to change at least that going forward.
Zebediah and Giovanni's reviews and comments that have been flowing in the meantime have been very helpful and you can assume that I agree if I don't say otherwise.
libs/vkd3d-shader/hlsl.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 636882c4..5a17449a 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -326,7 +326,7 @@ static bool append_conditional_break(struct hlsl_ctx *ctx, struct list *cond_lis struct hlsl_ir_if *iff;
/* E.g. "for (i = 0; ; ++i)". */ - if (!list_count(cond_list)) + if (list_empty(cond_list)) return true;
condition = node_from_list(cond_list);
From: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- libs/vkd3d-shader/hlsl_codegen.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 75716bdf..e43e6378 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -724,6 +724,31 @@ static bool fold_constants(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, voi { switch (expr->op) { + case HLSL_OP1_CAST: + if (instr->data_type->dimx != arg1->node.data_type->dimx + || instr->data_type->dimy != arg1->node.data_type->dimy) + { + FIXME("Cast from %s to %s.\n", debug_hlsl_type(ctx, arg1->node.data_type), + debug_hlsl_type(ctx, instr->data_type)); + vkd3d_free(res); + return false; + } + + switch (arg1->node.data_type->base_type) + { + case HLSL_TYPE_INT: + for (i = 0; i < dimx; ++i) + res->value[i].i = arg1->value[i].u; + break; + + default: + FIXME("Cast from %s to %s.\n", debug_hlsl_type(ctx, arg1->node.data_type), + debug_hlsl_type(ctx, instr->data_type)); + vkd3d_free(res); + return false; + } + break; + case HLSL_OP1_NEG: for (i = 0; i < instr->data_type->dimx; ++i) res->value[i].u = -arg1->value[i].u;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- I see, this shows that the override is per-overload, nice...
Makefile.am | 2 ++ tests/hlsl-intrinsic-override.shader_test | 31 +++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 tests/hlsl-intrinsic-override.shader_test
diff --git a/Makefile.am b/Makefile.am index 20fee06d..0c2fbf7d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -68,6 +68,7 @@ vkd3d_shader_tests = \ tests/hlsl-duplicate-modifiers.shader_test \ tests/hlsl-for.shader_test \ tests/hlsl-function-overload.shader_test \ + tests/hlsl-intrinsic-override.shader_test \ tests/hlsl-invalid.shader_test \ tests/hlsl-majority-pragma.shader_test \ tests/hlsl-majority-typedef.shader_test \ @@ -293,6 +294,7 @@ XFAIL_TESTS = \ tests/hlsl-duplicate-modifiers.shader_test \ tests/hlsl-for.shader_test \ tests/hlsl-function-overload.shader_test \ + tests/hlsl-intrinsic-override.shader_test \ tests/hlsl-majority-pragma.shader_test \ tests/hlsl-majority-typedef.shader_test \ tests/hlsl-nested-arrays.shader_test \ diff --git a/tests/hlsl-intrinsic-override.shader_test b/tests/hlsl-intrinsic-override.shader_test new file mode 100644 index 00000000..55a23f21 --- /dev/null +++ b/tests/hlsl-intrinsic-override.shader_test @@ -0,0 +1,31 @@ +[pixel shader] + +float2 max(float2 a, float2 b) +{ + return a + b; +} + +float4 main() : sv_target +{ + return float4(max(0.1, 0.2), max(float2(0.1, 0.2), float2(0.3, 0.4))); +} + +[test] +draw quad +probe all rgba (0.3, 0.3, 0.4, 0.6) + +[pixel shader] + +float2 max(float2 a, float3 b) +{ + return a + b.xy; +} + +float4 main() : sv_target +{ + return float4(max(0.1, 0.2), max(float2(0.1, 0.2), float2(0.3, 0.4))); +} + +[test] +draw quad +probe all rgba (0.3, 0.3, 0.3, 0.4)
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Giovanni Mascellani gmascellani@codeweavers.com
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v3: Get rid of the '\n's at the end of hlsl_fixme() messages, fix up a message.
libs/vkd3d-shader/hlsl_sm4.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 2458018f..90bb32e6 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1489,6 +1489,41 @@ 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" operands.", + debug_hlsl_type(ctx, src_type)); + break; + } + break; + } + + default: + hlsl_fixme(ctx, &expr->node.loc, "SM4 bool "%s" expression.", debug_hlsl_expr_op(expr->op)); + break; + } + break; + } + default: { struct vkd3d_string_buffer *string;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Giovanni Mascellani gmascellani@codeweavers.com
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v3: Get rid of the '\n's at the end, fix up an hlsl_fixme() message.
libs/vkd3d-shader/hlsl_sm4.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 90bb32e6..53dca71c 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1517,6 +1517,30 @@ 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" operands.", + debug_hlsl_type(ctx, src_type)); + break; + } + break; + } + default: hlsl_fixme(ctx, &expr->node.loc, "SM4 bool "%s" expression.", debug_hlsl_expr_op(expr->op)); break;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Giovanni Mascellani gmascellani@codeweavers.com
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v3: Get rid of the '\n's at the end, fix up an hlsl_fixme() message, use ULT for HLSL_TYPE_BOOL.
libs/vkd3d-shader/hlsl_sm4.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 53dca71c..cbdd5fa4 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1541,6 +1541,33 @@ 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_INT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_ILT, &expr->node, arg1, arg2); + break; + + case HLSL_TYPE_BOOL: + 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" operands.", + debug_hlsl_type(ctx, src_type)); + break; + } + break; + } + default: hlsl_fixme(ctx, &expr->node.loc, "SM4 bool "%s" expression.", debug_hlsl_expr_op(expr->op)); break;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Giovanni Mascellani gmascellani@codeweavers.com
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v3: Get rid of the '\n's at the end, fix up an hlsl_fixme() message, use UGE for HLSL_TYPE_BOOL.
libs/vkd3d-shader/hlsl_sm4.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index cbdd5fa4..8fc4e738 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1568,6 +1568,33 @@ 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_INT: + write_sm4_binary_op(buffer, VKD3D_SM4_OP_IGE, &expr->node, arg1, arg2); + break; + + case HLSL_TYPE_BOOL: + 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-than-or-equal between "%s" operands.", + debug_hlsl_type(ctx, src_type)); + break; + } + break; + } + default: hlsl_fixme(ctx, &expr->node.loc, "SM4 bool "%s" expression.", debug_hlsl_expr_op(expr->op)); break;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Giovanni Mascellani gmascellani@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 Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- 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 0c2fbf7d..a3ec6850 100644 --- a/Makefile.am +++ b/Makefile.am @@ -288,7 +288,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 5a17449a..cff56a74 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: Henri Verbeet hverbeet@codeweavers.com