Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tsd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ option(TSD_USE_MPI "Enable MPI support" OFF)
option(TSD_USE_NETWORKING "Enable networking support via boost.asio" OFF)
option(TSD_NANOVDB_SKIP_INVALID_VOLUMES
"Skip NanoVDB volumes with zero active voxels" OFF)
option(TSD_NANOVDB_USE_ZIP
"Enable zlib so NanoVDB importer can read ZIP-compressed .nvdb files" ON)
option(TSD_USE_LUA "Enable Lua scripting support" ON)

if (APPLE)
Expand Down
1 change: 1 addition & 0 deletions tsd/external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ add_subdirectory(tsd_tinyexr)
add_subdirectory(tsd_tinygltf)
add_subdirectory(tsd_tinyobjloader)
add_subdirectory(tsd_tinyply)
add_subdirectory(tsd_zlib EXCLUDE_FROM_ALL)

add_subdirectory(
${CMAKE_CURRENT_LIST_DIR}/../../devices/rtx/external
Expand Down
9 changes: 9 additions & 0 deletions tsd/external/tsd_nanovdb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,12 @@ if (TSD_USE_TBB)
project_link_libraries(INTERFACE TBB::tbb)
project_compile_definitions(INTERFACE NANOVDB_USE_TBB)
endif()

if (TSD_NANOVDB_USE_ZIP)
# zlib decompresses ZIP-encoded .nvdb files at read time. ANARI always
# receives the decompressed in-memory grid buffer — the codec only
# affects on-disk storage. The tsd FindZLIB.cmake module supplies a
# fetched static fallback when no system zlib is available.
project_link_libraries(INTERFACE tsd_ext_zlib)
project_compile_definitions(INTERFACE NANOVDB_USE_ZIP)
endif()
58 changes: 58 additions & 0 deletions tsd/external/tsd_zlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
## Copyright 2026 NVIDIA Corporation
## SPDX-License-Identifier: Apache-2.0

# zlib - compression/decompression library
# Static fallback build when no system zlib is available.

project(tsd_ext_zlib LANGUAGES C)

find_package(ZLIB QUIET)
if(ZLIB_FOUND)
project_add_library(INTERFACE)
project_link_libraries(INTERFACE ZLIB::ZLIB)
return()
endif()

message(STATUS
"ZLIB not found via find_package — fetching upstream zlib 1.3.1.")
anari_sdk_fetch_project(
NAME ${PROJECT_NAME}
URL https://github.com/madler/zlib/releases/download/v1.3.1/zlib-1.3.1.tar.gz
MD5 9855b6d802d7fe5b7bd5b196a2271655
)

# Minimal static build — only the bits the compress/uncompress path needs.
# gzip stream I/O (gz*.c) is intentionally excluded.
project_add_library(STATIC
${tsd_ext_zlib_LOCATION}/adler32.c
${tsd_ext_zlib_LOCATION}/crc32.c
${tsd_ext_zlib_LOCATION}/deflate.c
${tsd_ext_zlib_LOCATION}/infback.c
${tsd_ext_zlib_LOCATION}/inffast.c
${tsd_ext_zlib_LOCATION}/inflate.c
${tsd_ext_zlib_LOCATION}/inftrees.c
${tsd_ext_zlib_LOCATION}/trees.c
${tsd_ext_zlib_LOCATION}/zutil.c
${tsd_ext_zlib_LOCATION}/compress.c
${tsd_ext_zlib_LOCATION}/uncompr.c
)

project_include_directories(
PUBLIC
$<BUILD_INTERFACE:${tsd_ext_zlib_LOCATION}>
)

set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)

# Suppress warnings from zlib code
if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
project_compile_options(PRIVATE -w)
elseif(MSVC)
# zlib uses a handful of CRT functions MSVC flags as "unsafe".
project_compile_options(PRIVATE /W0)
project_compile_definitions(PRIVATE
_CRT_SECURE_NO_DEPRECATE
_CRT_NONSTDC_NO_DEPRECATE
)
endif()

11 changes: 11 additions & 0 deletions tsd/src/tsd/io/importers/import_NVDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include <filesystem>
#include <limits>
#include <string_view>

namespace tsd::io {

Expand Down Expand Up @@ -186,7 +187,17 @@ SpatialFieldRef import_NVDB(Scene &scene, const char *filepath)

logStatus("[import_NVDB] ...done!");
} catch (const std::exception &e) {
using namespace std::string_view_literals;
const std::string_view msg(e.what());
logStatus("[import_NVDB] failed: %s", e.what());
if (msg.find("compression codec was disabled"sv) != std::string_view::npos) {
logStatus(
"[import_NVDB] '%s' is stored with a compressed codec but TSD was "
"built without it. Reconfigure with -DTSD_NANOVDB_USE_ZIP=ON (and "
"ensure zlib is available) to decompress at read time. ANARI is "
"always handed the uncompressed in-memory grid buffer.",
filepath);
}
scene.removeObject(field.data());
return {};
}
Expand Down
Loading