Skip to content

Commit

Permalink
Merge branch 'next_release'
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffamstutz committed Oct 18, 2024
2 parents 1bcfb82 + 8b33579 commit 0c7036a
Show file tree
Hide file tree
Showing 798 changed files with 16,764 additions and 66,831 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/anari_sdk_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: ANARI-SDK CI

on:
push:
branches: [ jda/remote-device ]
branches: [ next_release ]
pull_request:
branches: [ main, next_release ]

Expand All @@ -22,7 +22,7 @@ jobs:

- name: Install Packages
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt install -y libboost-filesystem-dev libboost-system-dev libboost-iostreams-dev
run: sudo apt install -y libboost-system-dev

- name: Configure CMake
run: >
Expand All @@ -31,6 +31,7 @@ jobs:
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/install
-DBUILD_SHARED_LIBS=ON
-DBUILD_EXAMPLES=ON
-DBUILD_HDANARI=OFF
-DBUILD_HELIDE_DEVICE=ON
-DBUILD_REMOTE_DEVICE=${{ matrix.os == 'ubuntu-latest' }}
-DBUILD_TESTING=ON
Expand All @@ -46,3 +47,7 @@ jobs:
- name: Render Tests
working-directory: ${{github.workspace}}/build
run: ctest -R render_test -C ${{ matrix.config }}

- name: Tutorial Tests
working-directory: ${{github.workspace}}/build
run: ctest -R anariTutorial -C ${{ matrix.config }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ cts/*.exp
cts/*.lib
cts/*.ilk
cts/*.pdb
cts/gltf-Sample-Assets
36 changes: 33 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)

## Establish project

project(anari VERSION 0.10.0 LANGUAGES C CXX)
set(ANARI_SDK_VERSION_MAJOR 0)
set(ANARI_SDK_VERSION_MINOR 11)
set(ANARI_SDK_VERSION_PATCH 0)
set(ANARI_SDK_VERSION
${ANARI_SDK_VERSION_MAJOR}.${ANARI_SDK_VERSION_MINOR}.${ANARI_SDK_VERSION_PATCH}
)

project(anari VERSION ${ANARI_SDK_VERSION} LANGUAGES C CXX)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
Expand All @@ -37,17 +44,32 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
include(GNUInstallDirs)
include(CMakeDependentOption)

enable_testing()

set(CMAKE_INSTALL_RPATH "$ORIGIN:$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")

# Built-in CMake options
option(BUILD_SHARED_LIBS "Build shared libraries instead of static" ON)
option(BUILD_TESTING "Build tests for CTest" ON)
# ANARI specific options
option(BUILD_CTS "Build cts toolkit" ON)

option(BUILD_CTS "Build cts toolkit" OFF)
cmake_dependent_option(CTS_ENABLE_GLTF "Enable glTF support for cts" ON "BUILD_CTS" ON)
option(USE_DRACO "Use draco when loading glTF files" OFF)
option(USE_WEBP "Use webp when loading glTF files" OFF)
option(USE_KTX "Use ktx when loading glTF files" OFF)

if (CTS_ENABLE_GLTF)
# To enforce WEBP, KTX and DRACO support (CI does not have these dependecies)
# set(USE_KTX ON)
# set(USE_WEBP ON)
# set(USE_DRACO ON)
endif()

option(BUILD_EXAMPLES "Build example applications and example device" ON)
cmake_dependent_option(BUILD_VIEWER
"Build interactive viewer app (requires GLFW)"
ON
OFF
"BUILD_EXAMPLES"
OFF
)
Expand All @@ -66,12 +88,20 @@ cmake_dependent_option(VIEWER_ENABLE_GLTF
"BUILD_VIEWER"
OFF
)
if (VIEWER_ENABLE_GLTF)
# To enforce WEBP and DRACO support (CI does not have these dependecies)
# set(USE_WEBP ON)
# set(USE_DRACO ON)
endif()
cmake_dependent_option(VIEWER_ENABLE_KTX
"Enable KTX support in viewer"
OFF
"BUILD_VIEWER"
OFF
)
if (VIEWER_ENABLE_KTX)
set(USE_KTX ON)
endif()

## The generate_all targets collects all offline code generation targets

Expand Down
56 changes: 50 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ ANARI-SDK

This repository contains the source for the ANARI API SDK. This includes:

- [Front-end library + implementation guide](libs/anari)
- [Device implementation utilties for implementations](libs/helium)
- [Example device implementation](libs/helide) (not intended for production use)
- [Front-end library + implementation guide](src/anari)
- [Device implementation utilties for implementations](src/helium)
- [Example device implementation](src/helide) (not intended for production use)
- [Example applications](examples/)
- [Interactive sample viewer](examples/viewer)
- [Render tests](tests/render)
- [(experimental) OpenUSD Hydra render delegate plugin](src/hdanari)

The 1.0 ANARI specification can be found on the Khronos website
[here](https://www.khronos.org/registry/ANARI/).
Expand Down Expand Up @@ -56,6 +57,7 @@ available to enable. The following CMake options are offered:
- `BUILD_REMOTE_DEVICE` : build the provided experimental `remote` device implementation
- `BUILD_EXAMPLES` : build example applications
- `BUILD_VIEWER` : build viewer too (needs glfw3) if building examples
- `BUILD_HDANARI` : build (experimental) OpenUSD Hydra delegate plugin

Once built, the library can be installed via the `install` target created by
CMake. This can be invoked from your build directory with (on any platform):
Expand Down Expand Up @@ -120,16 +122,58 @@ the viewer to select/override which library is loaded at runtime.

## Available Implementations

### SDK provided ExampleDevice implementation
### SDK provided example implementation

An example device implementation [helide](libs/helide) is provided as a
An example device implementation [helide](src/helide) is provided as a
starting point for users exploring the SDK and for implementors to see how the
API might be implemented. It implements a very simple, geometry-only ray tracing
implementation using Embree for intersection. Users should look to use vendor
provided, hardware-optimized ANARI implementations which are shipped
independently from the SDK. (see below)

### List of publically available implementaions
### Using the debug device layer

The ANARI-SDK ships with a [debug layer](src/debug_device) implemented as an ordinary
`ANARIDevice` which wraps a device (set as the `wrappedDevice` parameter on the
debug device). This device uses the object queries reported by the wrapped
device to validate correct usage of object subtypes, parameters, and properties,
as well as validate correct object lifetimes. The wrapped device is then used
to actually implement the ANARI API to allow applications to still function
normally.

The device can be created by using the normal library loading mechanics using
`anariLoadLibrary("debug", ...)`, creating a the debug device instances with,
`anariNewDevice(debugLibrary, "default")`, and then creating a device to use
and set it on the device with
`anariSetParameter(debugDevice, "wrappedDevice", ANARI_DEVICE, &wrappedHandle)`.

As a convenience, users can use the `ANARI_DEBUG_WRAPPED_LIBRARY` environment
variable to have the debug device do the mechanics of loading and creating the
underlying wrapped library. For example, you can do the following to run the
viewer with the debug device wrapping `helide`:

```
% ANARI_LIBRARY=debug ANARI_DEBUG_WRAPPED_LIBRARY=helide ./anariViewer
```

Or using the `-l` syntax for specifying the library:

```
% ANARI_DEBUG_WRAPPED_LIBRARY=helide ./anariViewer -l debug
```

See the [simple debug device turorial](examples/simple/anariTutorialDebug.c) for
how to setup the debug device without using environment variables.

Note that if `ANARI_DEBUG_WRAPPED_LIBRARY` is set, it will take priority over
programatically set wrapped devices.

Tracing features of the debug device can be set using the following environment
variables:
- `ANARI_DEBUG_TRACE_MODE` sets the tracing mode, only `code` is supported for now.
- `ANARI_DEBUG_TRACE_DIR` set the folder where the trace will be dumped.

### Unofficial list of publically available implementaions

Below is a list of available ANARI implemenations compatible with this SDK:

Expand Down
6 changes: 6 additions & 0 deletions cmake/Findanari.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ set_target_properties(anari::anari PROPERTIES
"anari"
)

add_library(anari::anari_static INTERFACE IMPORTED)
set_target_properties(anari::anari_static PROPERTIES
INTERFACE_LINK_LIBRARIES
"anari_static"
)

add_library(anari::anari_test_scenes INTERFACE IMPORTED)
set_target_properties(anari::anari_test_scenes PROPERTIES
INTERFACE_LINK_LIBRARIES
Expand Down
72 changes: 56 additions & 16 deletions code_gen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ if(CMAKE_VERSION VERSION_LESS "3.12")
return()
endif()

find_package(Python3 OPTIONAL_COMPONENTS Interpreter)
find_package(Python3 OPTIONAL_COMPONENTS Interpreter Development.Module)

if (NOT TARGET Python3::Interpreter)
message(WARNING "Unable to find python interpreter, skipping code-gen + API bindings")
return()
endif()

option(INSTALL_PYTHON_BINDINGS "Install python bindings" OFF) # If turned on, draws in all the custom targets below (generate_all)
cmake_dependent_option(LINK_BINDINGS_TO_RELEASE_PYTHON "Force the python bindings to implicitly link to a release python library on Windows, overriding possible debug python linking" OFF INSTALL_PYTHON_BINDINGS OFF)

set(API_JSON api/anari_core_1_0.json api/khr_frame_completion_callback.json)

Expand Down Expand Up @@ -74,25 +75,64 @@ if (INSTALL_PYTHON_BINDINGS)
set(BUILD_PYTHON_BINDINGS_BY_DEFAULT ALL)
endif()

if (LINK_BINDINGS_TO_RELEASE_PYTHON)
set(LINK_BINDINGS_TO_RELEASE_PYTHON_FLAG "-R")
endif()

# Generate the C file using the Python script
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pyanari_bindings.c
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/pyanari_build.py
-d ${CMAKE_CURRENT_SOURCE_DIR}/devices/generic_device.json
-j ${CMAKE_CURRENT_SOURCE_DIR}/api/
${LINK_BINDINGS_TO_RELEASE_PYTHON_FLAG}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS pyanari_build.py ${API_JSON} devices/generic_device.json
COMMENT "Generating Python bindings C file"
)

# Create the Python extension module
add_library(pyanari MODULE EXCLUDE_FROM_ALL
${CMAKE_CURRENT_BINARY_DIR}/pyanari_bindings.c
)

# Set the output name to match Python's expectations
if (WIN32)
set(PYTHON_OBJ_EXT .pyd)
else()
set(PYTHON_OBJ_EXT .so)
endif()
set_target_properties(pyanari
PROPERTIES
PREFIX ""
SUFFIX ${PYTHON_OBJ_EXT}
)

# Force cffi to keep the python api as usual
target_compile_definitions(pyanari PRIVATE
_CFFI_NO_LIMITED_API
)

# Link against Python libraries and anari
target_link_libraries(pyanari PRIVATE Python3::Module anari)

# Include directories for Python and anari headers
target_include_directories(pyanari PRIVATE
${Python3_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/src/anari/include/
${CMAKE_BINARY_DIR}/src/anari/include/anari/
)

# Add the custom target for Python bindings
add_custom_target(python_bindings ${BUILD_PYTHON_BINDINGS_BY_DEFAULT}
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/pyanari_build.py
-d ${CMAKE_CURRENT_SOURCE_DIR}/devices/generic_device.json
-j ${CMAKE_CURRENT_SOURCE_DIR}/api/
-I ${CMAKE_SOURCE_DIR}/src/anari/include/
-I ${CMAKE_BINARY_DIR}/src/anari/include/anari/
-L ${CMAKE_BINARY_DIR}
-L ${CMAKE_BINARY_DIR}/$<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS pyanari_build.py anari ${API_JSON} devices/generic_device.json
DEPENDS pyanari
)

if (INSTALL_PYTHON_BINDINGS)
if (WIN32)
set(PYANARI_LIB_FILE pyanari.pyd)
else()
set(PYANARI_LIB_FILE pyanari.so)
endif()
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/anari.py ${CMAKE_CURRENT_BINARY_DIR}/${PYANARI_LIB_FILE}
FILES ${CMAKE_CURRENT_BINARY_DIR}/anari.py
DESTINATION ${CMAKE_INSTALL_LIBDIR}/python_bindings)
install(TARGETS pyanari
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/python_bindings
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/python_bindings)
endif()
Loading

0 comments on commit 0c7036a

Please sign in to comment.