Skip to content
Snippets Groups Projects

vkd3d-shader/hlsl: Improve support for logarithmic functions.

Merged Nikolay Sivov requested to merge nsivov/vkd3d:hlsl_log into master
5 unresolved threads

Merge request reports

Checking pipeline status.

Merged by Alexandre JulliardAlexandre Julliard 2 years ago (Apr 13, 2023 9:19pm UTC)

Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
1 [pixel shader]
2 uniform float4 x;
3
4 float4 main() : sv_target
5 {
6 return log2(x);
7 }
8
9 [test]
10 uniform 0 float4 2.0 4.0 5.0 0.4
    • +    /* ln(10) / ln(2) */
      +    if (!(coeff = hlsl_new_float_constant(ctx, 0.301029995664f, loc)))
      +        return false;

      That's ln(2) / ln(10), right? (Or 1 / log2(10), if you prefer.) I think the constant is a few digits beyond what a float can actually represent, but I suppose that's not a problem.

    • Author Developer

      You're right, I pushed something for that.

    • Please register or sign in to reply
  • Nikolay Sivov added 2 commits

    added 2 commits

    • 968188b3 - vkd3d-shader/hlsl: Support log10() intrinsic.
    • 0f446e03 - vkd3d-shader/hlsl: Support log() intrinsic.

    Compare with previous version

  • Elizabeth Figura approved this merge request

    approved this merge request

  • Nikolay Sivov added 35 commits

    added 35 commits

    • 0f446e03...d86db8bc - 31 commits from branch wine:master
    • cf60c0df - vkd3d-shader/hlsl: Write 'log' instruction for SM1.
    • 8f429deb - vkd3d-shader/hlsl: Support log2() intrinsic.
    • 815d958e - vkd3d-shader/hlsl: Support log10() intrinsic.
    • 8f33e59e - vkd3d-shader/hlsl: Support log() intrinsic.

    Compare with previous version

    • In the implementations of the log2(), log10(), and log() intrinsics, while, for a single argument, elementwise_intrinsic_float_convert_args() and intrinsic_float_convert_arg() do the same thing, the internal logic of the former is more complex than the latter, so, I think that for intrinsics with a single argument, it makes more sense to use the latter.

    • Author Developer

      Okay, I changed that. To me, having a single helper that handles everything is better than two.

    • Please register or sign in to reply
  • Nikolay Sivov added 19 commits

    added 19 commits

    • 8f33e59e...5f904e50 - 15 commits from branch wine:master
    • 98c8d722 - vkd3d-shader/hlsl: Write 'log' instruction for SM1.
    • dfa932fe - vkd3d-shader/hlsl: Support log2() intrinsic.
    • 92fd38dc - vkd3d-shader/hlsl: Support log10() intrinsic.
    • 5c6422c6 - vkd3d-shader/hlsl: Support log() intrinsic.

    Compare with previous version

  • Francisco Casas approved this merge request

    approved this merge request

  • Nikolay Sivov added 57 commits

    added 57 commits

    • 5c6422c6...57d92a15 - 53 commits from branch wine:master
    • e796c1ce - vkd3d-shader/hlsl: Write 'log' instruction for SM1.
    • 91bdc1fa - vkd3d-shader/hlsl: Support log2() intrinsic.
    • 5b6687d1 - vkd3d-shader/hlsl: Support log10() intrinsic.
    • e3e90aad - vkd3d-shader/hlsl: Support log() intrinsic.

    Compare with previous version

  • Nikolay Sivov added 45 commits

    added 45 commits

    • e3e90aad...616c4bf5 - 41 commits from branch wine:master
    • 230203e4 - vkd3d-shader/hlsl: Write 'log' instruction for SM1.
    • 9b52068e - vkd3d-shader/hlsl: Support log2() intrinsic.
    • 64937cb6 - vkd3d-shader/hlsl: Support log10() intrinsic.
    • eb6f0004 - vkd3d-shader/hlsl: Support log() intrinsic.

    Compare with previous version

  • Author Developer

    Anything else I should do here? Question from !89 (comment 23902) I believe was answered.

    • As far as I can tell we're not yet taking the logarithm of a negative number, and it's not completely clear to me why we cannot do that in a test constrained to SM4+. But I am not sure it's a good idea to waste more time on this, so I'm approving.

    • Author Developer

      For SM4+ it will results in nans, for older versions it will abs() input. None of that behavior is compiled in as a part of intrinsic.

    • Please register or sign in to reply
  • Giovanni Mascellani approved this merge request

    approved this merge request

  • For SM4+ it will results in nans, for older versions it will abs() input.

    Yes, but that is part of what makes this useful to test.

    Somewhat similarly, there are other known (and likely some unknown) differences in behaviour between the different shader models. It's helpful for shader_runner to be able to handle those for the cases we care about.

  • Henri Verbeet approved this merge request

    approved this merge request

  • Alexandre Julliard approved this merge request

    approved this merge request

  • Please register or sign in to reply
    Loading