mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-09-13 09:16:14 -07:00
vkd3d-shader/hlsl: Implement tanh.
This commit is contained in:
parent
c4182cc272
commit
1fb9e7526b
Notes:
Alexandre Julliard
2024-04-15 22:22:07 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/740
@ -3991,6 +3991,39 @@ static bool intrinsic_tan(struct hlsl_ctx *ctx,
|
||||
return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_DIV, sin, cos, loc);
|
||||
}
|
||||
|
||||
static bool intrinsic_tanh(struct hlsl_ctx *ctx,
|
||||
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
struct hlsl_ir_function_decl *func;
|
||||
struct hlsl_ir_node *arg;
|
||||
struct hlsl_type *type;
|
||||
char *body;
|
||||
|
||||
static const char template[] =
|
||||
"%s tanh(%s x)\n"
|
||||
"{\n"
|
||||
" %s exp_pos, exp_neg;\n"
|
||||
" exp_pos = exp(x);\n"
|
||||
" exp_neg = exp(-x);\n"
|
||||
" return (exp_pos - exp_neg) / (exp_pos + exp_neg);\n"
|
||||
"}\n";
|
||||
|
||||
if (!(arg = intrinsic_float_convert_arg(ctx, params, params->args[0], loc)))
|
||||
return false;
|
||||
type = arg->data_type;
|
||||
|
||||
if (!(body = hlsl_sprintf_alloc(ctx, template,
|
||||
type->name, type->name, type->name)))
|
||||
return false;
|
||||
|
||||
func = hlsl_compile_internal_function(ctx, "tanh", body);
|
||||
vkd3d_free(body);
|
||||
if (!func)
|
||||
return false;
|
||||
|
||||
return add_user_call(ctx, func, params, loc);
|
||||
}
|
||||
|
||||
static bool intrinsic_tex(struct hlsl_ctx *ctx, const struct parse_initializer *params,
|
||||
const struct vkd3d_shader_location *loc, const char *name, enum hlsl_sampler_dim dim)
|
||||
{
|
||||
@ -4366,6 +4399,7 @@ intrinsic_functions[] =
|
||||
{"sqrt", 1, true, intrinsic_sqrt},
|
||||
{"step", 2, true, intrinsic_step},
|
||||
{"tan", 1, true, intrinsic_tan},
|
||||
{"tanh", 1, true, intrinsic_tanh},
|
||||
{"tex1D", -1, false, intrinsic_tex1D},
|
||||
{"tex2D", -1, false, intrinsic_tex2D},
|
||||
{"tex2Dlod", 2, false, intrinsic_tex2Dlod},
|
||||
|
@ -111,7 +111,7 @@ todo(glsl) draw quad
|
||||
probe all rgba (1.0, 1.0, 1.0e39, 1.0e39) 1
|
||||
|
||||
|
||||
[pixel shader todo]
|
||||
[pixel shader]
|
||||
uniform float4 a;
|
||||
|
||||
float4 main() : sv_target
|
||||
@ -121,8 +121,8 @@ float4 main() : sv_target
|
||||
|
||||
[test]
|
||||
uniform 0 float4 -1.57079633 -0.54930614 0.54930614 1.57079633
|
||||
todo(sm<6) draw quad
|
||||
todo(glsl) draw quad
|
||||
probe all rgba (-0.91715234, -0.5, 0.5, 0.91715234) 2
|
||||
uniform 0 float4 -10.0 -0.0 0.0 10.0
|
||||
todo(sm<6) draw quad
|
||||
todo(glsl) draw quad
|
||||
probe all rgba (-1.0, 0.0, 0.0, 1.0) 1
|
||||
|
Loading…
Reference in New Issue
Block a user