Module: vkd3d Branch: master Commit: 8bb023e5af87b8dc4dfbf20174136ccbd87b9003 URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/8bb023e5af87b8dc4dfbf20174136c...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Wed Jan 25 21:03:56 2023 +0300
vkd3d-shader/hlsl: Support exp() intrinsic.
---
libs/vkd3d-shader/hlsl.y | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 3eee09ae..a4de0edd 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -2491,6 +2491,26 @@ static bool intrinsic_dot(struct hlsl_ctx *ctx, return !!add_binary_dot_expr(ctx, params->instrs, params->args[0], params->args[1], loc); }
+static bool intrinsic_exp(struct hlsl_ctx *ctx, + const struct parse_initializer *params, const struct vkd3d_shader_location *loc) +{ + struct hlsl_ir_constant *coeff; + struct hlsl_ir_node *arg, *mul; + + if (!(arg = intrinsic_float_convert_arg(ctx, params, params->args[0], loc))) + return false; + + /* 1/ln(2) */ + if (!(coeff = hlsl_new_float_constant(ctx, 1.442695f, loc))) + return false; + list_add_tail(params->instrs, &coeff->node.entry); + + if (!(mul = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, &coeff->node, params->args[0], loc))) + return false; + + return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_EXP2, mul, loc); +} + static bool intrinsic_exp2(struct hlsl_ctx *ctx, const struct parse_initializer *params, const struct vkd3d_shader_location *loc) { @@ -2943,6 +2963,7 @@ intrinsic_functions[] = {"cos", 1, true, intrinsic_cos}, {"cross", 2, true, intrinsic_cross}, {"dot", 2, true, intrinsic_dot}, + {"exp", 1, true, intrinsic_exp}, {"exp2", 1, true, intrinsic_exp2}, {"floor", 1, true, intrinsic_floor}, {"frac", 1, true, intrinsic_frac},