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

Java implementation or bindings ? #261

Open
jsorel opened this issue Nov 13, 2024 · 7 comments
Open

Java implementation or bindings ? #261

jsorel opened this issue Nov 13, 2024 · 7 comments

Comments

@jsorel
Copy link

jsorel commented Nov 13, 2024

Hello,

I've been searching for an ANARI implementation or at least a binding for Java, but could not find any.

Have any links or informations ?

Thanks

@jeffamstutz
Copy link
Contributor

Hi, sorry for the late reply!

We don't have any language bindings for anything beyond Python, but would welcome a PR if someone were to make them! I personally don't have any experience binding C to Java, so if you have pointers that would be helpful.

@jsorel
Copy link
Author

jsorel commented Jan 9, 2025

I can give it a try, using Java Panama.
but I need the C header files that must be used and a doc on how to install an anari compliant engine on linux.

@jeffamstutz
Copy link
Contributor

The main C header can be found here, which gets installed to ${CMAKE_INSTALL_PREFIX}/include/anari.

By default, a very simple CPU-only engine comes with the SDK called helide (enabled with BUILD_HELIDE_DEVICE in CMake). Any of the other engines you can find (list here) is a matter of building them against your install of ANARI-SDK and then installing them in a place loadable by the main front end library. "Loadable" means either a) the engine library is physically next to the front end library, or b) the system library loader can find it (e.g. LD_LIBRARY_PATH). Basically the front end library just does a dlopen() and follows the rules for that based on whatever platform you are on. Other setups are possible (i.e. static linking), but what I described is the most common way people load engines.

I would expect that the bindings are only built against the front end library, then engines are loaded at runtime (using anariLoadLibrary()) based on whatever users have installed locally. If this approach won't work for whatever reason (or isn't desirable), we can talk through alternatives that will suffice.

Feel free to treat this thread as a Q&A for any issues that come up!

@jsorel
Copy link
Author

jsorel commented Jan 13, 2025

Hello, I manage to bind three methods to test, looks like it works. There's much more work to do but it's not going to be too complex, just the callback function I'm not sure how to map yet.

Do you think it could be possible to have static builds of ANARI for each release+os ?

In the java world when dealing with native code, we test if it's available on the system, and if not we use a bundled version. So if we could have windows/linux/mac standalone builds (so,dll,...) available for download it would be great.

@jeffamstutz
Copy link
Contributor

I was able to get our CI to make some basic builds, which is now merged. I'll be sure to upload those artifacts as a part of each upcoming tagged release. I'm putting the final touches on a v0.12.1 patch release right now, which should be up today or tomorrow.

Note we also have the ANARI-SDK in vcpkg (in-progress update PR here), and would love to see other package managers pick it up too.

@jsorel
Copy link
Author

jsorel commented Jan 15, 2025

Thanks,
On my side, I managed to make the callback working, made the binding for all the methods and started to convert the first example in java. (https://github.com/KhronosGroup/ANARI-SDK/blob/next_release/examples/simple/anariTutorial.c)

current log of the application :

initialize ANARI...
Available devices:
  - default
Available renderers:
  - default
Default renderer has no parameters.
done!

setting up camera...
Anari report:DEBUG UNKNOWN_ERROR Anari.Device:139731597401680 Anari.Object:139731597401680 type:DEVICE message:
	| initializing helide device (0x7f15cc3a1e50)
done!

setting up scene...
Anari report:PERFORMANCE_WARNING UNKNOWN_ERROR Anari.Device:139731597401680 Anari.Object:139731597512560 type:ARRAY1D message:
	| making private copy of shared array (type 'ANARI_FLOAT32_VEC3') | ownership: (1:2)
Anari report:PERFORMANCE_WARNING UNKNOWN_ERROR Anari.Device:139731597401680 Anari.Object:139731597520768 type:ARRAY1D message:
	| making private copy of shared array (type 'ANARI_FLOAT32_VEC4') | ownership: (1:2)
Anari report:PERFORMANCE_WARNING UNKNOWN_ERROR Anari.Device:139731597401680 Anari.Object:139731596593088 type:ARRAY1D message:
	| making private copy of shared array (type 'ANARI_UINT32_VEC3') | ownership: (1:2)
done!

Anari report:DEBUG UNKNOWN_ERROR Anari.Device:139731597401680 Anari.Object:139731597510960 type:WORLD message:
	| helide::World will add zero instance
Anari report:DEBUG UNKNOWN_ERROR Anari.Device:139731597401680 Anari.Object:139731597510960 type:WORLD message:
	| helide::World found 1 surfaces in zero instance
Anari report:DEBUG UNKNOWN_ERROR Anari.Device:139731597401680 Anari.Object:139731597510960 type:WORLD message:
	| helide::World rebuilding 1 BLSs
Anari report:DEBUG UNKNOWN_ERROR Anari.Device:139731597401680 Anari.Object:139731597288480 type:GROUP message:
	| helide::Group rebuilding embree scene
Anari report:DEBUG UNKNOWN_ERROR Anari.Device:139731597401680 Anari.Object:139731597288480 type:GROUP message:
	| helide::Group committing embree scene
Anari report:DEBUG UNKNOWN_ERROR Anari.Device:139731597401680 Anari.Object:139731597510960 type:WORLD message:
	| helide::World rebuilding TLS over 1 instances

world bounds: ({0,000000, 0,000000, -0,000000}, {0,000000, 0,000000, 0,000000}

setting up renderer...
rendering initial frame to firstFrame.ppm...
done!

rendering 10 accumulated frames to accumulatedFrame.ppm...
done!


cleaning up objects...
Anari report:DEBUG UNKNOWN_ERROR Anari.Device:139731597401680 Anari.Object:139731597530224 type:ARRAY1D message:
	| freeing managed array
Anari report:DEBUG UNKNOWN_ERROR Anari.Device:139731597401680 Anari.Object:139731597401680 type:DEVICE message:
	| destroying helide device (0x7f15cc3a1e50)
done!

image output :

Image

@jeffamstutz
Copy link
Contributor

This is really really cool -- so glad you were able to get it running! Keep the images coming 😉

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

No branches or pull requests

2 participants