mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
vkd3d-shader/hlsl: Support distance() intrinsic.
This commit is contained in:
parent
d6b656641c
commit
a18f3d4dd5
Notes:
Alexandre Julliard
2023-03-08 21:51:08 +01:00
Approved-by: Zebediah Figura (@zfigura) Approved-by: Francisco Casas (@fcasas) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/76
@ -61,6 +61,7 @@ vkd3d_shader_tests = \
|
|||||||
tests/cbuffer.shader_test \
|
tests/cbuffer.shader_test \
|
||||||
tests/compute.shader_test \
|
tests/compute.shader_test \
|
||||||
tests/conditional.shader_test \
|
tests/conditional.shader_test \
|
||||||
|
tests/distance.shader_test \
|
||||||
tests/entry-point-semantics.shader_test \
|
tests/entry-point-semantics.shader_test \
|
||||||
tests/exp.shader_test \
|
tests/exp.shader_test \
|
||||||
tests/floor.shader_test \
|
tests/floor.shader_test \
|
||||||
|
@ -2533,6 +2533,29 @@ static bool intrinsic_cross(struct hlsl_ctx *ctx,
|
|||||||
return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_ADD, mul2, mul1_neg, loc);
|
return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_ADD, mul2, mul1_neg, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool intrinsic_distance(struct hlsl_ctx *ctx,
|
||||||
|
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||||
|
{
|
||||||
|
struct hlsl_ir_node *arg1, *arg2, *neg, *add, *dot;
|
||||||
|
|
||||||
|
if (!(arg1 = intrinsic_float_convert_arg(ctx, params, params->args[0], loc)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!(arg2 = intrinsic_float_convert_arg(ctx, params, params->args[1], loc)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!(neg = add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_NEG, arg2, loc)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!(add = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_ADD, arg1, neg, loc)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!(dot = add_binary_dot_expr(ctx, params->instrs, add, add, loc)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_SQRT, dot, loc);
|
||||||
|
}
|
||||||
|
|
||||||
static bool intrinsic_dot(struct hlsl_ctx *ctx,
|
static bool intrinsic_dot(struct hlsl_ctx *ctx,
|
||||||
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||||
{
|
{
|
||||||
@ -3203,6 +3226,7 @@ intrinsic_functions[] =
|
|||||||
{"clamp", 3, true, intrinsic_clamp},
|
{"clamp", 3, true, intrinsic_clamp},
|
||||||
{"cos", 1, true, intrinsic_cos},
|
{"cos", 1, true, intrinsic_cos},
|
||||||
{"cross", 2, true, intrinsic_cross},
|
{"cross", 2, true, intrinsic_cross},
|
||||||
|
{"distance", 2, true, intrinsic_distance},
|
||||||
{"dot", 2, true, intrinsic_dot},
|
{"dot", 2, true, intrinsic_dot},
|
||||||
{"exp", 1, true, intrinsic_exp},
|
{"exp", 1, true, intrinsic_exp},
|
||||||
{"exp2", 1, true, intrinsic_exp2},
|
{"exp2", 1, true, intrinsic_exp2},
|
||||||
|
23
tests/distance.shader_test
Normal file
23
tests/distance.shader_test
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
[pixel shader]
|
||||||
|
uniform float4 x;
|
||||||
|
uniform float4 y;
|
||||||
|
|
||||||
|
float4 main() : sv_target
|
||||||
|
{
|
||||||
|
return distance(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
[test]
|
||||||
|
uniform 0 float4 -2.0 3.0 4.0 0.1
|
||||||
|
uniform 4 float4 2.0 -1.0 4.0 5.0
|
||||||
|
draw quad
|
||||||
|
probe all rgba (7.483983, 7.483983, 7.483983, 7.483983) 1
|
||||||
|
|
||||||
|
[pixel shader]
|
||||||
|
uniform int4 x;
|
||||||
|
uniform int4 y;
|
||||||
|
|
||||||
|
float4 main() : sv_target
|
||||||
|
{
|
||||||
|
return distance(x, y);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user