vkd3d-shader/hlsl: Parse the saturate() intrinsic.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-09-16 20:55:56 +02:00 committed by Alexandre Julliard
parent 4ecdd280ac
commit f0955c164a
3 changed files with 21 additions and 0 deletions

View File

@ -87,6 +87,7 @@ vkd3d_shader_tests = \
tests/preproc-invalid.shader_test \ tests/preproc-invalid.shader_test \
tests/preproc-macro.shader_test \ tests/preproc-macro.shader_test \
tests/preproc-misc.shader_test \ tests/preproc-misc.shader_test \
tests/saturate.shader_test \
tests/swizzle-0.shader_test \ tests/swizzle-0.shader_test \
tests/swizzle-1.shader_test \ tests/swizzle-1.shader_test \
tests/swizzle-2.shader_test \ tests/swizzle-2.shader_test \
@ -295,6 +296,7 @@ XFAIL_TESTS = \
tests/hlsl-vector-indexing-uniform.shader_test \ tests/hlsl-vector-indexing-uniform.shader_test \
tests/math.shader_test \ tests/math.shader_test \
tests/max.shader_test \ tests/max.shader_test \
tests/saturate.shader_test \
tests/trigonometry.shader_test \ tests/trigonometry.shader_test \
tests/writemask-assignop-1.shader_test tests/writemask-assignop-1.shader_test
endif endif

View File

@ -1577,6 +1577,14 @@ static bool intrinsic_max(struct hlsl_ctx *ctx,
return !!add_expr(ctx, params->instrs, HLSL_OP2_MAX, args, &loc); return !!add_expr(ctx, params->instrs, HLSL_OP2_MAX, args, &loc);
} }
static bool intrinsic_saturate(struct hlsl_ctx *ctx,
const struct parse_initializer *params, struct vkd3d_shader_location loc)
{
struct hlsl_ir_node *args[3] = {params->args[0]};
return !!add_expr(ctx, params->instrs, HLSL_OP1_SAT, args, &loc);
}
static const struct intrinsic_function static const struct intrinsic_function
{ {
const char *name; const char *name;
@ -1588,6 +1596,7 @@ intrinsic_functions[] =
{ {
{"clamp", 3, true, intrinsic_clamp}, {"clamp", 3, true, intrinsic_clamp},
{"max", 2, true, intrinsic_max}, {"max", 2, true, intrinsic_max},
{"saturate", 1, true, intrinsic_saturate},
}; };
static int intrinsic_function_name_compare(const void *a, const void *b) static int intrinsic_function_name_compare(const void *a, const void *b)

View File

@ -0,0 +1,10 @@
[pixel shader]
float4 main(uniform float2 u) : sv_target
{
return float4(saturate(u), saturate(u.x + 0.5), saturate(-1.2));
}
[test]
uniform 0 float4 0.7 -0.1 0.0 0.0
draw quad
probe all rgba (0.7, 0.0, 1.0, 0.0)