Closed eloj closed 4 weeks ago
Ran the matrix of clang++-19 and GCC 14.2 before and after this change using the timing branch (#11), no special prep:
before-gcc.txt:Frame 8 time: 1529 ms, avg: 1531.00 ms
after-gcc.txt:Frame 8 time: 1531 ms, avg: 1529.00 ms
before-clang.txt:Frame 8 time: 1352 ms, avg: 1348.75 ms
after-clang.txt:Frame 8 time: 1339 ms, avg: 1339.38 ms
Removing the casts is fine and makes the code more compact and clear. Originally I had that TriVertex thing in there but that was silly, bvhvec4 is just fine and has automatic conversion to and from bvhvec3.
The code gen isn't exactly the same before-and-after, but it's very minor. Some timings in the post after this.
The GCC diff is less clean and slightly worse-looking, but the clang one looks okay to me.
I understand if you prefer the casting in the end.
(Before this example was updated, I got it bit-exact by using adding a conversion function[^1] to the
TriVertex
type. I imagine it would be possible to do the same directly on thebvhvec4
, but that's a more intrusive change.)[^1]: i.e
operator bvhvec3&() const { return *(bvhvec3*)(this); }