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

Basic OpenVDB read support #2010

Merged
merged 13 commits into from Sep 26, 2018
Merged

Conversation

marsupial
Copy link
Contributor

Description

Add OpenVDB reader to OIIO

Tests

Not yet, no

Checklist:

  • I have read the contribution guidelines.
  • If this is more extensive than a small change to existing code, I
    have previously submitted a Contributor License Agreement
    (individual, and if there is any way my
    employers might think my programming belongs to them, then also
    corporate).
  • I have updated the documentation, if applicable.
  • I have ensured that the change is tested somewhere in the testsuite
    (adding new test cases if necessary).
  • My code follows the prevailing code style of this project.

Makefile Outdated
endif

ifneq (${OPENVDB_HOME},)
MY_CMAKE_FLAGS += -DOPENVDB_ROOT:STRING=${OPENVDB_ROOT}
Copy link
Collaborator

Choose a reason for hiding this comment

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

OPENVDB_HOME or OPENVDB_ROOT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OPENVDB_ROOT will do more interesting things...my Makefile knowledge pretty much starts and ends with these changes so probably wise to be thorough there.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, I just meant to make the names consistent. If the important thing on the cmake side is OPENVDB_ROOT, let's use the same name on the makefile wrapper side.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I got that, but wasn't the original just wrong as well:
make OPENVDB_HOME=/somewhere would have done nothing useful to MY_CMAKE_FLAGS

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I think it's all fine as long as it's always ROOT

Copy link
Collaborator

@lgritz lgritz left a comment

Choose a reason for hiding this comment

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

This is looking good.

TBB -- is that a strict requirement of OpenVDB? Is it just a link time dependency, or do we need include files?

I'd really like you to add a testsuite case for this. It can be somewhat like the field3d case. Does not have to exercise every feature, just a simple (small!) file to be sure it's able to open and read vdb.

CMakeLists.txt Show resolved Hide resolved
site/spi/Makefile-bits-arnold Outdated Show resolved Hide resolved
@@ -7,6 +7,7 @@ if (NOT VERBOSE)
set (DCMTK_FIND_QUIETLY true)
set (FFmpeg_FIND_QUIETLY true)
set (Field3D_FIND_QUIETLY true)
set (OpenVDB_FIND_QUIETLY true)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also TBB_FIND_QUIETLY

@marsupial
Copy link
Contributor Author

As I remember TBB was required as somewhere deep in VDB headers it was being pulled in.
But I'll investigate and make sure it wasn't from inclusion of something not included here.

@marsupial
Copy link
Contributor Author

TBB indeed needs to be visible for compile & link.
Split out TBB to be a separate CMake object.
Added cached variables OPENVDB_LOCATION for TBB_LOCATION.

Might still need to be an update to travis & appveyor to run the test.

@marsupial
Copy link
Contributor Author

CI seems to show not having VDB doesn't break the build, is it worth trying to get it supported there?

@lgritz
Copy link
Collaborator

lgritz commented Sep 24, 2018

LGTM, except that I tried to check on my laptop and it failed to find TBB. Offline, Roman and I discussed and he's going to substitute a different FindTBB.cmake, the one from USD, which seems to work better.

@lgritz
Copy link
Collaborator

lgritz commented Sep 24, 2018

Correct, not having VDB should not break the build.

I'll go back later and adjust the travis files to make sure openvdb is installed (at least on Mac, where it's easy thanks to Homebrew) so that this feature is exercised. You can try that, too, if you want, but no big deal if you want to move on and I'll take care of it separately.

@marsupial
Copy link
Contributor Author

Seems good here, probably worth trying to make sure it works as expected on OS X.
Next travis build should give it a try..

@lgritz
Copy link
Collaborator

lgritz commented Sep 24, 2018

On OSX (both on my laptop and Travis), its finding TBB but not finding OpenVDB. Not sure why.

@marsupial
Copy link
Contributor Author

Could NO_DEFAULT_PATH in FindOpenVDB.cmake:66 be the culprit? Seems I stripped that from the header portion but not the library.

@lgritz
Copy link
Collaborator

lgritz commented Sep 25, 2018

I tried messing with that, and it didn't help on my laptop.

I did find another FindOpenVDB file, however: https://github.com/dfelinto/blender/blob/master/build_files/cmake/Modules/FindOpenVDB.cmake

Using this simple one from Blender (which says it's BSD license) seems to do the trick to build it, if you also change the appropriate variables in externalpackages.cmake and openvdb.imageio/CMakeLists.txt.

I do still fail the openvdb unit test, getting errors like this:

ERROR: Could not open 'src/sphereCd.vdb': IoError: Blosc decoding is not supported

Do you know what that's about?

@marsupial
Copy link
Contributor Author

An older version of VDB, or one compiled without blosc support? SideFx forum also mentioned possible incompatible versions of the blosc lib itself causing issues. I'll see if there's a way to convert or output from an older version of Houdini.

@marsupial
Copy link
Contributor Author

Updated test to not use blosc, are you going to push something on top with the working CMake or is that something to be done here?

@lgritz
Copy link
Collaborator

lgritz commented Sep 25, 2018

I'm happy to do it (since I already made the changes on my end to test it).
Should I merge what you have and then send a separate PR for that? Or should I push back to your branch to make it all one merge (you need to have checked the box that lets me push to your branch, for that to work)?

@marsupial
Copy link
Contributor Author

I'll push the button..

@lgritz
Copy link
Collaborator

lgritz commented Sep 25, 2018

Builds on OSX and passes the unit test!
I'm going to add some touch-ups and then push back so you can see and approve.

The original FindOpenVDB.cmake was unreliable. Replaced with one found
elsewhere on the net (from Blender, bearing a BSD license).
@marsupial
Copy link
Contributor Author

Great thanks...Out of curiosity the VDB library was 4 or 3?

@lgritz
Copy link
Collaborator

lgritz commented Sep 25, 2018

5

* Makefile wrapper: directly use OPENVDB_ROOT_DIR

* Update INSTALL.md and oiiointro.tex to document the new optional
  dependencies and how we incorporated those two new Find*.cmake files
  from other projects (with appropriate licenses).

* Simplification of the TBB and OpenVDB sections of externalpackages.cmake,
  they didn't need to be quite so verbose, didn't need to -UUSE_BLAH if not
  found, did not need to set BLAH_FOUND (done by the FindBlah itself),
  and I added minimum versions of both packages based on this year's
  VFX Platform guidelines (as a forward-looking new feature in master,
  I don't feel the need to verify support of older versions).

* Update oiio docs chapter on supported formats to include OpenVDB.

* Some extremely minor formatting and whitespace fixes in
  openvdbinput.cpp to conform to prevailing project style.

* Simplification of the SPI-specific Makefile-bits.

* Minor touch of field3d to add "worldtolocal" metadata to conform to the
  new convention we're using with vdb.
@lgritz
Copy link
Collaborator

lgritz commented Sep 25, 2018

OK, I pushed some minor fixes on top of yours. A lot was just minor cleanup I would have done at some later time as I touched up the docs or prepared for a release.

  • The original FindOpenVDB.cmake was unreliable. Replaced with one found elsewhere on the net (from Blender, bearing a BSD license).

  • Makefile wrapper: directly use OPENVDB_ROOT_DIR

  • Update INSTALL.md and oiiointro.tex to document the new optional dependencies and how we incorporated those two new Find*.cmake files from other projects (with appropriate licenses).

  • Simplification of the TBB and OpenVDB sections of externalpackages.cmake, they didn't need to be quite so verbose, didn't need to -UUSE_BLAH if not found, did not need to set BLAH_FOUND (done by the FindBlah itself), and I added minimum versions of both packages based on this year's VFX Platform guidelines (as a forward-looking new feature in master, I don't feel the need to verify support of older versions).

  • Update oiio docs chapter on supported formats to include OpenVDB.

  • Some extremely minor formatting and whitespace fixes in openvdbinput.cpp to conform to prevailing project style.

  • Simplification of the SPI-specific Makefile-bits.

  • Minor touch of field3d to add "worldtolocal" metadata to conform to the new convention we're using with vdb.

bool
OpenVDBInput::open (const std::string &filename, ImageSpec &newspec)
{
if (m_input)
close();

auto file = openVDB(filename, this);
if (!file)
if (!file || !file->isOpen())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ASSERT removed was because the contract from the openVDB function is not to return a io::File unless isOpen has returned true already. In the scheme of what's about to be done the additional check likely adds nothing, but I did like the ASSERTION of that promise.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see. I was just trying to reduce the number of cases where we couldn't recover. From the point of an app, I think it's preferable to return "I can't open this file" whether it be that it's malformed, or OpenVDB is somehow broken, then to terminate the whole process.

How about if I use DASSERT, which will do the hard crash/error when in debug mode? But for release build, the app will get a failure state rather than terminate?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I'm fine with how you had it. Changing back.

set (oiio_vdb_why ", could not find Intel TBB")
endif ()
message (STATUS "OpenVDB will not be used${oiio_vdb_why}")
message (STATUS "OpenVDB will not be used, could not find Intel TBB")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Won't this spew the message when invoked with -DUSE_OPENVDB=OFF

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you're right, I will fix it.

@marsupial
Copy link
Contributor Author

Everything seems to work as was, so I'd say good to go.
Left two little comments above, but totally fine if you want to show them to the waste-bin.

@lgritz lgritz merged commit 47e9a4c into AcademySoftwareFoundation:master Sep 26, 2018
@lgritz
Copy link
Collaborator

lgritz commented Sep 26, 2018

Merged.
Great work, Roman!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants