Code Monkey home page Code Monkey logo

Comments (4)

redorav avatar redorav commented on June 10, 2024

The issue was that std::round was not giving me the same results as hlsl for 0.5, but rounding 0.9 to -1 is definitely wrong, I'll take a look at that again, thanks for reporting

from hlslpp.

redorav avatar redorav commented on June 10, 2024

Can you try latest code? There was an issue with one of the conditions, it should be good now. I also verified that std::round is incorrect wrt to HLSL and the SIMD _mm_round_ps

from hlslpp.

mlangerak avatar mlangerak commented on June 10, 2024

That fixes my immediate issue, but I did not double check that the fixed code is correct for rounding negative numbers, does the unit test cover these cases? (In my particular case where I ran into this bug, negative numbers are clamped to zero after the rounding operation so any bugs in rounding negative numbers would not show up there.)

What are the differences between HLSL and std::round?

from hlslpp.

redorav avatar redorav commented on June 10, 2024

It's at x.5 that it goes wrong, not just with hlsl but with the simd intrinsics as well. 0.5 rounds to 1 with std::round but to 0 in the other cases.

The unit tests have negative numbers as well. However I may have to improve them because they clearly didn't catch the issue last time. I did do a few more tests locally.

from hlslpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.