Skip to content

Commit e5ea7fb

Browse files
committed
Merge remote-tracking branch 'upstream/master' into improve_vdb_tool_2
2 parents f9a3b04 + 90c02c3 commit e5ea7fb

25 files changed

Lines changed: 782 additions & 1219 deletions

cmake/FindBlosc.cmake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,11 @@ if(NOT TARGET Blosc::blosc)
419419
set(${BLOSC_EXTERNAL_LIB}_LIBRARIES ${${BLOSC_EXTERNAL_LIB}_LIBRARY_DEBUG})
420420
endif()
421421

422-
target_link_libraries(Blosc::blosc INTERFACE
423-
$<$<CONFIG:Release>:${${BLOSC_EXTERNAL_LIB}_LIBRARY_RELEASE}>
424-
$<$<CONFIG:Debug>:${${BLOSC_EXTERNAL_LIB}_LIBRARY_DEBUG}>)
422+
if(${BLOSC_EXTERNAL_LIB}_LIBRARY_RELEASE OR ${BLOSC_EXTERNAL_LIB}_LIBRARY_DEBUG)
423+
target_link_libraries(Blosc::blosc INTERFACE
424+
$<$<CONFIG:Release>:${${BLOSC_EXTERNAL_LIB}_LIBRARY_RELEASE}>
425+
$<$<CONFIG:Debug>:${${BLOSC_EXTERNAL_LIB}_LIBRARY_DEBUG}>)
426+
endif()
425427

426428
endforeach()
427429
endif()

nanovdb/nanovdb/GridHandle.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ GridHandle<BufferT>::deviceGrid(uint32_t n) const
400400
template<typename BufferT>
401401
void GridHandle<BufferT>::read(std::istream& is, const BufferT& pool)
402402
{
403+
const std::streampos start = is.tellg();// remember where the raw buffer begins
403404
GridData data;
404405
is.read((char*)&data, sizeof(GridData));
405406
if (data.isValid()) {
@@ -410,7 +411,7 @@ void GridHandle<BufferT>::read(std::istream& is, const BufferT& pool)
410411
sum += data.mGridSize;
411412
}
412413
auto buffer = BufferT::create(size + sum, &pool);
413-
is.seekg(-int64_t(sum + sizeof(GridData)), std::ios::cur);// rewind to start
414+
is.seekg(start);// rewind to the start of the raw buffer
414415
is.read((char*)(buffer.data()), buffer.size());
415416
*this = GridHandle(std::move(buffer));
416417
} else {

nanovdb/nanovdb/unittest/TestNanoVDB.cc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8386,6 +8386,38 @@ TEST_F(TestNanoVDB, CustomStreamGridHandleIO)
83868386
}
83878387
}// CustomStreamGridHandleIO
83888388

8389+
// make -j testNanoVDB && ./unittest/testNanoVDB --gtest_filter="*GridHandleReadMultiGridRawBuffer"
8390+
TEST_F(TestNanoVDB, GridHandleReadMultiGridRawBuffer)
8391+
{
8392+
std::vector<nanovdb::GridHandle<>> handles;
8393+
handles.emplace_back(nanovdb::tools::createLevelSetSphere<float>(20.0));
8394+
handles.emplace_back(nanovdb::tools::createLevelSetSphere<float>(40.0));
8395+
ASSERT_EQ(2u, handles.size());
8396+
ASSERT_NE(handles[0].bufferSize(), handles[1].bufferSize());
8397+
8398+
auto mergedHandle = nanovdb::mergeGrids<nanovdb::HostBuffer, std::vector>(handles);
8399+
ASSERT_EQ(2u, mergedHandle.gridCount());
8400+
8401+
std::stringstream stream(std::ios_base::in | std::ios_base::out | std::ios_base::binary);
8402+
mergedHandle.write(stream);
8403+
stream.seekg(0);
8404+
8405+
nanovdb::GridHandle<> handle;
8406+
handle.read(stream);
8407+
8408+
EXPECT_EQ(mergedHandle.bufferSize(), handle.bufferSize());
8409+
EXPECT_EQ(2u, handle.gridCount());
8410+
for (uint32_t i = 0; i < handle.gridCount(); ++i) {
8411+
const auto* grid = handle.grid<float>(i);
8412+
ASSERT_TRUE(grid);
8413+
EXPECT_EQ(i, grid->gridIndex());
8414+
EXPECT_EQ(2u, grid->gridCount());
8415+
EXPECT_EQ(handles[i].bufferSize(), grid->gridSize());
8416+
EXPECT_TRUE(nanovdb::tools::validateChecksum(grid));
8417+
EXPECT_TRUE(nanovdb::tools::validateChecksum(grid, nanovdb::CheckMode::Full));
8418+
}
8419+
}// GridHandleReadMultiGridRawBuffer
8420+
83898421
// make -j testNanoVDB && ./unittest/testNanoVDB --gtest_filter="*strcpy"
83908422
TEST_F(TestNanoVDB, strcpy)
83918423
{

openvdb/openvdb/io/Archive.cc

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -800,9 +800,11 @@ Archive::readGridCompression(std::istream& is)
800800
{
801801
checkFormatVersion(is);
802802

803-
uint32_t c = COMPRESS_NONE;
804-
is.read(reinterpret_cast<char*>(&c), sizeof(uint32_t));
805-
io::setDataCompression(is, c);
803+
if (getFormatVersion(is) >= OPENVDB_FILE_VERSION_NODE_MASK_COMPRESSION) {
804+
uint32_t c = COMPRESS_NONE;
805+
is.read(reinterpret_cast<char*>(&c), sizeof(uint32_t));
806+
io::setDataCompression(is, c);
807+
}
806808
}
807809

808810

@@ -978,6 +980,14 @@ Archive::readHeader(std::istream& is)
978980
// Prior to the introduction of Blosc, ZLIB was the default compression scheme.
979981
mCompression = (COMPRESS_ZIP | COMPRESS_ACTIVE_MASK);
980982
}
983+
if (mFileVersion >= OPENVDB_FILE_VERSION_SELECTIVE_COMPRESSION &&
984+
mFileVersion < OPENVDB_FILE_VERSION_NODE_MASK_COMPRESSION)
985+
{
986+
char isCompressed;
987+
is.read(&isCompressed, sizeof(char));
988+
mCompression = (isCompressed != 0 ? COMPRESS_ZIP : COMPRESS_NONE);
989+
}
990+
981991

982992
// 6) Read the 16-byte (128-bit) uuid.
983993
std::string oldUuid = mUuid;

openvdb_ax/openvdb_ax/ast/AST.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ struct Variable : public Expression
348348
const Expression* basetype() const override { return this; }
349349
//
350350
size_t children() const override { return 0; }
351-
const Node* child(const size_t) const override { return nullptr; }
351+
const Node* child([[maybe_unused]] const size_t index) const override { return nullptr; }
352352
//
353353
inline const std::string& name() const { return mName; }
354354

@@ -366,7 +366,7 @@ struct ValueBase : public Expression
366366
const Expression* basetype() const override { return this; }
367367
//
368368
size_t children() const override { return 0; }
369-
const Node* child(const size_t) const override { return nullptr; }
369+
const Node* child([[maybe_unused]] const size_t index) const override { return nullptr; }
370370
};
371371

372372

@@ -1665,7 +1665,7 @@ struct Keyword : public Statement
16651665
/// @copybrief Node::children()
16661666
size_t children() const override final { return 0; }
16671667
/// @copybrief Node::child()
1668-
const Node* child(const size_t) const override final {
1668+
const Node* child([[maybe_unused]] const size_t index) const override final {
16691669
return nullptr;
16701670
}
16711671
/// @brief Query the keyword held on this node.

openvdb_ax/openvdb_ax/codegen/FunctionTypes.cc

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
#include <llvm/Support/ModRef.h> // MemoryEffects
2121
#endif
2222

23+
#include <limits>
24+
#include <vector>
25+
#include <set>
26+
2327
namespace openvdb {
2428
OPENVDB_USE_VERSION_NAMESPACE
2529
namespace OPENVDB_VERSION_NAME {
@@ -100,7 +104,8 @@ inline ArgInfo llvmTypeToArgInfo(llvm::Type* in)
100104
in = in->getContainedType(0);
101105
++nptrs;
102106
}
103-
return ArgInfo(in, nptrs);
107+
OPENVDB_ASSERT(nptrs < size_t(std::numeric_limits<uint8_t>::max()));
108+
return ArgInfo(in, uint8_t(nptrs));
104109
}
105110

106111
inline ArgInfoVector llvmTypeToArgInfo(const std::vector<llvm::Type*>& in)
@@ -705,6 +710,16 @@ Value IRFunctionBase::call(const Arguments& args,
705710
///////////////////////////////////////////////////////////////////////////
706711
///////////////////////////////////////////////////////////////////////////
707712

713+
bool
714+
FunctionGroup::HasUniqueFunctionSymbols() const
715+
{
716+
std::set<std::string> symset;
717+
for (const auto& function : mFunctionList) {
718+
if (!symset.insert(function->symbol()).second) return false;
719+
}
720+
return true;
721+
}
722+
708723
bool
709724
FunctionGroup::HasUniqueTypeSignatures(llvm::LLVMContext& C) const
710725
{

openvdb_ax/openvdb_ax/codegen/FunctionTypes.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,6 +1293,7 @@ struct OPENVDB_AX_API IRFunctionBase : public Function
12931293
if (result->getType()->isPointerTy())
12941294
{
12951295
#if LLVM_VERSION_MAJOR <= 15
1296+
(void)this;
12961297
return Value(result, result->getType()->getPointerElementType());
12971298
#else
12981299
ArgInfoVector unused;
@@ -1403,10 +1404,16 @@ struct OPENVDB_AX_API FunctionGroup
14031404
const FunctionList& list)
14041405
: mName(name)
14051406
, mDoc(doc)
1406-
, mFunctionList(list) {}
1407+
, mFunctionList(list) {
1408+
// Can't verify signatures yet without an LLVM context, asserted on demand
1409+
OPENVDB_ASSERT(this->HasUniqueFunctionSymbols());
1410+
}
14071411
~FunctionGroup() = default;
14081412

1409-
/// @brief Verify the function signatures in this group.
1413+
/// @brief Verify the function symbol names in this group (must be unique).
1414+
bool HasUniqueFunctionSymbols() const;
1415+
1416+
/// @brief Verify the function signatures in this group (must be unique).
14101417
bool HasUniqueTypeSignatures(llvm::LLVMContext& C) const;
14111418

14121419
/// @brief Given a vector of args, automatically returns the best

openvdb_ax/openvdb_ax/test/backend/TestFunctionGroup.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ axtestmulti(llvm::LLVMContext& C)
9090
}, voidty, "ax.i32x2")),
9191
Function::Ptr(new unittest_util::TestFunction({
9292
ArgInfo(llvm::ArrayType::get(llvm::Type::getInt32Ty(C), 3), 1)
93-
}, voidty, "ax.i32x2")),
93+
}, voidty, "ax.i32x3")),
9494
}));
9595
return group;
9696
}

openvdb_houdini/openvdb_houdini/GeometryUtil.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,17 +198,25 @@ drawFrustum(
198198
#if SYS_VERSION_MAJOR_INT >= 21
199199
openvdb::math::Transform::Ptr
200200
frustumTransformFromCamera(
201-
const OBJ_CameraParms& camparms,
201+
const UT_CameraParms& camparms,
202202
const UT_Matrix4D &cameratosop,
203203
float offset, float nearPlaneDist, float farPlaneDist,
204204
float voxelDepthSize, int voxelCountX)
205205
{
206206
// Eval camera parms
207+
#if SYS_VERSION_MAJOR_INT >= 22
208+
const fpreal camAspect = camparms.pixelaspect;
209+
const fpreal camFocal = camparms.focal;
210+
const fpreal camAperture = camparms.aperture;
211+
const fpreal camXRes = camparms.resx;
212+
const fpreal camYRes = camparms.resy;
213+
#else
207214
const fpreal camAspect = camparms.aspect;
208215
const fpreal camFocal = camparms.focal;
209216
const fpreal camAperture = camparms.aperture;
210217
const fpreal camXRes = camparms.xres;
211218
const fpreal camYRes = camparms.yres;
219+
#endif
212220

213221
nearPlaneDist += offset;
214222
farPlaneDist += offset;

openvdb_houdini/openvdb_houdini/GeometryUtil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ drawFrustum(GU_Detail&, const openvdb::math::Transform&,
5353
#if SYS_VERSION_MAJOR_INT >= 21
5454
openvdb::math::Transform::Ptr
5555
frustumTransformFromCamera(
56-
const OBJ_CameraParms&, const UT_Matrix4D&,
56+
const UT_CameraParms&, const UT_Matrix4D&,
5757
float offset, float nearPlaneDist, float farPlaneDist,
5858
float voxelDepthSize = 1.0, int voxelCountX = 100);
5959
#else

0 commit comments

Comments
 (0)