cpp-io2d / P0267_RefImpl

Reference Implementations of P0267, the proposed 2D graphics API for ISO C++
Other
313 stars 114 forks source link

Use float instead of doubles #139

Closed TerensTare closed 3 years ago

TerensTare commented 3 years ago

Since this is supposed to be the "standard way" of doing 2d graphics in C++, I think we need it to be as fast as it can. From what I saw from the implementation, vector_2d and rectangle use double for members. C++ also offers a float type with smaller precision, but which is proven to be faster. I personally have been using float for my Vector2d class and I have seen no problems, so I think the implementation would gain some performance by using floats.

kritzikratzi commented 3 years ago

afaik this is not true. https://stackoverflow.com/a/417591/347508

TerensTare commented 3 years ago

Apparently, if we do computations on GPU, floats are faster (link here). But on Android, floats are even slower than ints (link here).

kritzikratzi commented 3 years ago

before this gets religious ... i checked the source. can you provide links? i've found almost all double usage is in the examples and graphics backends, but not the main implementation:

https://github.com/cpp-io2d/P0267_RefImpl/search?q=double&unscoped_q=double

TerensTare commented 3 years ago

I read the paper about this proposal (Revision 6). There I saw two classes (namely vector_2d and rectangle), which used double for members. I found a fork of this repo with the implementation of these classes. I decided to file an issue there, but since you can't open an issue on a fork, I went to this repo (the parent one). It appears that the forked repo is some commits (and a revision) behind this one, as the classes are now renamed to basic_point_2d and basic_bounding_box and use float for members. Guess it was just my bad at all๐Ÿ˜…๐Ÿ˜….