Skip to content

Commit

Permalink
Merge braupdatench 'master' of https://github.com/NVlabs/instant-ngp
Browse files Browse the repository at this point in the history
  • Loading branch information
jc211 committed Feb 15, 2023
2 parents e8ec69a + b1124c6 commit 8914ed3
Show file tree
Hide file tree
Showing 15 changed files with 810 additions and 127 deletions.
63 changes: 28 additions & 35 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ if (NOT NGP_DEPLOY)
set(NGP_VERSION "${NGP_VERSION}dev")
endif()

option(NGP_BUILD_EXECUTABLE "Build instant-ngp.exe?" ON)
option(NGP_BUILD_WITH_GUI "Build with GUI support (requires GLFW and GLEW)?" ON)
option(NGP_BUILD_WITH_VULKAN "Build with Vulkan to enable DLSS support?" ON)
option(NGP_BUILD_WITH_OPTIX "Build with OptiX to enable hardware ray tracing?" ON)
option(NGP_BUILD_WITH_PYTHON_BINDINGS "Build bindings that allow instrumenting instant-ngp with Python?" ON)
option(NGP_BUILD_WITH_VULKAN "Build with Vulkan to enable DLSS support?" ON)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

Expand Down Expand Up @@ -200,6 +202,7 @@ list(APPEND NGP_INCLUDE_DIRECTORIES
"dependencies/eigen"
"dependencies/filesystem"
"dependencies/nanovdb"
"dependencies/NaturalSort"
"dependencies/tinylogger"
)

Expand All @@ -215,9 +218,11 @@ if (NGP_BUILD_WITH_OPTIX)
list(APPEND NGP_DEFINITIONS -DNGP_OPTIX)
endif()

find_package(Python 3.7 COMPONENTS Interpreter Development)
if (Python_FOUND)
add_subdirectory("dependencies/pybind11")
if (NGP_BUILD_WITH_PYTHON_BINDINGS)
find_package(Python 3.7 COMPONENTS Interpreter Development)
if (Python_FOUND)
add_subdirectory("dependencies/pybind11")
endif()
endif()

# Compile zlib (only on Windows)
Expand Down Expand Up @@ -328,10 +333,7 @@ target_include_directories(ngp PUBLIC ${NGP_INCLUDE_DIRECTORIES})
target_link_directories(ngp PUBLIC ${NGP_LINK_DIRECTORIES})
target_link_libraries(ngp PUBLIC ${NGP_LIBRARIES} tiny-cuda-nn)

add_executable(instant-ngp src/main.cu)
target_link_libraries(instant-ngp PRIVATE ngp)

# Copy DLSS shared libraries
# Copy shared libraries to the binary directory as needed
if (NGP_VULKAN)
set(NGX_BUILD_DIR "$<IF:$<CONFIG:Debug>,dev,rel>")
if (MSVC)
Expand All @@ -340,23 +342,32 @@ if (NGP_VULKAN)
set(NGX_SHARED_LIB "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/dlss/lib/Linux_x86_64/${NGX_BUILD_DIR}/libnvidia-ngx-dlss.so.*")
endif()

add_custom_command(TARGET instant-ngp POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${NGX_SHARED_LIB}" $<TARGET_FILE_DIR:instant-ngp>
COMMAND_EXPAND_LISTS
)
add_custom_command(TARGET ngp POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "${NGX_SHARED_LIB}" "${CMAKE_CURRENT_BINARY_DIR}" COMMAND_EXPAND_LISTS)
endif()

if (MSVC)
# Copy CUDA runtime DLLs to the build directory so that Python can find them.
file(GLOB CUDA_DLLS "${CUDA_COMPILER_BIN}/cudart64*.dll")
if (CUDA_DLLS)
add_custom_command(TARGET instant-ngp POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CUDA_DLLS} $<TARGET_FILE_DIR:instant-ngp>
COMMAND_EXPAND_LISTS
)
add_custom_command(TARGET ngp POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CUDA_DLLS} "${CMAKE_CURRENT_BINARY_DIR}" COMMAND_EXPAND_LISTS)
endif()
endif()

if (NGP_BUILD_EXECUTABLE)
add_executable(instant-ngp src/main.cu)
target_link_libraries(instant-ngp PRIVATE ngp)

# Link the executable to the project directory and copy over DLLs such that instant-ngp can be invoked without going into the build folder.
set(NGP_BINARY_FILE "\"${CMAKE_CURRENT_SOURCE_DIR}/$<TARGET_FILE_NAME:instant-ngp>\"")
if (MSVC)
add_custom_command(TARGET instant-ngp POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:instant-ngp> ${CMAKE_CURRENT_SOURCE_DIR})
file(GLOB NGP_REQUIRED_DLLS "${CMAKE_CURRENT_BINARY_DIR}/*.dll")
if (NGP_REQUIRED_DLLS)
add_custom_command(TARGET instant-ngp POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${NGP_REQUIRED_DLLS} ${CMAKE_CURRENT_SOURCE_DIR} COMMAND_EXPAND_LISTS)
endif()
else()
add_custom_command(TARGET instant-ngp POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink $<TARGET_FILE:instant-ngp> "${NGP_BINARY_FILE}")
endif()
endif(NGP_BUILD_EXECUTABLE)

if (Python_FOUND)
add_library(pyngp SHARED src/python_api.cu)
Expand All @@ -365,21 +376,3 @@ if (Python_FOUND)
target_compile_definitions(pyngp PUBLIC -DNGP_PYTHON)
pybind11_extension(pyngp)
endif()

# Link the executable to the project directory and copy over DLLs such that instant-ngp can be invoked without going into the build folder.
set(NGP_BINARY_FILE "\"${CMAKE_CURRENT_SOURCE_DIR}/$<TARGET_FILE_NAME:instant-ngp>\"")
if (MSVC)
add_custom_command(TARGET instant-ngp POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:instant-ngp> ${CMAKE_CURRENT_SOURCE_DIR})
file(GLOB NGP_REQUIRED_DLLS "${CUDA_COMPILER_BIN}/cudart64*.dll")
if (NGP_VULKAN)
list(APPEND NGP_REQUIRED_DLLS "${NGX_SHARED_LIB}")
endif()
if (NGP_REQUIRED_DLLS)
add_custom_command(TARGET instant-ngp POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${NGP_REQUIRED_DLLS} ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND_EXPAND_LISTS
)
endif()
else()
add_custom_command(TARGET instant-ngp POST_BUILD COMMAND ${CMAKE_COMMAND} -E create_symlink $<TARGET_FILE:instant-ngp> "${NGP_BINARY_FILE}")
endif()
21 changes: 21 additions & 0 deletions dependencies/NaturalSort/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Gagan Kumar

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
9 changes: 9 additions & 0 deletions dependencies/NaturalSort/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CC = g++
CFLAGS = -Wall

test: natural_sort_test.cpp natural_sort.hpp
$(CC) $(CFLAGS) -o $@ $<
./$@

clean:
rm -f test
61 changes: 61 additions & 0 deletions dependencies/NaturalSort/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# NaturalSort ![CI](https://github.com/scopeInfinity/NaturalSort/workflows/CI/badge.svg)
C++ Header File for Natural Comparison and Natural Sort


##### Calling Methods

* __For Natural Sorting__

void SI::natural::sort(Container<String>);
void SI::natural::sort(IteratorBegin<String>,IteratorEnd<String>);
void SI::natural::sort<String,CArraySize>(CArray<String>);

* __For Natural Comparision__

bool SI::natural::compare<String>(String lhs,String rhs);
bool SI::natural::compare<String>(char *const lhs,char *const rhs);

Here we can have
std::vector<std::string> as Container<String>
String as std::string
CArray<String> as std::string[CArraySize]



##### Example

* __Inputs__

Hello 100
Hello 34
Hello 9
Hello 25
Hello 10
Hello 8

* __Normal Sort Output__

Hello 10
Hello 100
Hello 25
Hello 34
Hello 8
Hello 9

* __Natural Sort Output__

Hello 8
Hello 9
Hello 10
Hello 25
Hello 34
Hello 100



Loading

0 comments on commit 8914ed3

Please sign in to comment.