diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 7b058a65..56736a65 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -4065,6 +4065,17 @@ static bool intrinsic_radians(struct hlsl_ctx *ctx, return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, arg, rad, loc); } +static bool intrinsic_rcp(struct hlsl_ctx *ctx, + const struct parse_initializer *params, const struct vkd3d_shader_location *loc) +{ + struct hlsl_ir_node *arg; + + if (!(arg = intrinsic_float_convert_arg(ctx, params, params->args[0], loc))) + return false; + + return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_RCP, arg, loc); +} + static bool intrinsic_reflect(struct hlsl_ctx *ctx, const struct parse_initializer *params, const struct vkd3d_shader_location *loc) { @@ -4760,6 +4771,7 @@ intrinsic_functions[] = {"normalize", 1, true, intrinsic_normalize}, {"pow", 2, true, intrinsic_pow}, {"radians", 1, true, intrinsic_radians}, + {"rcp", 1, true, intrinsic_rcp}, {"reflect", 2, true, intrinsic_reflect}, {"refract", 3, true, intrinsic_refract}, {"round", 1, true, intrinsic_round}, diff --git a/tests/hlsl/rcp.shader_test b/tests/hlsl/rcp.shader_test index dcfeb924..65cf1a81 100644 --- a/tests/hlsl/rcp.shader_test +++ b/tests/hlsl/rcp.shader_test @@ -1,4 +1,4 @@ -[pixel shader todo] +[pixel shader todo(sm>=4)] uniform float4 f; float4 main() : sv_target @@ -8,28 +8,28 @@ float4 main() : sv_target [test] uniform 0 float4 1.0 2.0 3.0 4.0 -todo(sm<6) draw quad +todo(sm>=4 & sm<6) draw quad probe (0, 0) rgba (1.0, 0.5, 0.3333333, 0.25) 8 uniform 0 float4 -1.0 -2.0 -3.0 -4.0 -todo(sm<6) draw quad +todo(sm>=4 & sm<6) draw quad probe (0, 0) rgba (-1.0, -0.5, -0.3333333, -0.25) 8 uniform 0 float4 12.34 56.78 -90.12 -34.56 -todo(sm<6) draw quad +todo(sm>=4 & sm<6) draw quad probe (0, 0) rgba (0.081037275, 0.017611835, -0.011096316, -0.028935184) 8 uniform 0 float4 0.25 0.125 0.0625 0.3333333 -todo(sm<6) draw quad +todo(sm>=4 & sm<6) draw quad probe (0, 0) rgba (4.0, 8.0, 16.0, 3.0) 8 % Degenerate cases uniform 0 float4 0.0 -0.0 1.0e39 -1.0e39 -todo(sm<6) draw quad +todo(sm>=4 & sm<6) draw quad probe (0, 0) rgba (1.0e39, -1.0e39, 0.0, -0.0) 8 -[pixel shader todo] +[pixel shader todo(sm>=4)] % Check invertibility uniform float4 f; @@ -40,19 +40,19 @@ float4 main() : sv_target [test] uniform 0 float4 1.0 2.0 3.0 4.0 -todo(sm<6) draw quad +todo(sm>=4 & sm<6) draw quad probe (0, 0) rgba (1.0, 2.0, 3.0, 4.0) 8 uniform 0 float4 7.604 3.1415 2.72 9.876 -todo(sm<6) draw quad +todo(sm>=4 & sm<6) draw quad probe (0, 0) rgba (7.604, 3.1415, 2.72, 9.876) 8 uniform 0 float4 0.0 -0.0 1.0e39 -1.0e39 -todo(sm<6) draw quad +todo(sm>=4 & sm<6) draw quad probe (0, 0) rgba (0.0, -0.0, 1.0e39, -1.0e39) -[pixel shader todo] +[pixel shader todo(sm>=4)] % Make sure swizzling works uniform float4 f; @@ -68,9 +68,9 @@ float4 main() : sv_target [test] uniform 0 float4 1.0 2.0 3.0 4.0 -todo(sm<6) draw quad +todo(sm>=4 & sm<6) draw quad probe (0, 0) rgba (1.0, 0.5, 0.3333333, 0.25) 8 uniform 0 float4 -1.0 -2.0 -3.0 -4.0 -todo(sm<6) draw quad +todo(sm>=4 & sm<6) draw quad probe (0, 0) rgba (-1.0, -0.5, -0.3333333, -0.25) 8