Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
vkd3d
Manage
Activity
Members
Labels
Plan
Wiki
Bugzilla
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wine
vkd3d
Commits
c4182cc2
Commit
c4182cc2
authored
1 year ago
by
Petrichor Park
Committed by
Alexandre Julliard
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
vkd3d-shader/hlsl: Implement hyperbolic sin and cos.
parent
2b7d9790
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!740
Implement hyperbolic trigonometry operations.
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libs/vkd3d-shader/hlsl.y
+48
-0
48 additions, 0 deletions
libs/vkd3d-shader/hlsl.y
tests/hlsl/trigonometry.shader_test
+6
-6
6 additions, 6 deletions
tests/hlsl/trigonometry.shader_test
with
54 additions
and
6 deletions
libs/vkd3d-shader/hlsl.y
+
48
−
0
View file @
c4182cc2
...
...
@@ -3028,6 +3028,46 @@ static bool intrinsic_cos(struct hlsl_ctx *ctx,
return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_COS, arg, loc);
}
static bool write_cosh_or_sinh(struct hlsl_ctx *ctx,
const struct parse_initializer *params, const struct vkd3d_shader_location *loc, bool sinh_mode)
{
struct hlsl_ir_function_decl *func;
struct hlsl_ir_node *arg;
const char *fn_name, *type_name;
char *body;
static const char template[] =
"%s %s(%s x)\n"
"{\n"
" return (exp(x) %s exp(-x)) / 2;\n"
"}\n";
static const char fn_name_sinh[] = "sinh";
static const char fn_name_cosh[] = "cosh";
if (!(arg = intrinsic_float_convert_arg(ctx, params, params->args[0], loc)))
return false;
type_name = arg->data_type->name;
fn_name = sinh_mode ? fn_name_sinh : fn_name_cosh;
if (!(body = hlsl_sprintf_alloc(ctx, template,
type_name, fn_name, type_name, sinh_mode ? "-" : "+")))
return false;
func = hlsl_compile_internal_function(ctx, fn_name, body);
vkd3d_free(body);
if (!func)
return false;
return add_user_call(ctx, func, params, loc);
}
static bool intrinsic_cosh(struct hlsl_ctx *ctx,
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
{
return write_cosh_or_sinh(ctx, params, loc, false);
}
static bool intrinsic_cross(struct hlsl_ctx *ctx,
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
{
...
...
@@ -3873,6 +3913,12 @@ static bool intrinsic_sin(struct hlsl_ctx *ctx,
return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_SIN, arg, loc);
}
static bool intrinsic_sinh(struct hlsl_ctx *ctx,
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
{
return write_cosh_or_sinh(ctx, params, loc, true);
}
/* smoothstep(a, b, x) = p^2 (3 - 2p), where p = saturate((x - a)/(b - a)) */
static bool intrinsic_smoothstep(struct hlsl_ctx *ctx,
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
...
...
@@ -4277,6 +4323,7 @@ intrinsic_functions[] =
{"clamp", 3, true, intrinsic_clamp},
{"clip", 1, true, intrinsic_clip},
{"cos", 1, true, intrinsic_cos},
{"cosh", 1, true, intrinsic_cosh},
{"cross", 2, true, intrinsic_cross},
{"ddx", 1, true, intrinsic_ddx},
{"ddx_coarse", 1, true, intrinsic_ddx_coarse},
...
...
@@ -4314,6 +4361,7 @@ intrinsic_functions[] =
{"saturate", 1, true, intrinsic_saturate},
{"sign", 1, true, intrinsic_sign},
{"sin", 1, true, intrinsic_sin},
{"sinh", 1, true, intrinsic_sinh},
{"smoothstep", 3, true, intrinsic_smoothstep},
{"sqrt", 1, true, intrinsic_sqrt},
{"step", 2, true, intrinsic_step},
...
...
This diff is collapsed.
Click to expand it.
tests/hlsl/trigonometry.shader_test
+
6
−
6
View file @
c4182cc2
...
...
@@ -76,7 +76,7 @@ todo(sm<4 | glsl) draw quad
probe all rgba (0, 1000, -1000.0, 0)
[pixel shader
todo
]
[pixel shader]
uniform float4 a;
float4 main() : sv_target
...
...
@@ -86,15 +86,15 @@ float4 main() : sv_target
[test]
uniform 0 float4 -6.28318531 -0.88137359 0.88137359 6.28318531
todo(
sm<6
) draw quad
todo(
glsl
) draw quad
probe all rgba (-267.744894, -1.0, 1.0, 267.744894) 2
uniform 0 float4 -0.0 0.0 -90.0 90.0
todo(
sm<6
) draw quad
todo(
glsl
) draw quad
% mingw does not support "inf" for scanf(), but numbers beyond FLOAT_MAX consistently result in inf.
probe all rgba (0.0, 0.0, -1.0e39, 1.0e39) 1
[pixel shader
todo
]
[pixel shader]
uniform float4 a;
float4 main() : sv_target
...
...
@@ -104,10 +104,10 @@ float4 main() : sv_target
[test]
uniform 0 float4 -1.76274717 -1.3169579 1.3169579 1.76274717
todo(
sm<6
) draw quad
todo(
glsl
) draw quad
probe all rgba (3.0, 2.0, 2.0, 3.0) 2
uniform 0 float4 -0.0 0.0 -90.0 90.0
todo(
sm<6
) draw quad
todo(
glsl
) draw quad
probe all rgba (1.0, 1.0, 1.0e39, 1.0e39) 1
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment