Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instancing support (shapegroup and instance plugins) #170

Merged
merged 5 commits into from
Jul 22, 2020
Merged

Conversation

Speierers
Copy link
Member

@Speierers Speierers commented Jun 8, 2020

This is PR ports the shapegroup and instance plugins to Mitsuba 2.

Thanks @nathan96g for his great work!

TODOs

  • Minor fixes in current implementation
  • Check Embree support
  • OptiX support
  • Documentation
  • Add more tests

@Speierers Speierers self-assigned this Jun 8, 2020
@Speierers Speierers marked this pull request as draft June 8, 2020 07:47
Copy link
Member Author

@Speierers Speierers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work @4str0m ! Just a few minor feedbacks.

include/mitsuba/render/optix/ray.cuh Outdated Show resolved Hide resolved
include/mitsuba/render/optix/ray.cuh Outdated Show resolved Hide resolved
include/mitsuba/render/optix/shapes.h Outdated Show resolved Hide resolved
include/mitsuba/render/optix/shapes.h Outdated Show resolved Hide resolved
src/shapes/instance.cpp Outdated Show resolved Hide resolved
src/shapes/instance.cpp Outdated Show resolved Hide resolved
@Speierers Speierers marked this pull request as ready for review June 12, 2020 10:00
@Speierers Speierers requested a review from wjakob June 12, 2020 10:01
Copy link
Member

@wjakob wjakob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This generally looks great -- I left a few low-level comments. Here are a few higher level thoughts on the interfaces:

The amount of backend-specific methods in the Shape class has gotten a little out of hand IMO, and I would like this to be reduced if possible. For example: I think it should be possible to merge init_embree_scene into embree_geometry, and put cleanup logic in destructor without losing anything.

The various OptiX-specific methods in shape.h are very hard to understand (just short 1-liner comments) that don’t really tell us much about their role in the process (this was fine when there was just a single one like optix_geometry that does "the obvious", but now that is no longer the case). Like this one where the comment is really just a placeholder that provides no extra information over the function signature:

/// Fill the OptixBuildInput struct
virtual void optix_build_input(OptixBuildInput&) const;

So: this will need significantly more extensive documentation (A rough guide is probably > 10 lines — a thorough explanation followed by separate documentation for each function parameter explaining its role in relation to the intro). Can you add this? I’d then like to do another pass over these functions to see if it can be condensed a bit more.

Another thing to consider: sometimes such methods are extremely specific to a single plugin like “instance” or “shapegroup” — check out Mitsuba 1. There, the instance actually had its own header file (int the “shape” directory) to add a few function declarations that were not in shape.h. I propose that we follow a similar approach.

Testing needs to be improved: right now we’re only testing scalar RGB mode, and we are only testing an analytic sphere with a single instance. It would be good to test the “wide” backends on CPU and GPU with something more interesting where we will truly find out when something breaks.

include/mitsuba/render/optix/matrix.cuh Outdated Show resolved Hide resolved
include/mitsuba/render/optix/shapes.h Outdated Show resolved Hide resolved
include/mitsuba/render/optix/vector.cuh Outdated Show resolved Hide resolved
include/mitsuba/render/optix/vector.cuh Outdated Show resolved Hide resolved
src/librender/scene_embree.inl Outdated Show resolved Hide resolved
src/shapes/shapegroup.cpp Outdated Show resolved Hide resolved
src/shapes/shapegroup.cpp Outdated Show resolved Hide resolved
src/shapes/shapegroup.cpp Outdated Show resolved Hide resolved
src/shapes/shapegroup.cpp Outdated Show resolved Hide resolved
include/mitsuba/render/shape.h Outdated Show resolved Hide resolved
@4str0m
Copy link
Contributor

4str0m commented Jun 18, 2020

Another thing to consider: sometimes such methods are extremely specific to a single plugin like “instance” or “shapegroup” — check out Mitsuba 1. There, the instance actually had its own header file (int the “shape” directory) to add a few function declarations that were not in shape.h. I propose that we follow a similar approach.

This method was usefull for cases like the optix_accel_handle method, which was only defined inside the ShapeGroup plugin, and used in the Instance plugin. Unfortunately, even though it could be done for the optix_prepare_instance method (that is currently only defined inside the Instance plugin), this method is used in librender (more specifically in the include/mitsuba/render/optix/shapes.h file). This prevents it to be defined in an instance.h header, as the actual implementation would have to be visible to the linker when compiling librender.so.

@wjakob : do you have an idea on how we could keep the current architecture (Instance and Shapegroup classes as separate plugins) while still allowing the optix_prepare_instance method to be specific to the instance's plugin only.

@wjakob
Copy link
Member

wjakob commented Jul 4, 2020

@4strom: thinking about this a bit more, I think it would only be possible if you declare these as inline method in a hypothetical instance.h/shapegroup.h that is then included called from librender. That is the only way to avoid having to link librender to the plugin. Effectively it would mean that librender knows about the instance layout of these two classes and then performs any method calls directly there. What do you think?

@wjakob
Copy link
Member

wjakob commented Jul 4, 2020

(This, by the way, is IIRC also how it was handled in Mitsuba 1.)

@Speierers Speierers force-pushed the instancing branch 3 times, most recently from e79b7d4 to af1afea Compare July 21, 2020 15:03
@Speierers Speierers added the ✨ new feature New feature or request label Jul 21, 2020
@Speierers Speierers merged commit 74253f4 into master Jul 22, 2020
@Speierers Speierers deleted the instancing branch February 25, 2021 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants