feat(physics): wire physx sdk into build

This commit is contained in:
2026-04-15 12:22:15 +08:00
parent 5bf258df6d
commit 31f40e2cbb
2044 changed files with 752623 additions and 1 deletions

View File

@@ -0,0 +1,40 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef OMNI_PVD_DEFINES_INTERNAL_H
#define OMNI_PVD_DEFINES_INTERNAL_H
#include <stdint.h>
// types used to store certain properties in the PVD data stream
typedef uint8_t OmniPvdCommandStorageType;
typedef uint16_t OmniPvdDataTypeStorageType;
#endif

View File

@@ -0,0 +1,144 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "OmniPvdFileReadStreamImpl.h"
OmniPvdFileReadStreamImpl::OmniPvdFileReadStreamImpl()
{
mFileName = 0;
resetFileParams();
}
OmniPvdFileReadStreamImpl::~OmniPvdFileReadStreamImpl()
{
closeFile();
delete[] mFileName;
mFileName = 0;
}
void OmniPvdFileReadStreamImpl::resetFileParams()
{
mFileOpenAttempted = false;
mPFile = 0;
}
void OMNI_PVD_CALL OmniPvdFileReadStreamImpl::setFileName(const char* fileName)
{
if (!fileName) return;
int n = (int)strlen(fileName) + 1;
if (n < 2) return;
delete[] mFileName;
mFileName = new char[n];
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
strcpy_s(mFileName, n, fileName);
#else
strcpy(mFileName, fileName);
#endif
mFileName[n - 1] = 0;
}
bool OMNI_PVD_CALL OmniPvdFileReadStreamImpl::openFile()
{
if (mFileOpenAttempted)
{
return (mPFile!=0);
}
if (!mFileName)
{
return false;
}
mPFile = 0;
mFileOpenAttempted = true;
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
errno_t err = fopen_s(&mPFile, mFileName, "rb");
if (err != 0)
{
mPFile = 0;
}
else
{
fseek(mPFile, 0, SEEK_SET);
}
#else
mPFile = fopen(mFileName, "rb");
if (mPFile)
{
fseek(mPFile, 0, SEEK_SET);
}
#endif
return (mPFile!=0);
}
bool OMNI_PVD_CALL OmniPvdFileReadStreamImpl::closeFile()
{
bool returnOK = true;
if (mFileOpenAttempted && (mPFile!=0))
{
fclose(mPFile);
mPFile = 0;
}
else
{
returnOK = false;
}
resetFileParams();
return returnOK;
}
uint64_t OMNI_PVD_CALL OmniPvdFileReadStreamImpl::readBytes(uint8_t* bytes, uint64_t nbrBytes)
{
size_t result = 0;
if (mPFile!=0)
{
result = fread(bytes, 1, nbrBytes, mPFile);
}
return result;
}
uint64_t OMNI_PVD_CALL OmniPvdFileReadStreamImpl::skipBytes(uint64_t nbrBytes)
{
if (mPFile==0)
{
return 0;
}
if (fseek(mPFile, (long)nbrBytes, SEEK_CUR)==0)
{
return nbrBytes;
}
return 0;
}
bool OMNI_PVD_CALL OmniPvdFileReadStreamImpl::openStream()
{
return openFile();
}
bool OMNI_PVD_CALL OmniPvdFileReadStreamImpl::closeStream()
{
return closeFile();
}

View File

@@ -0,0 +1,56 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef OMNI_PVD_FILE_READ_STREAM_IMPL_H
#define OMNI_PVD_FILE_READ_STREAM_IMPL_H
#include "OmniPvdFileReadStream.h"
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
class OmniPvdFileReadStreamImpl : public OmniPvdFileReadStream
{
public:
OmniPvdFileReadStreamImpl();
~OmniPvdFileReadStreamImpl();
void resetFileParams();
void OMNI_PVD_CALL setFileName(const char *fileName);
bool OMNI_PVD_CALL openFile();
bool OMNI_PVD_CALL closeFile();
uint64_t OMNI_PVD_CALL readBytes(uint8_t* bytes, uint64_t nbrBytes);
uint64_t OMNI_PVD_CALL skipBytes(uint64_t nbrBytes);
bool OMNI_PVD_CALL openStream();
bool OMNI_PVD_CALL closeStream();
char* mFileName;
bool mFileOpenAttempted;
FILE* mPFile;
};
#endif

View File

@@ -0,0 +1,132 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "OmniPvdFileWriteStreamImpl.h"
OmniPvdFileWriteStreamImpl::OmniPvdFileWriteStreamImpl()
{
mFileName = 0;
resetFileParams();
}
void OmniPvdFileWriteStreamImpl::resetFileParams()
{
mFileOpenAttempted = false;
mPFile = 0;
}
OmniPvdFileWriteStreamImpl::~OmniPvdFileWriteStreamImpl()
{
closeFile();
delete[] mFileName;
mFileName = 0;
}
void OMNI_PVD_CALL OmniPvdFileWriteStreamImpl::setFileName(const char* fileName)
{
if (!fileName) return;
int n = (int)strlen(fileName) + 1;
if (n < 2) return;
delete[] mFileName;
mFileName = new char[n];
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
strcpy_s(mFileName, n, fileName);
#else
strcpy(mFileName, fileName);
#endif
mFileName[n - 1] = 0;
}
bool OMNI_PVD_CALL OmniPvdFileWriteStreamImpl::openFile()
{
if (mFileOpenAttempted)
{
return (mPFile!=0);
}
if (!mFileName)
{
return false;
}
mPFile = 0;
mFileOpenAttempted = true;
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
errno_t err = fopen_s(&mPFile, mFileName, "wb");
if (err != 0)
{
mPFile = 0;
}
#else
mPFile = fopen(mFileName, "wb");
#endif
return (mPFile!=0);
}
bool OMNI_PVD_CALL OmniPvdFileWriteStreamImpl::closeFile()
{
bool returnOK = true;
if (mFileOpenAttempted && (mPFile!=0))
{
fclose(mPFile);
}
else
{
returnOK = false;
}
resetFileParams();
return returnOK;
}
uint64_t OMNI_PVD_CALL OmniPvdFileWriteStreamImpl::writeBytes(const uint8_t *bytes, uint64_t nbrBytes)
{
size_t result = 0;
if (mPFile!=0)
{
result = fwrite(bytes, 1, nbrBytes, mPFile);
}
return result;
}
bool OMNI_PVD_CALL OmniPvdFileWriteStreamImpl::flush()
{
if (mPFile==0)
{
return false;
}
return fflush(mPFile) != 0;
}
bool OMNI_PVD_CALL OmniPvdFileWriteStreamImpl::openStream()
{
return openFile();
}
bool OMNI_PVD_CALL OmniPvdFileWriteStreamImpl::closeStream()
{
return closeFile();
}

View File

@@ -0,0 +1,55 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef OMNI_PVD_FILE_WRITE_STREAM_IMPL_H
#define OMNI_PVD_FILE_WRITE_STREAM_IMPL_H
#include "OmniPvdFileWriteStream.h"
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
class OmniPvdFileWriteStreamImpl : public OmniPvdFileWriteStream {
public:
OmniPvdFileWriteStreamImpl();
~OmniPvdFileWriteStreamImpl();
void resetFileParams();
void OMNI_PVD_CALL setFileName(const char *fileName);
bool OMNI_PVD_CALL openFile();
bool OMNI_PVD_CALL closeFile();
uint64_t OMNI_PVD_CALL writeBytes(const uint8_t* bytes, uint64_t nbrBytes);
bool OMNI_PVD_CALL flush();
bool OMNI_PVD_CALL openStream();
bool OMNI_PVD_CALL closeStream();
char *mFileName;
FILE *mPFile;
bool mFileOpenAttempted;
};
#endif

View File

@@ -0,0 +1,72 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "OmniPvdHelpers.h"
uint8_t OmniPvdCompressInt(uint64_t handle, uint8_t *bytes) {
uint8_t lastBitGroupIndex = 0;
uint8_t shiftBits = 0;
for (int i = 0; i < 8; i++) {
if ((handle >> shiftBits) & 0x7f) {
lastBitGroupIndex = static_cast<uint8_t>(i);
}
shiftBits += 7;
}
shiftBits = 0;
for (int i = 0; i <= lastBitGroupIndex; i++) {
uint8_t currentBitGroup = (handle >> shiftBits) & 0x7f;
if (i < lastBitGroupIndex) {
currentBitGroup |= 0x80; // Set the continuation flag bit to true
}
bytes[i] = currentBitGroup;
shiftBits += 7;
}
return lastBitGroupIndex;
}
uint64_t OmniPvdDeCompressInt(uint8_t *bytes, uint8_t maxBytes) {
if (maxBytes > 8) {
maxBytes = 8;
}
uint64_t decompressedInt = 0;
uint8_t continueFlag = 1;
uint8_t readBytes = 0;
uint8_t shiftBits = 0;
while (continueFlag && (readBytes < maxBytes)) {
const uint8_t currentByte = *bytes;
uint64_t decompressedBits = currentByte & 0x7f;
continueFlag = currentByte & 0x80;
decompressedInt |= (decompressedBits << shiftBits);
shiftBits += 7;
if (continueFlag) {
bytes++;
}
}
return decompressedInt;
}

View File

@@ -0,0 +1,37 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef OMNI_PVD_HELPERS_H
#define OMNI_PVD_HELPERS_H
#include <stdint.h>
extern uint8_t OmniPvdCompressInt(uint64_t handle, uint8_t *bytes);
extern uint64_t OmniPvdDeCompressInt(uint8_t *bytes, uint8_t maxBytes);
#endif

View File

@@ -0,0 +1,89 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "OmniPvdLibraryFunctions.h"
#include "OmniPvdReaderImpl.h"
#include "OmniPvdWriterImpl.h"
#include "OmniPvdFileReadStreamImpl.h"
#include "OmniPvdFileWriteStreamImpl.h"
#include "OmniPvdMemoryStreamImpl.h"
OMNI_PVD_EXPORT OmniPvdReader* OMNI_PVD_CALL createOmniPvdReader()
{
return new OmniPvdReaderImpl();
}
OMNI_PVD_EXPORT void OMNI_PVD_CALL destroyOmniPvdReader(OmniPvdReader& reader)
{
OmniPvdReaderImpl* impl = (OmniPvdReaderImpl*)(&reader);
delete impl;
}
OMNI_PVD_EXPORT OmniPvdWriter* OMNI_PVD_CALL createOmniPvdWriter()
{
return new OmniPvdWriterImpl();
}
OMNI_PVD_EXPORT void OMNI_PVD_CALL destroyOmniPvdWriter(OmniPvdWriter& writer)
{
OmniPvdWriterImpl* impl = (OmniPvdWriterImpl*)(&writer);
delete impl;
}
OMNI_PVD_EXPORT OmniPvdFileReadStream* OMNI_PVD_CALL createOmniPvdFileReadStream()
{
return new OmniPvdFileReadStreamImpl();
}
OMNI_PVD_EXPORT void OMNI_PVD_CALL destroyOmniPvdFileReadStream(OmniPvdFileReadStream& readStream)
{
OmniPvdFileReadStreamImpl* impl = (OmniPvdFileReadStreamImpl*)(&readStream);
delete impl;
}
OMNI_PVD_EXPORT OmniPvdFileWriteStream* OMNI_PVD_CALL createOmniPvdFileWriteStream()
{
return new OmniPvdFileWriteStreamImpl();
}
OMNI_PVD_EXPORT void OMNI_PVD_CALL destroyOmniPvdFileWriteStream(OmniPvdFileWriteStream& writeStream)
{
OmniPvdFileWriteStreamImpl* impl = (OmniPvdFileWriteStreamImpl*)(&writeStream);
delete impl;
}
OMNI_PVD_EXPORT OmniPvdMemoryStream* OMNI_PVD_CALL createOmniPvdMemoryStream()
{
return new OmniPvdMemoryStreamImpl();
}
OMNI_PVD_EXPORT void OMNI_PVD_CALL destroyOmniPvdMemoryStream(OmniPvdMemoryStream& memoryStream)
{
OmniPvdMemoryStreamImpl* impl = (OmniPvdMemoryStreamImpl*)(&memoryStream);
delete impl;
}

View File

@@ -0,0 +1,57 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "OmniPvdLog.h"
#include <stdarg.h>
#include <stdio.h>
OmniPvdLog::OmniPvdLog()
{
mLogFunction = 0;
}
OmniPvdLog::~OmniPvdLog()
{
}
void OmniPvdLog::setLogFunction(OmniPvdLogFunction logFunction)
{
mLogFunction = logFunction;
}
void OmniPvdLog::outputLine(const char* fmt, ...)
{
if (!mLogFunction) return;
char logLineBuff[2048];
va_list args;
va_start(args, fmt);
vsprintf(logLineBuff, fmt, args);
va_end(args);
mLogFunction(logLineBuff);
}

View File

@@ -0,0 +1,43 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef OMNI_PVD_LOG_H
#define OMNI_PVD_LOG_H
#include "OmniPvdDefines.h"
class OmniPvdLog {
public:
OmniPvdLog();
~OmniPvdLog();
void setLogFunction(OmniPvdLogFunction logFunction);
void outputLine(const char* fmt, ...);
OmniPvdLogFunction mLogFunction;
};
#endif

View File

@@ -0,0 +1,58 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "OmniPvdMemoryStreamImpl.h"
#include "OmniPvdMemoryReadStreamImpl.h"
OmniPvdMemoryReadStreamImpl::OmniPvdMemoryReadStreamImpl()
{
}
OmniPvdMemoryReadStreamImpl::~OmniPvdMemoryReadStreamImpl()
{
}
uint64_t OMNI_PVD_CALL OmniPvdMemoryReadStreamImpl::readBytes(uint8_t* destination, uint64_t nbrBytes)
{
return mMemoryStream->readBytes(destination, nbrBytes);
}
uint64_t OMNI_PVD_CALL OmniPvdMemoryReadStreamImpl::skipBytes(uint64_t nbrBytes)
{
return mMemoryStream->skipBytes(nbrBytes);
}
bool OMNI_PVD_CALL OmniPvdMemoryReadStreamImpl::openStream()
{
return true;
}
bool OMNI_PVD_CALL OmniPvdMemoryReadStreamImpl::closeStream()
{
return true;
}

View File

@@ -0,0 +1,50 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef OMNI_PVD_MEMORY_READ_STREAM_IMPL_H
#define OMNI_PVD_MEMORY_READ_STREAM_IMPL_H
#include "OmniPvdReadStream.h"
class OmniPvdMemoryStreamImpl;
class OmniPvdMemoryReadStreamImpl : public OmniPvdReadStream
{
public:
OmniPvdMemoryReadStreamImpl();
~OmniPvdMemoryReadStreamImpl();
uint64_t OMNI_PVD_CALL readBytes(uint8_t* destination, uint64_t nbrBytes);
uint64_t OMNI_PVD_CALL skipBytes(uint64_t nbrBytes);
bool OMNI_PVD_CALL openStream();
bool OMNI_PVD_CALL closeStream();
OmniPvdMemoryStreamImpl* mMemoryStream;
};
#endif

View File

@@ -0,0 +1,202 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "OmniPvdMemoryStreamImpl.h"
#include "OmniPvdMemoryReadStreamImpl.h"
#include "OmniPvdMemoryWriteStreamImpl.h"
#include <string.h>
OmniPvdMemoryStreamImpl::OmniPvdMemoryStreamImpl()
{
mReadStream = 0;
mWriteStream = 0;
mBuffer = 0;
mBufferLength = 0;
mWrittenBytes = 0;
mWritePosition = 0;
mReadPosition = 0;
mReadStream = new OmniPvdMemoryReadStreamImpl();
mReadStream->mMemoryStream = this;
mWriteStream = new OmniPvdMemoryWriteStreamImpl();
mWriteStream->mMemoryStream = this;
}
OmniPvdMemoryStreamImpl::~OmniPvdMemoryStreamImpl()
{
delete[] mBuffer;
delete mReadStream;
delete mWriteStream;
}
OmniPvdReadStream* OMNI_PVD_CALL OmniPvdMemoryStreamImpl::getReadStream()
{
return mReadStream;
}
OmniPvdWriteStream* OMNI_PVD_CALL OmniPvdMemoryStreamImpl::getWriteStream()
{
return mWriteStream;
}
uint64_t OMNI_PVD_CALL OmniPvdMemoryStreamImpl::setBufferSize(uint64_t bufferLength)
{
if (bufferLength < mBufferLength)
{
return mBufferLength;
}
delete[] mBuffer;
mBuffer = new uint8_t[bufferLength];
mBufferLength = bufferLength;
mWrittenBytes = 0;
mWritePosition = 0;
mReadPosition = 0;
return bufferLength;
}
uint64_t OMNI_PVD_CALL OmniPvdMemoryStreamImpl::readBytes(uint8_t* destination, uint64_t nbrBytes)
{
if (mWrittenBytes < 1) return 0;
////////////////////////////////////////////////////////////////////////////////
// Limit the number of bytes requested to requestedReadBytes
////////////////////////////////////////////////////////////////////////////////
uint64_t requestedReadBytes = nbrBytes;
if (requestedReadBytes > mBufferLength)
{
requestedReadBytes = mBufferLength;
}
if (requestedReadBytes > mWrittenBytes)
{
return 0;
}
////////////////////////////////////////////////////////////////////////////////
// Separate the reading of bytes into two operations:
// tail bytes : bytes from mReadPosition until maximum the end of the buffer
// head bytes : bytes from start of the buffer until maximum the mReadPosition-1
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Tail bytes
////////////////////////////////////////////////////////////////////////////////
uint64_t tailBytes = mBufferLength - mReadPosition;
if (tailBytes > requestedReadBytes)
{
tailBytes = requestedReadBytes;
}
if (destination)
{
memcpy(destination, mBuffer + mReadPosition, tailBytes);
}
////////////////////////////////////////////////////////////////////////////////
// Head bytes
////////////////////////////////////////////////////////////////////////////////
uint64_t headBytes = requestedReadBytes - tailBytes;
if (destination)
{
memcpy(destination + tailBytes, mBuffer, headBytes);
}
////////////////////////////////////////////////////////////////////////////////
// Update the internal parameters : mReadPosition and mWrittenBytes
////////////////////////////////////////////////////////////////////////////////
mReadPosition += requestedReadBytes;
if (mReadPosition >= mBufferLength)
{
mReadPosition -= mBufferLength;
}
mWrittenBytes -= requestedReadBytes;
return requestedReadBytes;
}
uint64_t OmniPvdMemoryStreamImpl::skipBytes(uint64_t nbrBytes)
{
return readBytes(0, nbrBytes);
}
uint64_t OmniPvdMemoryStreamImpl::writeBytes(const uint8_t* source, uint64_t nbrBytes)
{
if (mWrittenBytes >= mBufferLength)
{
return 0;
}
////////////////////////////////////////////////////////////////////////////////
// Limit the number of bytes requested to requestedWriteBytes
////////////////////////////////////////////////////////////////////////////////
uint64_t requestedWriteBytes = nbrBytes;
if (requestedWriteBytes > mBufferLength)
{
requestedWriteBytes = mBufferLength;
}
uint64_t writeBytesLeft = mBufferLength - mWrittenBytes;
if (requestedWriteBytes > writeBytesLeft)
{
return 0;
//requestedWriteBytes = writeBytesLeft;
}
////////////////////////////////////////////////////////////////////////////////
// Tail bytes
////////////////////////////////////////////////////////////////////////////////
uint64_t tailBytes = mBufferLength - mWritePosition;
if (tailBytes > requestedWriteBytes)
{
tailBytes = requestedWriteBytes;
}
if (source)
{
memcpy(mBuffer + mWritePosition, source, tailBytes);
}
////////////////////////////////////////////////////////////////////////////////
// Head bytes
////////////////////////////////////////////////////////////////////////////////
uint64_t headBytes = requestedWriteBytes - tailBytes;
if (source)
{
memcpy(mBuffer, source + tailBytes, headBytes);
}
////////////////////////////////////////////////////////////////////////////////
// Update the internal parameters : mReadPosition and mWrittenBytes
////////////////////////////////////////////////////////////////////////////////
mWritePosition += requestedWriteBytes;
if (mWritePosition >= mBufferLength)
{
mWritePosition -= mBufferLength;
}
mWrittenBytes += requestedWriteBytes;
return requestedWriteBytes;
}
bool OmniPvdMemoryStreamImpl::flush()
{
return true;
}

View File

@@ -0,0 +1,75 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef OMNI_PVD_MEMORY_STREAM_IMPL_H
#define OMNI_PVD_MEMORY_STREAM_IMPL_H
#include "OmniPvdMemoryStream.h"
class OmniPvdMemoryReadStreamImpl;
class OmniPvdMemoryWriteStreamImpl;
class OmniPvdMemoryStreamImpl : public OmniPvdMemoryStream
{
public:
OmniPvdMemoryStreamImpl();
~OmniPvdMemoryStreamImpl();
OmniPvdReadStream* OMNI_PVD_CALL getReadStream();
OmniPvdWriteStream* OMNI_PVD_CALL getWriteStream();
uint64_t OMNI_PVD_CALL setBufferSize(uint64_t bufferLength);
////////////////////////////////////////////////////////////////////////////////
// Read part
////////////////////////////////////////////////////////////////////////////////
uint64_t readBytes(uint8_t* destination, uint64_t nbrBytes);
uint64_t skipBytes(uint64_t nbrBytes);
////////////////////////////////////////////////////////////////////////////////
// Write part
////////////////////////////////////////////////////////////////////////////////
uint64_t writeBytes(const uint8_t* source, uint64_t nbrBytes);
bool flush();
////////////////////////////////////////////////////////////////////////////////
// Read/write streams
////////////////////////////////////////////////////////////////////////////////
OmniPvdMemoryReadStreamImpl *mReadStream;
OmniPvdMemoryWriteStreamImpl *mWriteStream;
////////////////////////////////////////////////////////////////////////////////
// Round robin buffer
////////////////////////////////////////////////////////////////////////////////
uint8_t *mBuffer;
uint64_t mBufferLength;
uint64_t mWrittenBytes;
uint64_t mWritePosition;
uint64_t mReadPosition;
};
#endif

View File

@@ -0,0 +1,58 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "OmniPvdMemoryStreamImpl.h"
#include "OmniPvdMemoryWriteStreamImpl.h"
OmniPvdMemoryWriteStreamImpl::OmniPvdMemoryWriteStreamImpl()
{
}
OmniPvdMemoryWriteStreamImpl::~OmniPvdMemoryWriteStreamImpl()
{
}
uint64_t OMNI_PVD_CALL OmniPvdMemoryWriteStreamImpl::writeBytes(const uint8_t* source, uint64_t nbrBytes)
{
return mMemoryStream->writeBytes(source, nbrBytes);
}
bool OMNI_PVD_CALL OmniPvdMemoryWriteStreamImpl::flush()
{
return mMemoryStream->flush();
}
bool OMNI_PVD_CALL OmniPvdMemoryWriteStreamImpl::openStream()
{
return true;
}
bool OMNI_PVD_CALL OmniPvdMemoryWriteStreamImpl::closeStream()
{
return true;
}

View File

@@ -0,0 +1,49 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef OMNI_PVD_MEMORY_WRITE_STREAM_IMPL_H
#define OMNI_PVD_MEMORY_WRITE_STREAM_IMPL_H
#include "OmniPvdWriteStream.h"
class OmniPvdMemoryStreamImpl;
class OmniPvdMemoryWriteStreamImpl : public OmniPvdWriteStream
{
public:
OmniPvdMemoryWriteStreamImpl();
~OmniPvdMemoryWriteStreamImpl();
uint64_t OMNI_PVD_CALL writeBytes(const uint8_t* source, uint64_t nbrBytes);
bool OMNI_PVD_CALL flush();
bool OMNI_PVD_CALL openStream();
bool OMNI_PVD_CALL closeStream();
OmniPvdMemoryStreamImpl *mMemoryStream;
};
#endif

View File

@@ -0,0 +1,572 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "OmniPvdDefinesInternal.h"
#include "OmniPvdReaderImpl.h"
#include <inttypes.h>
OmniPvdReaderImpl::OmniPvdReaderImpl()
{
mMajorVersion = OMNI_PVD_VERSION_MAJOR;
mMinorVersion = OMNI_PVD_VERSION_MINOR;
mPatch = OMNI_PVD_VERSION_PATCH;
mDataBuffer = 0;
mDataBuffAllocatedLen = 0;
mCmdAttributeDataPtr = 0;
mIsReadingStarted = false;
mReadBaseClassHandle = 1;
}
OmniPvdReaderImpl::~OmniPvdReaderImpl()
{
mCmdAttributeDataPtr = 0;
delete[] mDataBuffer;
mDataBuffer = 0;
mDataBuffAllocatedLen = 0;
}
void OMNI_PVD_CALL OmniPvdReaderImpl::setLogFunction(OmniPvdLogFunction logFunction)
{
mLog.setLogFunction(logFunction);
}
void OMNI_PVD_CALL OmniPvdReaderImpl::setReadStream(OmniPvdReadStream& stream)
{
mStream = &stream;
mStream->openStream();
}
bool OMNI_PVD_CALL OmniPvdReaderImpl::startReading(OmniPvdVersionType& majorVersion, OmniPvdVersionType& minorVersion, OmniPvdVersionType& patch)
{
if (mIsReadingStarted)
{
return true;
}
if (mStream)
{
mStream->readBytes((uint8_t*)&majorVersion, sizeof(OmniPvdVersionType));
mStream->readBytes((uint8_t*)&minorVersion, sizeof(OmniPvdVersionType));
mStream->readBytes((uint8_t*)&patch, sizeof(OmniPvdVersionType));
mCmdMajorVersion = majorVersion;
mCmdMinorVersion = minorVersion;
mCmdPatch = patch;
if ((mCmdMajorVersion == 0) && (mCmdMinorVersion < 3))
{
mCmdBaseClassHandle = 0;
mReadBaseClassHandle = 0;
}
else
{
mCmdBaseClassHandle = 0;
mReadBaseClassHandle = 1;
}
mLog.outputLine("OmniPvdRuntimeReaderImpl::startReading majorVersion(%lu), minorVersion(%lu), patch(%lu)", static_cast<unsigned long>(majorVersion), static_cast<unsigned long>(minorVersion), static_cast<unsigned long>(patch));
if (majorVersion > mMajorVersion)
{
mLog.outputLine("[parser] major version too new\n");
return false;
}
else if (majorVersion == mMajorVersion)
{
if (minorVersion > mMinorVersion)
{
mLog.outputLine("[parser] minor version too new\n");
return false;
}
else if (minorVersion == mMinorVersion)
{
if (patch > mPatch)
{
mLog.outputLine("[parser] patch too new\n");
return false;
}
}
}
mIsReadingStarted = true;
return true;
}
else {
return false;
}
}
static OmniPvdDataType::Enum readDataType(OmniPvdReadStream& stream)
{
OmniPvdDataTypeStorageType dataType;
stream.readBytes((uint8_t*)&dataType, sizeof(OmniPvdDataTypeStorageType));
return static_cast<OmniPvdDataType::Enum>(dataType);
}
bool OmniPvdReaderImpl::readStringFromStream(char* string, uint16_t& stringLength)
{
mStream->readBytes((uint8_t*)&stringLength, sizeof(uint16_t));
if (stringLength < OMNI_PVD_MAX_STRING_LENGTH)
{
mStream->readBytes((uint8_t*)string, stringLength);
string[stringLength] = 0; // trailing zero
return true;
}
else
{
uint16_t readBytes = OMNI_PVD_MAX_STRING_LENGTH - 1;
mStream->readBytes((uint8_t*)string, readBytes);
string[readBytes] = 0; // trailing zero
mStream->skipBytes(stringLength - readBytes);
mLog.outputLine("[parser] ERROR: string name %s... exceeds max length of %d\n", string, OMNI_PVD_MAX_STRING_LENGTH);
return false;
}
}
OmniPvdCommand::Enum OMNI_PVD_CALL OmniPvdReaderImpl::getNextCommand()
{
OmniPvdCommand::Enum cmdType = OmniPvdCommand::eINVALID;
resetCommandParams();
if (!mIsReadingStarted)
{
if (!startReading(mCmdMajorVersion, mCmdMinorVersion, mCmdPatch))
{
return cmdType;
}
}
if (mStream) {
OmniPvdCommandStorageType command;
if (mStream->readBytes(&command, sizeof(OmniPvdCommandStorageType)))
{
mCmdMessageParsed = false;
switch (command) {
case OmniPvdCommand::eREGISTER_CLASS:
{
cmdType = OmniPvdCommand::eREGISTER_CLASS;
mStream->readBytes((uint8_t*)&mCmdClassHandle, sizeof(OmniPvdClassHandle));
////////////////////////////////////////////////////////////////////////////////
// Skip reading the base class if the stream is older or equal to (0,2,x)
////////////////////////////////////////////////////////////////////////////////
if (mReadBaseClassHandle)
{
mStream->readBytes((uint8_t*)&mCmdBaseClassHandle, sizeof(OmniPvdClassHandle));
}
readStringFromStream(mCmdClassName, mCmdClassNameLen);
mLog.outputLine("[parser] register class (handle: %d, name: %s)\n", mCmdClassHandle, mCmdClassName);
}
break;
case OmniPvdCommand::eREGISTER_ATTRIBUTE:
{
cmdType = OmniPvdCommand::eREGISTER_ATTRIBUTE;
mStream->readBytes((uint8_t*)&mCmdClassHandle, sizeof(OmniPvdClassHandle));
mStream->readBytes((uint8_t*)&mCmdAttributeHandle, sizeof(OmniPvdAttributeHandle));
mCmdAttributeDataType = readDataType(*mStream);
if (mCmdAttributeDataType == OmniPvdDataType::eENUM_VALUE)
{
mStream->readBytes((uint8_t*)&mCmdEnumValue, sizeof(OmniPvdEnumValueType));
}
else if (mCmdAttributeDataType == OmniPvdDataType::eFLAGS_WORD)
{
mStream->readBytes((uint8_t*)&mCmdEnumClassHandle, sizeof(OmniPvdClassHandle));
}
else
{
mCmdEnumValue = 0;
mStream->readBytes((uint8_t*)&mCmdAttributeNbElements, sizeof(uint32_t));
}
readStringFromStream(mCmdAttributeName, mCmdAttributeNameLen);
mLog.outputLine("[parser] register attribute (classHandle: %d, attributeHandle: %d, attributeDataType: %d, nrFields: %d, name: %s)\n", mCmdClassHandle, mCmdAttributeHandle, mCmdAttributeDataType, mCmdAttributeNbElements, mCmdAttributeName);
}
break;
case OmniPvdCommand::eREGISTER_CLASS_ATTRIBUTE:
{
cmdType = OmniPvdCommand::eREGISTER_CLASS_ATTRIBUTE;
mStream->readBytes((uint8_t*)&mCmdClassHandle, sizeof(OmniPvdClassHandle));
mStream->readBytes((uint8_t*)&mCmdAttributeHandle, sizeof(OmniPvdAttributeHandle));
mStream->readBytes((uint8_t*)&mCmdAttributeClassHandle, sizeof(OmniPvdClassHandle));
readStringFromStream(mCmdAttributeName, mCmdAttributeNameLen);
mLog.outputLine("[parser] register class attribute (classHandle: %d, attributeHandle: %d, attribute classAttributeHandle: %d, name: %s)\n", mCmdClassHandle, mCmdAttributeHandle, mCmdAttributeClassHandle, mCmdAttributeName);
}
break;
case OmniPvdCommand::eREGISTER_UNIQUE_LIST_ATTRIBUTE:
{
cmdType = OmniPvdCommand::eREGISTER_UNIQUE_LIST_ATTRIBUTE;
mStream->readBytes((uint8_t*)&mCmdClassHandle, sizeof(OmniPvdClassHandle));
mStream->readBytes((uint8_t*)&mCmdAttributeHandle, sizeof(OmniPvdAttributeHandle));
mCmdAttributeDataType = readDataType(*mStream);
readStringFromStream(mCmdAttributeName, mCmdAttributeNameLen);
mLog.outputLine("[parser] register attributeSet (classHandle: %d, attributeHandle: %d, attributeDataType: %d, name: %s)\n", mCmdClassHandle, mCmdAttributeHandle, mCmdAttributeDataType, mCmdAttributeName);
}
break;
case OmniPvdCommand::eSET_ATTRIBUTE:
{
cmdType = OmniPvdCommand::eSET_ATTRIBUTE;
mStream->readBytes((uint8_t*)&mCmdContextHandle, sizeof(OmniPvdContextHandle));
mStream->readBytes((uint8_t*)&mCmdObjectHandle, sizeof(OmniPvdObjectHandle));
mStream->readBytes((uint8_t*)&mCmdAttributeHandleDepth, sizeof(uint8_t));
uint32_t* attributeHandleStack = mCmdAttributeHandleStack;
for (int i = 0; i < mCmdAttributeHandleDepth; i++) {
mStream->readBytes((uint8_t*)&mCmdAttributeHandle, sizeof(OmniPvdAttributeHandle));
attributeHandleStack++;
}
mStream->readBytes((uint8_t*)&mCmdAttributeDataLen, sizeof(uint32_t));
readLongDataFromStream(mCmdAttributeDataLen);
mLog.outputLine("[parser] set attribute (contextHandle:%d, objectHandle: %d, attributeHandle: %d, dataLen: %d)\n", mCmdContextHandle, mCmdObjectHandle, mCmdAttributeHandle, mCmdAttributeDataLen);
}
break;
case OmniPvdCommand::eADD_TO_UNIQUE_LIST_ATTRIBUTE:
{
cmdType = OmniPvdCommand::eADD_TO_UNIQUE_LIST_ATTRIBUTE;
mStream->readBytes((uint8_t*)&mCmdContextHandle, sizeof(OmniPvdContextHandle));
mStream->readBytes((uint8_t*)&mCmdObjectHandle, sizeof(OmniPvdObjectHandle));
mStream->readBytes((uint8_t*)&mCmdAttributeHandleDepth, sizeof(uint8_t));
uint32_t* attributeHandleStack = mCmdAttributeHandleStack;
for (int i = 0; i < mCmdAttributeHandleDepth; i++) {
mStream->readBytes((uint8_t*)&mCmdAttributeHandle, sizeof(OmniPvdAttributeHandle));
attributeHandleStack++;
}
mStream->readBytes((uint8_t*)&mCmdAttributeDataLen, sizeof(uint32_t));
readLongDataFromStream(mCmdAttributeDataLen);
mLog.outputLine("[parser] add to attributeSet (contextHandle:%d, objectHandle: %d, attributeHandle: %d, dataLen: %d)\n", mCmdContextHandle, mCmdObjectHandle, mCmdAttributeHandle, mCmdAttributeDataLen);
}
break;
case OmniPvdCommand::eREMOVE_FROM_UNIQUE_LIST_ATTRIBUTE:
{
cmdType = OmniPvdCommand::eREMOVE_FROM_UNIQUE_LIST_ATTRIBUTE;
mStream->readBytes((uint8_t*)&mCmdContextHandle, sizeof(OmniPvdContextHandle));
mStream->readBytes((uint8_t*)&mCmdObjectHandle, sizeof(OmniPvdObjectHandle));
mStream->readBytes((uint8_t*)&mCmdAttributeHandleDepth, sizeof(uint8_t));
uint32_t* attributeHandleStack = mCmdAttributeHandleStack;
for (int i = 0; i < mCmdAttributeHandleDepth; i++) {
mStream->readBytes((uint8_t*)&mCmdAttributeHandle, sizeof(OmniPvdAttributeHandle));
attributeHandleStack++;
}
mStream->readBytes((uint8_t*)&mCmdAttributeDataLen, sizeof(uint32_t));
readLongDataFromStream(mCmdAttributeDataLen);
mLog.outputLine("[parser] remove from attributeSet (contextHandle:%d, objectHandle: %d, attributeHandle: %d, dataLen: %d)\n", mCmdContextHandle, mCmdObjectHandle, mCmdAttributeHandle, mCmdAttributeDataLen);
}
break;
case OmniPvdCommand::eCREATE_OBJECT:
{
cmdType = OmniPvdCommand::eCREATE_OBJECT;
mStream->readBytes((uint8_t*)&mCmdContextHandle, sizeof(OmniPvdContextHandle));
mStream->readBytes((uint8_t*)&mCmdClassHandle, sizeof(OmniPvdClassHandle));
mStream->readBytes((uint8_t*)&mCmdObjectHandle, sizeof(OmniPvdObjectHandle));
readStringFromStream(mCmdObjectName, mCmdObjectNameLen);
mLog.outputLine("[parser] create object (contextHandle: %d, classHandle: %d, objectHandle: %d, name: %s)\n", mCmdContextHandle, mCmdClassHandle, mCmdObjectHandle, mCmdObjectName);
}
break;
case OmniPvdCommand::eDESTROY_OBJECT:
{
cmdType = OmniPvdCommand::eDESTROY_OBJECT;
mStream->readBytes((uint8_t*)&mCmdContextHandle, sizeof(OmniPvdContextHandle));
mStream->readBytes((uint8_t*)&mCmdObjectHandle, sizeof(OmniPvdObjectHandle));
mLog.outputLine("[parser] destroy object (contextHandle: %d, objectHandle: %d)\n", mCmdContextHandle, mCmdObjectHandle);
}
break;
case OmniPvdCommand::eSTART_FRAME:
{
cmdType = OmniPvdCommand::eSTART_FRAME;
mStream->readBytes((uint8_t*)&mCmdContextHandle, sizeof(OmniPvdContextHandle));
mStream->readBytes((uint8_t*)&mCmdFrameTimeStart, sizeof(uint64_t));
mLog.outputLine("[parser] start frame (contextHandle: %d, timeStamp: %d)\n", mCmdContextHandle, mCmdFrameTimeStart);
}
break;
case OmniPvdCommand::eSTOP_FRAME:
{
cmdType = OmniPvdCommand::eSTOP_FRAME;
mStream->readBytes((uint8_t*)&mCmdContextHandle, sizeof(OmniPvdContextHandle));
mStream->readBytes((uint8_t*)&mCmdFrameTimeStop, sizeof(uint64_t));
mLog.outputLine("[parser] stop frame (contextHandle: %d, timeStamp: %d)\n", mCmdContextHandle, mCmdFrameTimeStop);
}
break;
case OmniPvdCommand::eRECORD_MESSAGE:
{
cmdType = OmniPvdCommand::eRECORD_MESSAGE;
mStream->readBytes((uint8_t*)&mCmdContextHandle, sizeof(OmniPvdContextHandle));
// Message.
readStringFromStream(mCmdMessage, mCmdMessageLength);
// File name.
readStringFromStream(mCmdMessageFile, mCmdMessageFileLength);
mStream->readBytes((uint8_t*)&mCmdMessageLine, sizeof(uint32_t));
mStream->readBytes((uint8_t*)&mCmdMessageType, sizeof(uint32_t));
mStream->readBytes((uint8_t*)&mCmdMessageClassHandle, sizeof(OmniPvdClassHandle));
mCmdMessageParsed = true;
mLog.outputLine("[parser] message (contextHandle: %d, message: %s, file: %s, line: %d, type: %d)\n",
mCmdContextHandle,
mCmdMessage, mCmdMessageFile, mCmdMessageLine, mCmdMessageType
);
}
break;
default:
{
}
break;
}
return cmdType;
} else {
return cmdType;
}
}
else {
return cmdType;
}
}
uint32_t OMNI_PVD_CALL OmniPvdReaderImpl::getMajorVersion()
{
return mCmdMajorVersion;
}
uint32_t OMNI_PVD_CALL OmniPvdReaderImpl::getMinorVersion()
{
return mCmdMinorVersion;
}
uint32_t OMNI_PVD_CALL OmniPvdReaderImpl::getPatch()
{
return mCmdPatch;
}
uint64_t OMNI_PVD_CALL OmniPvdReaderImpl::getContextHandle()
{
return mCmdContextHandle;
}
OmniPvdClassHandle OMNI_PVD_CALL OmniPvdReaderImpl::getClassHandle()
{
return mCmdClassHandle;
}
OmniPvdClassHandle OMNI_PVD_CALL OmniPvdReaderImpl::getBaseClassHandle()
{
return mCmdBaseClassHandle;
}
uint32_t OMNI_PVD_CALL OmniPvdReaderImpl::getAttributeHandle()
{
return mCmdAttributeHandle;
}
uint64_t OMNI_PVD_CALL OmniPvdReaderImpl::getObjectHandle()
{
return mCmdObjectHandle;
}
const char* OMNI_PVD_CALL OmniPvdReaderImpl::getClassName()
{
return mCmdClassName;
}
const char* OMNI_PVD_CALL OmniPvdReaderImpl::getAttributeName()
{
return mCmdAttributeName;
}
const char* OMNI_PVD_CALL OmniPvdReaderImpl::getObjectName()
{
return mCmdObjectName;
}
const uint8_t* OMNI_PVD_CALL OmniPvdReaderImpl::getAttributeDataPointer()
{
return mCmdAttributeDataPtr;
}
OmniPvdDataType::Enum OMNI_PVD_CALL OmniPvdReaderImpl::getAttributeDataType()
{
return mCmdAttributeDataType;
}
uint32_t OMNI_PVD_CALL OmniPvdReaderImpl::getAttributeDataLength()
{
return mCmdAttributeDataLen;
}
uint32_t OMNI_PVD_CALL OmniPvdReaderImpl::getAttributeNumberElements()
{
return mCmdAttributeNbElements;
}
OmniPvdClassHandle OMNI_PVD_CALL OmniPvdReaderImpl::getAttributeClassHandle()
{
return mCmdAttributeClassHandle;
}
uint8_t OMNI_PVD_CALL OmniPvdReaderImpl::getAttributeNumberHandles()
{
return mCmdAttributeHandleDepth;
}
uint32_t* OMNI_PVD_CALL OmniPvdReaderImpl::getAttributeHandles()
{
return mCmdAttributeHandleStack;
}
uint64_t OMNI_PVD_CALL OmniPvdReaderImpl::getFrameTimeStart()
{
return mCmdFrameTimeStart;
}
uint64_t OMNI_PVD_CALL OmniPvdReaderImpl::getFrameTimeStop()
{
return mCmdFrameTimeStop;
}
bool OMNI_PVD_CALL OmniPvdReaderImpl::getMessageData(const char*& message, const char*& file, uint32_t& line, uint32_t& type, OmniPvdClassHandle& handle)
{
message = mCmdMessage;
file = mCmdMessageFile;
line = mCmdMessageLine;
type = mCmdMessageType;
handle = mCmdMessageClassHandle;
return mCmdMessageParsed;
}
OmniPvdClassHandle OMNI_PVD_CALL OmniPvdReaderImpl::getEnumClassHandle()
{
return mCmdEnumClassHandle;
}
uint32_t OMNI_PVD_CALL OmniPvdReaderImpl::getEnumValue()
{
return mCmdEnumValue;
}
void OmniPvdReaderImpl::readLongDataFromStream(uint32_t streamByteLen)
{
if (streamByteLen < 1) return;
if (streamByteLen > mDataBuffAllocatedLen) {
delete[] mDataBuffer;
mDataBuffAllocatedLen = (uint32_t)(streamByteLen * 1.3f);
mDataBuffer = new uint8_t[mDataBuffAllocatedLen];
}
mCmdAttributeDataPtr = mDataBuffer;
mStream->readBytes(mCmdAttributeDataPtr, streamByteLen);
}
////////////////////////////////////////////////////////////////////////////////
// Resets all command parameters before a new read command is executed,
// except for those parameters that are "stateful" which are left commented out.
////////////////////////////////////////////////////////////////////////////////
void OmniPvdReaderImpl::resetCommandParams()
{
////////////////////////////////////////////////////////////////////////////////
// Stateful: Depends on the version of the stream reader
////////////////////////////////////////////////////////////////////////////////
// OmniPvdVersionType mMajorVersion;
// OmniPvdVersionType mMinorVersion;
// OmniPvdVersionType mPatch;
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Stateful: Depends on the stream being read and stay the same
////////////////////////////////////////////////////////////////////////////////
// OmniPvdVersionType mCmdMajorVersion;
// OmniPvdVersionType mCmdMinorVersion;
// OmniPvdVersionType mCmdPatch;
////////////////////////////////////////////////////////////////////////////////
mCmdContextHandle = OMNI_PVD_INVALID_HANDLE;
mCmdObjectHandle = OMNI_PVD_INVALID_HANDLE;
mCmdClassHandle = OMNI_PVD_INVALID_HANDLE;
mCmdBaseClassHandle = OMNI_PVD_INVALID_HANDLE;
mCmdAttributeHandle = OMNI_PVD_INVALID_HANDLE;
mCmdClassName[0] = 0;
mCmdAttributeName[0] = 0;
mCmdObjectName[0] = 0;
mCmdClassNameLen = 0;
mCmdAttributeNameLen = 0;
mCmdObjectNameLen = 0;
mCmdAttributeDataPtr = 0;
////////////////////////////////////////////////////////////////////////////////
// Unsure how to handle this, a zero value could still be valid
////////////////////////////////////////////////////////////////////////////////
//mCmdAttributeDataType = OmniPvdDataType::eINT8; // int 8 is 0
////////////////////////////////////////////////////////////////////////////////
mCmdAttributeDataLen = 0;
mCmdAttributeNbElements = 0;
mCmdEnumValue = 0;
mCmdEnumClassHandle = OMNI_PVD_INVALID_HANDLE;
mCmdAttributeClassHandle = OMNI_PVD_INVALID_HANDLE;
////////////////////////////////////////////////////////////////////////////////
// Left untouched/dirty : instead depends on the depth parameter below
////////////////////////////////////////////////////////////////////////////////
// OmniPvdAttributeHandle mCmdAttributeHandleStack[32];
////////////////////////////////////////////////////////////////////////////////
mCmdAttributeHandleDepth = 0;
////////////////////////////////////////////////////////////////////////////////
// Stateful for the duration of a frame
////////////////////////////////////////////////////////////////////////////////
// uint64_t mCmdFrameTimeStart;
// uint64_t mCmdFrameTimeStop;
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Internal scratch buffer, instead the mCmdAttributeDataPtr is set to 0
////////////////////////////////////////////////////////////////////////////////
// uint8_t *mDataBuffer;
// uint32_t mDataBuffAllocatedLen;
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Internal message buffer
////////////////////////////////////////////////////////////////////////////////
mCmdMessageParsed = false;
mCmdMessageLength = 0;
mCmdMessage[0] = 0;
mCmdMessageFileLength = 0;
mCmdMessageFile[0] = 0;
mCmdMessageLine = 0;
mCmdMessageType = 0;
mCmdMessageClassHandle = 0;
}

View File

@@ -0,0 +1,141 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef OMNI_PVD_RUNTIME_READER_IMPL_H
#define OMNI_PVD_RUNTIME_READER_IMPL_H
#include "OmniPvdReader.h"
#include "OmniPvdLog.h"
class OmniPvdReaderImpl : public OmniPvdReader {
public:
OmniPvdReaderImpl();
~OmniPvdReaderImpl();
void OMNI_PVD_CALL setLogFunction(OmniPvdLogFunction logFunction);
void OMNI_PVD_CALL setReadStream(OmniPvdReadStream& stream);
bool OMNI_PVD_CALL startReading(OmniPvdVersionType& majorVersion, OmniPvdVersionType& minorVersion, OmniPvdVersionType& patch);
OmniPvdCommand::Enum OMNI_PVD_CALL getNextCommand();
OmniPvdVersionType OMNI_PVD_CALL getMajorVersion();
OmniPvdVersionType OMNI_PVD_CALL getMinorVersion();
OmniPvdVersionType OMNI_PVD_CALL getPatch();
OmniPvdContextHandle OMNI_PVD_CALL getContextHandle();
OmniPvdObjectHandle OMNI_PVD_CALL getObjectHandle();
OmniPvdClassHandle OMNI_PVD_CALL getClassHandle();
OmniPvdClassHandle OMNI_PVD_CALL getBaseClassHandle();
OmniPvdAttributeHandle OMNI_PVD_CALL getAttributeHandle();
const char* OMNI_PVD_CALL getClassName();
const char* OMNI_PVD_CALL getAttributeName();
const char* OMNI_PVD_CALL getObjectName();
const uint8_t* OMNI_PVD_CALL getAttributeDataPointer();
OmniPvdDataType::Enum OMNI_PVD_CALL getAttributeDataType();
uint32_t OMNI_PVD_CALL getAttributeDataLength();
uint32_t OMNI_PVD_CALL getAttributeNumberElements();
OmniPvdClassHandle OMNI_PVD_CALL getAttributeClassHandle();
uint8_t OMNI_PVD_CALL getAttributeNumberHandles();
OmniPvdAttributeHandle* OMNI_PVD_CALL getAttributeHandles();
uint64_t OMNI_PVD_CALL getFrameTimeStart();
uint64_t OMNI_PVD_CALL getFrameTimeStop();
bool OMNI_PVD_CALL getMessageData(const char*& message, const char*& file, uint32_t& line, uint32_t& type, OmniPvdClassHandle& handle) override;
OmniPvdClassHandle OMNI_PVD_CALL getEnumClassHandle();
uint32_t OMNI_PVD_CALL getEnumValue();
// Internal helper
void readLongDataFromStream(uint32_t streamByteLen);
bool readStringFromStream(char* string, uint16_t& stringLength);
void resetCommandParams();
OmniPvdLog mLog;
OmniPvdReadStream *mStream;
OmniPvdVersionType mMajorVersion;
OmniPvdVersionType mMinorVersion;
OmniPvdVersionType mPatch;
OmniPvdVersionType mCmdMajorVersion;
OmniPvdVersionType mCmdMinorVersion;
OmniPvdVersionType mCmdPatch;
OmniPvdContextHandle mCmdContextHandle;
OmniPvdObjectHandle mCmdObjectHandle;
uint32_t mCmdClassHandle;
uint32_t mCmdBaseClassHandle;
uint32_t mCmdAttributeHandle;
char mCmdClassName[OMNI_PVD_MAX_STRING_LENGTH];
char mCmdAttributeName[OMNI_PVD_MAX_STRING_LENGTH];
char mCmdObjectName[OMNI_PVD_MAX_STRING_LENGTH];
uint16_t mCmdClassNameLen;
uint16_t mCmdAttributeNameLen;
uint16_t mCmdObjectNameLen;
uint8_t* mCmdAttributeDataPtr;
OmniPvdDataType::Enum mCmdAttributeDataType;
uint32_t mCmdAttributeDataLen;
uint32_t mCmdAttributeNbElements;
OmniPvdEnumValueType mCmdEnumValue;
OmniPvdClassHandle mCmdEnumClassHandle;
OmniPvdClassHandle mCmdAttributeClassHandle;
OmniPvdAttributeHandle mCmdAttributeHandleStack[32];
uint8_t mCmdAttributeHandleDepth;
uint64_t mCmdFrameTimeStart;
uint64_t mCmdFrameTimeStop;
uint8_t *mDataBuffer;
uint32_t mDataBuffAllocatedLen;
bool mIsReadingStarted;
uint8_t mReadBaseClassHandle;
// Messages
bool mCmdMessageParsed;
uint16_t mCmdMessageLength;
char mCmdMessage[OMNI_PVD_MAX_STRING_LENGTH];
uint16_t mCmdMessageFileLength;
char mCmdMessageFile[OMNI_PVD_MAX_STRING_LENGTH];
uint32_t mCmdMessageLine;
uint32_t mCmdMessageType;
OmniPvdClassHandle mCmdMessageClassHandle;
};
#endif

View File

@@ -0,0 +1,384 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "OmniPvdWriterImpl.h"
#include "OmniPvdDefines.h"
#include <string.h>
OmniPvdWriterImpl::OmniPvdWriterImpl()
{
resetParams();
}
OmniPvdWriterImpl::~OmniPvdWriterImpl()
{
}
void OmniPvdWriterImpl::resetParams()
{
mStream = 0;
mLastClassHandle = 0;
mLastAttributeHandle = 0;
mIsFirstWrite = true;
mStatusFlags = 0; // That or set all flag bits off
}
void OMNI_PVD_CALL OmniPvdWriterImpl::setLogFunction(OmniPvdLogFunction logFunction)
{
mLog.setLogFunction(logFunction);
}
void OmniPvdWriterImpl::setVersionHelper()
{
if (mStream && mIsFirstWrite)
{
const OmniPvdVersionType omniPvdVersionMajor = OMNI_PVD_VERSION_MAJOR;
const OmniPvdVersionType omniPvdVersionMinor = OMNI_PVD_VERSION_MINOR;
const OmniPvdVersionType omniPvdVersionPatch = OMNI_PVD_VERSION_PATCH;
setVersion(omniPvdVersionMajor, omniPvdVersionMinor, omniPvdVersionPatch);
}
}
void OmniPvdWriterImpl::setVersion(OmniPvdVersionType majorVersion, OmniPvdVersionType minorVersion, OmniPvdVersionType patch)
{
if (mStream && mIsFirstWrite)
{
if (!mStream->openStream())
{
return;
}
writeWithStatus((const uint8_t*)&majorVersion, sizeof(OmniPvdVersionType));
writeWithStatus((const uint8_t*)&minorVersion, sizeof(OmniPvdVersionType));
writeWithStatus((const uint8_t*)&patch, sizeof(OmniPvdVersionType));
mLog.outputLine("OmniPvdRuntimeWriterImpl::setVersion majorVersion(%lu), minorVersion(%lu), patch(%lu)", static_cast<unsigned long>(majorVersion), static_cast<unsigned long>(minorVersion), static_cast<unsigned long>(patch));
mIsFirstWrite = false;
}
}
void OMNI_PVD_CALL OmniPvdWriterImpl::setWriteStream(OmniPvdWriteStream& stream)
{
mLog.outputLine("OmniPvdRuntimeWriterImpl::setWriteStream");
mStream = &stream;
}
OmniPvdWriteStream* OMNI_PVD_CALL OmniPvdWriterImpl::getWriteStream()
{
return mStream;
}
OmniPvdClassHandle OMNI_PVD_CALL OmniPvdWriterImpl::registerClass(const char* className, OmniPvdClassHandle baseClass)
{
setVersionHelper();
if (mStream)
{
mLog.outputLine("OmniPvdWriterImpl::registerClass className(%s)", className);
int classNameLen = (int)strlen(className);
writeCommand(OmniPvdCommand::eREGISTER_CLASS);
mLastClassHandle++;
writeWithStatus((const uint8_t*)&mLastClassHandle, sizeof(OmniPvdClassHandle));
writeWithStatus((const uint8_t*)&baseClass, sizeof(OmniPvdClassHandle));
writeWithStatus((const uint8_t*)&classNameLen, sizeof(uint16_t));
writeWithStatus((const uint8_t*)className, classNameLen);
return mLastClassHandle;
} else {
return OMNI_PVD_INVALID_HANDLE;
}
}
OmniPvdAttributeHandle OMNI_PVD_CALL OmniPvdWriterImpl::registerAttribute(OmniPvdClassHandle classHandle, const char* attributeName, OmniPvdDataType::Enum attributeDataType, uint32_t nbElements)
{
setVersionHelper();
if (mStream) {
mLog.outputLine("OmniPvdWriterImpl::registerAttribute classHandle(%llu), attributeName(%s), attributeDataType(%d), nbrFields(%llu)", static_cast<unsigned long long>(classHandle), attributeName, static_cast<int>(attributeDataType), static_cast<unsigned long long>(nbElements));
int attribNameLen = (int)strlen(attributeName);
writeCommand(OmniPvdCommand::eREGISTER_ATTRIBUTE);
mLastAttributeHandle++;
writeWithStatus((const uint8_t*)&classHandle, sizeof(OmniPvdClassHandle));
writeWithStatus((const uint8_t*)&mLastAttributeHandle, sizeof(OmniPvdAttributeHandle));
writeDataType(attributeDataType);
writeWithStatus((const uint8_t*)&nbElements, sizeof(uint32_t));
writeWithStatus((const uint8_t*)&attribNameLen, sizeof(uint16_t));
writeWithStatus((const uint8_t*)attributeName, attribNameLen);
return mLastAttributeHandle;
}
else {
return OMNI_PVD_INVALID_HANDLE;
}
}
OmniPvdAttributeHandle OMNI_PVD_CALL OmniPvdWriterImpl::registerFlagsAttribute(OmniPvdClassHandle classHandle, const char* attributeName, OmniPvdClassHandle enumClassHandle)
{
setVersionHelper();
if (mStream) {
mLog.outputLine("OmniPvdWriterImpl::registerFlagsAttribute classHandle(%llu), enumClassHandle(%llu), attributeName(%s)", static_cast<unsigned long long>(classHandle), static_cast<unsigned long long>(enumClassHandle), attributeName);
int attribNameLen = (int)strlen(attributeName);
writeCommand(OmniPvdCommand::eREGISTER_ATTRIBUTE);
mLastAttributeHandle++;
writeWithStatus((const uint8_t*)&classHandle, sizeof(OmniPvdClassHandle));
writeWithStatus((const uint8_t*)&mLastAttributeHandle, sizeof(OmniPvdAttributeHandle));
writeDataType(OmniPvdDataType::eFLAGS_WORD);
writeWithStatus((const uint8_t*)&enumClassHandle, sizeof(OmniPvdClassHandle));
writeWithStatus((const uint8_t*)&attribNameLen, sizeof(uint16_t));
writeWithStatus((const uint8_t*)attributeName, attribNameLen);
return mLastAttributeHandle;
}
else {
return OMNI_PVD_INVALID_HANDLE;
}
}
OmniPvdAttributeHandle OMNI_PVD_CALL OmniPvdWriterImpl::registerEnumValue(OmniPvdClassHandle classHandle, const char* attributeName, OmniPvdEnumValueType value)
{
setVersionHelper();
if (mStream) {
int attribNameLen = (int)strlen(attributeName);
writeCommand(OmniPvdCommand::eREGISTER_ATTRIBUTE);
mLastAttributeHandle++;
writeWithStatus((const uint8_t*)&classHandle, sizeof(OmniPvdClassHandle));
writeWithStatus((const uint8_t*)&mLastAttributeHandle, sizeof(OmniPvdAttributeHandle));
writeDataType(OmniPvdDataType::eENUM_VALUE);
writeWithStatus((const uint8_t*)&value, sizeof(OmniPvdEnumValueType));
writeWithStatus((const uint8_t*)&attribNameLen, sizeof(uint16_t));
writeWithStatus((const uint8_t*)attributeName, attribNameLen);
return mLastAttributeHandle;
}
else {
return OMNI_PVD_INVALID_HANDLE;
}
}
OmniPvdAttributeHandle OMNI_PVD_CALL OmniPvdWriterImpl::registerClassAttribute(OmniPvdClassHandle classHandle, const char* attributeName, OmniPvdClassHandle classAttributeHandle)
{
setVersionHelper();
if (mStream)
{
int attribNameLen = (int)strlen(attributeName);
writeCommand(OmniPvdCommand::eREGISTER_CLASS_ATTRIBUTE);
mLastAttributeHandle++;
writeWithStatus((const uint8_t*)&classHandle, sizeof(OmniPvdClassHandle));
writeWithStatus((const uint8_t*)&mLastAttributeHandle, sizeof(OmniPvdAttributeHandle));
writeWithStatus((const uint8_t*)&classAttributeHandle, sizeof(OmniPvdClassHandle));
writeWithStatus((const uint8_t*)&attribNameLen, sizeof(uint16_t));
writeWithStatus((const uint8_t*)attributeName, attribNameLen);
return mLastAttributeHandle;
}
else {
return OMNI_PVD_INVALID_HANDLE;
}
}
OmniPvdAttributeHandle OMNI_PVD_CALL OmniPvdWriterImpl::registerUniqueListAttribute(OmniPvdClassHandle classHandle, const char* attributeName, OmniPvdDataType::Enum attributeDataType)
{
setVersionHelper();
if (mStream)
{
int attribNameLen = (int)strlen(attributeName);
writeCommand(OmniPvdCommand::eREGISTER_UNIQUE_LIST_ATTRIBUTE);
mLastAttributeHandle++;
writeWithStatus((const uint8_t*)&classHandle, sizeof(OmniPvdClassHandle));
writeWithStatus((const uint8_t*)&mLastAttributeHandle, sizeof(OmniPvdAttributeHandle));
writeDataType(attributeDataType);
writeWithStatus((const uint8_t*)&attribNameLen, sizeof(uint16_t));
writeWithStatus((const uint8_t*)attributeName, attribNameLen);
return mLastAttributeHandle;
}
else
{
return OMNI_PVD_INVALID_HANDLE;
}
}
void OMNI_PVD_CALL OmniPvdWriterImpl::setAttribute(OmniPvdContextHandle contextHandle, OmniPvdObjectHandle objectHandle, const OmniPvdAttributeHandle* attributeHandles, uint8_t nbAttributeHandles, const uint8_t* data, uint32_t nbrBytes)
{
setVersionHelper();
if (mStream)
{
writeCommand(OmniPvdCommand::eSET_ATTRIBUTE);
writeWithStatus((const uint8_t*)&contextHandle, sizeof(OmniPvdContextHandle));
writeWithStatus((const uint8_t*)&objectHandle, sizeof(OmniPvdObjectHandle));
writeWithStatus((const uint8_t*)&nbAttributeHandles, sizeof(uint8_t));
for (int i = 0; i < nbAttributeHandles; i++)
{
writeWithStatus((const uint8_t*)attributeHandles, sizeof(OmniPvdAttributeHandle));
attributeHandles++;
}
writeWithStatus((const uint8_t*)&nbrBytes, sizeof(uint32_t));
writeWithStatus((const uint8_t*)data, nbrBytes);
}
}
void OMNI_PVD_CALL OmniPvdWriterImpl::addToUniqueListAttribute(OmniPvdContextHandle contextHandle, OmniPvdObjectHandle objectHandle, const OmniPvdAttributeHandle* attributeHandles, uint8_t nbAttributeHandles, const uint8_t* data, uint32_t nbrBytes)
{
setVersionHelper();
if (mStream)
{
writeCommand(OmniPvdCommand::eADD_TO_UNIQUE_LIST_ATTRIBUTE);
writeWithStatus((const uint8_t*)&contextHandle, sizeof(OmniPvdContextHandle));
writeWithStatus((const uint8_t*)&objectHandle, sizeof(OmniPvdObjectHandle));
writeWithStatus((const uint8_t*)&nbAttributeHandles, sizeof(uint8_t));
for (int i = 0; i < nbAttributeHandles; i++)
{
writeWithStatus((const uint8_t*)attributeHandles, sizeof(OmniPvdAttributeHandle));
attributeHandles++;
}
writeWithStatus((const uint8_t*)&nbrBytes, sizeof(uint32_t));
writeWithStatus((const uint8_t*)data, nbrBytes);
}
}
void OMNI_PVD_CALL OmniPvdWriterImpl::removeFromUniqueListAttribute(OmniPvdContextHandle contextHandle, OmniPvdObjectHandle objectHandle, const OmniPvdAttributeHandle* attributeHandles, uint8_t nbAttributeHandles, const uint8_t* data, uint32_t nbrBytes)
{
setVersionHelper();
if (mStream)
{
writeCommand(OmniPvdCommand::eREMOVE_FROM_UNIQUE_LIST_ATTRIBUTE);
writeWithStatus((const uint8_t*)&contextHandle, sizeof(OmniPvdContextHandle));
writeWithStatus((const uint8_t*)&objectHandle, sizeof(OmniPvdObjectHandle));
writeWithStatus((const uint8_t*)&nbAttributeHandles, sizeof(uint8_t));
for (int i = 0; i < nbAttributeHandles; i++)
{
writeWithStatus((const uint8_t*)attributeHandles, sizeof(OmniPvdAttributeHandle));
attributeHandles++;
}
writeWithStatus((const uint8_t*)&nbrBytes, sizeof(uint32_t));
writeWithStatus((const uint8_t*)data, nbrBytes);
}
}
void OMNI_PVD_CALL OmniPvdWriterImpl::createObject(OmniPvdContextHandle contextHandle, OmniPvdClassHandle classHandle, OmniPvdObjectHandle objectHandle, const char* objectName)
{
setVersionHelper();
if (mStream)
{
writeCommand(OmniPvdCommand::eCREATE_OBJECT);
writeWithStatus((const uint8_t*)&contextHandle, sizeof(OmniPvdContextHandle));
writeWithStatus((const uint8_t*)&classHandle, sizeof(OmniPvdClassHandle));
writeWithStatus((const uint8_t*)&objectHandle, sizeof(OmniPvdObjectHandle));
int objectNameLen = 0;
if (objectName)
{
objectNameLen = (int)strlen(objectName);
writeWithStatus((const uint8_t*)&objectNameLen, sizeof(uint16_t));
writeWithStatus((const uint8_t*)objectName, objectNameLen);
}
else
{
writeWithStatus((const uint8_t*)&objectNameLen, sizeof(uint16_t));
}
}
}
void OMNI_PVD_CALL OmniPvdWriterImpl::destroyObject(OmniPvdContextHandle contextHandle, OmniPvdObjectHandle objectHandle)
{
setVersionHelper();
if (mStream)
{
writeCommand(OmniPvdCommand::eDESTROY_OBJECT);
writeWithStatus((const uint8_t*)&contextHandle, sizeof(OmniPvdContextHandle));
writeWithStatus((const uint8_t*)&objectHandle, sizeof(OmniPvdObjectHandle));
}
}
void OMNI_PVD_CALL OmniPvdWriterImpl::startFrame(OmniPvdContextHandle contextHandle, uint64_t timeStamp)
{
setVersionHelper();
if (mStream)
{
writeCommand(OmniPvdCommand::eSTART_FRAME);
writeWithStatus((const uint8_t*)&contextHandle, sizeof(OmniPvdContextHandle));
writeWithStatus((const uint8_t*)&timeStamp, sizeof(uint64_t));
}
}
void OMNI_PVD_CALL OmniPvdWriterImpl::stopFrame(OmniPvdContextHandle contextHandle, uint64_t timeStamp)
{
setVersionHelper();
if (mStream)
{
writeCommand(OmniPvdCommand::eSTOP_FRAME);
writeWithStatus((const uint8_t*)&contextHandle, sizeof(OmniPvdContextHandle));
writeWithStatus((const uint8_t*)&timeStamp, sizeof(uint64_t));
}
}
void OMNI_PVD_CALL OmniPvdWriterImpl::recordMessage(OmniPvdContextHandle contextHandle, const char* message, const char* file, uint32_t line, uint32_t type, OmniPvdClassHandle handle)
{
setVersionHelper();
if (mStream)
{
writeCommand(OmniPvdCommand::eRECORD_MESSAGE);
writeWithStatus((const uint8_t*)&contextHandle, sizeof(OmniPvdContextHandle));
int messageLength = 0;
if (message)
{
messageLength = (int)strlen(message);
writeWithStatus((const uint8_t*)&messageLength, sizeof(uint16_t));
writeWithStatus((const uint8_t*)message, messageLength);
}
else
{
writeWithStatus((const uint8_t*)&messageLength, sizeof(uint16_t));
}
int filenameLength = 0;
if (file)
{
filenameLength = (int)strlen(file);
writeWithStatus((const uint8_t*)&filenameLength, sizeof(uint16_t));
writeWithStatus((const uint8_t*)file, filenameLength);
}
else
{
writeWithStatus((const uint8_t*)&filenameLength, sizeof(uint16_t));
}
writeWithStatus((const uint8_t*)&line, sizeof(uint32_t));
writeWithStatus((const uint8_t*)&type, sizeof(uint32_t));
writeWithStatus((const uint8_t*)&handle, sizeof(OmniPvdClassHandle));
}
}
uint32_t OMNI_PVD_CALL OmniPvdWriterImpl::getStatus()
{
return mStatusFlags;
}
void OMNI_PVD_CALL OmniPvdWriterImpl::clearStatus()
{
mStatusFlags = 0;
}

View File

@@ -0,0 +1,129 @@
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2025 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef OMNI_PVD_WRITER_IMPL_H
#define OMNI_PVD_WRITER_IMPL_H
#include "OmniPvdWriter.h"
#include "OmniPvdCommands.h"
#include "OmniPvdDefinesInternal.h"
#include "OmniPvdLog.h"
class OmniPvdWriterImpl : public OmniPvdWriter {
public:
OmniPvdWriterImpl();
~OmniPvdWriterImpl();
void OMNI_PVD_CALL setLogFunction(OmniPvdLogFunction logFunction);
void setVersionHelper();
void setVersion(OmniPvdVersionType majorVersion, OmniPvdVersionType minorVersion, OmniPvdVersionType patch);
void OMNI_PVD_CALL setWriteStream(OmniPvdWriteStream& stream);
OmniPvdWriteStream* OMNI_PVD_CALL getWriteStream();
OmniPvdClassHandle OMNI_PVD_CALL registerClass(const char* className, OmniPvdClassHandle baseClass);
OmniPvdAttributeHandle OMNI_PVD_CALL registerEnumValue(OmniPvdClassHandle classHandle, const char* attributeName, OmniPvdEnumValueType value);
OmniPvdAttributeHandle OMNI_PVD_CALL registerAttribute(OmniPvdClassHandle classHandle, const char* attributeName, OmniPvdDataType::Enum attributeDataType, uint32_t nbElements);
OmniPvdAttributeHandle OMNI_PVD_CALL registerFlagsAttribute(OmniPvdClassHandle classHandle, const char* attributeName, OmniPvdClassHandle enumClassHandle);
OmniPvdAttributeHandle OMNI_PVD_CALL registerClassAttribute(OmniPvdClassHandle classHandle, const char* attributeName, OmniPvdClassHandle classAttributeHandle);
OmniPvdAttributeHandle OMNI_PVD_CALL registerUniqueListAttribute(OmniPvdClassHandle classHandle, const char* attributeName, OmniPvdDataType::Enum attributeDataType);
void OMNI_PVD_CALL setAttribute(OmniPvdContextHandle contextHandle, OmniPvdObjectHandle objectHandle, const OmniPvdAttributeHandle* attributeHandles, uint8_t nbAttributeHandles, const uint8_t* data, uint32_t nbrBytes);
void OMNI_PVD_CALL addToUniqueListAttribute(OmniPvdContextHandle contextHandle, OmniPvdObjectHandle objectHandle, const OmniPvdAttributeHandle* attributeHandles, uint8_t nbAttributeHandles, const uint8_t* data, uint32_t nbrBytes);
void OMNI_PVD_CALL removeFromUniqueListAttribute(OmniPvdContextHandle contextHandle, OmniPvdObjectHandle objectHandle, const OmniPvdAttributeHandle* attributeHandles, uint8_t nbAttributeHandles, const uint8_t* data, uint32_t nbrBytes);
void OMNI_PVD_CALL createObject(OmniPvdContextHandle contextHandle, OmniPvdClassHandle classHandle, OmniPvdObjectHandle objectHandle, const char* objectName);
void OMNI_PVD_CALL destroyObject(OmniPvdContextHandle contextHandle, OmniPvdObjectHandle objectHandle);
void OMNI_PVD_CALL startFrame(OmniPvdContextHandle contextHandle, uint64_t timeStamp);
void OMNI_PVD_CALL stopFrame(OmniPvdContextHandle contextHandle, uint64_t timeStamp);
void OMNI_PVD_CALL recordMessage(OmniPvdContextHandle contextHandle, const char* message, const char* file, uint32_t line, uint32_t type, OmniPvdClassHandle handle) override;
uint32_t OMNI_PVD_CALL getStatus();
void OMNI_PVD_CALL clearStatus();
void resetParams();
bool isFlagOn(OmniPvdWriterStatusFlag::Enum flagBitMask)
{
return mStatusFlags & uint32_t(flagBitMask);
}
void setFlagOn(OmniPvdWriterStatusFlag::Enum flagBitMask)
{
mStatusFlags = mStatusFlags | uint32_t(flagBitMask);
}
void setFlagOff(OmniPvdWriterStatusFlag::Enum flagBitMask)
{
mStatusFlags = mStatusFlags & ~uint32_t(flagBitMask);
}
void setFlagVal(OmniPvdWriterStatusFlag::Enum flagBitMask, bool value)
{
if (value)
{
setFlagOn(flagBitMask);
}
else
{
setFlagOff(flagBitMask);
}
}
void writeWithStatus(const uint8_t* writePtr, uint64_t nbrBytesToWrite)
{
if (! (mStream && writePtr && (nbrBytesToWrite > 0)) ) return;
uint64_t nbrBytesWritten = mStream->writeBytes(writePtr, nbrBytesToWrite);
const bool writeFailure = nbrBytesWritten != nbrBytesToWrite;
if (writeFailure) {
setFlagOn(OmniPvdWriterStatusFlag::eSTREAM_WRITE_FAILURE);
}
}
void writeDataType(OmniPvdDataType::Enum attributeDataType)
{
const OmniPvdDataTypeStorageType dataType = static_cast<OmniPvdDataTypeStorageType>(attributeDataType);
writeWithStatus((const uint8_t*)&dataType, sizeof(OmniPvdDataTypeStorageType));
}
void writeCommand(OmniPvdCommand::Enum command)
{
const OmniPvdCommandStorageType commandTmp = static_cast<OmniPvdCommandStorageType>(command);
writeWithStatus((const uint8_t*)&commandTmp, sizeof(OmniPvdCommandStorageType));
}
bool mIsFirstWrite;
OmniPvdLog mLog;
OmniPvdWriteStream* mStream;
int mLastClassHandle;
int mLastAttributeHandle;
uint32_t mStatusFlags;
};
#endif