jeremyong/klein

Klein 2.0 API changes inbound

Closed this issue · 2 comments

I hate breaking compatibility. Especially frequently. This issue is my attempt to explain what the issue is, what I’m doing to fix it, and what assurances can be afforded about API breakages in the future.

First, the issues:

  1. On some compilers, inheritance is causing subclasses of entity to be passed on the stack instead of in registers.
  2. On some compilers, branch optimization limits are being hit causing certain loops over constexpr variables to not get optimized out at runtime.

For Klein whose primary goal is realtime PGA, both of these problems are unacceptable. As a result, the entity base class needs to go. This will have the following consequences:

  1. Implicit conversions using the entity as a medium will go away. All conversions will be explicit
  2. Because of (1), most operators will move to separate headers (one per operation) to avoid circular dependencies while maintaining type safety
  3. All the underlying implementation structure will remain the same.

As for testing, I have vetted that the changes outlined above solve all the issues mentioned and checked assembly/perf against all major compilers. All that remains is to finalize the implementation. The internal SSE code does not need to be changed as it is just the “outer shell” that has this problem. Personally, I much prefer the new API, but it is nevertheless a breaking change. As a result, Klein will get a 2.0 label despite the 1.0 being released relatively recently.

Feel free to comment with suggestions or feedback below.

FYI most geometric operations (meet, join, GP, etc) will work as they currently do (they might just require a header change if you didn't include klein.hpp. The only operations that need to be lifted out are operators that change the argument types (mainly exp/log)

RC checkin d447c5d