From: Francisco Casas fcasas@codeweavers.com
--- libs/vkd3d-shader/hlsl.y | 23 +++++++++++++++++++++-- tests/step.shader_test | 18 +++++++++--------- 2 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index f56df476..e38fe652 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1486,7 +1486,7 @@ static struct list *add_binary_bitwise_expr_merge(struct hlsl_ctx *ctx, struct l
static struct hlsl_ir_node *add_binary_comparison_expr(struct hlsl_ctx *ctx, struct list *instrs, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1, struct hlsl_ir_node *arg2, - struct vkd3d_shader_location *loc) + const struct vkd3d_shader_location *loc) { struct hlsl_type *common_type, *return_type; enum hlsl_base_type base = expr_common_base_type(arg1->data_type->base_type, arg2->data_type->base_type); @@ -1510,7 +1510,7 @@ static struct hlsl_ir_node *add_binary_comparison_expr(struct hlsl_ctx *ctx, str }
static struct list *add_binary_comparison_expr_merge(struct hlsl_ctx *ctx, struct list *list1, struct list *list2, - enum hlsl_ir_expr_op op, struct vkd3d_shader_location loc) + enum hlsl_ir_expr_op op, const struct vkd3d_shader_location loc) { struct hlsl_ir_node *arg1 = node_from_list(list1), *arg2 = node_from_list(list2);
@@ -2794,6 +2794,24 @@ static bool intrinsic_sqrt(struct hlsl_ctx *ctx, return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_SQRT, arg, loc); }
+static bool intrinsic_step(struct hlsl_ctx *ctx, + const struct parse_initializer *params, const struct vkd3d_shader_location *loc) +{ + struct hlsl_ir_node *ge; + struct hlsl_type *type; + + if (!elementwise_intrinsic_float_convert_args(ctx, params, loc)) + return false; + + if (!(ge = add_binary_comparison_expr(ctx, params->instrs, HLSL_OP2_GEQUAL, + params->args[1], params->args[0], loc))) + return false; + + type = ge->data_type; + type = hlsl_get_numeric_type(ctx, type->type, HLSL_TYPE_FLOAT, type->dimx, type->dimy); + return !!add_implicit_conversion(ctx, params->instrs, ge, type, loc); +} + static bool intrinsic_transpose(struct hlsl_ctx *ctx, const struct parse_initializer *params, const struct vkd3d_shader_location *loc) { @@ -2883,6 +2901,7 @@ intrinsic_functions[] = {"sin", 1, true, intrinsic_sin}, {"smoothstep", 3, true, intrinsic_smoothstep}, {"sqrt", 1, true, intrinsic_sqrt}, + {"step", 2, true, intrinsic_step}, {"transpose", 1, true, intrinsic_transpose}, };
diff --git a/tests/step.shader_test b/tests/step.shader_test index 8a8b1fd2..e201e15f 100644 --- a/tests/step.shader_test +++ b/tests/step.shader_test @@ -1,4 +1,4 @@ -[pixel shader todo] +[pixel shader] uniform float4 f, p;
float4 main() : sv_target @@ -9,11 +9,11 @@ float4 main() : sv_target [test] uniform 0 float4 5.0 -2.6 3.0 2.0 uniform 4 float4 1.0 -4.3 3.0 4.0 -todo draw quad -todo probe all rgba (0.0, 0.0, 1.0, 1.0) +draw quad +probe all rgba (0.0, 0.0, 1.0, 1.0)
-[pixel shader todo] +[pixel shader] float4 main() : sv_target { float2x2 a = {1, 2, 3, 4}; @@ -23,8 +23,8 @@ float4 main() : sv_target }
[test] -todo draw quad -todo probe all rgba (1.0, 1.0, 1.0, 0.0) +draw quad +probe all rgba (1.0, 1.0, 1.0, 0.0)
[pixel shader fail] @@ -38,7 +38,7 @@ float4 main() : sv_target }
-[pixel shader todo] +[pixel shader] float4 main() : sv_target { float3x2 a = {8, 0, @@ -51,5 +51,5 @@ float4 main() : sv_target }
[test] -todo draw quad -todo probe all rgba (0.0, 1.0, 1.0, 0.0) +draw quad +probe all rgba (0.0, 1.0, 1.0, 0.0)