vkd3d-shader/hlsl: Parse step() intrinsic.

This commit is contained in:
Francisco Casas 2023-01-13 16:22:41 -03:00 committed by Alexandre Julliard
parent 4e1a4a76d9
commit 13c8e8b856
Notes: Alexandre Julliard 2023-01-19 22:45:36 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Zebediah Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/62
2 changed files with 30 additions and 11 deletions

View File

@ -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);
@ -2828,6 +2828,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)
{
@ -2917,6 +2935,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},
};

View File

@ -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)