bvh icon indicating copy to clipboard operation
bvh copied to clipboard

optimizations and other improvements

Open dbenson24 opened this issue 2 years ago • 9 comments

#71

Opening the PR, it's definitely not ready to be merged yet there's a couple more things I'm finishing up but I wanted to open earlier so if you wanted to read things over you'd be able to

dbenson24 avatar Jan 14 '22 15:01 dbenson24

Is there any chance you could cut down the PR into smaller chunks? I realize you did a lot of refactoring but are there perhaps any smaller chunks to make reviewing easier?

svenstaro avatar Jan 15 '22 03:01 svenstaro

The FFI stuff can very easily be separated so I'll do that. I'm not even sure what the best way to distribute that is

I think I can also pull the new shapes out into a separate change, I'll see what I can come up with

dbenson24 avatar Jan 15 '22 11:01 dbenson24

Hey, how are we looking here? Do you want to fix and then we can see how to get this integrated? If you like, I can even make you co-maintainer.

svenstaro avatar Feb 12 '22 00:02 svenstaro

ok I think I've fixed all the lints now

dbenson24 avatar Feb 12 '22 13:02 dbenson24

I've been a bit busy last couple of weeks haven't had time to look at breaking this apart. if that's still something you would prefer I can start working on trying to do so

dbenson24 avatar Feb 12 '22 14:02 dbenson24

Well if we can somehow do this in small incremental PRs that would be ideal but I can understand if you don't want to go down that path but it would make reviewing faster for me for sure. You get to decide. :)

svenstaro avatar Feb 14 '22 23:02 svenstaro

I've pulled the ffi bindings out, I can add them back in if you want them in the repo otherwise I will just throw them up in a separate repo.

In terms of reviewing this, the big change that affects the whole crate is refactoring all the types to use the vec/float types defined at the crate root. Otherwise the changes are pretty much file by file but because of that change to all of the types it's kind of a pain to break this down into little commits.

dbenson24 avatar Mar 16 '22 11:03 dbenson24

So I decided to try building a toy pathtracer against this branch, and I'm curious about how users are supposed to use the included shapes?

Currently none of them can actually be used in the BVH since none of them have a BHShape impl, so you can't actually include them in the BVH. If you're supposed to shoot rays and intersect them against the included shapes, it'd be nice if they used a Structure of Arrays (SoA) layout (a simple SoA layout gets me ~2x the performance with 100 spheres, or ~3x with 1000 spheres in my pathtracer), however because intersects_ray (from the IntersectionRay impl) doesn't have a way to return an index, you can't currently use your own SOA layouts.

I believe IntersectionAABB also doesn't have any way to return an index, so it also can't be used with SOA layouts.

edit: Remove outdated info.

Elabajaba avatar Jun 02 '22 19:06 Elabajaba

@Elabajaba the shapes missing impls are just because I haven't had time to write that code. This PR stems entirely from me writing other code and adding stuff to BVH as I needed it. In terms of the shapes not being able to be used in SOA, I chose not to attach an index to any of the shapes because it's very easy if you want to do that yourself. Just define an IndexedShape<T> that stores the shape and it's index. I didn't think that it made sense to force an index onto every shape.

dbenson24 avatar Jun 12 '22 11:06 dbenson24

Because of the discussion in the other thread: I wouldn't mind a co-maintainer on this. I don't use it much myself currently and I think someone with more stakes in this could really drive it forward a bit.

svenstaro avatar Apr 10 '23 20:04 svenstaro

Because of the discussion in the other thread: I wouldn't mind a co-maintainer on this. I don't use it much myself currently and I think someone with more stakes in this could really drive it forward a bit.

I may be interested, I plan to use it quite a bit in the future. I am a bit new to the rust side of things, but I generally worked with c++ metaprogramming before my switch to game engine development in rust.

marstaik avatar Apr 10 '23 22:04 marstaik

Because of the discussion in the other thread: I wouldn't mind a co-maintainer on this. I don't use it much myself currently and I think someone with more stakes in this could really drive it forward a bit.

I may be interested, I plan to use it quite a bit in the future. I am a bit new to the rust side of things, but I generally worked with c++ metaprogramming before my switch to game engine development in rust.

How about you start off by making one or two PRs that I'll review and then I can make you contrib from there if we click well?

svenstaro avatar Apr 11 '23 01:04 svenstaro

@marstaik how do you wanna play this PR? Shall we close it? Shall we leave it open until you have implemented the bits that you are interested in? I don't think the original author is going to return to this any time soon and the rebase is very gnarly at this point.

svenstaro avatar May 07 '23 02:05 svenstaro

I'm going to close this, the original author has already started porting the changes incrementally starting with this: https://github.com/svenstaro/bvh/pull/99

marstaik avatar May 07 '23 04:05 marstaik