aboutsummaryrefslogtreecommitdiff
path: root/APEX_1.4/NvParameterized/include
diff options
context:
space:
mode:
authorgit perforce import user <a@b>2016-10-25 12:29:14 -0600
committerSheikh Dawood Abdul Ajees <Sheikh Dawood Abdul Ajees>2016-10-25 18:56:37 -0500
commit3dfe2108cfab31ba3ee5527e217d0d8e99a51162 (patch)
treefa6485c169e50d7415a651bf838f5bcd0fd3bfbd /APEX_1.4/NvParameterized/include
downloadphysx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.tar.xz
physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.zip
Initial commit:
PhysX 3.4.0 Update @ 21294896 APEX 1.4.0 Update @ 21275617 [CL 21300167]
Diffstat (limited to 'APEX_1.4/NvParameterized/include')
-rw-r--r--APEX_1.4/NvParameterized/include/AbstractSerializer.h173
-rw-r--r--APEX_1.4/NvParameterized/include/ApbDefinitions.h217
-rw-r--r--APEX_1.4/NvParameterized/include/BinSerializer.h132
-rw-r--r--APEX_1.4/NvParameterized/include/BinaryHelper.h290
-rw-r--r--APEX_1.4/NvParameterized/include/NvDefaultTraits.h503
-rw-r--r--APEX_1.4/NvParameterized/include/NvParamConversionTemplate.h147
-rw-r--r--APEX_1.4/NvParameterized/include/NvParameters.h650
-rw-r--r--APEX_1.4/NvParameterized/include/NvParametersTypes.h58
-rw-r--r--APEX_1.4/NvParameterized/include/NvRegistrationsForTraitsBase.h29
-rw-r--r--APEX_1.4/NvParameterized/include/NvSerializerInternal.h63
-rw-r--r--APEX_1.4/NvParameterized/include/NvTraitsInternal.h85
-rw-r--r--APEX_1.4/NvParameterized/include/PlatformABI.h135
-rw-r--r--APEX_1.4/NvParameterized/include/PlatformABI.inl267
-rw-r--r--APEX_1.4/NvParameterized/include/PlatformInputStream.h115
-rw-r--r--APEX_1.4/NvParameterized/include/PlatformInputStream.inl117
-rw-r--r--APEX_1.4/NvParameterized/include/PlatformOutputStream.h212
-rw-r--r--APEX_1.4/NvParameterized/include/PlatformOutputStream.inl138
-rw-r--r--APEX_1.4/NvParameterized/include/PlatformStream.h151
-rw-r--r--APEX_1.4/NvParameterized/include/SerializerCommon.h172
-rw-r--r--APEX_1.4/NvParameterized/include/XmlDeserializer.h307
-rw-r--r--APEX_1.4/NvParameterized/include/XmlSerializer.h114
21 files changed, 4075 insertions, 0 deletions
diff --git a/APEX_1.4/NvParameterized/include/AbstractSerializer.h b/APEX_1.4/NvParameterized/include/AbstractSerializer.h
new file mode 100644
index 00000000..1b7b43b1
--- /dev/null
+++ b/APEX_1.4/NvParameterized/include/AbstractSerializer.h
@@ -0,0 +1,173 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2013 NVIDIA Corporation. All rights reserved.
+
+#ifndef PX_ABSTRACT_SERIALIZER_H
+#define PX_ABSTRACT_SERIALIZER_H
+
+#include "nvparameterized/NvParameterized.h"
+#include "nvparameterized/NvParameterizedTraits.h"
+#include "nvparameterized/NvSerializer.h"
+
+#include "NvSerializerInternal.h"
+#include "NvTraitsInternal.h"
+
+#include "SerializerCommon.h"
+
+namespace NvParameterized
+{
+
+// Base for other serializers which takes care of common stuff
+
+class AbstractSerializer : public Serializer
+{
+public:
+ AbstractSerializer(Traits *traits):
+ mDoUpdate(true),
+ mPlatform(GetCurrentPlatform()),
+ mTraits(traits) {}
+
+ virtual ~AbstractSerializer() {}
+
+ Traits *getTraits() const { return mTraits; }
+
+ //This is used in static Serializer::deserializer
+ void setTraits(Traits *traits) { mTraits = traits; }
+
+ void setAutoUpdate(bool doUpdate)
+ {
+ mDoUpdate = doUpdate;
+ }
+
+ Serializer::ErrorType peekInplaceAlignment(physx::PxFileBuf& /*stream*/, uint32_t& /*align*/)
+ {
+ return Serializer::ERROR_NOT_IMPLEMENTED;
+ }
+
+ Serializer::ErrorType setTargetPlatform(const SerializePlatform &platform)
+ {
+ mPlatform = platform;
+ return Serializer::ERROR_NONE; //Only pdb cares about platforms
+ }
+
+ Serializer::ErrorType serialize(physx::PxFileBuf &stream,const NvParameterized::Interface **objs, uint32_t nobjs, bool doMetadata)
+ {
+#ifdef WITHOUT_APEX_SERIALIZATION
+ PX_UNUSED(stream);
+ PX_UNUSED(objs);
+ PX_UNUSED(nobjs);
+ PX_UNUSED(doMetadata);
+
+ return Serializer::ERROR_NOT_IMPLEMENTED;
+#else
+
+ NV_BOOL_ERR_CHECK_WARN_RETURN(
+ stream.isOpen(),
+ Serializer::ERROR_STREAM_ERROR,
+ "Stream not opened" );
+
+ for(uint32_t i = 0; i < nobjs; ++i)
+ {
+ NV_BOOL_ERR_CHECK_WARN_RETURN(
+ objs[i]->callPreSerializeCallback() == 0,
+ Serializer::ERROR_PRESERIALIZE_FAILED,
+ "Preserialize callback failed" );
+ }
+
+ return internalSerialize(stream, objs, nobjs, doMetadata);
+#endif
+ }
+
+ using Serializer::deserialize;
+ virtual Serializer::ErrorType deserialize(physx::PxFileBuf &stream, Serializer::DeserializedData &res, bool &isUpdated)
+ {
+ NV_BOOL_ERR_CHECK_WARN_RETURN(
+ stream.isOpen(),
+ Serializer::ERROR_STREAM_ERROR,
+ "Stream not opened" );
+
+ isUpdated = false;
+ bool doesNeedUpdate = true;
+ NV_ERR_CHECK_RETURN( internalDeserialize(stream, res, doesNeedUpdate) );
+ return doesNeedUpdate && mDoUpdate ? upgrade(res, isUpdated) : Serializer::ERROR_NONE;
+ }
+
+ using Serializer::deserializeInplace;
+ Serializer::ErrorType deserializeInplace(void *data, uint32_t dataLen, Serializer::DeserializedData &res, bool &isUpdated)
+ {
+ isUpdated = false;
+ bool doesNeedUpdate = true;
+ NV_ERR_CHECK_RETURN( internalDeserializeInplace(data, dataLen, res, doesNeedUpdate) );
+ return doesNeedUpdate && mDoUpdate ? upgrade(res, isUpdated) : Serializer::ERROR_NONE;
+ }
+
+protected:
+
+ bool mDoUpdate;
+ SerializePlatform mPlatform;
+ Traits *mTraits;
+
+#ifndef WITHOUT_APEX_SERIALIZATION
+ virtual Serializer::ErrorType internalSerialize(
+ physx::PxFileBuf &stream,
+ const NvParameterized::Interface **objs,
+ uint32_t n,
+ bool doMetadata) = 0;
+#endif
+
+ // doesNeedUpdate allows serializer to avoid costly depth-first scanning of included refs
+ virtual Serializer::ErrorType internalDeserialize(
+ physx::PxFileBuf &stream,
+ Serializer::DeserializedData &res,
+ bool &doesNeedUpdate) = 0;
+
+ // See note for internalDeserialize
+ virtual Serializer::ErrorType internalDeserializeInplace(
+ void * /*data*/,
+ uint32_t /*dataLen*/,
+ Serializer::DeserializedData & /*res*/,
+ bool & /*doesNeedUpdate*/)
+ {
+ DEBUG_ALWAYS_ASSERT();
+ return Serializer::ERROR_NOT_IMPLEMENTED;
+ }
+
+private:
+ Serializer::ErrorType upgrade(Serializer::DeserializedData &res, bool &isUpdated)
+ {
+ //Upgrade legacy objects
+ NV_BOOL_ERR_CHECK_WARN_RETURN(
+ UpgradeLegacyObjects(res, isUpdated, mTraits),
+ Serializer::ERROR_CONVERSION_FAILED,
+ "Upgrading legacy objects failed" );
+
+ return Serializer::ERROR_NONE;
+ }
+};
+
+} // namespace NvParameterized
+
+#endif
diff --git a/APEX_1.4/NvParameterized/include/ApbDefinitions.h b/APEX_1.4/NvParameterized/include/ApbDefinitions.h
new file mode 100644
index 00000000..467ea025
--- /dev/null
+++ b/APEX_1.4/NvParameterized/include/ApbDefinitions.h
@@ -0,0 +1,217 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2013 NVIDIA Corporation. All rights reserved.
+
+#ifndef APB_DEFINITIONS_H_
+#define APB_DEFINITIONS_H_
+
+// This file contains definitions of various parts of APB file format
+
+// WARNING: before doing any changes to this file
+// check comments at the head of BinSerializer.cpp
+
+#include "SerializerCommon.h"
+#include "BinaryHelper.h"
+
+namespace NvParameterized
+{
+
+#define APB_MAGIC 0x5A5B5C5D
+
+namespace BinVersions
+{
+ static const uint32_t Initial = 0x00010000,
+ AllRefsCounted = 0x00010001,
+ WithAlignment = 0x00010002,
+ WithExtendedHeader = 0x00010003;
+}
+
+// Type of relocation in binary file
+enum RelocType
+{
+ //Raw bytes
+ RELOC_ABS_RAW = 0,
+
+ //NvParameterized (will be initialized on deserialization)
+ RELOC_ABS_REF,
+
+ RELOC_LAST
+};
+
+// Relocation record in binary file
+struct BinaryReloc
+{
+ uint32_t type;
+ uint32_t off;
+};
+
+// Format of data in binary file; only BINARY_TYPE_PLAIN is used for now
+enum BinaryType
+{
+ BINARY_TYPE_PLAIN = 0,
+ BINARY_TYPE_XML_GZ,
+ BINARY_TYPE_LAST
+};
+
+// Some dummy version control systems insert '\r' before '\n'.
+// This short string in header is used to catch this.
+// We also use 0xff byte to guarantee that we have non-printable chars
+// (s.t. VCS can detect that file is binary).
+#define VCS_SAFETY_FLAGS "ab\n\xff"
+
+// File header
+#pragma pack(push,1) // For cross-platform compatibility!
+
+// Convert to platform-independent format
+static void CanonizeArrayOfU32s(char *data, uint32_t len)
+{
+ PX_ASSERT(len % 4U == 0);
+
+ if( IsBigEndian() )
+ return;
+
+ for(uint32_t i = 0; i < len; i += 4U)
+ SwapBytes(data + i, 4U, TYPE_U32);
+}
+
+// Main binary header
+struct BinaryHeader
+{
+ uint32_t magic;
+ uint32_t type;
+ uint32_t version;
+ int32_t numObjects;
+
+ uint32_t fileLength;
+ uint32_t dictOffset;
+ uint32_t dataOffset;
+ uint32_t relocOffset;
+
+ uint32_t metadataOffset;
+ uint32_t archType;
+ uint32_t compilerType;
+ uint32_t compilerVer;
+
+ uint32_t osType;
+ uint32_t osVer;
+ uint32_t numMetadata;
+ uint32_t alignment;
+
+ static bool CheckAlignment()
+ {
+ bool isPushPackOk = 4 != offsetof(BinaryHeader, type);
+ if( isPushPackOk )
+ {
+ DEBUG_ASSERT( 0 && "PX_PUSH_PACK failed!" );
+ return false;
+ }
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable:4127)
+#endif
+ if( sizeof(BinaryHeader) % 16 != 0 )
+ {
+ return false;
+ }
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
+ return true;
+ }
+
+ Serializer::ErrorType getPlatform(SerializePlatform &platform) const
+ {
+ if( archType >= SerializePlatform::ARCH_LAST
+ || compilerType >= SerializePlatform::COMP_LAST
+ || osType >= SerializePlatform::OS_LAST )
+ {
+ DEBUG_ALWAYS_ASSERT();
+ return Serializer::ERROR_INVALID_PLATFORM;
+ }
+
+ platform = SerializePlatform(
+ static_cast<SerializePlatform::ArchType>(archType),
+ static_cast<SerializePlatform::CompilerType>(compilerType),
+ compilerVer,
+ static_cast<SerializePlatform::OsType>(osType),
+ osVer
+ );
+
+ return Serializer::ERROR_NONE;
+ }
+
+ void canonize()
+ {
+ CanonizeArrayOfU32s((char*)this, sizeof(BinaryHeader));
+ }
+
+ void decanonize() { canonize(); }
+};
+
+// Extended header (only in new versions)
+struct BinaryHeaderExt
+{
+ uint32_t vcsSafetyFlags;
+ uint32_t res[3 + 8]; // Pad to multiple of 16 byte
+
+ void canonize()
+ {
+ // vcsSafetyFlags should be stored as-is
+ }
+
+ void decanonize()
+ {
+ // vcsSafetyFlags should be stored as-is
+ }
+};
+
+#pragma pack(pop)
+
+// NvParameterized object header
+struct ObjHeader
+{
+ uint32_t dataOffset;
+ const char *className;
+ const char *name;
+ bool isIncluded;
+ uint32_t version;
+ uint32_t checksumSize;
+ const uint32_t *checksum;
+};
+
+// Element of root references table
+struct ObjectTableEntry
+{
+ Interface *obj;
+ const char *className;
+ const char *name;
+ const char *filename;
+};
+
+} // namespace NvParameterized
+
+#endif
diff --git a/APEX_1.4/NvParameterized/include/BinSerializer.h b/APEX_1.4/NvParameterized/include/BinSerializer.h
new file mode 100644
index 00000000..97306946
--- /dev/null
+++ b/APEX_1.4/NvParameterized/include/BinSerializer.h
@@ -0,0 +1,132 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2013 NVIDIA Corporation. All rights reserved.
+
+#ifndef PX_BIN_SERIALIZER_H
+#define PX_BIN_SERIALIZER_H
+
+// APB serializer
+
+// WARNING: before doing any changes to this file
+// check comments at the head of BinSerializer.cpp
+
+#include "nvparameterized/NvParameterized.h"
+#include "nvparameterized/NvSerializer.h"
+
+#include "AbstractSerializer.h"
+
+#include "ApbDefinitions.h"
+
+namespace NvParameterized
+{
+
+class DefinitionImpl;
+class PlatformInputStream;
+class PlatformOutputStream;
+struct PlatformABI;
+
+class BinSerializer : public AbstractSerializer
+{
+ // Methods for updating legacy formats
+ Serializer::ErrorType updateInitial2AllCounted(BinaryHeader &hdr, char *start);
+ Serializer::ErrorType updateAllCounted2WithAlignment(BinaryHeader &hdr, char *start);
+
+ Serializer::ErrorType readMetadataInfo(const BinaryHeader &hdr, PlatformInputStream &s, DefinitionImpl *def);
+
+ // Read array of arbitrary type (slow version)
+ Serializer::ErrorType readArraySlow(Handle &handle, PlatformInputStream &s);
+
+ // Read NvParameterized object data
+ Serializer::ErrorType readObject(NvParameterized::Interface *&obj, PlatformInputStream &data);
+
+ // Read binary data of NvParameterized object addressed by handle
+ Serializer::ErrorType readBinaryData(Handle &handle, PlatformInputStream &data);
+
+#ifndef WITHOUT_APEX_SERIALIZATION
+ Serializer::ErrorType storeMetadataInfo(const Definition *def, PlatformOutputStream &s);
+
+ // Store array of arbitrary type (slow version)
+ Serializer::ErrorType storeArraySlow(Handle &handle, PlatformOutputStream &s);
+
+ // Print binary data for part of NvParameterized object addressed by handle
+ Serializer::ErrorType storeBinaryData(const NvParameterized::Interface &obj, Handle &handle, PlatformOutputStream &res, bool isRootObject = true);
+#endif
+
+ BinSerializer(BinSerializer &); // Don't
+ void operator=(BinSerializer &); // Don't
+
+ Serializer::ErrorType verifyFileHeader(
+ const BinaryHeader &hdr,
+ const BinaryHeaderExt *ext,
+ uint32_t dataLen ) const;
+
+ Serializer::ErrorType getPlatformInfo(
+ BinaryHeader &hdr,
+ BinaryHeaderExt *ext,
+ PlatformABI &abi ) const;
+
+ Serializer::ErrorType verifyObjectHeader(const ObjHeader &hdr, const Interface *obj, Traits *traits) const;
+
+protected:
+
+ Serializer::ErrorType internalDeserialize(physx::PxFileBuf &stream, Serializer::DeserializedData &res, bool &doesNeedUpdate);
+ Serializer::ErrorType internalDeserializeInplace(void *mdata, uint32_t dataLen, Serializer::DeserializedData &res, bool &doesNeedUpdate);
+
+#ifndef WITHOUT_APEX_SERIALIZATION
+ Serializer::ErrorType internalSerialize(physx::PxFileBuf &stream,const NvParameterized::Interface **objs, uint32_t nobjs, bool doMetadata);
+#endif
+
+public:
+ BinSerializer(Traits *traits): AbstractSerializer(traits) {}
+
+ void release()
+ {
+ Traits *t = mTraits;
+ this->~BinSerializer();
+ serializerMemFree(this, t);
+ }
+
+ static const uint32_t Magic = APB_MAGIC;
+ static const uint32_t Version = BinVersions::WithExtendedHeader;
+
+ Serializer::ErrorType peekNumObjects(physx::PxFileBuf &stream, uint32_t &numObjects);
+
+ Serializer::ErrorType peekNumObjectsInplace(const void *data, uint32_t dataLen, uint32_t &numObjects);
+
+ Serializer::ErrorType peekClassNames(physx::PxFileBuf &stream, char **classNames, uint32_t &numClassNames);
+
+ Serializer::ErrorType peekInplaceAlignment(physx::PxFileBuf& stream, uint32_t& align);
+
+ Serializer::ErrorType deserializeMetadata(physx::PxFileBuf &stream, DeserializedMetadata &desData);
+};
+
+bool isBinaryFormat(physx::PxFileBuf &stream);
+
+Serializer::ErrorType peekBinaryPlatform(physx::PxFileBuf &stream, SerializePlatform &platform);
+
+} // namespace NvParameterized
+
+#endif
diff --git a/APEX_1.4/NvParameterized/include/BinaryHelper.h b/APEX_1.4/NvParameterized/include/BinaryHelper.h
new file mode 100644
index 00000000..15e56386
--- /dev/null
+++ b/APEX_1.4/NvParameterized/include/BinaryHelper.h
@@ -0,0 +1,290 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2013 NVIDIA Corporation. All rights reserved.
+
+#ifndef PX_SERIALIZE_BINARY_HELPER_H
+#define PX_SERIALIZE_BINARY_HELPER_H
+
+// WARNING: before doing any changes to this file
+// check comments at the head of BinSerializer.cpp
+
+#include "PxAssert.h"
+
+#include <PsArray.h>
+
+#include "nvparameterized/NvParameterized.h"
+#include "nvparameterized/NvParameterizedTraits.h"
+
+namespace NvParameterized
+{
+
+template<typename T> static PX_INLINE T NvMax3(T x, T y, T z)
+{
+ return physx::PxMax<T>(x, physx::PxMax<T>(y, z));
+}
+
+#ifndef offsetof
+# define offsetof(StructType, field) reinterpret_cast<size_t>(&((StructType *)0)->field)
+#endif
+
+// Alignment calculator
+template<typename T> class GetAlignment {
+ struct TestStruct {
+ char _;
+ T x;
+ };
+
+public:
+ static const size_t value = offsetof(struct TestStruct, x);
+};
+
+// Maps C type to NvParameterized::DataType
+template<typename T> struct GetDataType {
+ static const DataType value = NvParameterized::TYPE_UNDEFINED;
+};
+
+// Currently we only need to distinguish PxVec2 from other 64-bit stuff
+// (like uint64_t, int64_t, double, pointer) in SwapBytes
+
+template<> struct GetDataType <physx::PxVec2> {
+ static const DataType value = NvParameterized::TYPE_VEC2;
+};
+
+//Copied from NvApexStream
+PX_INLINE static bool IsBigEndian()
+{
+ uint32_t i = 1;
+ return 0 == *(char *)&i;
+}
+
+PX_INLINE static void SwapBytes(char *data, uint32_t size, NvParameterized::DataType type)
+{
+ // XDK compiler does not like switch here
+ if( 1 == size )
+ {
+ // Do nothing
+ }
+ else if( 2 == size )
+ {
+ char one_byte;
+ one_byte = data[0]; data[0] = data[1]; data[1] = one_byte;
+ }
+ else if( 4 == size )
+ {
+ char one_byte;
+ one_byte = data[0]; data[0] = data[3]; data[3] = one_byte;
+ one_byte = data[1]; data[1] = data[2]; data[2] = one_byte;
+ }
+ else if( 8 == size )
+ {
+ //Handling of PxVec2 agregate is different from 64-bit atomic types
+ if( TYPE_VEC2 == type )
+ {
+ //PxVec2 => swap each field separately
+ SwapBytes(data + 0, 4, TYPE_F32);
+ SwapBytes(data + 4, 4, TYPE_F32);
+ }
+ else
+ {
+ char one_byte;
+ one_byte = data[0]; data[0] = data[7]; data[7] = one_byte;
+ one_byte = data[1]; data[1] = data[6]; data[6] = one_byte;
+ one_byte = data[2]; data[2] = data[5]; data[5] = one_byte;
+ one_byte = data[3]; data[3] = data[4]; data[4] = one_byte;
+ }
+ }
+ else
+ {
+ //Generic algorithm for containers of float
+
+ const size_t elemSize = sizeof(float); //We assume that float sizes match on both platforms
+ PX_ASSERT( elemSize >= GetAlignment<float>::value ); //If alignment is non-trivial below algorithm will not work
+ PX_ASSERT( size > elemSize );
+
+ //Just swap all PxReals
+ for(size_t i = 0; i < size; i += elemSize)
+ SwapBytes(data + i, elemSize, TYPE_F32);
+ }
+}
+
+//Convert value to platform-independent format (network byte order)
+template<typename T> PX_INLINE static T Canonize(T x)
+{
+ if( !IsBigEndian() )
+ SwapBytes((char *)&x, sizeof(T), GetDataType<T>::value);
+
+ return x;
+}
+
+//Convert value to native format (from network byte order)
+template<typename T> PX_INLINE static T Decanonize(T x)
+{
+ return Canonize(x);
+}
+
+//Read platform-independent value from stream and convert it to native format
+template<typename T> static PX_INLINE T readAndConvert(const char *&p)
+{
+ T val;
+ memcpy((char *)&val, p, sizeof(T));
+ val = Decanonize(val);
+ p += sizeof(T);
+
+ return val;
+}
+
+//Byte array used for data serialization
+//TODO: replace this with Array?
+class StringBuf
+{
+ Traits *mTraits;
+ char *mData;
+ uint32_t mSize, mCapacity;
+
+ PX_INLINE void internalAppend(const char *data, uint32_t size, bool doCopy = true)
+ {
+ if( 0 == size )
+ return;
+
+ if( mCapacity < mSize + size )
+ reserve(physx::PxMax(mSize + size, 3 * mCapacity / 2));
+
+ if( doCopy )
+ memcpy(mData + mSize, data, size);
+ else
+ memset(mData + mSize, 0, size); //We want padding bytes filled with 0
+
+ mSize += size;
+ }
+
+public:
+
+ PX_INLINE StringBuf(Traits *traits)
+ : mTraits(traits), mData(0), mSize(0), mCapacity(0)
+ {}
+
+ PX_INLINE StringBuf(const StringBuf &s)
+ : mTraits(s.mTraits), mSize(s.mSize), mCapacity(s.mSize)
+ {
+ mData = (char *)mTraits->alloc(mSize);
+ memcpy(mData, s.mData, mSize);
+ }
+
+ PX_INLINE ~StringBuf() { mTraits->free((void *)mData); }
+
+ PX_INLINE void reserve(uint32_t newCapacity)
+ {
+ if( mCapacity >= newCapacity )
+ return;
+
+ char *newData = (char *)mTraits->alloc(newCapacity);
+ PX_ASSERT(newData);
+
+ if( mData )
+ {
+ memcpy(newData, mData, mSize);
+ mTraits->free(mData);
+ }
+
+ mData = newData;
+ mCapacity = newCapacity;
+ }
+
+ PX_INLINE char *getBuffer()
+ {
+ char *data = mData;
+
+ mSize = mCapacity = 0;
+ mData = 0;
+
+ return data;
+ }
+
+ PX_INLINE uint32_t size() const { return mSize; }
+
+ template< typename T > PX_INLINE void append(T x)
+ {
+ internalAppend((char *)&x, sizeof(T));
+ }
+
+ template< typename T > PX_INLINE void append(T *x)
+ {
+ PX_UNUSED(x);
+ PX_ASSERT(0 && "Unable to append pointer");
+ }
+
+ PX_INLINE void appendBytes(const char *data, uint32_t size) { internalAppend(data, size); }
+
+ PX_INLINE void skipBytes(uint32_t size) { internalAppend(0, size, false); }
+
+ PX_INLINE char &operator [](uint32_t i)
+ {
+ PX_ASSERT( i < mSize );
+ return mData[i];
+ }
+
+ PX_INLINE operator char *() { return mData; }
+
+ PX_INLINE operator const char *() const { return mData; }
+};
+
+//Dictionary of strings used for binary serialization
+class Dictionary
+{
+ struct Entry
+ {
+ const char *s;
+ uint32_t offset;
+ };
+
+ physx::shdfnd::Array<Entry, Traits::Allocator> entries; //TODO: use hash map after DE402 is fixed
+
+public:
+ Dictionary(Traits *traits_): entries(Traits::Allocator(traits_)) {}
+
+ uint32_t put(const char *s);
+
+ void setOffset(const char *s, uint32_t off);
+
+ PX_INLINE void setOffset(uint32_t i, uint32_t off) { setOffset(get(i), off); }
+
+ uint32_t getOffset(const char *s) const;
+
+ uint32_t getOffset(uint32_t i) const { return getOffset(get(i)); }
+
+ const char *get(uint32_t i) const { return entries[i].s; }
+
+ PX_INLINE uint32_t size() const { return entries.size(); }
+
+ void serialize(StringBuf &res) const;
+};
+
+//Binary file pretty-printer (mimics xxd)
+void dumpBytes(const char *data, uint32_t nbytes);
+
+}
+
+#endif
diff --git a/APEX_1.4/NvParameterized/include/NvDefaultTraits.h b/APEX_1.4/NvParameterized/include/NvDefaultTraits.h
new file mode 100644
index 00000000..ed70ed17
--- /dev/null
+++ b/APEX_1.4/NvParameterized/include/NvDefaultTraits.h
@@ -0,0 +1,503 @@
+#ifndef PX_MODULE_DEFAULT_TRAITS_H
+#define PX_MODULE_DEFAULT_TRAITS_H
+
+// overload new and delete operators
+#include "PsAllocator.h"
+
+// NxParameterized headers
+#include "nvparameterized/NvParameterized.h"
+#include "nvparameterized/NvParameterizedTraits.h"
+#include "PxAssert.h"
+#include "PxErrorCallback.h"
+
+// NsFoundation and NvFoundation
+#include "PsArray.h"
+#include "PsAlignedMalloc.h"
+#include "PxFoundation.h"
+
+// system
+#include <stdio.h>
+#include <stdint.h>
+
+namespace NvParameterized
+{
+ class DefaultTraits : public NvParameterized::Traits
+ {
+ public:
+ struct BehaviourFlags
+ {
+ enum Enum
+ {
+ CLEAN_FACTORIES = 0x1 << 0, ///< DefaultTraits is responsible destruct factories
+ CLEAN_CONVERTES = 0x1 << 1, ///< DefaultTraits is responsible destruct converters
+ COLLECT_ALLOCATE_OBJECTS = 0x1 << 2, ///< Collect allocated NvParameterized::Interface objects for profiling
+ WARN_IF_CONVERSION_HAPPENED = 0x1 << 3, ///< Emit warning if conversion happened
+
+
+ DEFAULT_POLICY = CLEAN_FACTORIES | CLEAN_CONVERTES,
+ };
+ };
+
+ protected:
+ struct ConversionInfo
+ {
+ ConversionInfo(::NvParameterized::Conversion* theConv = 0,
+ const char * theClassName = 0,
+ uint32_t theFrom = 0,
+ uint32_t theTo = 0)
+ : conv(theConv)
+ , className(theClassName)
+ , from(theFrom)
+ , to(theTo)
+ {}
+
+ ::NvParameterized::Conversion* conv;
+ const char * className;
+ uint32_t from;
+ uint32_t to;
+
+ bool operator == (const ConversionInfo& rhs)
+ {
+ // ignore "conv" field
+ return from == rhs.from && to == rhs.to && strcmp(className, rhs.className) == 0;
+ }
+ };
+
+ physx::shdfnd::Array<NvParameterized::Factory*> factories;
+ physx::shdfnd::Array<NvParameterized::Interface*> objects;
+ physx::shdfnd::Array<ConversionInfo> converters;
+
+ template <class T>
+ static T removeAndReturn(physx::shdfnd::Array<T>& ctr, uint32_t index)
+ {
+ T res = ctr[index];
+ ctr.remove(index);
+ return res;
+ }
+
+ bool findLastFactoryIndexByClassName(uint32_t& index, const char* className) const {
+ if (!className)
+ return false;
+ index = 0;
+ bool findSomeFactory = false;
+ for (uint32_t i = 0; i < factories.size(); ++i) {
+ if (const char* factoryClassName = factories[i]->getClassName())
+ {
+ if (strcmp(factoryClassName, className) == 0) {
+ if (!findSomeFactory || factories[i]->getVersion() > factories[index]->getVersion())
+ index = i;
+ findSomeFactory = true;
+ }
+ }
+ }
+ return findSomeFactory;
+ }
+
+ bool findFactoryIndexByClassNameAndVersion(uint32_t& index, const char* className, uint32_t version) const
+ {
+ if (!className)
+ return false;
+
+ for (uint32_t i = 0; i < factories.size(); ++i) {
+ if (const char* factoryClassName = factories[i]->getClassName())
+ {
+ if (strcmp(factoryClassName, className) == 0 && factories[i]->getVersion() == version)
+ {
+ index = i;
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ void unregisterAllFactories()
+ {
+ if ((behaviourPolicy & BehaviourFlags::CLEAN_FACTORIES) == 0)
+ return;
+
+ for (uint32_t i = 0; i < factories.size(); ++i)
+ {
+ factories[i]->freeParameterDefinitionTable(this);
+ delete factories[i];
+ }
+ factories.clear();
+ }
+
+ void unregisterAllConverters()
+ {
+ if ((behaviourPolicy & BehaviourFlags::CLEAN_CONVERTES) == 0)
+ return;
+
+ for (uint32_t i = 0; i < converters.size(); ++i)
+ {
+ converters[i].conv->release();
+ converters[i].conv = 0;
+ }
+ converters.clear();
+ }
+
+ protected:
+ uint32_t behaviourPolicy;
+
+ public:
+
+ DefaultTraits(uint32_t behaviourFlags)
+ : behaviourPolicy(behaviourFlags)
+ {
+ }
+
+ virtual ~DefaultTraits()
+ {
+ PX_ASSERT(objects.size() == 0);
+ unregisterAllFactories();
+ unregisterAllConverters();
+ }
+
+ virtual void registerFactory(::NvParameterized::Factory& factory)
+ {
+ if (!doesFactoryExist(factory.getClassName(), factory.getVersion()))
+ {
+ factories.pushBack(&factory);
+ }
+ else
+ {
+ PX_ASSERT_WITH_MESSAGE(0, "Factory has already exist");
+ }
+ }
+
+ virtual ::NvParameterized::Factory *removeFactory(const char * className)
+ {
+ uint32_t index = 0;
+ if (!findLastFactoryIndexByClassName(index, className))
+ return NULL;
+
+ ::NvParameterized::Factory* res = removeAndReturn(factories, index);
+ return res;
+ }
+
+ virtual ::NvParameterized::Factory *removeFactory(const char * className, uint32_t version)
+ {
+ uint32_t index = 0;
+ if (!findFactoryIndexByClassNameAndVersion(index, className, version))
+ return NULL;
+
+ ::NvParameterized::Factory* res = removeAndReturn(factories, index);
+ return res;
+ }
+
+ virtual bool doesFactoryExist(const char* className)
+ {
+ uint32_t index = 0;
+ return findLastFactoryIndexByClassName(index, className);
+ }
+
+ virtual bool doesFactoryExist(const char* className, uint32_t version)
+ {
+ uint32_t index = 0;
+ return findFactoryIndexByClassNameAndVersion(index, className, version);
+ }
+
+ virtual ::NvParameterized::Interface* createNvParameterized(const char * name)
+ {
+ uint32_t index = 0;
+ if (findLastFactoryIndexByClassName(index, name))
+ {
+ ::NvParameterized::Interface* result = factories[index]->create(this);
+ if (behaviourPolicy & BehaviourFlags::COLLECT_ALLOCATE_OBJECTS)
+ {
+ objects.pushBack(result);
+ }
+ return result;
+ }
+ return NULL;
+ }
+
+ virtual ::NvParameterized::Interface * createNvParameterized(const char * name, uint32_t ver)
+ {
+ uint32_t index = 0;
+ if (!findFactoryIndexByClassNameAndVersion(index, name, ver))
+ return NULL;
+ ::NvParameterized::Interface* result = factories[index]->create(this);
+
+ if (behaviourPolicy & BehaviourFlags::COLLECT_ALLOCATE_OBJECTS)
+ {
+ objects.pushBack(result);
+ }
+ return result;
+ }
+
+ virtual ::NvParameterized::Interface * finishNvParameterized(const char * name, void *obj, void *buf, int32_t *refCount)
+ {
+ uint32_t index = 0;
+ if (!findLastFactoryIndexByClassName(index, name))
+ return 0;
+ return factories[index]->finish(this, obj, buf, refCount);
+ }
+
+ virtual ::NvParameterized::Interface * finishNvParameterized( const char * name, uint32_t ver, void *obj, void *buf, int32_t *refCount )
+ {
+ uint32_t index = 0;
+ if (!findFactoryIndexByClassNameAndVersion(index, name, ver))
+ return 0;
+ return factories[index]->finish(this, obj, buf, refCount);
+ }
+
+ virtual uint32_t getCurrentVersion(const char *className) const {
+ uint32_t index = 0;
+ if (!findLastFactoryIndexByClassName(index, className))
+ return 0;
+ return factories[index]->getVersion();
+ }
+
+ virtual uint32_t getAlignment(const char *className, uint32_t classVersion) const
+ {
+ uint32_t index = 0;
+ if (!findFactoryIndexByClassNameAndVersion(index, className, classVersion))
+ return uint32_t(1);
+ return factories[index]->getAlignment();
+ }
+
+ virtual bool getNvParameterizedNames( const char ** names, uint32_t &outCount, uint32_t inCount) const
+ {
+ uint32_t currentOutSize = 0;
+ outCount = 0;
+ for (uint32_t i = 0; i < factories.size(); ++i)
+ {
+ const char* curClassName = factories[i]->getClassName();
+ bool foundClassName = false;
+ for (uint32_t j = 0; j < currentOutSize; ++j) {
+ if (strcmp(names[j], curClassName) == 0)
+ {
+ foundClassName = true;
+ break;
+ }
+ }
+
+ if (foundClassName)
+ continue;
+
+ if (outCount < inCount)
+ names[currentOutSize++] = factories[i]->getClassName();
+
+ outCount++;
+ }
+
+ return outCount <= inCount;
+ }
+
+ virtual bool getNvParameterizedVersions(const char* className, uint32_t* versions, uint32_t &outCount, uint32_t inCount) const
+ {
+ outCount = 0;
+ for (uint32_t i = 0; i < factories.size(); ++i) {
+ if (strcmp(factories[i]->getClassName(), className) == 0)
+ {
+ if (outCount < inCount)
+ versions[outCount] = factories[i]->getVersion();
+ outCount++;
+ }
+ }
+ return outCount <= inCount;
+ }
+
+
+ virtual void registerConversion(const char * className, uint32_t from, uint32_t to, ::NvParameterized::Conversion & conv)
+ {
+ ConversionInfo convInfo(&conv, className, from, to);
+ for (uint32_t i = 0; i < converters.size(); ++i)
+ {
+ if (converters[i] == convInfo)
+ {
+ PX_ASSERT_WITH_MESSAGE(false, "Conversion has already been registered");
+ return;
+ }
+ }
+ converters.pushBack(convInfo);
+ }
+
+ virtual ::NvParameterized::Conversion *removeConversion(const char * className, uint32_t from, uint32_t to)
+ {
+ ConversionInfo convInfo(NULL, className, from, to);
+ for (uint32_t i = 0; i < converters.size(); ++i) {
+ if (converters[i] == convInfo)
+ return removeAndReturn(converters, i).conv;
+ }
+ return NULL;
+ }
+
+ virtual bool updateLegacyNvParameterized(::NvParameterized::Interface &legacyObj, ::NvParameterized::Interface &obj)
+ {
+ // updateLegacyNvParameterized should not destroy legacyObj and obj. The code before this stackframe was responsible for it
+ if (legacyObj.version() > obj.version())
+ {
+ PX_ASSERT_WITH_MESSAGE(false, "Downgrade is not permited");
+ return false;
+ }
+
+ if (legacyObj.version() == obj.version())
+ {
+ PX_ASSERT_WITH_MESSAGE(false, "Object to upgrade already up to date version");
+ return false;
+ }
+
+ const char* legacyClassName = legacyObj.className();
+ const char* newClassName = obj.className();
+ if (!legacyClassName || !newClassName)
+ {
+ PX_ASSERT_WITH_MESSAGE(false, "updateLegacyNvParameterized get empty class names");
+ }
+
+ ::NvParameterized::Interface* prevObj = &legacyObj;
+ ::NvParameterized::Interface* nextObj = NULL;
+ bool res = true;
+
+ for (;prevObj->version() != obj.version() && res;)
+ {
+ // TODO: Here is the problem:
+ // We store our version in 32 bits - higher 16 bits store major version, lower 16 bits store minor version.
+ // If we agree on the fact that there are only 10 minor version (0-9) within one 1 major version, then this code should behave correctly
+ // otherwise there will be problems
+ const uint32_t version = prevObj->version();
+ uint32_t nextVersion = 0;
+ if ((version & 0xFFFF) == 9)
+ {
+ nextVersion = (((version & 0xFFFF0000) >> 16) + 1) << 16;
+ }
+ else
+ {
+ nextVersion = version + 1;
+ }
+ bool findConverter = false;
+
+ for (uint32_t i = 0; i < converters.size(); ++i)
+ {
+ if (strcmp(converters[i].className, legacyObj.className()) == 0 && converters[i].from == version)
+ {
+ if (converters[i].to == nextVersion || converters[i].to == version + 1)
+ {
+ if (converters[i].to == version + 1)
+ {
+ nextVersion = version + 1;
+ }
+ findConverter = true;
+
+ if (nextVersion == obj.version())
+ nextObj = &obj;
+ else
+ nextObj = createNvParameterized(legacyObj.className(), nextVersion);
+
+ if (behaviourPolicy & BehaviourFlags::WARN_IF_CONVERSION_HAPPENED)
+ {
+ char buff[512] = {0};
+ sprintf(buff, "Conversion %s,%i=>%i", legacyObj.className(), int(version), int(nextVersion));
+ traitsWarn(buff);
+ }
+
+ if (!(*converters[i].conv)(*prevObj, *nextObj))
+ {
+ res = false;
+ break;;
+ }
+
+ if (prevObj != &legacyObj && prevObj != &obj)
+ {
+ prevObj->destroy();
+ }
+ prevObj = nextObj;
+ nextObj = NULL;
+ }
+ }
+ }
+
+ if (!findConverter)
+ {
+ char buff[512] = {0};
+ sprintf(buff, "Needed conversion routine doesn't exist %s,%i=>%i !", legacyObj.className(), int(version), int(nextVersion));
+ PX_ASSERT_WITH_MESSAGE(false, buff);
+
+ break;
+ }
+ }
+
+ if (prevObj && prevObj != &legacyObj && prevObj != &obj)
+ prevObj->destroy();
+
+ if (nextObj && nextObj != &legacyObj && nextObj != &obj)
+ nextObj->destroy();
+
+ PX_ASSERT_WITH_MESSAGE(res, "Failed to upgrade NvParameterized::Interface");
+
+ return res;
+ }
+
+ virtual int32_t incRefCount(int32_t *refCount)
+ {
+ (*refCount)++;
+ return *refCount;
+ }
+
+ virtual int32_t decRefCount(int32_t *refCount)
+ {
+ (*refCount)--;
+ return *refCount;
+ }
+
+ virtual void *alloc(uint32_t nbytes)
+ {
+ return alloc(nbytes, 16);
+ }
+
+ virtual void *alloc(uint32_t nbytes, uint32_t align)
+ {
+ if (align <= 16)
+ {
+ return physx::shdfnd::AlignedAllocator<16>().allocate(nbytes, __FILE__, __LINE__);
+ }
+ else
+ {
+ switch (align){
+ case 32:
+ return physx::shdfnd::AlignedAllocator<32>().allocate(nbytes, __FILE__, __LINE__);
+ case 64:
+ return physx::shdfnd::AlignedAllocator<64>().allocate(nbytes, __FILE__, __LINE__);
+ case 128:
+ return physx::shdfnd::AlignedAllocator<128>().allocate(nbytes, __FILE__, __LINE__);
+ default:
+ PX_ASSERT_WITH_MESSAGE(false, "Unsupported alignment");
+ return 0;
+ }
+ }
+ }
+
+ virtual void free(void *buf)
+ {
+ physx::shdfnd::AlignedAllocator<16>().deallocate(buf);
+
+ if (behaviourPolicy & BehaviourFlags::COLLECT_ALLOCATE_OBJECTS)
+ {
+ // Try to find in objects
+ for (uint32_t i = 0; i < objects.size(); ++i)
+ {
+ if (objects[i] == reinterpret_cast<NvParameterized::Interface*>(buf))
+ {
+
+ objects.remove(i);
+ break;
+ }
+ }
+ }
+ }
+
+ virtual void traitsWarn(const char * msg) const
+ {
+ PxGetFoundation().getErrorCallback().reportError(physx::PxErrorCode::eDEBUG_WARNING, msg, __FILE__, __LINE__);
+ }
+
+ virtual void release(void)
+ {
+ delete this;
+ }
+ };
+}
+
+#endif
diff --git a/APEX_1.4/NvParameterized/include/NvParamConversionTemplate.h b/APEX_1.4/NvParameterized/include/NvParamConversionTemplate.h
new file mode 100644
index 00000000..fa363dfc
--- /dev/null
+++ b/APEX_1.4/NvParameterized/include/NvParamConversionTemplate.h
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
+ *
+ * NVIDIA CORPORATION and its licensors retain all intellectual property
+ * and proprietary rights in and to this software, related documentation
+ * and any modifications thereto. Any use, reproduction, disclosure or
+ * distribution of this software and related documentation without an express
+ * license agreement from NVIDIA CORPORATION is strictly prohibited.
+ */
+
+
+#ifndef NV_PARAMETERIZED_CONVERSION_TEMPLATE_H
+#define NV_PARAMETERIZED_CONVERSION_TEMPLATE_H
+
+#include <NvTraitsInternal.h>
+#include <nvparameterized/NvParameterizedTraits.h>
+
+namespace NvParameterized
+{
+/**
+\brief Class to handle all the redundant part of version upgrades.
+
+It verifies class names and versions, and it runs the default converter. The user may overload
+convert(), getPreferredVersions() and release() methods.
+*/
+template<typename Told, typename Tnew, uint32_t oldVersion, uint32_t newVersion>
+class ParamConversionTemplate : public NvParameterized::Conversion
+{
+public:
+ typedef Told TOldClass;
+ typedef Tnew TNewClass;
+
+ bool operator()(NvParameterized::Interface& legacyObj, NvParameterized::Interface& obj)
+ {
+ if (!mDefaultConversion)
+ {
+ mDefaultConversion = NvParameterized::internalCreateDefaultConversion(mTraits, getPreferredVersions());
+ }
+
+ // verify class names
+ if (physx::shdfnd::strcmp(legacyObj.className(), Told::staticClassName()) != 0)
+ {
+ return false;
+ }
+ if (physx::shdfnd::strcmp(obj.className(), Tnew::staticClassName()) != 0)
+ {
+ return false;
+ }
+
+ // verify version
+ if (legacyObj.version() != oldVersion)
+ {
+ return false;
+ }
+ if (obj.version() != newVersion)
+ {
+ return false;
+ }
+
+ //Copy unchanged fields
+ if (!(*mDefaultConversion)(legacyObj, obj))
+ {
+ return false;
+ }
+
+ mLegacyData = static_cast<Told*>(&legacyObj);
+ mNewData = static_cast<Tnew*>(&obj);
+
+ if (!convert())
+ {
+ return false;
+ }
+
+ NvParameterized::Handle invalidHandle(mNewData);
+ if (!mNewData->areParamsOK(&invalidHandle, 1))
+ {
+ if (invalidHandle.isValid())
+ {
+ char buf[256];
+ physx::shdfnd::strlcpy(buf, 256, "First invalid item: ");
+ invalidHandle.getLongName(buf + strlen("First invalid item: "), 256UL - static_cast<uint32_t>(strlen("First invalid item: ")));
+ mTraits->traitsWarn(buf);
+ }
+ return false;
+ }
+
+ return true;
+ }
+
+ /// User code, frees itself with the traits, and also calls destroy() on the ParamConversionTemplate object
+ virtual void release()
+ {
+ destroy();
+ mTraits->free(this);
+ }
+
+protected:
+ ParamConversionTemplate(NvParameterized::Traits* traits)
+ : mTraits(traits), mDefaultConversion(0), mLegacyData(0), mNewData(0)
+ {
+ // Virtual method getPreferredVersions() can not be called in constructors
+ // so we defer construction of mDefaultConversion
+ }
+
+ ~ParamConversionTemplate()
+ {
+ destroy();
+ }
+
+ /// User code, return list of preferred versions.
+ virtual const NvParameterized::PrefVer* getPreferredVersions() const
+ {
+ return 0;
+ }
+
+ /// User code, return true if conversion is successful.
+ virtual bool convert()
+ {
+ return true;
+ }
+
+ void destroy()
+ {
+ if (mDefaultConversion)
+ {
+ mDefaultConversion->release();
+ }
+ }
+
+
+ NvParameterized::Traits* mTraits;
+ NvParameterized::Conversion* mDefaultConversion;
+
+ Told* mLegacyData;
+ Tnew* mNewData;
+};
+}
+
+// Force inclusion of files with initParamRef before we redefine it below
+#include "nvparameterized/NvParameterized.h"
+#include "nvparameterized/NvParamUtils.h"
+#include "NvParameters.h"
+// Do not call initParamRef in converter - prefer Traits::createNvParameterized with explicit version
+// (see wiki for more details)
+#define initParamRef DO_NOT_USE_ME
+
+#endif // PARAM_CONVERSION_TEMPLATE_H
diff --git a/APEX_1.4/NvParameterized/include/NvParameters.h b/APEX_1.4/NvParameterized/include/NvParameters.h
new file mode 100644
index 00000000..7676cf48
--- /dev/null
+++ b/APEX_1.4/NvParameterized/include/NvParameters.h
@@ -0,0 +1,650 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2013 NVIDIA Corporation. All rights reserved.
+
+#ifndef PX_PARAMETERS_H
+#define PX_PARAMETERS_H
+
+#include "PsMutex.h"
+#include "PsAllocator.h"
+#include "PxAssert.h"
+#include "nvparameterized/NvParameterized.h"
+#include "NvParametersTypes.h"
+
+#define NV_PARAM_PLACEMENT_NEW(p, T) new(p) T
+
+namespace NvParameterized
+{
+ typedef physx::shdfnd::MutexT<physx::shdfnd::RawAllocator> MutexType;
+
+ const char *typeToStr(DataType type);
+ DataType strToType(const char *str);
+
+ PX_INLINE static bool IsAligned(const void *p, uint32_t border)
+ {
+ return !(reinterpret_cast<size_t>(p) % border); //size_t == uintptr_t
+ }
+
+ PX_INLINE static bool IsAligned(uint32_t x, uint32_t border)
+ {
+ return !(x % border);
+ }
+
+ // Used for associating useful info with parameters (e.g. min, max, step, etc...)
+ class HintImpl : public Hint
+ {
+ public:
+
+ HintImpl();
+ HintImpl(const char *name, uint64_t value);
+ HintImpl(const char *name, double value);
+ HintImpl(const char *name, const char *value);
+ virtual ~HintImpl();
+
+ void init(const char *name, uint64_t value, bool static_allocation = false);
+ void init(const char *name, double value, bool static_allocation = false);
+ void init(const char *name, const char *value, bool static_allocation = false);
+ void cleanup();
+
+ const char *name(void) const { return(mName); }
+ DataType type(void) const { return(mType); }
+
+ uint64_t asUInt(void) const;
+ double asFloat(void) const;
+ const char *asString(void) const;
+ bool setAsUInt(uint64_t v);
+
+ private:
+
+ bool mStaticAllocation;
+ char *mName;
+ DataType mType;
+
+ union
+ {
+ uint64_t mUIntValue;
+ double mFloatValue;
+ char *mStringValue;
+ };
+ };
+
+
+ class DefinitionImpl : public Definition
+ {
+ public:
+
+ DefinitionImpl(Traits &traits, bool staticAlloc = true);
+ DefinitionImpl(const char *name, DataType t, const char *structName, Traits &traits, bool staticAlloc = true);
+ virtual ~DefinitionImpl();
+
+ // can be used instead of the constructors and destructor
+ void init(const char *name, DataType t, const char *structName, bool static_allocation = false);
+ void cleanup(void);
+ void destroy();
+
+ const char *name(void) const
+ {
+ return(mName);
+ }
+ const char *longName(void) const { return(mLongName); }
+ const char *structName(void) const { return(mStructName); }
+ DataType type(void) const { return(mType); }
+ const char* typeString() const { return typeToStr(mType); }
+
+ int32_t arrayDimension(void) const;
+ int32_t arraySize(int32_t dimension = 0) const;
+ bool arraySizeIsFixed(void) const;
+ bool setArraySize(int32_t size); // -1 if the size is not fixed
+
+ bool isIncludedRef(void) const;
+
+ bool isLeaf(void) const { return(type() != TYPE_STRUCT && type() != TYPE_ARRAY); }
+
+ const Definition *parent(void) const { return(mParent); }
+ const Definition *root(void) const;
+
+ // Only used with parameters of TYPE_STRUCT or TYPE_ARRAY
+ int32_t numChildren(void) const;
+ const Definition *child(int32_t index) const;
+ const Definition *child(const char *name, int32_t &index) const; // only used with TYPE_STRUCT
+ void setChildren(Definition **children, int32_t n);
+ void addChild(Definition *child);
+
+ int32_t numHints(void) const;
+ const Hint *hint(int32_t index) const;
+ const Hint *hint(const char *name) const;
+ void setHints(const Hint **hints, int32_t n);
+ void addHint(Hint *hint);
+
+ int32_t numEnumVals(void) const;
+ int32_t enumValIndex( const char * enum_val ) const;
+
+ // The pointers returned by enumVal() are good for the lifetime of the DefinitionImpl object.
+ const char *enumVal(int32_t index) const;
+ void setEnumVals(const char **enum_vals, int32_t n);
+ void addEnumVal(const char *enum_val);
+
+
+ int32_t numRefVariants(void) const;
+ int32_t refVariantValIndex( const char * ref_val ) const;
+
+ // The pointers returned by refVariantVal() are good for the lifetime of the DefinitionImpl object.
+ const char * refVariantVal(int32_t index) const;
+ void setRefVariantVals(const char **ref_vals, int32_t n);
+ void addRefVariantVal(const char *ref_val);
+
+ uint32_t alignment(void) const;
+ void setAlignment(uint32_t align);
+
+ uint32_t padding(void) const;
+ void setPadding(uint32_t align);
+
+ void setDynamicHandleIndicesMap(const uint8_t *indices, uint32_t numIndices);
+ const uint8_t * getDynamicHandleIndicesMap(uint32_t &outNumIndices) const;
+
+ bool isSimpleType(bool simpleStructs, bool simpleStrings) const;
+
+ private:
+
+ enum { MAX_NAME_LEN = 256 };
+
+ void setDefaults(void);
+
+ bool mStaticAllocation;
+
+ const char * mName;
+ const char * mLongName;
+ const char * mStructName;
+ DataType mType;
+ int32_t mArraySize;
+
+ DefinitionImpl *mParent;
+
+ int32_t mNumChildren;
+ Definition **mChildren;
+
+ int32_t mNumHints;
+ HintImpl **mHints;
+
+ int32_t mNumEnumVals;
+ char **mEnumVals;
+
+ int32_t mNumRefVariants;
+ char **mRefVariantVals;
+
+ Traits *mTraits;
+ bool mLongNameAllocated;
+
+ uint32_t mAlign;
+ uint32_t mPad;
+
+ uint32_t mNumDynamicHandleIndices;
+ const uint8_t *mDynamicHandleIndices;
+ };
+
+ // Used by generated code
+ struct ParamLookupNode
+ {
+ NvParameterized::DataType type;
+ bool isDynamicArrayRoot;
+ size_t offset;
+ const size_t* children;
+ int numChildren;
+ };
+
+ //Constructs temporary object and extract vptr
+ template<typename T, size_t T_align>
+ const char* getVptr()
+ {
+ char buf[T_align + sizeof(T)];
+
+ // We want all isAllocated false
+ memset(buf, false, sizeof(buf));
+
+ // Align
+ char* bufAligned = (char*)((size_t)(buf + T_align) & ~(T_align - 1));
+
+ // Call "fast" constructor (buf and refCount != NULL)
+ // which does not allocate members
+ T* tmp = NV_PARAM_PLACEMENT_NEW(bufAligned, T)(0, reinterpret_cast<void*>(16), reinterpret_cast<int32_t*>(16));
+
+ // vptr is usually stored at the beginning of object...
+ const char* vptr = *reinterpret_cast<const char**>(tmp);
+
+ //Cleanup
+ tmp->~T();
+
+ return vptr;
+ }
+
+class NvParameters : public NvParameterized::Interface
+{
+public:
+
+ NvParameters(Traits *traits, void *buf = 0, int32_t *refCount = 0); //Long form is used for inplace objects
+ virtual ~NvParameters();
+
+ // placement delete
+ virtual void destroy();
+ virtual void initDefaults(void) { }
+ virtual void initRandom(void);
+
+ virtual const char * className(void) const { return mClassName; }
+ virtual void setClassName(const char *name);
+
+ virtual const char * name(void) const { return mName; }
+ virtual void setName(const char *name);
+
+ virtual uint32_t version(void) const { return 0; }
+ virtual uint16_t getMajorVersion(void) const;
+ virtual uint16_t getMinorVersion(void) const;
+
+ virtual const uint32_t * checksum(uint32_t &bits) const
+ {
+ bits = 0;
+ return 0;
+ }
+
+ int32_t numParameters(void);
+ const Definition *parameterDefinition(int32_t index);
+
+ const Definition *rootParameterDefinition(void);
+ const Definition *rootParameterDefinition(void) const;
+
+ // Given a long name like "mystruct.somearray[10].foo", it will return
+ // a handle to that specific parameter. The handle can then be used to
+ // set/get values, as long as it's a handle to a leaf node.
+ virtual ErrorType getParameterHandle(const char *long_name, Handle &handle) const;
+ virtual ErrorType getParameterHandle(const char *long_name, Handle &handle);
+
+ virtual void setSerializationCallback(SerializationCallback *cb, void *userData = NULL);
+ virtual ErrorType callPreSerializeCallback() const;
+
+ ErrorType initParamRef(const Handle &handle, const char *chosenRefStr = 0, bool doDestroyOld = false);
+
+ // These functions wrap the raw(Get|Set)XXXXX() methods. They deal with
+ // error handling and casting.
+ ErrorType getParamBool(const Handle &handle, bool &val) const;
+ ErrorType setParamBool(const Handle &handle, bool val);
+ ErrorType getParamBoolArray(const Handle &handle, bool *array, int32_t n, int32_t offset = 0) const;
+ ErrorType setParamBoolArray(const Handle &handle, const bool *array, int32_t n, int32_t offset= 0);
+
+ ErrorType getParamString(const Handle &handle, const char *&val) const;
+ ErrorType setParamString(const Handle &handle, const char *val);
+ ErrorType getParamStringArray(const Handle &handle, char **array, int32_t n, int32_t offset = 0) const;
+ ErrorType setParamStringArray(const Handle &handle, const char **array, int32_t n, int32_t offset= 0);
+
+ ErrorType getParamEnum(const Handle &handle, const char *&val) const;
+ ErrorType setParamEnum(const Handle &handle, const char *val);
+ ErrorType getParamEnumArray(const Handle &handle, char **array, int32_t n, int32_t offset = 0) const;
+ ErrorType setParamEnumArray(const Handle &handle, const char **array, int32_t n, int32_t offset= 0);
+
+ ErrorType getParamRef(const Handle &handle, NvParameterized::Interface *&val) const;
+ ErrorType setParamRef(const Handle &handle, NvParameterized::Interface * val, bool doDestroyOld = false);
+ ErrorType getParamRefArray(const Handle &handle, NvParameterized::Interface **array, int32_t n, int32_t offset = 0) const;
+ ErrorType setParamRefArray(const Handle &handle, /*const*/ NvParameterized::Interface **array, int32_t n, int32_t offset = 0, bool doDestroyOld = false);
+
+ ErrorType getParamI8(const Handle &handle, int8_t &val) const;
+ ErrorType setParamI8(const Handle &handle, int8_t val);
+ ErrorType getParamI8Array(const Handle &handle, int8_t *array, int32_t n, int32_t offset = 0) const;
+ ErrorType setParamI8Array(const Handle &handle, const int8_t *val, int32_t n, int32_t offset= 0);
+
+ ErrorType getParamI16(const Handle &handle, int16_t &val) const;
+ ErrorType setParamI16(const Handle &handle, int16_t val);
+ ErrorType getParamI16Array(const Handle &handle, int16_t *array, int32_t n, int32_t offset = 0) const;
+ ErrorType setParamI16Array(const Handle &handle, const int16_t *val, int32_t n, int32_t offset= 0);
+
+ ErrorType getParamI32(const Handle &handle, int32_t &val) const;
+ ErrorType setParamI32(const Handle &handle, int32_t val);
+ ErrorType getParamI32Array(const Handle &handle, int32_t *array, int32_t n, int32_t offset = 0) const;
+ ErrorType setParamI32Array(const Handle &handle, const int32_t *val, int32_t n, int32_t offset= 0);
+
+ ErrorType getParamI64(const Handle &handle, int64_t &val) const;
+ ErrorType setParamI64(const Handle &handle, int64_t val);
+ ErrorType getParamI64Array(const Handle &handle, int64_t *array, int32_t n, int32_t offset = 0) const;
+ ErrorType setParamI64Array(const Handle &handle, const int64_t *val, int32_t n, int32_t offset= 0);
+
+ ErrorType getParamU8(const Handle &handle, uint8_t &val) const;
+ ErrorType setParamU8(const Handle &handle, uint8_t val);
+ ErrorType getParamU8Array(const Handle &handle, uint8_t *array, int32_t n, int32_t offset = 0) const;
+ ErrorType setParamU8Array(const Handle &handle, const uint8_t *val, int32_t n, int32_t offset= 0);
+
+ ErrorType getParamU16(const Handle &handle, uint16_t &val) const;
+ ErrorType setParamU16(const Handle &handle, uint16_t val);
+ ErrorType getParamU16Array(const Handle &handle, uint16_t *array, int32_t n, int32_t offset = 0) const;
+ ErrorType setParamU16Array(const Handle &handle, const uint16_t *array, int32_t n, int32_t offset= 0);
+
+ ErrorType getParamU32(const Handle &handle, uint32_t &val) const;
+ ErrorType setParamU32(const Handle &handle, uint32_t val);
+ ErrorType getParamU32Array(const Handle &handle, uint32_t *array, int32_t n, int32_t offset = 0) const;
+ ErrorType setParamU32Array(const Handle &handle, const uint32_t *array, int32_t n, int32_t offset= 0);
+
+ ErrorType getParamU64(const Handle &handle, uint64_t &val) const;
+ ErrorType setParamU64(const Handle &handle, uint64_t val);
+ ErrorType getParamU64Array(const Handle &handle, uint64_t *array, int32_t n, int32_t offset = 0) const;
+ ErrorType setParamU64Array(const Handle &handle, const uint64_t *array, int32_t n, int32_t offset= 0);
+
+ ErrorType getParamF32(const Handle &handle, float &val) const;
+ ErrorType setParamF32(const Handle &handle, float val);
+ ErrorType getParamF32Array(const Handle &handle, float *array, int32_t n, int32_t offset = 0) const;
+ ErrorType setParamF32Array(const Handle &handle, const float *array, int32_t n, int32_t offset= 0);
+
+ ErrorType getParamF64(const Handle &handle, double &val) const;
+ ErrorType setParamF64(const Handle &handle, double val);
+ ErrorType getParamF64Array(const Handle &handle, double *array, int32_t n, int32_t offset = 0) const;
+ ErrorType setParamF64Array(const Handle &handle, const double *array, int32_t n, int32_t offset= 0);
+
+ ErrorType setParamVec2(const Handle &handle, const physx::PxVec2 &val);
+ ErrorType getParamVec2(const Handle &handle, physx::PxVec2 &val) const;
+ ErrorType getParamVec2Array(const Handle &handle, physx::PxVec2 *array, int32_t n, int32_t offset = 0) const;
+ ErrorType setParamVec2Array(const Handle &handle, const physx::PxVec2 *array, int32_t n, int32_t offset= 0);
+
+ ErrorType setParamVec3(const Handle &handle, const physx::PxVec3 &val);
+ ErrorType getParamVec3(const Handle &handle, physx::PxVec3 &val) const;
+ ErrorType getParamVec3Array(const Handle &handle, physx::PxVec3 *array, int32_t n, int32_t offset = 0) const;
+ ErrorType setParamVec3Array(const Handle &handle, const physx::PxVec3 *array, int32_t n, int32_t offset= 0);
+
+ ErrorType setParamVec4(const Handle &handle, const physx::PxVec4 &val);
+ ErrorType getParamVec4(const Handle &handle, physx::PxVec4 &val) const;
+ ErrorType getParamVec4Array(const Handle &handle, physx::PxVec4 *array, int32_t n, int32_t offset = 0) const;
+ ErrorType setParamVec4Array(const Handle &handle, const physx::PxVec4 *array, int32_t n, int32_t offset= 0);
+
+ ErrorType setParamQuat(const Handle &handle, const physx::PxQuat &val);
+ ErrorType getParamQuat(const Handle &handle, physx::PxQuat &val) const;
+ ErrorType getParamQuatArray(const Handle &handle, physx::PxQuat *array, int32_t n, int32_t offset = 0) const;
+ ErrorType setParamQuatArray(const Handle &handle, const physx::PxQuat *array, int32_t n, int32_t offset= 0);
+
+ ErrorType setParamMat33(const Handle &handle, const physx::PxMat33 &val);
+ ErrorType getParamMat33(const Handle &handle, physx::PxMat33 &val) const;
+ ErrorType getParamMat33Array(const Handle &handle, physx::PxMat33 *array, int32_t n, int32_t offset = 0) const;
+ ErrorType setParamMat33Array(const Handle &handle, const physx::PxMat33 *array, int32_t n, int32_t offset= 0);
+
+ ErrorType setParamMat34Legacy(const Handle &handle, const float (&val)[12]);
+ ErrorType getParamMat34Legacy(const Handle &handle, float (&val)[12]) const;
+ ErrorType getParamMat34LegacyArray(const Handle &handle, float *array, int32_t n, int32_t offset = 0) const;
+ ErrorType setParamMat34LegacyArray(const Handle &handle, const float *array, int32_t n, int32_t offset = 0);
+
+ ErrorType setParamMat44(const Handle &handle, const physx::PxMat44 &val);
+ ErrorType getParamMat44(const Handle &handle, physx::PxMat44 &val) const;
+ ErrorType getParamMat44Array(const Handle &handle, physx::PxMat44 *array, int32_t n, int32_t offset = 0) const;
+ ErrorType setParamMat44Array(const Handle &handle, const physx::PxMat44 *array, int32_t n, int32_t offset= 0);
+
+ ErrorType setParamBounds3(const Handle &handle, const physx::PxBounds3 &val);
+ ErrorType getParamBounds3(const Handle &handle, physx::PxBounds3 &val) const;
+ ErrorType getParamBounds3Array(const Handle &handle, physx::PxBounds3 *array, int32_t n, int32_t offset = 0) const;
+ ErrorType setParamBounds3Array(const Handle &handle, const physx::PxBounds3 *array, int32_t n, int32_t offset= 0);
+
+ ErrorType setParamTransform(const Handle &handle, const physx::PxTransform &val);
+ ErrorType getParamTransform(const Handle &handle, physx::PxTransform &val) const;
+ ErrorType getParamTransformArray(const Handle &handle, physx::PxTransform *array, int32_t n, int32_t offset = 0) const;
+ ErrorType setParamTransformArray(const Handle &handle, const physx::PxTransform *array, int32_t n, int32_t offset= 0);
+
+ ErrorType valueToStr(const Handle &array_handle, char *str, uint32_t n, const char *&ret);
+ ErrorType strToValue(Handle &handle,const char *str,const char **endptr); // assigns this string to the value
+
+ ErrorType resizeArray(const Handle &array_handle, int32_t new_size);
+ ErrorType getArraySize(const Handle &array_handle, int32_t &size, int32_t dimension = 0) const;
+ ErrorType swapArrayElements(const Handle &array_handle, uint32_t firstElement, uint32_t secondElement);
+
+ bool equals(const NvParameterized::Interface &obj, Handle* handleOfInequality, uint32_t numHandlesOfInequality, bool doCompareNotSerialized = true) const;
+
+ bool areParamsOK(Handle *invalidHandles = NULL, uint32_t numInvalidHandles = 0);
+
+ ErrorType copy(const NvParameterized::Interface &other);
+
+ ErrorType clone(NvParameterized::Interface *&obj) const;
+
+ static physx::PxVec2 getVec2(const char *str, const char **endptr);
+ static physx::PxVec3 getVec3(const char *str, const char **endptr);
+ static physx::PxVec4 getVec4(const char *str, const char **endptr);
+ static physx::PxQuat getQuat(const char *str, const char **endptr);
+ static physx::PxMat33 getMat33(const char *str, const char **endptr);
+ static void getMat34Legacy(const char *str, const char **endptr, float (&val)[12]);
+ static physx::PxMat44 getMat44(const char *str, const char **endptr);
+ static physx::PxBounds3 getBounds3(const char *str, const char **endptr);
+ static physx::PxTransform getTransform(const char *str, const char **endptr);
+
+ static physx::PxVec2 init(float x,float y);
+ static physx::PxVec3 init(float x,float y,float z);
+ static physx::PxVec4 initVec4(float x,float y,float z,float w);
+ static physx::PxQuat init(float x,float y,float z,float w);
+ static physx::PxMat33 init(float _11,float _12,float _13,float _21,float _22,float _23,float _31,float _32,float _33);
+ static physx::PxMat44 init(float _11,float _12,float _13,float _14,float _21,float _22,float _23,float _24,float _31,float _32,float _33,float _34,float _41,float _42,float _43,float _44);
+ static physx::PxBounds3 init(float minx,float miny,float minz,float maxx,float maxy,float maxz);
+ static physx::PxTransform init(float x,float y,float z,float qx,float qy,float qz,float qw);
+
+ static int32_t MultIntArray(const int32_t *array, int32_t n);
+ static ErrorType resizeArray(Traits *parameterizedTraits,
+ void *&buf,
+ int32_t *array_sizes,
+ int32_t dimension,
+ int32_t resize_dim,
+ int32_t new_size,
+ bool doFree,
+ int32_t element_size,
+ uint32_t element_align,
+ bool &isMemAllocated);
+ static void recursiveCopy(const void *src,
+ const int32_t *src_sizes,
+ void *dst,
+ const int32_t *dst_sizes,
+ int32_t dimension,
+ int32_t element_size,
+ int32_t *indexes = NULL,
+ int32_t level = 0);
+
+ virtual void getVarPtr(const Handle &, void *&ptr, size_t &offset) const
+ {
+ PX_ALWAYS_ASSERT();
+ ptr = 0;
+ offset = 0;
+ }
+
+ Traits * getTraits(void) const
+ {
+ return mParameterizedTraits;
+ }
+
+ virtual bool checkAlignments() const;
+
+protected:
+
+ void *getVarPtrHelper(const ParamLookupNode *rootNode, void *paramStruct, const Handle &handle, size_t &offset) const;
+
+ static void destroy(NvParameters *obj, NvParameterized::Traits *traits, bool doDeallocateSelf, int32_t *refCount, void *buf);
+
+ // All classes deriving from NvParameterized must overload this function. It
+ // returns the parameter definition tree. The root node must be a struct
+ // with an empty string for its name.
+ virtual const Definition *getParameterDefinitionTree(void) {return NULL;}
+ virtual const Definition *getParameterDefinitionTree(void) const {return NULL;}
+
+ ErrorType releaseDownsizedParameters(const Handle &handle, int newSize, int oldSize);
+ ErrorType initNewResizedParameters(const Handle &handle, int newSize, int oldSize);
+ virtual ErrorType rawResizeArray(const Handle &handle, int new_size);
+ virtual ErrorType rawGetArraySize(const Handle &array_handle, int &size, int dimension) const;
+ virtual ErrorType rawSwapArrayElements(const Handle &array_handle, unsigned int firstElement, unsigned int secondElement);
+
+ // The methods for the types that are supported by the class deriving from
+ // NvParameterized must be overloaded.
+ virtual ErrorType rawSetParamBool(const Handle &handle, bool val);
+ virtual ErrorType rawGetParamBool(const Handle &handle, bool &val) const;
+ virtual ErrorType rawGetParamBoolArray(const Handle &handle, bool *array, int32_t n, int32_t offset) const;
+ virtual ErrorType rawSetParamBoolArray(const Handle &handle, const bool *array, int32_t n, int32_t offset);
+
+ virtual ErrorType rawGetParamString(const Handle &handle, const char *&val) const;
+ virtual ErrorType rawSetParamString(const Handle &handle, const char *val);
+ virtual ErrorType rawGetParamStringArray(const Handle &handle, char **array, int32_t n, int32_t offset) const;
+ virtual ErrorType rawSetParamStringArray(const Handle &handle, const char **array, int32_t n, int32_t offset);
+
+ virtual ErrorType rawGetParamEnum(const Handle &handle, const char *&val) const;
+ virtual ErrorType rawSetParamEnum(const Handle &handle, const char *val);
+ virtual ErrorType rawGetParamEnumArray(const Handle &handle, char **array, int32_t n, int32_t offset) const;
+ virtual ErrorType rawSetParamEnumArray(const Handle &handle, const char **array, int32_t n, int32_t offset);
+
+ virtual ErrorType rawGetParamRef(const Handle &handle, NvParameterized::Interface *&val) const;
+ virtual ErrorType rawSetParamRef(const Handle &handle, NvParameterized::Interface * val);
+ virtual ErrorType rawGetParamRefArray(const Handle &handle, NvParameterized::Interface **array, int32_t n, int32_t offset) const;
+ virtual ErrorType rawSetParamRefArray(const Handle &handle, /*const*/ NvParameterized::Interface **array, int32_t n, int32_t offset);
+
+ virtual ErrorType rawGetParamI8(const Handle &handle, int8_t &val) const;
+ virtual ErrorType rawSetParamI8(const Handle &handle, int8_t val);
+ virtual ErrorType rawGetParamI8Array(const Handle &handle, int8_t *array, int32_t n, int32_t offset) const;
+ virtual ErrorType rawSetParamI8Array(const Handle &handle, const int8_t *array, int32_t n, int32_t offset);
+
+ virtual ErrorType rawGetParamI16(const Handle &handle, int16_t &val) const;
+ virtual ErrorType rawSetParamI16(const Handle &handle, int16_t val);
+ virtual ErrorType rawGetParamI16Array(const Handle &handle, int16_t *array, int32_t n, int32_t offset) const;
+ virtual ErrorType rawSetParamI16Array(const Handle &handle, const int16_t *array, int32_t n, int32_t offset);
+
+ virtual ErrorType rawGetParamI32(const Handle &handle, int32_t &val) const;
+ virtual ErrorType rawSetParamI32(const Handle &handle, int32_t val);
+ virtual ErrorType rawGetParamI32Array(const Handle &handle, int32_t *array, int32_t n, int32_t offset) const;
+ virtual ErrorType rawSetParamI32Array(const Handle &handle, const int32_t *array, int32_t n, int32_t offset);
+
+ virtual ErrorType rawGetParamI64(const Handle &handle, int64_t &val) const;
+ virtual ErrorType rawSetParamI64(const Handle &handle, int64_t val);
+ virtual ErrorType rawGetParamI64Array(const Handle &handle, int64_t *array, int32_t n, int32_t offset) const;
+ virtual ErrorType rawSetParamI64Array(const Handle &handle, const int64_t *array, int32_t n, int32_t offset);
+
+
+ virtual ErrorType rawGetParamU8(const Handle &handle, uint8_t &val) const;
+ virtual ErrorType rawSetParamU8(const Handle &handle, uint8_t val);
+ virtual ErrorType rawGetParamU8Array(const Handle &handle, uint8_t *array, int32_t n, int32_t offset) const;
+ virtual ErrorType rawSetParamU8Array(const Handle &handle, const uint8_t *array, int32_t n, int32_t offset);
+
+ virtual ErrorType rawGetParamU16(const Handle &handle, uint16_t &val) const;
+ virtual ErrorType rawSetParamU16(const Handle &handle, uint16_t val);
+ virtual ErrorType rawGetParamU16Array(const Handle &handle, uint16_t *array, int32_t n, int32_t offset) const;
+ virtual ErrorType rawSetParamU16Array(const Handle &handle, const uint16_t *array, int32_t n, int32_t offset);
+
+ virtual ErrorType rawGetParamU32(const Handle &handle, uint32_t &val) const;
+ virtual ErrorType rawSetParamU32(const Handle &handle, uint32_t val);
+ virtual ErrorType rawGetParamU32Array(const Handle &handle, uint32_t *array, int32_t n, int32_t offset) const;
+ virtual ErrorType rawSetParamU32Array(const Handle &handle, const uint32_t *array, int32_t n, int32_t offset);
+
+ virtual ErrorType rawSetParamU64(const Handle &handle, uint64_t val);
+ virtual ErrorType rawGetParamU64(const Handle &handle, uint64_t &val) const;
+ virtual ErrorType rawGetParamU64Array(const Handle &handle, uint64_t *array, int32_t n, int32_t offset) const;
+ virtual ErrorType rawSetParamU64Array(const Handle &handle, const uint64_t *array, int32_t n, int32_t offset);
+
+ virtual ErrorType rawGetParamF32(const Handle &handle, float &val) const;
+ virtual ErrorType rawSetParamF32(const Handle &handle, float val);
+ virtual ErrorType rawGetParamF32Array(const Handle &handle, float *array, int32_t n, int32_t offset) const;
+ virtual ErrorType rawSetParamF32Array(const Handle &handle, const float *array, int32_t n, int32_t offset);
+
+ virtual ErrorType rawGetParamF64(const Handle &handle, double &val) const;
+ virtual ErrorType rawSetParamF64(const Handle &handle, double val);
+ virtual ErrorType rawGetParamF64Array(const Handle &handle, double *array, int32_t n, int32_t offset) const;
+ virtual ErrorType rawSetParamF64Array(const Handle &handle, const double *array, int32_t n, int32_t offset);
+
+ virtual ErrorType rawSetParamVec2(const Handle &handle,physx::PxVec2 val);
+ virtual ErrorType rawGetParamVec2(const Handle &handle,physx::PxVec2 &val) const;
+ virtual ErrorType rawGetParamVec2Array(const Handle &handle,physx::PxVec2 *array, int32_t n, int32_t offset) const;
+ virtual ErrorType rawSetParamVec2Array(const Handle &handle, const physx::PxVec2 *array, int32_t n, int32_t offset);
+
+ virtual ErrorType rawSetParamVec3(const Handle &handle,physx::PxVec3 val);
+ virtual ErrorType rawGetParamVec3(const Handle &handle,physx::PxVec3 &val) const;
+ virtual ErrorType rawGetParamVec3Array(const Handle &handle,physx::PxVec3 *array, int32_t n, int32_t offset) const;
+ virtual ErrorType rawSetParamVec3Array(const Handle &handle, const physx::PxVec3 *array, int32_t n, int32_t offset);
+
+ virtual ErrorType rawSetParamVec4(const Handle &handle,physx::PxVec4 val);
+ virtual ErrorType rawGetParamVec4(const Handle &handle,physx::PxVec4 &val) const;
+ virtual ErrorType rawGetParamVec4Array(const Handle &handle,physx::PxVec4 *array, int32_t n, int32_t offset) const;
+ virtual ErrorType rawSetParamVec4Array(const Handle &handle, const physx::PxVec4 *array, int32_t n, int32_t offset);
+
+ virtual ErrorType rawSetParamQuat(const Handle &handle,physx::PxQuat val);
+ virtual ErrorType rawGetParamQuat(const Handle &handle,physx::PxQuat &val) const;
+ virtual ErrorType rawGetParamQuatArray(const Handle &handle,physx::PxQuat *array, int32_t n, int32_t offset) const;
+ virtual ErrorType rawSetParamQuatArray(const Handle &handle, const physx::PxQuat *array, int32_t n, int32_t offset);
+
+ virtual ErrorType rawSetParamMat33(const Handle &handle,physx::PxMat33 val);
+ virtual ErrorType rawGetParamMat33(const Handle &handle,physx::PxMat33 &val) const;
+ virtual ErrorType rawGetParamMat33Array(const Handle &handle,physx::PxMat33 *array, int32_t n, int32_t offset) const;
+ virtual ErrorType rawSetParamMat33Array(const Handle &handle, const physx::PxMat33 *array, int32_t n, int32_t offset);
+
+ virtual ErrorType rawSetParamMat44(const Handle &handle,physx::PxMat44 val);
+ virtual ErrorType rawGetParamMat44(const Handle &handle,physx::PxMat44 &val) const;
+ virtual ErrorType rawGetParamMat44Array(const Handle &handle,physx::PxMat44 *array, int32_t n, int32_t offset) const;
+ virtual ErrorType rawSetParamMat44Array(const Handle &handle, const physx::PxMat44 *array, int32_t n, int32_t offset);
+
+ virtual ErrorType rawSetParamMat34Legacy(const Handle &handle,const float (&val)[12]);
+ virtual ErrorType rawGetParamMat34Legacy(const Handle &handle,float (&val)[12]) const;
+ virtual ErrorType rawGetParamMat34LegacyArray(const Handle &handle, float *array, int32_t n, int32_t offset) const;
+ virtual ErrorType rawSetParamMat34LegacyArray(const Handle &handle, const float *array, int32_t n, int32_t offset);
+
+ virtual ErrorType rawSetParamBounds3(const Handle &handle,physx::PxBounds3 val);
+ virtual ErrorType rawGetParamBounds3(const Handle &handle,physx::PxBounds3 &val) const;
+ virtual ErrorType rawGetParamBounds3Array(const Handle &handle,physx::PxBounds3 *array, int32_t n, int32_t offset) const;
+ virtual ErrorType rawSetParamBounds3Array(const Handle &handle, const physx::PxBounds3 *array, int32_t n, int32_t offset);
+
+ virtual ErrorType rawSetParamTransform(const Handle &handle,physx::PxTransform val);
+ virtual ErrorType rawGetParamTransform(const Handle &handle,physx::PxTransform &val) const;
+ virtual ErrorType rawGetParamTransformArray(const Handle &handle,physx::PxTransform *array, int32_t n, int32_t offset) const;
+ virtual ErrorType rawSetParamTransformArray(const Handle &handle, const physx::PxTransform *array, int32_t n, int32_t offset);
+
+ // WARNING!
+ // Binary deserializer relies on layout of fields
+ // If you change anything be sure to update it as well
+
+ Traits *mParameterizedTraits;
+ SerializationCallback *mSerializationCb;
+ void *mCbUserData;
+ void *mBuffer;
+ int32_t *mRefCount;
+ const char *mName;
+ const char *mClassName;
+ bool mDoDeallocateSelf; //if true - memory should be deallocated in destroy()
+ bool mDoDeallocateName; //if true - mName is in inplace-buffer and should not be freed
+ bool mDoDeallocateClassName; //see comment for mDoDeallocateName
+
+private:
+
+ void initRandom(NvParameterized::Handle& handle);
+
+ bool equals(const NvParameterized::Interface &obj,
+ Handle &param_handle,
+ Handle *handlesOfInequality,
+ uint32_t numHandlesOfInequality,
+ bool doCompareNotSerialized) const;
+
+ bool checkAlignments(Handle &param_handle) const;
+
+ bool areParamsOK(Handle &handle, Handle *invalidHandles, uint32_t numInvalidHandles, uint32_t &numRemainingHandles);
+
+ ErrorType copy(const NvParameterized::Interface &other,
+ Handle &param_handle);
+
+ // recursively call pre serialization callback
+ ErrorType callPreSerializeCallback(Handle& handle) const;
+
+ ErrorType checkParameterHandle(const Handle &handle) const;
+
+};
+
+} // end of namespace
+
+#endif // PX_PARAMETERS_H
diff --git a/APEX_1.4/NvParameterized/include/NvParametersTypes.h b/APEX_1.4/NvParameterized/include/NvParametersTypes.h
new file mode 100644
index 00000000..aba2b756
--- /dev/null
+++ b/APEX_1.4/NvParameterized/include/NvParametersTypes.h
@@ -0,0 +1,58 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2013 NVIDIA Corporation. All rights reserved.
+
+#ifndef PX_PARAMETERS_TYPES_H
+#define PX_PARAMETERS_TYPES_H
+
+namespace NvParameterized
+{
+
+struct DummyDynamicArrayStruct
+{
+ void *buf;
+ bool isAllocated;
+ int elementSize;
+ int arraySizes[1];
+};
+
+struct DummyStringStruct
+{
+ const char *buf;
+ bool isAllocated;
+
+ //This is needed for compatibility with existing code
+ operator const char *() const
+ {
+ return buf;
+ }
+};
+
+class Interface; // necessary for NV_PARAMETERIZED_ONLY_LAYOUTS
+
+}
+
+#endif
diff --git a/APEX_1.4/NvParameterized/include/NvRegistrationsForTraitsBase.h b/APEX_1.4/NvParameterized/include/NvRegistrationsForTraitsBase.h
new file mode 100644
index 00000000..2af6ddf2
--- /dev/null
+++ b/APEX_1.4/NvParameterized/include/NvRegistrationsForTraitsBase.h
@@ -0,0 +1,29 @@
+#ifndef MODULE_REGISTRATION_FOR_TRAITS_BASE_H
+#define MODULE_REGISTRATION_FOR_TRAITS_BASE_H
+
+#include "nvparameterized/NvParameterizedTraits.h"
+
+namespace NvParameterized
+{
+ class RegistrationsForTraitsBase
+ {
+ public:
+ virtual void registerAvailableFactories(NvParameterized::Traits& parameterizedTraits) = 0;
+ virtual void registerAvailableConverters(NvParameterized::Traits& parameterizedTraits) = 0;
+ virtual void registerAll(NvParameterized::Traits& parameterizedTraits)
+ {
+ registerAvailableFactories(parameterizedTraits);
+ registerAvailableConverters(parameterizedTraits);
+ }
+
+ virtual void unregisterAvailableFactories(NvParameterized::Traits& parameterizedTraits) = 0;
+ virtual void unregisterAvailableConverters(NvParameterized::Traits& parameterizedTraits) = 0;
+ virtual void unregisterAll(NvParameterized::Traits& parameterizedTraits)
+ {
+ unregisterAvailableFactories(parameterizedTraits);
+ unregisterAvailableConverters(parameterizedTraits);
+ }
+ };
+}
+
+#endif
diff --git a/APEX_1.4/NvParameterized/include/NvSerializerInternal.h b/APEX_1.4/NvParameterized/include/NvSerializerInternal.h
new file mode 100644
index 00000000..d17d64ff
--- /dev/null
+++ b/APEX_1.4/NvParameterized/include/NvSerializerInternal.h
@@ -0,0 +1,63 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2013 NVIDIA Corporation. All rights reserved.
+
+#ifndef PX_SERIALIZER_INTERNAL_H
+#define PX_SERIALIZER_INTERNAL_H
+
+/*!
+\file
+\brief NvParameterized serializer factory
+*/
+
+
+#include "nvparameterized/NvSerializer.h"
+#include "nvparameterized/NvParameterizedTraits.h"
+
+namespace NvParameterized
+{
+
+PX_PUSH_PACK_DEFAULT
+
+/**
+\brief A factory function to create an instance of the Serializer class
+\param [in] type serializer type (binary, xml, etc.)
+\param [in] traits traits-object to do memory allocation, legacy version conversions, callback calls, etc.
+*/
+Serializer *internalCreateSerializer(Serializer::SerializeType type, Traits *traits);
+
+
+// Query the current platform
+const SerializePlatform &GetCurrentPlatform();
+bool GetPlatform(const char *name, SerializePlatform &platform);
+const char *GetPlatformName(const SerializePlatform &platform);
+
+
+PX_POP_PACK
+
+} // end of namespace
+
+#endif
diff --git a/APEX_1.4/NvParameterized/include/NvTraitsInternal.h b/APEX_1.4/NvParameterized/include/NvTraitsInternal.h
new file mode 100644
index 00000000..a8d737d8
--- /dev/null
+++ b/APEX_1.4/NvParameterized/include/NvTraitsInternal.h
@@ -0,0 +1,85 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2013 NVIDIA Corporation. All rights reserved.
+
+#ifndef PX_TRAITS_INTERNAL_H
+#define PX_TRAITS_INTERNAL_H
+
+#include "nvparameterized/NvParameterizedTraits.h"
+#include "PsString.h"
+
+namespace NvParameterized
+{
+
+PX_PUSH_PACK_DEFAULT
+
+#ifndef WITHOUT_APEX_SERIALIZATION
+#ifdef _MSC_VER
+#pragma warning(disable:4127) // conditional expression is constant
+#endif
+#define NV_PARAM_TRAITS_WARNING(_traits, _format, ...) do { \
+ char _tmp[256]; \
+ physx::shdfnd::snprintf(_tmp, sizeof(_tmp), _format, ##__VA_ARGS__); \
+ _traits->traitsWarn(_tmp); \
+ } while(0)
+
+#else
+#define NV_PARAM_TRAITS_WARNING(...)
+#endif
+
+// Determines how default converter handles included references
+struct RefConversionMode
+{
+ enum Enum
+ {
+ // Simply move it to new object (and remove from old)
+ REF_CONVERT_COPY = 0,
+
+ // Same as REF_CONVERT_COPY but also update legacy references
+ REF_CONVERT_UPDATE,
+
+ // Skip references
+ REF_CONVERT_SKIP,
+
+ REF_CONVERT_LAST
+ };
+};
+
+// Specifies preferred version for element at position specified in longName
+struct PrefVer
+{
+ const char *longName;
+ uint32_t ver;
+};
+
+// A factory function to create an instance of default conversion.
+Conversion *internalCreateDefaultConversion(Traits *traits, const PrefVer *prefVers = 0, RefConversionMode::Enum refMode = RefConversionMode::REF_CONVERT_COPY);
+
+PX_POP_PACK
+
+}
+
+#endif \ No newline at end of file
diff --git a/APEX_1.4/NvParameterized/include/PlatformABI.h b/APEX_1.4/NvParameterized/include/PlatformABI.h
new file mode 100644
index 00000000..58f4f6f8
--- /dev/null
+++ b/APEX_1.4/NvParameterized/include/PlatformABI.h
@@ -0,0 +1,135 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2013 NVIDIA Corporation. All rights reserved.
+
+#ifndef PLATFORM_ABI_H_
+#define PLATFORM_ABI_H_
+
+// WARNING: before doing any changes to this file
+// check comments at the head of BinSerializer.cpp
+
+#include "BinaryHelper.h"
+#include "nvparameterized/NvSerializer.h"
+
+namespace NvParameterized
+{
+
+//Describes platform ABI (endian, alignment, etc.)
+struct PlatformABI
+{
+ enum Endian
+ {
+ LITTLE,
+ BIG
+ };
+
+ Endian endian;
+
+ //Sizes of basic types
+ struct
+ {
+ uint32_t Char,
+ Bool,
+ pointer,
+ real;
+ } sizes;
+
+ //Alignments of basic types
+ struct
+ {
+ uint32_t Char,
+ Bool,
+ pointer,
+ real,
+ i8,
+ i16,
+ i32,
+ i64,
+ f32,
+ f64;
+ } aligns;
+
+ //Does child class reuse tail padding of parent? (google for "overlaying tail padding")
+ bool doReuseParentPadding;
+
+ //Are empty base classes eliminated? (google for "empty base class optimization")
+ //We may need this in future
+ bool doEbo;
+
+ //Get ABI of platform
+ static Serializer::ErrorType GetPredefinedABI(const SerializePlatform &platform, PlatformABI &params);
+
+ //Get alignment of (complex) NvParameterized data type
+ uint32_t getAlignment(const Definition *pd) const;
+
+ //Get padding of (complex) NvParameterized data type
+ uint32_t getPadding(const Definition *pd) const;
+
+ //Get size of (complex) NvParameterized data type
+ uint32_t getSize(const Definition *pd) const;
+
+ //Helper function which calculates aligned value
+ PX_INLINE static uint32_t align(uint32_t len, uint32_t border);
+
+ //Verifying that platforms are going to work with our serializer
+ PX_INLINE bool isNormal() const;
+ static bool VerifyCurrentPlatform();
+
+ //Alignment of metadata table entry in metadata section
+ //TODO: find better place for this
+ PX_INLINE uint32_t getMetaEntryAlignment() const;
+
+ //Alignment of metadata info in metadata section
+ //TODO: find better place for this
+ PX_INLINE uint32_t getMetaInfoAlignment() const;
+
+ //Alignment of hint in metadata section
+ //TODO: find better place for this
+ PX_INLINE uint32_t getHintAlignment() const;
+
+ //Alignment of hint value (union of uint32_t, uint64_t, const char *) in metadata section
+ //TODO: find better place for this
+ PX_INLINE uint32_t getHintValueAlignment() const;
+
+ //Size of hint value (union of uint32_t, uint64_t, const char *) in metadata section
+ //TODO: find better place for this
+ PX_INLINE uint32_t getHintValueSize() const;
+
+ //Template for getting target alignment of T
+ template <typename T> PX_INLINE uint32_t getAlignment() const;
+
+ //Template for getting target size of T
+ template <typename T> PX_INLINE uint32_t getSize() const;
+
+private:
+ uint32_t getNatAlignment(const Definition *pd) const;
+};
+
+#include "PlatformABI.inl"
+
+}
+
+#endif
diff --git a/APEX_1.4/NvParameterized/include/PlatformABI.inl b/APEX_1.4/NvParameterized/include/PlatformABI.inl
new file mode 100644
index 00000000..04fe9ac4
--- /dev/null
+++ b/APEX_1.4/NvParameterized/include/PlatformABI.inl
@@ -0,0 +1,267 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2013 NVIDIA Corporation. All rights reserved.
+
+// WARNING: before doing any changes to this file
+// check comments at the head of BinSerializer.cpp
+
+PX_INLINE uint32_t PlatformABI::align(uint32_t len, uint32_t border)
+{
+ uint32_t n = (len + border - 1) / border;
+ return n * border;
+}
+
+PX_INLINE bool PlatformABI::isNormal() const
+{
+ return 1 == sizes.Char && 1 == sizes.Bool //Wide (> 1) bytes not supported
+ && 4 == sizes.real //Some code relies on short float (float)
+ && ( 4 == sizes.pointer || 8 == sizes.pointer ); //Some code relies on pointers being either 32- or 64-bit
+}
+
+PX_INLINE uint32_t PlatformABI::getMetaEntryAlignment() const
+{
+ return physx::PxMax(aligns.i32, aligns.pointer);
+}
+
+PX_INLINE uint32_t PlatformABI::getMetaInfoAlignment() const
+{
+ return NvMax3(getHintAlignment(), aligns.i32, aligns.pointer);
+}
+
+PX_INLINE uint32_t PlatformABI::getHintAlignment() const
+{
+ return physx::PxMax(aligns.i32, getHintValueAlignment());
+}
+
+PX_INLINE uint32_t PlatformABI::getHintValueAlignment() const
+{
+ return NvMax3(aligns.pointer, aligns.i64, aligns.f64);
+}
+
+PX_INLINE uint32_t PlatformABI::getHintValueSize() const
+{
+ return align(8, getHintValueAlignment()); //Size of union = aligned size of maximum element
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getAlignment<bool>() const
+{
+ return aligns.Bool;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getAlignment<int8_t>() const
+{
+ return aligns.i8;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getAlignment<int16_t>() const
+{
+ return aligns.i16;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getAlignment<int32_t>() const
+{
+ return aligns.i32;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getAlignment<int64_t>() const
+{
+ return aligns.i64;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getAlignment<uint8_t>() const
+{
+ return getAlignment<int8_t>();
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getAlignment<uint16_t>() const
+{
+ return getAlignment<int16_t>();
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getAlignment<uint32_t>() const
+{
+ return getAlignment<int32_t>();
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getAlignment<uint64_t>() const
+{
+ return getAlignment<int64_t>();
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getAlignment<float>() const
+{
+ return aligns.f32;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getAlignment<double>() const
+{
+ return aligns.f64;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getAlignment<physx::PxVec2>() const
+{
+ return aligns.real;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getAlignment<physx::PxVec3>() const
+{
+ return aligns.real;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getAlignment<physx::PxVec4>() const
+{
+ return aligns.real;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getAlignment<physx::PxQuat>() const
+{
+ return aligns.real;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getAlignment<physx::PxMat33>() const
+{
+ return aligns.real;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getAlignment<physx::PxMat44>() const
+{
+ return aligns.real;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getAlignment<physx::PxBounds3>() const
+{
+ return aligns.real;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getAlignment<void *>() const
+{
+ return aligns.pointer;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getAlignment<physx::PxTransform>() const
+{
+ return aligns.real;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getSize<bool>() const
+{
+ return sizes.Bool;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getSize<int8_t>() const
+{
+ return 1;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getSize<int16_t>() const
+{
+ return 2;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getSize<int32_t>() const
+{
+ return 4;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getSize<int64_t>() const
+{
+ return 8;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getSize<uint8_t>() const
+{
+ return getSize<int8_t>();
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getSize<uint16_t>() const
+{
+ return getSize<int16_t>();
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getSize<uint32_t>() const
+{
+ return getSize<int32_t>();
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getSize<uint64_t>() const
+{
+ return getSize<int64_t>();
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getSize<float>() const
+{
+ return 4;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getSize<double>() const
+{
+ return 8;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getSize<physx::PxVec2>() const
+{
+ return 2 * sizes.real;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getSize<physx::PxVec3>() const
+{
+ return 3 * sizes.real;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getSize<physx::PxVec4>() const
+{
+ return 4 * sizes.real;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getSize<physx::PxQuat>() const
+{
+ return 4 * sizes.real;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getSize<physx::PxMat33>() const
+{
+ return 9 * sizes.real;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getSize<physx::PxMat44>() const
+{
+ return 16 * sizes.real;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getSize<physx::PxBounds3>() const
+{
+ return 6 * sizes.real;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getSize<void *>() const
+{
+ return sizes.pointer;
+}
+
+template <> PX_INLINE uint32_t PlatformABI::getSize<physx::PxTransform>() const
+{
+ return 7 * sizes.real;
+}
diff --git a/APEX_1.4/NvParameterized/include/PlatformInputStream.h b/APEX_1.4/NvParameterized/include/PlatformInputStream.h
new file mode 100644
index 00000000..45af2a3a
--- /dev/null
+++ b/APEX_1.4/NvParameterized/include/PlatformInputStream.h
@@ -0,0 +1,115 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2013 NVIDIA Corporation. All rights reserved.
+
+#ifndef PLATFORM_INPUT_STREAM_H_
+#define PLATFORM_INPUT_STREAM_H_
+
+// WARNING: before doing any changes to this file
+// check comments at the head of BinSerializer.cpp
+
+#include "PlatformStream.h"
+#include "ApbDefinitions.h"
+
+namespace NvParameterized
+{
+
+//ABI-aware input stream
+class PlatformInputStream: public PlatformStream
+{
+ physx::PxFileBuf &mStream;
+ physx::shdfnd::Array<uint32_t, Traits::Allocator> mPos;
+ uint32_t mStartPos; //This is necessary to handle NvParameterized streams starting in the middle of other files
+
+ PlatformInputStream(const PlatformInputStream &); //Don't
+ void operator =(const PlatformInputStream &); //Don't
+
+public:
+ PlatformInputStream(physx::PxFileBuf &stream, const PlatformABI &targetParams, Traits *traits);
+
+ Serializer::ErrorType skipBytes(uint32_t nbytes);
+
+ Serializer::ErrorType pushPos(uint32_t newPos);
+
+ void popPos();
+
+ uint32_t getPos() const;
+
+ //Read string stored at given offset
+ //TODO: this could much faster if we loaded whole dictionary in the beginning
+ Serializer::ErrorType readString(uint32_t off, const char *&s);
+
+ //Deserialize header of NvParameterized object (see wiki for details)
+ Serializer::ErrorType readObjHeader(ObjHeader &hdr);
+
+ //Deserialize primitive type
+ template<typename T> PX_INLINE Serializer::ErrorType read(T &x, bool doAlign = true);
+
+ //Deserialize array of primitive type (slow path)
+ template<typename T> PX_INLINE Serializer::ErrorType readSimpleArraySlow(Handle &handle);
+
+ //Deserialize array of structs of primitive type
+ Serializer::ErrorType readSimpleStructArray(Handle &handle);
+
+ //Deserialize array of primitive type
+ template<typename T> PX_INLINE Serializer::ErrorType readSimpleArray(Handle &handle);
+
+ //Align current offset according to supplied alignment and padding
+ void beginStruct(uint32_t align_, uint32_t pad_);
+
+ //Align current offset according to supplied alignment (padding = alignment)
+ void beginStruct(uint32_t align_);
+
+ //Align current offset according to supplied DataType
+ void beginStruct(const Definition *pd);
+
+ //Insert tail padding
+ void closeStruct();
+
+ //beginStruct for DummyStringStruct
+ void beginString();
+
+ //closeStruct for DummyStringStruct
+ void closeString();
+
+ //beginStruct for arrays
+ void beginArray(const Definition *pd);
+
+ //closeStruct for arrays
+ void closeArray();
+
+ //Align offset to be n*border
+ void align(uint32_t border);
+
+ //Read value of pointer (offset from start of file)
+ Serializer::ErrorType readPtr(uint32_t &val);
+};
+
+#include "PlatformInputStream.inl"
+
+}
+
+#endif
diff --git a/APEX_1.4/NvParameterized/include/PlatformInputStream.inl b/APEX_1.4/NvParameterized/include/PlatformInputStream.inl
new file mode 100644
index 00000000..8c3605ab
--- /dev/null
+++ b/APEX_1.4/NvParameterized/include/PlatformInputStream.inl
@@ -0,0 +1,117 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2013 NVIDIA Corporation. All rights reserved.
+
+// WARNING: before doing any changes to this file
+// check comments at the head of BinSerializer.cpp
+
+template<typename T> PX_INLINE Serializer::ErrorType PlatformInputStream::read(T &x, bool doAlign)
+{
+ if( doAlign )
+ align(mTargetParams.getAlignment<T>());
+
+ if( mCurParams.getSize<T>() != mTargetParams.getSize<T>() )
+ {
+ PX_ALWAYS_ASSERT();
+ return Serializer::ERROR_INVALID_PLATFORM;
+ }
+
+ mStream.read(&x, sizeof(T));
+
+ if( mCurParams.endian != mTargetParams.endian )
+ SwapBytes((char *)&x, sizeof(T), GetDataType<T>::value);
+
+ return Serializer::ERROR_NONE;
+}
+
+//Deserialize array of primitive type (slow path)
+template<typename T> PX_INLINE Serializer::ErrorType PlatformInputStream::readSimpleArraySlow(Handle &handle)
+{
+ int32_t n;
+ handle.getArraySize(n);
+
+ align(mTargetParams.getAlignment<T>());
+
+ for(int32_t i = 0; i < n; ++i)
+ {
+ handle.set(i);
+ T val;
+ NV_ERR_CHECK_RETURN( read(val) );
+ handle.setParam<T>(val);
+
+ handle.popIndex();
+ }
+
+ return Serializer::ERROR_NONE;
+}
+
+template<typename T> PX_INLINE Serializer::ErrorType PlatformInputStream::readSimpleArray(Handle &handle)
+{
+ if( mTargetParams.getSize<T>() == mCurParams.getSize<T>()
+ && mTargetParams.getSize<T>() >= mTargetParams.getAlignment<T>()
+ && mCurParams.getSize<T>() >= mCurParams.getAlignment<T>() ) //No gaps between array elements on both platforms
+ {
+ //Fast path
+
+ int32_t n;
+ handle.getArraySize(n);
+
+ align(mTargetParams.getAlignment<T>());
+
+ const int32_t elemSize = (int32_t)sizeof(T);
+
+ if( mStream.tellRead() + elemSize * n >= mStream.getFileLength() )
+ {
+ DEBUG_ALWAYS_ASSERT();
+ return Serializer::ERROR_INVALID_INTERNAL_PTR;
+ }
+
+ PX_ASSERT(elemSize * n >= 0);
+ char *p = (char *)mTraits->alloc(static_cast<uint32_t>(elemSize * n));
+ mStream.read(p, static_cast<uint32_t>(elemSize * n));
+
+ if( mCurParams.endian != mTargetParams.endian )
+ {
+ char *elem = p;
+ for(int32_t i = 0; i < n; ++i)
+ {
+ SwapBytes(elem, elemSize, GetDataType<T>::value);
+ elem += elemSize;
+ }
+ }
+
+ handle.setParamArray<T>((const T *)p, n);
+
+ mTraits->free(p);
+ }
+ else
+ {
+ return readSimpleArraySlow<T>(handle);
+ }
+
+ return Serializer::ERROR_NONE;
+}
+
diff --git a/APEX_1.4/NvParameterized/include/PlatformOutputStream.h b/APEX_1.4/NvParameterized/include/PlatformOutputStream.h
new file mode 100644
index 00000000..821d7a10
--- /dev/null
+++ b/APEX_1.4/NvParameterized/include/PlatformOutputStream.h
@@ -0,0 +1,212 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2013 NVIDIA Corporation. All rights reserved.
+
+#ifndef PLATFORM_OUTPUT_STREAM_H_
+#define PLATFORM_OUTPUT_STREAM_H_
+
+// WARNING: before doing any changes to this file
+// check comments at the head of BinSerializer.cpp
+
+#include "PlatformStream.h"
+#include "ApbDefinitions.h"
+
+#ifndef WITHOUT_APEX_SERIALIZATION
+
+namespace NvParameterized
+{
+
+class PlatformOutputStream;
+
+//Info about pointed data (and its subdata)
+struct Reloc
+{
+ RelocType type;
+ uint32_t ptrPos;
+ PlatformOutputStream *ptrData;
+ Traits *traits;
+
+ Reloc(RelocType type_, uint32_t ptrPos_, const PlatformOutputStream &parent);
+
+ Reloc(const Reloc &cinfo);
+
+ ~Reloc();
+};
+
+//Info about pointed string
+struct StringReloc
+{
+ uint32_t ptrPos;
+ const char *s;
+
+ StringReloc(uint32_t ptrPos_, const char *s_): ptrPos(ptrPos_), s(s_) {}
+};
+
+//Info about reloc which was already merged
+struct MergedReloc
+{
+ uint32_t ptrPos;
+ uint32_t targetPos;
+ RelocType type;
+ bool isExtern;
+};
+
+//ABI-aware output stream
+class PlatformOutputStream: public PlatformStream
+{
+ void operator = (const PlatformOutputStream &); //Don't
+
+ friend struct Reloc;
+public:
+ PlatformOutputStream(const PlatformABI &targetParams, Traits *traits, Dictionary &dict_);
+
+ //Array's copy constructor is broken so we implement it by hand
+ PlatformOutputStream(const PlatformOutputStream &s);
+
+#ifndef NDEBUG
+ void dump() const;
+#endif
+
+ PX_INLINE StringBuf &getData() { return data; }
+
+ uint32_t size() const { return data.size(); }
+
+ //Update uint32_t at given position
+ void storeU32At(uint32_t x, uint32_t i);
+
+ uint32_t storeString(const char *s);
+
+ //Serialize raw bytes
+ uint32_t storeBytes(const char *s, uint32_t n);
+
+ //Serialize value of primitive type with proper alignment
+ //(this is overriden for bools below)
+ template <typename T> PX_INLINE uint32_t storeSimple(T x);
+
+ PX_INLINE uint32_t storeSimple(float* x, uint32_t size);
+
+ //Serialize array of primitive type with proper alignment (slow path)
+ template <typename T> PX_INLINE int32_t storeSimpleArraySlow(Handle &handle);
+
+ //Serialize array of structs of primitive types with proper alignment
+ uint32_t storeSimpleStructArray(Handle &handle);
+
+ //Serialize array of primitive type with proper alignment
+ template <typename T> PX_INLINE uint32_t storeSimpleArray(Handle &handle);
+
+ //Serialize header of NvParameterized object (see wiki for details)
+ uint32_t storeObjHeader(const NvParameterized::Interface &obj, bool isIncluded = true);
+
+ //Serialize NvParameters-part of NvParameterized object
+ uint32_t beginObject(const NvParameterized::Interface &obj, bool /*isRoot*/, const Definition *pd);
+
+ //Insert tail padding bytes for NvParameterized object
+ void closeObject() { closeStruct(); }
+
+ //Align current offset according to supplied alignment and padding
+ uint32_t beginStruct(uint32_t align_, uint32_t pad_);
+
+ //Align current offset according to supplied alignment (padding = alignment)
+ uint32_t beginStruct(uint32_t align_);
+
+ //Align current offset according to supplied DataType
+ uint32_t beginStruct(const Definition *pd);
+
+ //Insert tail padding
+ void closeStruct();
+
+ //beginStruct for DummyStringStruct
+ uint32_t beginString();
+
+ //closeStruct for DummyStringStruct
+ void closeString();
+
+ //beginStruct for arrays
+ uint32_t beginArray(const Definition *pd);
+
+ //beginStruct for arrays
+ uint32_t beginArray(uint32_t align_);
+
+ //closeStruct for arrays
+ void closeArray();
+
+ void skipBytes(uint32_t nbytes);
+
+ //Align offset to be n*border
+ void align(uint32_t border);
+
+ //Align offset to be n * alignment of T
+ template <typename T> PX_INLINE void align();
+
+ //Add data (including relocations) from another stream
+ uint32_t merge(const PlatformOutputStream &mergee);
+
+ //Merge pointed data (including strings) thus flattening the stream
+ void flatten();
+
+ //Create relocation table
+ uint32_t writeRelocs();
+
+ //Serialize dictionary data
+ void mergeDict();
+
+ uint32_t storeNullPtr();
+
+ Reloc &storePtr(RelocType type, const Definition *pd);
+
+ Reloc &storePtr(RelocType type, uint32_t align);
+
+ void storeStringPtr(const char *s);
+
+ PX_INLINE uint32_t alignment() const { return mTotalAlign; }
+
+ PX_INLINE void setAlignment(uint32_t newAlign) { mTotalAlign = newAlign; }
+
+private:
+
+ //Byte stream
+ StringBuf data;
+
+ //Generic relocations
+ physx::shdfnd::Array<Reloc, Traits::Allocator> mRelocs;
+
+ //String relocations
+ physx::shdfnd::Array<StringReloc, Traits::Allocator> mStrings;
+
+ //Keep info about relocations after flattening
+ physx::shdfnd::Array<MergedReloc, Traits::Allocator> mMerges;
+
+ Dictionary &dict;
+
+ uint32_t mTotalAlign;
+};
+
+#include "PlatformOutputStream.inl"
+
+}
+
+#endif
+#endif
diff --git a/APEX_1.4/NvParameterized/include/PlatformOutputStream.inl b/APEX_1.4/NvParameterized/include/PlatformOutputStream.inl
new file mode 100644
index 00000000..bdbe88eb
--- /dev/null
+++ b/APEX_1.4/NvParameterized/include/PlatformOutputStream.inl
@@ -0,0 +1,138 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2013 NVIDIA Corporation. All rights reserved.
+
+// WARNING: before doing any changes to this file
+// check comments at the head of BinSerializer.cpp
+
+template <typename T> PX_INLINE void PlatformOutputStream::align()
+{
+ align(mTargetParams.getAlignment<T>());
+}
+
+template <typename T> PX_INLINE uint32_t PlatformOutputStream::storeSimple(T x)
+{
+ align(mTargetParams.getAlignment<T>());
+
+ uint32_t off = size();
+
+ data.append(x);
+
+ char *p = getData() + off;
+
+ //It is unsafe to call SwapBytes directly on floats (doubles, vectors, etc.)
+ //because values may become NaNs which will lead to all sorts of errors
+ if( mCurParams.endian != mTargetParams.endian )
+ SwapBytes(p, sizeof(T), GetDataType<T>::value);
+
+ return off;
+}
+
+PX_INLINE uint32_t PlatformOutputStream::storeSimple(float* x, uint32_t num)
+{
+ align(mTargetParams.getAlignment<float>());
+
+ uint32_t off = size();
+
+ for (uint32_t k = 0; k < num; ++k)
+ {
+ data.append(x[k]);
+ }
+
+ char *p = getData() + off;
+
+ //It is unsafe to call SwapBytes directly on floats (doubles, vectors, etc.)
+ //because values may become NaNs which will lead to all sorts of errors
+ if( mCurParams.endian != mTargetParams.endian )
+ SwapBytes(p, sizeof(float) * num, GetDataType<float>::value);
+
+ return off;
+}
+
+template <typename T> PX_INLINE int32_t PlatformOutputStream::storeSimpleArraySlow(Handle &handle)
+{
+ int32_t n;
+ handle.getArraySize(n);
+
+ align<T>();
+ uint32_t off = size();
+
+ data.reserve(size() + n * physx::PxMax(mTargetParams.getAlignment<T>(), mTargetParams.getSize<T>()));
+
+ for(int32_t i = 0; i < n; ++i)
+ {
+ handle.set(i);
+
+ T val;
+ handle.getParam<T>(val);
+ storeSimple<T>(val);
+
+ handle.popIndex();
+ }
+
+ int32_t offsetAsInt = static_cast<int32_t>(off);
+ PX_ASSERT(offsetAsInt >= 0);
+ return offsetAsInt;
+}
+
+template <typename T> PX_INLINE uint32_t PlatformOutputStream::storeSimpleArray(Handle &handle)
+{
+ if( TYPE_BOOL != handle.parameterDefinition()->child(0)->type() //Bools are special (see custom version of storeSimple)
+ && mTargetParams.getSize<T>() == mCurParams.getSize<T>()
+ && mTargetParams.getSize<T>() >= mTargetParams.getAlignment<T>()
+ && mCurParams.getSize<T>() >= mCurParams.getAlignment<T>() ) //No gaps between array elements on both platforms
+ {
+ //Fast path
+
+ int32_t n;
+ handle.getArraySize(n);
+
+ align<T>();
+ uint32_t off = size();
+
+ const int32_t elemSize = (int32_t)sizeof(T);
+
+ skipBytes((uint32_t)(elemSize * n));
+
+ char *p = getData() + off;
+ handle.getParamArray<T>((T *)p, n);
+
+ if( mCurParams.endian != mTargetParams.endian )
+ {
+ for(int32_t i = 0; i < n; ++i)
+ {
+ SwapBytes(p, elemSize, GetDataType<T>::value);
+ p += elemSize;
+ }
+ }
+
+ return off;
+ }
+ else
+ {
+ return static_cast<uint32_t>(storeSimpleArraySlow<T>(handle));
+ }
+}
diff --git a/APEX_1.4/NvParameterized/include/PlatformStream.h b/APEX_1.4/NvParameterized/include/PlatformStream.h
new file mode 100644
index 00000000..c17bda66
--- /dev/null
+++ b/APEX_1.4/NvParameterized/include/PlatformStream.h
@@ -0,0 +1,151 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2013 NVIDIA Corporation. All rights reserved.
+
+#ifndef PLATFORM_STREAM_H_
+#define PLATFORM_STREAM_H_
+
+#include <stdio.h>
+
+#include "nvparameterized/NvParameterized.h"
+#include "nvparameterized/NvSerializer.h"
+#include "NvSerializerInternal.h"
+#include "PlatformABI.h"
+
+namespace NvParameterized
+{
+
+// Base class for ABI-aware streams
+
+// TODO:
+// PlatformInput/OutputStream should probably be visitors
+
+class PlatformStream
+{
+ void operator =(const PlatformStream &); //Don't
+
+protected:
+ Traits *mTraits;
+
+ PlatformABI mTargetParams, mCurParams;
+
+ struct Agregate
+ {
+ enum Type
+ {
+ STRUCT,
+ ARRAY
+ };
+
+ Type type;
+ uint32_t align;
+
+ Agregate(Type t, uint32_t a): type(t), align(a) {}
+ };
+
+ //Agregate stack holds information about structs and their nesting (for automatic insertion of tail pad)
+ physx::shdfnd::Array<Agregate, Traits::Allocator> mStack;
+
+public:
+ PlatformStream(const PlatformABI &targetParams, Traits *traits)
+ : mTraits(traits),
+ mTargetParams(targetParams),
+ mStack(Traits::Allocator(traits))
+ {
+ // TODO: constructors should not fail...
+ if( Serializer::ERROR_NONE != PlatformABI::GetPredefinedABI(GetCurrentPlatform(), mCurParams) )
+ {
+ PX_ALWAYS_ASSERT();
+ return;
+ }
+ }
+
+ //Array's copy constructor is broken so we implement it by hand
+ PlatformStream(const PlatformStream &s)
+ : mTraits(s.mTraits),
+ mTargetParams(s.mTargetParams),
+ mCurParams(s.mCurParams),
+ mStack(Traits::Allocator(s.mTraits))
+ {
+ mStack.reserve(s.mStack.size());
+ for(uint32_t i = 0; i < s.mStack.size(); ++i)
+ mStack.pushBack(s.mStack[i]);
+ }
+
+ void dump() const
+ {
+ printf("Dumping PlatformStream at %p:\n", this);
+ }
+
+ const PlatformABI &getTargetABI() const
+ {
+ return mTargetParams;
+ }
+
+ uint32_t getTargetSize(const Definition *pd) const
+ {
+ return mTargetParams.getSize(pd);
+ }
+
+ uint32_t getTargetAlignment(const Definition *pd) const
+ {
+ return mTargetParams.getAlignment(pd);
+ }
+
+ uint32_t getTargetPadding(const Definition *pd) const
+ {
+ return mTargetParams.getPadding(pd);
+ }
+
+ //Align offset to be n*border
+ PX_INLINE uint32_t getAlign(uint32_t off, uint32_t border, bool &isAligned) const
+ {
+ PX_ASSERT(border <= 128);
+
+ //Array members are not aligned
+ //See http://www.gamasutra.com/view/feature/3975/data_alignment_part_2_objects_on_.php
+ if( !mStack.empty() && Agregate::ARRAY == mStack.back().type )
+ {
+ isAligned = false;
+ return off;
+ }
+
+ isAligned = true;
+ const uint32_t mask = border - 1;
+ return (off + mask) & ~mask;
+ }
+
+ //Align offset to be n*border
+ PX_INLINE uint32_t getAlign(uint32_t off, uint32_t border) const
+ {
+ bool tmp;
+ return getAlign(off, border, tmp);
+ }
+};
+
+}
+
+#endif
diff --git a/APEX_1.4/NvParameterized/include/SerializerCommon.h b/APEX_1.4/NvParameterized/include/SerializerCommon.h
new file mode 100644
index 00000000..59f4f98e
--- /dev/null
+++ b/APEX_1.4/NvParameterized/include/SerializerCommon.h
@@ -0,0 +1,172 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2013 NVIDIA Corporation. All rights reserved.
+
+#ifndef SERIALIZER_COMMON_H
+#define SERIALIZER_COMMON_H
+
+#include <stdio.h> // FILE
+
+#include "PxAssert.h"
+
+#include "PsArray.h"
+#include "PsHashMap.h"
+
+#include "nvparameterized/NvParameterized.h"
+#include "nvparameterized/NvParameterizedTraits.h"
+#include "nvparameterized/NvSerializer.h"
+
+#define ENABLE_DEBUG_ASSERTS 1
+
+#if ENABLE_DEBUG_ASSERTS
+# define DEBUG_ASSERT(x) PX_ASSERT(x)
+#else
+# define DEBUG_ASSERT(x)
+#endif
+#define DEBUG_ALWAYS_ASSERT() DEBUG_ASSERT(0)
+
+#define NV_ERR_CHECK_RETURN(x) { Serializer::ErrorType err = x; if( Serializer::ERROR_NONE != err ) { DEBUG_ALWAYS_ASSERT(); return err; } }
+#define NV_BOOL_ERR_CHECK_RETURN(x, err) { if( !(x) ) { DEBUG_ALWAYS_ASSERT(); return err; } }
+#define NV_PARAM_ERR_CHECK_RETURN(x, err) { if( NvParameterized::ERROR_NONE != (NvParameterized::ErrorType)(x) ) { DEBUG_ALWAYS_ASSERT(); return err; } }
+
+#define NV_ERR_CHECK_WARN_RETURN(x, ...) { \
+ Serializer::ErrorType err = x; \
+ if( Serializer::ERROR_NONE != err ) { \
+ NV_PARAM_TRAITS_WARNING(mTraits, ##__VA_ARGS__); \
+ DEBUG_ALWAYS_ASSERT(); \
+ return err; \
+ } \
+}
+
+#define NV_BOOL_ERR_CHECK_WARN_RETURN(x, err, ...) { \
+ if( !(x) ) { \
+ NV_PARAM_TRAITS_WARNING(mTraits, ##__VA_ARGS__); \
+ DEBUG_ALWAYS_ASSERT(); \
+ return err; \
+ } \
+}
+
+#define NV_PARAM_ERR_CHECK_WARN_RETURN(x, err, ...) { \
+ if( NvParameterized::ERROR_NONE != (NvParameterized::ErrorType)(x) ) \
+ { \
+ NV_PARAM_TRAITS_WARNING(mTraits, ##__VA_ARGS__); \
+ DEBUG_ALWAYS_ASSERT(); \
+ return err; \
+ } \
+}
+
+namespace NvParameterized
+{
+
+bool UpgradeLegacyObjects(Serializer::DeserializedData &data, bool &isUpdated, Traits *t);
+Interface *UpgradeObject(Interface &obj, bool &isUpdated, Traits *t);
+
+//This is used for releasing resources (I wish we had generic smart ptrs...)
+class Releaser
+{
+ FILE *mFile;
+
+ void *mBuf;
+ Traits *mTraits;
+
+ Interface *mObj;
+
+ Releaser(const Releaser &) {}
+
+public:
+
+ Releaser()
+ {
+ reset();
+ }
+
+ Releaser(void *buf, Traits *traits)
+ {
+ reset(buf, traits);
+ }
+
+ Releaser(FILE *file)
+ {
+ reset(file);
+ }
+
+ Releaser(Interface *obj)
+ {
+ reset(obj);
+ }
+
+ void reset()
+ {
+ mFile = 0;
+ mBuf = 0;
+ mTraits = 0;
+ mObj = 0;
+ }
+
+ void reset(Interface *obj)
+ {
+ reset();
+
+ mObj = obj;
+ }
+
+ void reset(FILE *file)
+ {
+ reset();
+
+ mFile = file;
+ }
+
+ void reset(void *buf, Traits *traits)
+ {
+ reset();
+
+ mBuf = buf;
+ mTraits = traits;
+ }
+
+ ~Releaser()
+ {
+ if( mBuf )
+ mTraits->free(mBuf);
+
+ if( mFile )
+ fclose(mFile);
+
+ if( mObj )
+ mObj->destroy();
+ }
+};
+
+void *serializerMemAlloc(uint32_t size, Traits *traits);
+void serializerMemFree(void *mem, Traits *traits);
+
+// Checksum for some classes is invalid
+bool DoIgnoreChecksum(const Interface &obj);
+
+} // namespace NvParameterized
+
+#endif
diff --git a/APEX_1.4/NvParameterized/include/XmlDeserializer.h b/APEX_1.4/NvParameterized/include/XmlDeserializer.h
new file mode 100644
index 00000000..ac6075fa
--- /dev/null
+++ b/APEX_1.4/NvParameterized/include/XmlDeserializer.h
@@ -0,0 +1,307 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2013 NVIDIA Corporation. All rights reserved.
+
+#ifndef XML_DESERIALIZER_H_
+#define XML_DESERIALIZER_H_
+
+//XML deserialization (by John Ratcliff)
+
+#include "PsFastXml.h"
+
+#include "nvparameterized/NvSerializer.h"
+#include "nvparameterized/NvParameterized.h"
+#include "nvparameterized/NvParameterizedTraits.h"
+
+#include "SerializerCommon.h"
+
+namespace NvParameterized
+{
+
+typedef enum
+{
+ ARRAY,
+ STRUCT,
+ VALUE,
+ SKIP
+} FieldType;
+
+struct FieldInfo
+{
+ PX_INLINE void init(const char *name_, FieldType type_)
+ {
+ name = name_;
+ type = type_;
+ idx = 0;
+ }
+
+ const char *name;
+ FieldType type;
+ uint32_t idx; //For arrays
+};
+
+class ObjectInfo
+{
+ static const uint32_t MAX_STRUCT_FIELD_STACK = 256;
+
+ Interface *mObj;
+
+ //Field stack
+ uint32_t mIndex;
+ FieldInfo mFields[MAX_STRUCT_FIELD_STACK];
+
+public:
+
+ PX_INLINE ObjectInfo(): mObj(0), mIndex(0) {}
+
+ PX_INLINE void init(Interface *obj)
+ {
+ mObj = obj;
+ }
+
+ PX_INLINE Interface *getObject()
+ {
+ return mObj;
+ }
+
+ PX_INLINE bool popField(const char *&name, FieldType &type)
+ {
+ if( !mIndex )
+ {
+ DEBUG_ALWAYS_ASSERT();
+ return false;
+ }
+
+ FieldInfo &field = mFields[--mIndex];
+ name = field.name;
+ type = field.type;
+
+# ifndef NDEBUG
+ field.name = 0;
+# endif
+
+ if( mIndex )
+ {
+ FieldInfo &lastField = mFields[mIndex-1];
+ if( ARRAY == lastField.type )
+ ++lastField.idx;
+ }
+
+ return true;
+ }
+
+ PX_INLINE void pushField(const char *name, FieldType type)
+ {
+ PX_ASSERT( mIndex < MAX_STRUCT_FIELD_STACK );
+
+ if( mIndex < MAX_STRUCT_FIELD_STACK )
+ mFields[mIndex++].init(name, type);
+ }
+
+ PX_INLINE uint32_t getIndex() const { return mIndex; };
+
+ PX_INLINE FieldInfo &getFieldInfo(uint32_t i)
+ {
+ PX_ASSERT( i < mIndex );
+ return mFields[i];
+ }
+};
+
+class XmlDeserializer: public physx::shdfnd::FastXml::Callback
+{
+ static const uint32_t MAX_REF_STACK = 8,
+ MAX_ROOT_OBJ = 64;
+
+ Serializer::ErrorType mError;
+
+ Traits *mTraits;
+
+ //Object stack
+ uint32_t mObjIndex;
+ ObjectInfo mObjects[MAX_REF_STACK];
+
+ //Array of root objects
+ uint32_t mRootIndex;
+ Interface *mRootObjs[MAX_ROOT_OBJ];
+
+ //Check errors in <NvParameters>
+ uint32_t mRootTags;
+ bool mInRootElement;
+
+ //Check DOCTYPE
+ bool mHasDoctype;
+
+ uint32_t mVer;
+
+ // read simple structs in array
+ int32_t* mSimpleStructRedirect;
+ uint32_t mSimpleStructRedirectSize;
+
+ //Top Of Stack
+ PX_INLINE ObjectInfo &tos()
+ {
+ PX_ASSERT( mObjIndex >= 1 && mObjIndex <= MAX_REF_STACK );
+ return mObjIndex > 0 ? mObjects[mObjIndex - 1] : mObjects[0];
+ }
+
+ PX_INLINE void pushObj(Interface *obj)
+ {
+ if( mObjIndex >= MAX_REF_STACK )
+ {
+ PX_ALWAYS_ASSERT(); //included references nested too deeply
+ return;
+ }
+
+ ++mObjIndex;
+ tos().init(obj);
+ }
+
+ PX_INLINE bool popObj()
+ {
+ if( mObjIndex <= 0 )
+ return false;
+
+ --mObjIndex;
+
+ return true;
+ }
+
+ PX_INLINE void pushField(const char *name, FieldType type)
+ {
+ tos().pushField(mTraits->strdup(name), type);
+ }
+
+ PX_INLINE bool popField()
+ {
+ const char *name = 0;
+ FieldType type;
+ if( !tos().popField(name, type) )
+ return false;
+
+ mTraits->strfree(const_cast<char *>(name));
+
+ return true;
+ }
+
+ bool verifyObject(Interface *obj, const physx::shdfnd::FastXml::AttributePairs& attr);
+
+ bool initAddressString(char *dest, uint32_t len, const char *name);
+
+public:
+
+ PX_INLINE XmlDeserializer(Traits *traits, uint32_t ver):
+ mError(Serializer::ERROR_NONE),
+ mTraits(traits),
+ mObjIndex(0),
+ mRootIndex(0),
+ mRootTags(0),
+ mInRootElement(false),
+ mHasDoctype(false),
+ mVer(ver),
+ mSimpleStructRedirect(NULL),
+ mSimpleStructRedirectSize(0) {}
+
+ PX_INLINE virtual ~XmlDeserializer()
+ {
+ if (mSimpleStructRedirect != NULL)
+ {
+ mTraits->free(mSimpleStructRedirect);
+ }
+ mSimpleStructRedirect = NULL;
+ mSimpleStructRedirectSize = 0;
+ }
+
+ static PX_INLINE XmlDeserializer *Create(Traits *traits, uint32_t ver)
+ {
+ char *buf = (char *)serializerMemAlloc(sizeof(XmlDeserializer), traits);
+ return PX_PLACEMENT_NEW(buf, XmlDeserializer)(traits, ver);
+ }
+
+ PX_INLINE void destroy()
+ {
+ Traits *traits = mTraits;
+ this->~XmlDeserializer();
+ serializerMemFree(this, traits);
+ }
+
+ PX_INLINE Serializer::ErrorType getLastError() const
+ {
+ return mError;
+ }
+
+ PX_INLINE Interface **getObjs()
+ {
+ return mRootObjs;
+ }
+
+ PX_INLINE uint32_t getNobjs() const
+ {
+ return physx::PxMin(mRootIndex, MAX_ROOT_OBJ);
+ }
+
+ //Release all created objects (in case of error)
+ PX_INLINE void releaseAll()
+ {
+ for(uint32_t i = 0; i < getNobjs(); ++i)
+ mRootObjs[i]->destroy();
+ }
+
+ virtual bool processComment(const char *)
+ {
+ return true;
+ }
+
+ virtual bool processDoctype(const char * rootElement, const char *, const char *, const char *)
+ {
+ mHasDoctype = true;
+ return 0 == ::strcmp(rootElement, "NvParameters") || 0 == ::strcmp(rootElement, "NxParameters");
+ }
+
+ virtual void *allocate(uint32_t size)
+ {
+ return mTraits->alloc(size);
+ }
+
+ virtual void deallocate(void *ptr)
+ {
+ mTraits->free(ptr);
+ }
+
+ virtual bool processClose(const char *tag,uint32_t depth,bool &isError);
+
+ virtual bool processElement(
+ const char *elementName,
+ const char *elementData,
+ const physx::shdfnd::FastXml::AttributePairs& attr,
+ int32_t /*lineno*/
+ );
+
+ int32_t* getSimpleStructRedirect(uint32_t size);
+};
+
+}
+
+#endif
diff --git a/APEX_1.4/NvParameterized/include/XmlSerializer.h b/APEX_1.4/NvParameterized/include/XmlSerializer.h
new file mode 100644
index 00000000..47ae4984
--- /dev/null
+++ b/APEX_1.4/NvParameterized/include/XmlSerializer.h
@@ -0,0 +1,114 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2013 NVIDIA Corporation. All rights reserved.
+
+#ifndef PX_XML_SERIALIZER_H
+#define PX_XML_SERIALIZER_H
+
+//XML serialization (by John Ratcliff)
+
+#include "nvparameterized/NvSerializer.h"
+#include "AbstractSerializer.h"
+
+#include "PsIOStream.h"
+
+namespace NvParameterized
+{
+
+struct traversalState;
+
+bool isXmlFormat(physx::PxFileBuf &stream);
+
+// XML serializer implementation
+class XmlSerializer : public AbstractSerializer
+{
+ ErrorType peekNumObjects(char *data, uint32_t len, uint32_t &numObjects);
+
+ Serializer::ErrorType peekClassNames(physx::PxFileBuf &stream, char **classNames, uint32_t &numClassNames);
+
+#ifndef WITHOUT_APEX_SERIALIZATION
+ Serializer::ErrorType traverseParamDefTree(
+ const Interface &obj,
+ physx::PsIOStream &stream,
+ traversalState &state,
+ Handle &handle,
+ bool printValues = true);
+
+ Serializer::ErrorType emitElementNxHints(
+ physx::PsIOStream &stream,
+ Handle &handle,
+ traversalState &state,
+ bool &includedRef);
+
+ Serializer::ErrorType emitElement(
+ const Interface &obj,
+ physx::PsIOStream &stream,
+ const char *elementName,
+ Handle &handle,
+ bool includedRef,
+ bool printValues,
+ bool isRoot = false);
+#endif
+
+protected:
+
+#ifndef WITHOUT_APEX_SERIALIZATION
+ Serializer::ErrorType internalSerialize(physx::PxFileBuf &fbuf,const Interface **objs, uint32_t n, bool doMetadata);
+#endif
+
+ Serializer::ErrorType internalDeserialize(physx::PxFileBuf &stream, DeserializedData &res, bool &doesNeedUpdate);
+
+public:
+
+ XmlSerializer(Traits *traits): AbstractSerializer(traits) {}
+
+ ~XmlSerializer() {}
+
+ virtual void release(void)
+ {
+ this->~XmlSerializer();
+ serializerMemFree(this,mTraits);
+ }
+
+ PX_INLINE static uint32_t version()
+ {
+ return 0x00010000;
+ }
+
+ ErrorType peekNumObjectsInplace(const void * data, uint32_t dataLen, uint32_t & numObjects);
+
+ ErrorType peekNumObjects(physx::PxFileBuf &stream, uint32_t &numObjects);
+
+ using Serializer::deserializeMetadata;
+ ErrorType deserializeMetadata(physx::PxFileBuf & /*stream*/, Definition ** /*defs*/, uint32_t & /*ndefs*/)
+ {
+ return Serializer::ERROR_NOT_IMPLEMENTED;
+ }
+};
+
+} // namespace NvParameterized
+
+#endif