From 7115f60b91b5717d90f643fd692010905c7004db Mon Sep 17 00:00:00 2001 From: Bryan Galdrikian Date: Thu, 31 May 2018 11:36:08 -0700 Subject: Blast 1.1.3. See docs/release_notes.txt. --- .../include/NvBlastExtLlSerialization.h | 226 +++--- .../include/NvBlastExtPxSerialization.h | 198 ++--- .../include/NvBlastExtSerialization.h | 312 ++++---- .../include/NvBlastExtTkSerialization.h | 178 ++--- .../serialization/source/DTO/AssetDTO.cpp | 404 +++++------ sdk/extensions/serialization/source/DTO/AssetDTO.h | 68 +- .../serialization/source/DTO/DTOMacros.h | 86 +-- .../serialization/source/DTO/ExtPxAssetDTO.cpp | 316 ++++---- .../serialization/source/DTO/ExtPxAssetDTO.h | 68 +- .../serialization/source/DTO/ExtPxChunkDTO.cpp | 130 ++-- .../serialization/source/DTO/ExtPxChunkDTO.h | 68 +- .../serialization/source/DTO/ExtPxSubchunkDTO.cpp | 132 ++-- .../serialization/source/DTO/ExtPxSubchunkDTO.h | 68 +- .../serialization/source/DTO/NvBlastBondDTO.cpp | 172 ++--- .../serialization/source/DTO/NvBlastBondDTO.h | 68 +- .../serialization/source/DTO/NvBlastChunkDTO.cpp | 166 ++--- .../serialization/source/DTO/NvBlastChunkDTO.h | 72 +- .../serialization/source/DTO/NvBlastIDDTO.cpp | 140 ++-- .../serialization/source/DTO/NvBlastIDDTO.h | 68 +- .../source/DTO/PxConvexMeshGeometryDTO.cpp | 284 ++++---- .../source/DTO/PxConvexMeshGeometryDTO.h | 70 +- .../serialization/source/DTO/PxMeshScaleDTO.cpp | 128 ++-- .../serialization/source/DTO/PxMeshScaleDTO.h | 70 +- .../serialization/source/DTO/PxQuatDTO.cpp | 130 ++-- .../serialization/source/DTO/PxQuatDTO.h | 70 +- .../serialization/source/DTO/PxTransformDTO.cpp | 126 ++-- .../serialization/source/DTO/PxTransformDTO.h | 70 +- .../serialization/source/DTO/PxVec3DTO.cpp | 130 ++-- .../serialization/source/DTO/PxVec3DTO.h | 68 +- .../serialization/source/DTO/TkAssetDTO.cpp | 188 ++--- .../serialization/source/DTO/TkAssetDTO.h | 68 +- .../source/DTO/TkAssetJointDescDTO.cpp | 152 ++-- .../serialization/source/DTO/TkAssetJointDescDTO.h | 68 +- .../serialization/source/NvBlastExtInputStream.cpp | 112 +-- .../serialization/source/NvBlastExtInputStream.h | 106 +-- .../source/NvBlastExtKJPxInputStream.cpp | 106 +-- .../source/NvBlastExtKJPxInputStream.h | 124 ++-- .../source/NvBlastExtKJPxOutputStream.cpp | 110 +-- .../source/NvBlastExtKJPxOutputStream.h | 122 ++-- .../source/NvBlastExtLlSerialization.capn | 216 +++--- .../source/NvBlastExtLlSerialization.cpp | 272 +++---- .../source/NvBlastExtLlSerializerCAPN.h | 144 ++-- .../source/NvBlastExtOutputStream.cpp | 82 +-- .../serialization/source/NvBlastExtOutputStream.h | 104 +-- .../source/NvBlastExtPxSerialization.capn | 198 ++--- .../source/NvBlastExtPxSerialization.cpp | 218 +++--- .../source/NvBlastExtPxSerializerCAPN.h | 140 ++-- .../source/NvBlastExtPxSerializerRAW.cpp | 442 ++++++------ .../source/NvBlastExtPxSerializerRAW.h | 122 ++-- .../source/NvBlastExtSerialization.cpp | 802 ++++++++++----------- .../source/NvBlastExtSerializationCAPN.h | 376 +++++----- .../source/NvBlastExtSerializationInternal.h | 582 +++++++-------- .../source/NvBlastExtTkSerialization.capn | 110 +-- .../source/NvBlastExtTkSerialization.cpp | 210 +++--- .../source/NvBlastExtTkSerializerCAPN.h | 140 ++-- .../source/NvBlastExtTkSerializerRAW.cpp | 368 +++++----- .../source/NvBlastExtTkSerializerRAW.h | 108 +-- 57 files changed, 4938 insertions(+), 4938 deletions(-) mode change 100644 => 100755 sdk/extensions/serialization/include/NvBlastExtLlSerialization.h mode change 100644 => 100755 sdk/extensions/serialization/include/NvBlastExtPxSerialization.h mode change 100644 => 100755 sdk/extensions/serialization/include/NvBlastExtSerialization.h mode change 100644 => 100755 sdk/extensions/serialization/include/NvBlastExtTkSerialization.h mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/AssetDTO.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/AssetDTO.h mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/DTOMacros.h mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.h mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/ExtPxChunkDTO.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/ExtPxChunkDTO.h mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/ExtPxSubchunkDTO.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/ExtPxSubchunkDTO.h mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/NvBlastBondDTO.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/NvBlastBondDTO.h mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/NvBlastChunkDTO.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/NvBlastChunkDTO.h mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/NvBlastIDDTO.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/NvBlastIDDTO.h mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/PxConvexMeshGeometryDTO.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/PxConvexMeshGeometryDTO.h mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/PxMeshScaleDTO.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/PxMeshScaleDTO.h mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/PxQuatDTO.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/PxQuatDTO.h mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/PxTransformDTO.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/PxTransformDTO.h mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/PxVec3DTO.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/PxVec3DTO.h mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/TkAssetDTO.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/TkAssetDTO.h mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/TkAssetJointDescDTO.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/DTO/TkAssetJointDescDTO.h mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtInputStream.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtInputStream.h mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtKJPxInputStream.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtKJPxInputStream.h mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtKJPxOutputStream.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtKJPxOutputStream.h mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtLlSerialization.capn mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtLlSerialization.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtLlSerializerCAPN.h mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtOutputStream.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtOutputStream.h mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtPxSerialization.capn mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtPxSerialization.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtPxSerializerCAPN.h mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtPxSerializerRAW.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtPxSerializerRAW.h mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtSerialization.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtSerializationCAPN.h mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtSerializationInternal.h mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtTkSerialization.capn mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtTkSerialization.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtTkSerializerCAPN.h mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtTkSerializerRAW.cpp mode change 100644 => 100755 sdk/extensions/serialization/source/NvBlastExtTkSerializerRAW.h (limited to 'sdk/extensions/serialization') diff --git a/sdk/extensions/serialization/include/NvBlastExtLlSerialization.h b/sdk/extensions/serialization/include/NvBlastExtLlSerialization.h old mode 100644 new mode 100755 index 5e58300..155065b --- a/sdk/extensions/serialization/include/NvBlastExtLlSerialization.h +++ b/sdk/extensions/serialization/include/NvBlastExtLlSerialization.h @@ -1,113 +1,113 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once - -#include "NvBlastGlobals.h" - - -/** -Blast Low-level serialization support. Contains serializers which can be used by the ExtSerialization manager. -*/ - - -// Forward declarations -struct NvBlastAsset; -struct NvBlastFamily; - - -namespace Nv -{ -namespace Blast -{ - -// Forward declarations -class ExtSerialization; - - -/** Standard Object Type IDs */ -struct LlObjectTypeID -{ - enum Enum - { - Asset = NVBLAST_FOURCC('L', 'L', 'A', 'S'), - Family = NVBLAST_FOURCC('L', 'L', 'F', 'A'), - }; -}; - -} // namespace Blast -} // namespace Nv - - -/** -Load all low-level serializers into the ExtSerialization manager. *N.B.* This is done automatically when -the ExtSerialization manager is created via NvBlastExtSerializationCreate(), so currently this public function -is unnecessary. Note also that other modules' serializers (ExtTkSerialization and ExtPxSerialization) are -_not_ loaded automatically, and need to be explicitly loaded by the user using their respective load functions. - -It does no harm to call this function more than once; serializers already loaded will not be loaded again. - -\param[in] serialization Serialization manager into which to load serializers. - -\return the number of serializers loaded. -*/ -NVBLAST_API size_t NvBlastExtLlSerializerLoadSet(Nv::Blast::ExtSerialization& serialization); - - -/** -Utility wrapper function to serialize an NvBlastAsset. Allocates the buffer internally using the -callack set in ExtSerialization::setBufferProvider. - -Equivalent to: - - serialization.serializeIntoBuffer(buffer, asset, Nv::Blast::LlObjectTypeID::Asset); - -\param[out] buffer Pointer to the buffer created. -\param[in] serialization Serialization manager. -\param[in] asset Pointer to the NvBlastAsset to serialize. - -\return the number of bytes serialized into the buffer (zero if unsuccessful). -*/ -NVBLAST_API uint64_t NvBlastExtSerializationSerializeAssetIntoBuffer(void*& buffer, Nv::Blast::ExtSerialization& serialization, const NvBlastAsset* asset); - - -/** -Utility wrapper function to serialize an NvBlastFamily. Allocates the buffer internally using the -callack set in ExtSerialization::setBufferProvider. - -Equivalent to: - - serialization.serializeIntoBuffer(buffer, family, Nv::Blast::LlObjectTypeID::Family); - -\param[out] buffer Pointer to the buffer created. -\param[in] serialization Serialization manager. -\param[in] family Pointer to the NvBlastFamily to serialize. - -\return the number of bytes serialized into the buffer (zero if unsuccessful). -*/ -NVBLAST_API uint64_t NvBlastExtSerializationSerializeFamilyIntoBuffer(void*& buffer, Nv::Blast::ExtSerialization& serialization, const NvBlastFamily* family); +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once + +#include "NvBlastGlobals.h" + + +/** +Blast Low-level serialization support. Contains serializers which can be used by the ExtSerialization manager. +*/ + + +// Forward declarations +struct NvBlastAsset; +struct NvBlastFamily; + + +namespace Nv +{ +namespace Blast +{ + +// Forward declarations +class ExtSerialization; + + +/** Standard Object Type IDs */ +struct LlObjectTypeID +{ + enum Enum + { + Asset = NVBLAST_FOURCC('L', 'L', 'A', 'S'), + Family = NVBLAST_FOURCC('L', 'L', 'F', 'A'), + }; +}; + +} // namespace Blast +} // namespace Nv + + +/** +Load all low-level serializers into the ExtSerialization manager. *N.B.* This is done automatically when +the ExtSerialization manager is created via NvBlastExtSerializationCreate(), so currently this public function +is unnecessary. Note also that other modules' serializers (ExtTkSerialization and ExtPxSerialization) are +_not_ loaded automatically, and need to be explicitly loaded by the user using their respective load functions. + +It does no harm to call this function more than once; serializers already loaded will not be loaded again. + +\param[in] serialization Serialization manager into which to load serializers. + +\return the number of serializers loaded. +*/ +NVBLAST_API size_t NvBlastExtLlSerializerLoadSet(Nv::Blast::ExtSerialization& serialization); + + +/** +Utility wrapper function to serialize an NvBlastAsset. Allocates the buffer internally using the +callack set in ExtSerialization::setBufferProvider. + +Equivalent to: + + serialization.serializeIntoBuffer(buffer, asset, Nv::Blast::LlObjectTypeID::Asset); + +\param[out] buffer Pointer to the buffer created. +\param[in] serialization Serialization manager. +\param[in] asset Pointer to the NvBlastAsset to serialize. + +\return the number of bytes serialized into the buffer (zero if unsuccessful). +*/ +NVBLAST_API uint64_t NvBlastExtSerializationSerializeAssetIntoBuffer(void*& buffer, Nv::Blast::ExtSerialization& serialization, const NvBlastAsset* asset); + + +/** +Utility wrapper function to serialize an NvBlastFamily. Allocates the buffer internally using the +callack set in ExtSerialization::setBufferProvider. + +Equivalent to: + + serialization.serializeIntoBuffer(buffer, family, Nv::Blast::LlObjectTypeID::Family); + +\param[out] buffer Pointer to the buffer created. +\param[in] serialization Serialization manager. +\param[in] family Pointer to the NvBlastFamily to serialize. + +\return the number of bytes serialized into the buffer (zero if unsuccessful). +*/ +NVBLAST_API uint64_t NvBlastExtSerializationSerializeFamilyIntoBuffer(void*& buffer, Nv::Blast::ExtSerialization& serialization, const NvBlastFamily* family); diff --git a/sdk/extensions/serialization/include/NvBlastExtPxSerialization.h b/sdk/extensions/serialization/include/NvBlastExtPxSerialization.h old mode 100644 new mode 100755 index 7a5f8b6..9116d32 --- a/sdk/extensions/serialization/include/NvBlastExtPxSerialization.h +++ b/sdk/extensions/serialization/include/NvBlastExtPxSerialization.h @@ -1,99 +1,99 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once - -#include "NvBlastGlobals.h" - - -/** -Blast serialization support for the ExtPhysX extension. Contains serializers which can be used by the ExtSerialization manager. -*/ - - -namespace Nv -{ -namespace Blast -{ - -// Forward declarations -class TkFramework; -class ExtSerialization; -class ExtPxAsset; - - -/** Standard Object Type IDs */ -struct ExtPxObjectTypeID -{ - enum Enum - { - Asset = NVBLAST_FOURCC('P', 'X', 'A', 'S'), - }; -}; - -} // namespace Blast -} // namespace Nv - - -namespace physx -{ - -// Forward declarations -class PxPhysics; -class PxCooking; - -} // namespace physx - - -/** -Load all ExtPhysX extension serializers into the ExtSerialization manager. - -It does no harm to call this function more than once; serializers already loaded will not be loaded again. - -\param[in] serialization Serialization manager into which to load serializers. - -\return the number of serializers loaded. -*/ -NVBLAST_API size_t NvBlastExtPxSerializerLoadSet(Nv::Blast::TkFramework& framework, physx::PxPhysics& physics, physx::PxCooking& cooking, Nv::Blast::ExtSerialization& serialization); - - -/** -Utility wrapper function to serialize an ExtPxAsset. Allocates the buffer internally using the -callack set in ExtSerialization::setBufferProvider. - -Equivalent to: - - serialization.serializeIntoBuffer(buffer, asset, Nv::Blast::ExtPxObjectTypeID::Asset); - -\param[out] buffer Pointer to the buffer created. -\param[in] serialization Serialization manager. -\param[in] asset Pointer to the ExtPxAsset to serialize. - -\return the number of bytes serialized into the buffer (zero if unsuccessful). -*/ -NVBLAST_API uint64_t NvBlastExtSerializationSerializeExtPxAssetIntoBuffer(void*& buffer, Nv::Blast::ExtSerialization& serialization, const Nv::Blast::ExtPxAsset* asset); +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once + +#include "NvBlastGlobals.h" + + +/** +Blast serialization support for the ExtPhysX extension. Contains serializers which can be used by the ExtSerialization manager. +*/ + + +namespace Nv +{ +namespace Blast +{ + +// Forward declarations +class TkFramework; +class ExtSerialization; +class ExtPxAsset; + + +/** Standard Object Type IDs */ +struct ExtPxObjectTypeID +{ + enum Enum + { + Asset = NVBLAST_FOURCC('P', 'X', 'A', 'S'), + }; +}; + +} // namespace Blast +} // namespace Nv + + +namespace physx +{ + +// Forward declarations +class PxPhysics; +class PxCooking; + +} // namespace physx + + +/** +Load all ExtPhysX extension serializers into the ExtSerialization manager. + +It does no harm to call this function more than once; serializers already loaded will not be loaded again. + +\param[in] serialization Serialization manager into which to load serializers. + +\return the number of serializers loaded. +*/ +NVBLAST_API size_t NvBlastExtPxSerializerLoadSet(Nv::Blast::TkFramework& framework, physx::PxPhysics& physics, physx::PxCooking& cooking, Nv::Blast::ExtSerialization& serialization); + + +/** +Utility wrapper function to serialize an ExtPxAsset. Allocates the buffer internally using the +callack set in ExtSerialization::setBufferProvider. + +Equivalent to: + + serialization.serializeIntoBuffer(buffer, asset, Nv::Blast::ExtPxObjectTypeID::Asset); + +\param[out] buffer Pointer to the buffer created. +\param[in] serialization Serialization manager. +\param[in] asset Pointer to the ExtPxAsset to serialize. + +\return the number of bytes serialized into the buffer (zero if unsuccessful). +*/ +NVBLAST_API uint64_t NvBlastExtSerializationSerializeExtPxAssetIntoBuffer(void*& buffer, Nv::Blast::ExtSerialization& serialization, const Nv::Blast::ExtPxAsset* asset); diff --git a/sdk/extensions/serialization/include/NvBlastExtSerialization.h b/sdk/extensions/serialization/include/NvBlastExtSerialization.h old mode 100644 new mode 100755 index d929647..63db739 --- a/sdk/extensions/serialization/include/NvBlastExtSerialization.h +++ b/sdk/extensions/serialization/include/NvBlastExtSerialization.h @@ -1,156 +1,156 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once - -#include "NvBlastGlobals.h" - - -namespace Nv -{ -namespace Blast -{ - -/** - Serialization manager interface -*/ -class ExtSerialization -{ -public: - /** Standard Encoding IDs */ - struct EncodingID - { - enum Enum - { - CapnProtoBinary = NVBLAST_FOURCC('C', 'P', 'N', 'B'), - RawBinary = NVBLAST_FOURCC('R', 'A', 'W', ' '), - }; - }; - - /** Buffer provider API, used to request a buffer for serialization. */ - class BufferProvider - { - public: - virtual void* requestBuffer(size_t size) = 0; - }; - - /** - Set the serialization encoding to use. (See EncodingID.) - - \return true iff successful. - */ - virtual bool setSerializationEncoding(uint32_t encodingID) = 0; - - /** - Retrieve the current serialization encoding being used. Note, by default this is set to the encoding of the first - serializer registered by a module. Currently this is done automatically by the NvBlastExtLlExtension module. - - \return the current serialization encoding (zero if none is set). - */ - virtual uint32_t getSerializationEncoding() const = 0; - - /** - Set the buffer provider callback to use. (See BufferProvider.) If not set, a default provider using NVBLAST_ALLOC (see - NvBlastGlobals.h) is used, which may be freed using NvBLAST_FREE. - - \param[in] bufferProvider Buffer provider callback to use. If NULL, uses the default provider using the allocator given - in NvBlastGlobals. - */ - virtual void setBufferProvider(BufferProvider* bufferProvider) = 0; - - /** - Reads information from a buffer, returning the contained object type ID, encoding ID, and data size. - \param[out] objectTypeID If not NULL, the object type ID is written to *objectTypeID. - \param[out] encodingID If not NULL, the encoding ID is written to *encodingID. - \param[out] dataSize If not NULL, the data size is written to *dataSize. (Does not include the size of the header.) - \param[in] buffer Pointer to the buffer to read. - \param[in] bufferSize Size of the buffer to read. - - \return true iff the header is successfully read. - */ - virtual bool peekHeader(uint32_t* objectTypeID, uint32_t* encodingID, uint64_t* dataSize, const void* buffer, uint64_t bufferSize) = 0; - - /** - Determines the current object in the buffer and returns the position in the buffer immediately after the object. - - \param[in, out] bufferSize Size of the buffer to read on input, on output the remaining buffer size given the return buffer value. - \param[in] buffer Pointer to the buffer to read. - - \return a pointer to the new position in the buffer after the skipped object if successful, NULL otherwise. The bufferSize field is only updated if a valid pointer is returned. - */ - virtual const void* skipObject(uint64_t& bufferSize, const void* buffer) = 0; - - /** - Deserialize from a buffer into a newly allocated object. - - \param[in] buffer Pointer to the buffer to read. - \param[in] bufferSize Size of the buffer to read. - \param[out] objectTypeIDPtr Optional, if not NULL then *objectTypeIDPtr will be filled with the deserialized object's - type ID if deserialization is successful, or 0 if unsuccessful. - - \return object pointer; returns null if failed to deserialize. - */ - virtual void* deserializeFromBuffer(const void* buffer, uint64_t bufferSize, uint32_t* objectTypeIDPtr = nullptr) = 0; - - /** - Serialize into a buffer. Allocates the buffer internally using the callack set in setBufferProvider. - - \param[out] buffer Pointer to the buffer created. - \param[in] object Object pointer. - \param[in] objectTypeID Object type ID. - - \return the number of bytes serialized into the buffer (zero if unsuccessful). - */ - virtual uint64_t serializeIntoBuffer(void*& buffer, const void* object, uint32_t objectTypeID) = 0; - - /** - Release the serialization manager and all contained objects. - */ - virtual void release() = 0; - -protected: - /** - Destructor is virtual and not public - use the release() method instead of explicitly deleting the serialization manager - */ - virtual ~ExtSerialization() {} -}; - -} // namespace Blast -} // namespace Nv - - -//////// Global API to create serialization //////// - -/** -Create a new serialization manager. To release it, use its release() method. - -This uses the global allocator set in NvBlastGlobals.h. - -\return a new serialization manager. -*/ -NVBLAST_API Nv::Blast::ExtSerialization* NvBlastExtSerializationCreate(); +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once + +#include "NvBlastGlobals.h" + + +namespace Nv +{ +namespace Blast +{ + +/** + Serialization manager interface +*/ +class ExtSerialization +{ +public: + /** Standard Encoding IDs */ + struct EncodingID + { + enum Enum + { + CapnProtoBinary = NVBLAST_FOURCC('C', 'P', 'N', 'B'), + RawBinary = NVBLAST_FOURCC('R', 'A', 'W', ' '), + }; + }; + + /** Buffer provider API, used to request a buffer for serialization. */ + class BufferProvider + { + public: + virtual void* requestBuffer(size_t size) = 0; + }; + + /** + Set the serialization encoding to use. (See EncodingID.) + + \return true iff successful. + */ + virtual bool setSerializationEncoding(uint32_t encodingID) = 0; + + /** + Retrieve the current serialization encoding being used. Note, by default this is set to the encoding of the first + serializer registered by a module. Currently this is done automatically by the NvBlastExtLlExtension module. + + \return the current serialization encoding (zero if none is set). + */ + virtual uint32_t getSerializationEncoding() const = 0; + + /** + Set the buffer provider callback to use. (See BufferProvider.) If not set, a default provider using NVBLAST_ALLOC (see + NvBlastGlobals.h) is used, which may be freed using NvBLAST_FREE. + + \param[in] bufferProvider Buffer provider callback to use. If NULL, uses the default provider using the allocator given + in NvBlastGlobals. + */ + virtual void setBufferProvider(BufferProvider* bufferProvider) = 0; + + /** + Reads information from a buffer, returning the contained object type ID, encoding ID, and data size. + \param[out] objectTypeID If not NULL, the object type ID is written to *objectTypeID. + \param[out] encodingID If not NULL, the encoding ID is written to *encodingID. + \param[out] dataSize If not NULL, the data size is written to *dataSize. (Does not include the size of the header.) + \param[in] buffer Pointer to the buffer to read. + \param[in] bufferSize Size of the buffer to read. + + \return true iff the header is successfully read. + */ + virtual bool peekHeader(uint32_t* objectTypeID, uint32_t* encodingID, uint64_t* dataSize, const void* buffer, uint64_t bufferSize) = 0; + + /** + Determines the current object in the buffer and returns the position in the buffer immediately after the object. + + \param[in, out] bufferSize Size of the buffer to read on input, on output the remaining buffer size given the return buffer value. + \param[in] buffer Pointer to the buffer to read. + + \return a pointer to the new position in the buffer after the skipped object if successful, NULL otherwise. The bufferSize field is only updated if a valid pointer is returned. + */ + virtual const void* skipObject(uint64_t& bufferSize, const void* buffer) = 0; + + /** + Deserialize from a buffer into a newly allocated object. + + \param[in] buffer Pointer to the buffer to read. + \param[in] bufferSize Size of the buffer to read. + \param[out] objectTypeIDPtr Optional, if not NULL then *objectTypeIDPtr will be filled with the deserialized object's + type ID if deserialization is successful, or 0 if unsuccessful. + + \return object pointer; returns null if failed to deserialize. + */ + virtual void* deserializeFromBuffer(const void* buffer, uint64_t bufferSize, uint32_t* objectTypeIDPtr = nullptr) = 0; + + /** + Serialize into a buffer. Allocates the buffer internally using the callack set in setBufferProvider. + + \param[out] buffer Pointer to the buffer created. + \param[in] object Object pointer. + \param[in] objectTypeID Object type ID. + + \return the number of bytes serialized into the buffer (zero if unsuccessful). + */ + virtual uint64_t serializeIntoBuffer(void*& buffer, const void* object, uint32_t objectTypeID) = 0; + + /** + Release the serialization manager and all contained objects. + */ + virtual void release() = 0; + +protected: + /** + Destructor is virtual and not public - use the release() method instead of explicitly deleting the serialization manager + */ + virtual ~ExtSerialization() {} +}; + +} // namespace Blast +} // namespace Nv + + +//////// Global API to create serialization //////// + +/** +Create a new serialization manager. To release it, use its release() method. + +This uses the global allocator set in NvBlastGlobals.h. + +\return a new serialization manager. +*/ +NVBLAST_API Nv::Blast::ExtSerialization* NvBlastExtSerializationCreate(); diff --git a/sdk/extensions/serialization/include/NvBlastExtTkSerialization.h b/sdk/extensions/serialization/include/NvBlastExtTkSerialization.h old mode 100644 new mode 100755 index 18df1d5..35b4fdb --- a/sdk/extensions/serialization/include/NvBlastExtTkSerialization.h +++ b/sdk/extensions/serialization/include/NvBlastExtTkSerialization.h @@ -1,89 +1,89 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once - -#include "NvBlastGlobals.h" - - -/** -Blast High-level serialization support. Contains serializers which can be used by the ExtSerialization manager. -*/ - - -namespace Nv -{ -namespace Blast -{ - -// Forward declarations -class ExtSerialization; -class TkFramework; -class TkAsset; - - -/** Standard Object Type IDs */ -struct TkObjectTypeID -{ - enum Enum - { - Asset = NVBLAST_FOURCC('T', 'K', 'A', 'S'), - }; -}; - -} // namespace Blast -} // namespace Nv - - -/** -Load all high-level serializers into the ExtSerialization manager. - -It does no harm to call this function more than once; serializers already loaded will not be loaded again. - -\param[in] serialization Serialization manager into which to load serializers. - -\return the number of serializers loaded. -*/ -NVBLAST_API size_t NvBlastExtTkSerializerLoadSet(Nv::Blast::TkFramework& framework, Nv::Blast::ExtSerialization& serialization); - - -/** -Utility wrapper function to serialize a TkAsset. Allocates the buffer internally using the -callack set in ExtSerialization::setBufferProvider. - -Equivalent to: - - serialization.serializeIntoBuffer(buffer, asset, Nv::Blast::TkObjectTypeID::Asset); - -\param[out] buffer Pointer to the buffer created. -\param[in] serialization Serialization manager. -\param[in] asset Pointer to the TkAsset to serialize. - -\return the number of bytes serialized into the buffer (zero if unsuccessful). -*/ -NVBLAST_API uint64_t NvBlastExtSerializationSerializeTkAssetIntoBuffer(void*& buffer, Nv::Blast::ExtSerialization& serialization, const Nv::Blast::TkAsset* asset); +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once + +#include "NvBlastGlobals.h" + + +/** +Blast High-level serialization support. Contains serializers which can be used by the ExtSerialization manager. +*/ + + +namespace Nv +{ +namespace Blast +{ + +// Forward declarations +class ExtSerialization; +class TkFramework; +class TkAsset; + + +/** Standard Object Type IDs */ +struct TkObjectTypeID +{ + enum Enum + { + Asset = NVBLAST_FOURCC('T', 'K', 'A', 'S'), + }; +}; + +} // namespace Blast +} // namespace Nv + + +/** +Load all high-level serializers into the ExtSerialization manager. + +It does no harm to call this function more than once; serializers already loaded will not be loaded again. + +\param[in] serialization Serialization manager into which to load serializers. + +\return the number of serializers loaded. +*/ +NVBLAST_API size_t NvBlastExtTkSerializerLoadSet(Nv::Blast::TkFramework& framework, Nv::Blast::ExtSerialization& serialization); + + +/** +Utility wrapper function to serialize a TkAsset. Allocates the buffer internally using the +callack set in ExtSerialization::setBufferProvider. + +Equivalent to: + + serialization.serializeIntoBuffer(buffer, asset, Nv::Blast::TkObjectTypeID::Asset); + +\param[out] buffer Pointer to the buffer created. +\param[in] serialization Serialization manager. +\param[in] asset Pointer to the TkAsset to serialize. + +\return the number of bytes serialized into the buffer (zero if unsuccessful). +*/ +NVBLAST_API uint64_t NvBlastExtSerializationSerializeTkAssetIntoBuffer(void*& buffer, Nv::Blast::ExtSerialization& serialization, const Nv::Blast::TkAsset* asset); diff --git a/sdk/extensions/serialization/source/DTO/AssetDTO.cpp b/sdk/extensions/serialization/source/DTO/AssetDTO.cpp old mode 100644 new mode 100755 index a88717c..c7005fe --- a/sdk/extensions/serialization/source/DTO/AssetDTO.cpp +++ b/sdk/extensions/serialization/source/DTO/AssetDTO.cpp @@ -1,202 +1,202 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "AssetDTO.h" -#include "NvBlastGlobals.h" -#include "NvBlastIDDTO.h" -#include "NvBlastChunkDTO.h" -#include "NvBlastBondDTO.h" -#include "NvBlastAsset.h" - - -namespace Nv -{ -namespace Blast -{ - -bool AssetDTO::serialize(Nv::Blast::Serialization::Asset::Builder builder, const Nv::Blast::Asset * poco) -{ - NvBlastIDDTO::serialize(builder.initID(), &poco->m_ID); - - builder.setLeafChunkCount(poco->m_leafChunkCount); - - builder.setFirstSubsupportChunkIndex(poco->m_firstSubsupportChunkIndex); - - capnp::List::Builder chunks = builder.initChunks(poco->m_chunkCount); - - builder.setChunkCount(poco->m_chunkCount); - - NVBLAST_ASSERT_WITH_MESSAGE(builder.getChunkCount() == poco->m_chunkCount, "WTF"); - - for (uint32_t i = 0; i < poco->m_chunkCount; i++) - { - NvBlastChunk& chunk = poco->getChunks()[i]; - - NvBlastChunkDTO::serialize(chunks[i], &chunk); - } - - NVBLAST_ASSERT_WITH_MESSAGE(builder.getChunkCount() == poco->m_chunkCount, "WTF"); - - capnp::List::Builder bonds = builder.initBonds(poco->m_bondCount); - - builder.setBondCount(poco->m_bondCount); - - for (uint32_t i = 0; i < poco->m_bondCount; i++) - { - NvBlastBond& bond = poco->getBonds()[i]; - - NvBlastBondDTO::serialize(bonds[i], &bond); - } - - kj::ArrayPtr stlcArray(poco->getSubtreeLeafChunkCounts(), poco->m_chunkCount); - builder.initSubtreeLeafChunkCounts(poco->m_chunkCount); - builder.setSubtreeLeafChunkCounts(stlcArray); - - kj::ArrayPtr ctgnArray(poco->getChunkToGraphNodeMap(), poco->m_chunkCount); - builder.setChunkToGraphNodeMap(ctgnArray); - - Nv::Blast::Serialization::NvBlastSupportGraph::Builder graphBulder = builder.initGraph(); - - graphBulder.setNodeCount(poco->m_graph.m_nodeCount); - - uint32_t* ciPtr = poco->m_graph.getChunkIndices(); - - kj::ArrayPtr ciArray(ciPtr, poco->m_graph.m_nodeCount); - graphBulder.setChunkIndices(ciArray); - - kj::ArrayPtr adjPart(poco->m_graph.getAdjacencyPartition(), poco->m_graph.m_nodeCount + 1); - graphBulder.setAdjacencyPartition(adjPart); - - NVBLAST_ASSERT(graphBulder.getAdjacencyPartition().size() == poco->m_graph.m_nodeCount + 1); - - kj::ArrayPtr nodeIndices(poco->m_graph.getAdjacentNodeIndices(), poco->m_bondCount * 2); - graphBulder.setAdjacentNodeIndices(nodeIndices); - - NVBLAST_ASSERT(graphBulder.getAdjacentNodeIndices().size() == poco->m_bondCount * 2); - - kj::ArrayPtr bondIndices(poco->m_graph.getAdjacentBondIndices(), poco->m_bondCount * 2); - graphBulder.setAdjacentBondIndices(bondIndices); - - return true; -} - - -Nv::Blast::Asset* AssetDTO::deserialize(Nv::Blast::Serialization::Asset::Reader reader) -{ - NvBlastID EmptyId; - memset(EmptyId.data, 0, sizeof(NvBlastID)); - - void* mem = NVBLAST_ALLOC(reader.totalSize().wordCount * sizeof(uint64_t)); - - auto asset = Nv::Blast::initializeAsset(mem, EmptyId, reader.getChunkCount(), reader.getGraph().getNodeCount(), reader.getLeafChunkCount(), reader.getFirstSubsupportChunkIndex(), reader.getBondCount(), logLL); - - bool result = deserializeInto(reader, asset); - - return result ? asset : nullptr; -} - - -bool AssetDTO::deserializeInto(Nv::Blast::Serialization::Asset::Reader reader, Nv::Blast::Asset * poco) -{ - NvBlastIDDTO::deserializeInto(reader.getID(), &poco->m_ID); - - NvBlastBond* bonds = poco->getBonds(); - - uint32_t bondCount = reader.getBondCount(); - auto readerBonds = reader.getBonds(); - for (uint32_t i = 0; i < bondCount; i++) - { - auto bondReader = readerBonds[i]; - - NvBlastBondDTO::deserializeInto(bondReader, &bonds[i]); - } - - NvBlastChunk* chunks = poco->getChunks(); - - uint32_t chunkCount = reader.getChunkCount(); - auto readerChunks = reader.getChunks(); - for (uint32_t i = 0; i < chunkCount; i++) - { - auto chunkReader = readerChunks[i]; - - NvBlastChunkDTO::deserializeInto(chunkReader, &chunks[i]); - } - - poco->m_graph.m_nodeCount = reader.getGraph().getNodeCount(); - - NVBLAST_ASSERT(reader.getSubtreeLeafChunkCounts().size() == poco->m_chunkCount); - auto readerSubtreeLeafChunkCounts = reader.getSubtreeLeafChunkCounts(); - for (uint32_t i = 0; i < poco->m_chunkCount; i++) - { - poco->getSubtreeLeafChunkCounts()[i] = readerSubtreeLeafChunkCounts[i]; - } - - auto readerChunkToGraphNodeMap = reader.getChunkToGraphNodeMap(); - for (uint32_t i = 0; i < chunkCount; i++) - { - poco->getChunkToGraphNodeMap()[i] = readerChunkToGraphNodeMap[i]; - } - - uint32_t* ciPtr = poco->m_graph.getChunkIndices(); - - NVBLAST_ASSERT(reader.getGraph().getChunkIndices().size() == poco->m_graph.m_nodeCount); - auto readerGraphChunkIndices = reader.getGraph().getChunkIndices(); - for (uint32_t i = 0; i < poco->m_graph.m_nodeCount; i++) - { - ciPtr[i] = readerGraphChunkIndices[i]; - } - - uint32_t* adjPartition = poco->m_graph.getAdjacencyPartition(); - const uint32_t graphAdjacencyPartitionSize = reader.getGraph().getAdjacencyPartition().size(); - auto readerGraphAdjacencyPartition = reader.getGraph().getAdjacencyPartition(); - for (uint32_t i = 0; i < graphAdjacencyPartitionSize; ++i) - { - adjPartition[i] = readerGraphAdjacencyPartition[i]; - } - - uint32_t* adjNodes = poco->m_graph.getAdjacentNodeIndices(); - const uint32_t graphAdjacentNodeIndicesSize = reader.getGraph().getAdjacentNodeIndices().size(); - auto readerGraphAdjacentNodeIndices = reader.getGraph().getAdjacentNodeIndices(); - for (uint32_t i = 0; i < graphAdjacentNodeIndicesSize; ++i) - { - adjNodes[i] = readerGraphAdjacentNodeIndices[i]; - } - - uint32_t* adjBonds = poco->m_graph.getAdjacentBondIndices(); - const uint32_t graphAdjacentBondIndicesSize = reader.getGraph().getAdjacentBondIndices().size(); - auto readerGraphAdjacentBondIndices = reader.getGraph().getAdjacentBondIndices(); - for (uint32_t i = 0; i < graphAdjacentBondIndicesSize; ++i) - { - adjBonds[i] = readerGraphAdjacentBondIndices[i]; - } - - return true; -} - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "AssetDTO.h" +#include "NvBlastGlobals.h" +#include "NvBlastIDDTO.h" +#include "NvBlastChunkDTO.h" +#include "NvBlastBondDTO.h" +#include "NvBlastAsset.h" + + +namespace Nv +{ +namespace Blast +{ + +bool AssetDTO::serialize(Nv::Blast::Serialization::Asset::Builder builder, const Nv::Blast::Asset * poco) +{ + NvBlastIDDTO::serialize(builder.initID(), &poco->m_ID); + + builder.setLeafChunkCount(poco->m_leafChunkCount); + + builder.setFirstSubsupportChunkIndex(poco->m_firstSubsupportChunkIndex); + + capnp::List::Builder chunks = builder.initChunks(poco->m_chunkCount); + + builder.setChunkCount(poco->m_chunkCount); + + NVBLAST_ASSERT_WITH_MESSAGE(builder.getChunkCount() == poco->m_chunkCount, "WTF"); + + for (uint32_t i = 0; i < poco->m_chunkCount; i++) + { + NvBlastChunk& chunk = poco->getChunks()[i]; + + NvBlastChunkDTO::serialize(chunks[i], &chunk); + } + + NVBLAST_ASSERT_WITH_MESSAGE(builder.getChunkCount() == poco->m_chunkCount, "WTF"); + + capnp::List::Builder bonds = builder.initBonds(poco->m_bondCount); + + builder.setBondCount(poco->m_bondCount); + + for (uint32_t i = 0; i < poco->m_bondCount; i++) + { + NvBlastBond& bond = poco->getBonds()[i]; + + NvBlastBondDTO::serialize(bonds[i], &bond); + } + + kj::ArrayPtr stlcArray(poco->getSubtreeLeafChunkCounts(), poco->m_chunkCount); + builder.initSubtreeLeafChunkCounts(poco->m_chunkCount); + builder.setSubtreeLeafChunkCounts(stlcArray); + + kj::ArrayPtr ctgnArray(poco->getChunkToGraphNodeMap(), poco->m_chunkCount); + builder.setChunkToGraphNodeMap(ctgnArray); + + Nv::Blast::Serialization::NvBlastSupportGraph::Builder graphBulder = builder.initGraph(); + + graphBulder.setNodeCount(poco->m_graph.m_nodeCount); + + uint32_t* ciPtr = poco->m_graph.getChunkIndices(); + + kj::ArrayPtr ciArray(ciPtr, poco->m_graph.m_nodeCount); + graphBulder.setChunkIndices(ciArray); + + kj::ArrayPtr adjPart(poco->m_graph.getAdjacencyPartition(), poco->m_graph.m_nodeCount + 1); + graphBulder.setAdjacencyPartition(adjPart); + + NVBLAST_ASSERT(graphBulder.getAdjacencyPartition().size() == poco->m_graph.m_nodeCount + 1); + + kj::ArrayPtr nodeIndices(poco->m_graph.getAdjacentNodeIndices(), poco->m_bondCount * 2); + graphBulder.setAdjacentNodeIndices(nodeIndices); + + NVBLAST_ASSERT(graphBulder.getAdjacentNodeIndices().size() == poco->m_bondCount * 2); + + kj::ArrayPtr bondIndices(poco->m_graph.getAdjacentBondIndices(), poco->m_bondCount * 2); + graphBulder.setAdjacentBondIndices(bondIndices); + + return true; +} + + +Nv::Blast::Asset* AssetDTO::deserialize(Nv::Blast::Serialization::Asset::Reader reader) +{ + NvBlastID EmptyId; + memset(EmptyId.data, 0, sizeof(NvBlastID)); + + void* mem = NVBLAST_ALLOC(reader.totalSize().wordCount * sizeof(uint64_t)); + + auto asset = Nv::Blast::initializeAsset(mem, EmptyId, reader.getChunkCount(), reader.getGraph().getNodeCount(), reader.getLeafChunkCount(), reader.getFirstSubsupportChunkIndex(), reader.getBondCount(), logLL); + + bool result = deserializeInto(reader, asset); + + return result ? asset : nullptr; +} + + +bool AssetDTO::deserializeInto(Nv::Blast::Serialization::Asset::Reader reader, Nv::Blast::Asset * poco) +{ + NvBlastIDDTO::deserializeInto(reader.getID(), &poco->m_ID); + + NvBlastBond* bonds = poco->getBonds(); + + uint32_t bondCount = reader.getBondCount(); + auto readerBonds = reader.getBonds(); + for (uint32_t i = 0; i < bondCount; i++) + { + auto bondReader = readerBonds[i]; + + NvBlastBondDTO::deserializeInto(bondReader, &bonds[i]); + } + + NvBlastChunk* chunks = poco->getChunks(); + + uint32_t chunkCount = reader.getChunkCount(); + auto readerChunks = reader.getChunks(); + for (uint32_t i = 0; i < chunkCount; i++) + { + auto chunkReader = readerChunks[i]; + + NvBlastChunkDTO::deserializeInto(chunkReader, &chunks[i]); + } + + poco->m_graph.m_nodeCount = reader.getGraph().getNodeCount(); + + NVBLAST_ASSERT(reader.getSubtreeLeafChunkCounts().size() == poco->m_chunkCount); + auto readerSubtreeLeafChunkCounts = reader.getSubtreeLeafChunkCounts(); + for (uint32_t i = 0; i < poco->m_chunkCount; i++) + { + poco->getSubtreeLeafChunkCounts()[i] = readerSubtreeLeafChunkCounts[i]; + } + + auto readerChunkToGraphNodeMap = reader.getChunkToGraphNodeMap(); + for (uint32_t i = 0; i < chunkCount; i++) + { + poco->getChunkToGraphNodeMap()[i] = readerChunkToGraphNodeMap[i]; + } + + uint32_t* ciPtr = poco->m_graph.getChunkIndices(); + + NVBLAST_ASSERT(reader.getGraph().getChunkIndices().size() == poco->m_graph.m_nodeCount); + auto readerGraphChunkIndices = reader.getGraph().getChunkIndices(); + for (uint32_t i = 0; i < poco->m_graph.m_nodeCount; i++) + { + ciPtr[i] = readerGraphChunkIndices[i]; + } + + uint32_t* adjPartition = poco->m_graph.getAdjacencyPartition(); + const uint32_t graphAdjacencyPartitionSize = reader.getGraph().getAdjacencyPartition().size(); + auto readerGraphAdjacencyPartition = reader.getGraph().getAdjacencyPartition(); + for (uint32_t i = 0; i < graphAdjacencyPartitionSize; ++i) + { + adjPartition[i] = readerGraphAdjacencyPartition[i]; + } + + uint32_t* adjNodes = poco->m_graph.getAdjacentNodeIndices(); + const uint32_t graphAdjacentNodeIndicesSize = reader.getGraph().getAdjacentNodeIndices().size(); + auto readerGraphAdjacentNodeIndices = reader.getGraph().getAdjacentNodeIndices(); + for (uint32_t i = 0; i < graphAdjacentNodeIndicesSize; ++i) + { + adjNodes[i] = readerGraphAdjacentNodeIndices[i]; + } + + uint32_t* adjBonds = poco->m_graph.getAdjacentBondIndices(); + const uint32_t graphAdjacentBondIndicesSize = reader.getGraph().getAdjacentBondIndices().size(); + auto readerGraphAdjacentBondIndices = reader.getGraph().getAdjacentBondIndices(); + for (uint32_t i = 0; i < graphAdjacentBondIndicesSize; ++i) + { + adjBonds[i] = readerGraphAdjacentBondIndices[i]; + } + + return true; +} + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/DTO/AssetDTO.h b/sdk/extensions/serialization/source/DTO/AssetDTO.h old mode 100644 new mode 100755 index 986290d..b42a26d --- a/sdk/extensions/serialization/source/DTO/AssetDTO.h +++ b/sdk/extensions/serialization/source/DTO/AssetDTO.h @@ -1,34 +1,34 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once -#include "DTOMacros.h" -#include "NvBlastAsset.h" -#include "generated/NvBlastExtLlSerialization.capn.h" - -DTO_CLASS(Asset, Nv::Blast::Asset, Nv::Blast::Serialization::Asset) +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once +#include "DTOMacros.h" +#include "NvBlastAsset.h" +#include "generated/NvBlastExtLlSerialization.capn.h" + +DTO_CLASS(Asset, Nv::Blast::Asset, Nv::Blast::Serialization::Asset) diff --git a/sdk/extensions/serialization/source/DTO/DTOMacros.h b/sdk/extensions/serialization/source/DTO/DTOMacros.h old mode 100644 new mode 100755 index 99e1e19..e35365c --- a/sdk/extensions/serialization/source/DTO/DTOMacros.h +++ b/sdk/extensions/serialization/source/DTO/DTOMacros.h @@ -1,43 +1,43 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once - -#define DTO_CLASS(_NAME, _POCO, _SERIALIZER) \ -namespace Nv { \ -namespace Blast { \ -class _NAME ## DTO \ -{ \ -public: \ - \ - static bool serialize(_SERIALIZER::Builder builder, const _POCO * poco); \ - static _POCO* deserialize(_SERIALIZER::Reader reader); \ - static bool deserializeInto(_SERIALIZER::Reader reader, _POCO * poco); \ -}; \ -} \ -} +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once + +#define DTO_CLASS(_NAME, _POCO, _SERIALIZER) \ +namespace Nv { \ +namespace Blast { \ +class _NAME ## DTO \ +{ \ +public: \ + \ + static bool serialize(_SERIALIZER::Builder builder, const _POCO * poco); \ + static _POCO* deserialize(_SERIALIZER::Reader reader); \ + static bool deserializeInto(_SERIALIZER::Reader reader, _POCO * poco); \ +}; \ +} \ +} diff --git a/sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.cpp b/sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.cpp old mode 100644 new mode 100755 index ba20e56..3554240 --- a/sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.cpp +++ b/sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.cpp @@ -1,158 +1,158 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "ExtPxAssetDTO.h" -#include "TkAssetDTO.h" -#include "ExtPxChunkDTO.h" -#include "ExtPxSubchunkDTO.h" -#include "physics/NvBlastExtPxAssetImpl.h" -#include "NvBlastAssert.h" -#include "NvBlast.h" - - -namespace Nv -{ -namespace Blast -{ - -bool ExtPxAssetDTO::serialize(Nv::Blast::Serialization::ExtPxAsset::Builder builder, const Nv::Blast::ExtPxAsset * poco) -{ - TkAssetDTO::serialize(builder.getAsset(), &poco->getTkAsset()); - - auto chunks = builder.initChunks(poco->getChunkCount()); - - for (uint32_t i = 0; i getChunkCount(); i++) - { - ExtPxChunkDTO::serialize(chunks[i], &poco->getChunks()[i]); - } - - auto subchunks = builder.initSubchunks(poco->getSubchunkCount()); - - for (uint32_t i = 0; i < poco->getSubchunkCount(); i++) - { - ExtPxSubchunkDTO::serialize(subchunks[i], &poco->getSubchunks()[i]); - } - - const NvBlastActorDesc& actorDesc = poco->getDefaultActorDesc(); - - builder.setUniformInitialBondHealth(actorDesc.uniformInitialBondHealth); - - if (actorDesc.initialBondHealths != nullptr) - { - const uint32_t bondCount = poco->getTkAsset().getBondCount(); - kj::ArrayPtr bondHealthArray(actorDesc.initialBondHealths, bondCount); - builder.initBondHealths(bondCount); - builder.setBondHealths(bondHealthArray); - } - - builder.setUniformInitialLowerSupportChunkHealth(actorDesc.uniformInitialLowerSupportChunkHealth); - - if (actorDesc.initialSupportChunkHealths != nullptr) - { - const uint32_t supportChunkCount = NvBlastAssetGetSupportChunkCount(poco->getTkAsset().getAssetLL(), logLL); - kj::ArrayPtr supportChunkHealthArray(actorDesc.initialSupportChunkHealths, supportChunkCount); - builder.initSupportChunkHealths(supportChunkCount); - builder.setSupportChunkHealths(supportChunkHealthArray); - } - - return true; -} - - -Nv::Blast::ExtPxAsset* ExtPxAssetDTO::deserialize(Nv::Blast::Serialization::ExtPxAsset::Reader reader) -{ - auto tkAsset = TkAssetDTO::deserialize(reader.getAsset()); - - Nv::Blast::ExtPxAssetImpl* asset = reinterpret_cast(Nv::Blast::ExtPxAsset::create(tkAsset)); - - NVBLAST_ASSERT(asset != nullptr); - - auto& chunks = asset->getChunksArray(); - const uint32_t chunkCount = reader.getChunks().size(); - chunks.resize(chunkCount); - auto readerChunks = reader.getChunks(); - for (uint32_t i = 0; i < chunkCount; i++) - { - ExtPxChunkDTO::deserializeInto(readerChunks[i], &chunks[i]); - } - - auto& subchunks = asset->getSubchunksArray(); - const uint32_t subChunkCount = reader.getSubchunks().size(); - subchunks.resize(subChunkCount); - auto readerSubchunks = reader.getSubchunks(); - for (uint32_t i = 0; i < subChunkCount; i++) - { - ExtPxSubchunkDTO::deserializeInto(readerSubchunks[i], &subchunks[i]); - } - - NvBlastActorDesc& actorDesc = asset->getDefaultActorDesc(); - - actorDesc.uniformInitialBondHealth = reader.getUniformInitialBondHealth(); - - actorDesc.initialBondHealths = nullptr; - if (reader.hasBondHealths()) - { - const uint32_t bondCount = asset->getTkAsset().getBondCount(); - Nv::Blast::Array::type& bondHealths = asset->getBondHealthsArray(); - bondHealths.resize(bondCount); - auto readerBondHealths = reader.getBondHealths(); - for (uint32_t i = 0; i < bondCount; ++i) - { - bondHealths[i] = readerBondHealths[i]; - } - } - - actorDesc.uniformInitialLowerSupportChunkHealth = reader.getUniformInitialLowerSupportChunkHealth(); - - actorDesc.initialSupportChunkHealths = nullptr; - if (reader.hasSupportChunkHealths()) - { - const uint32_t supportChunkCount = NvBlastAssetGetSupportChunkCount(asset->getTkAsset().getAssetLL(), logLL); - Nv::Blast::Array::type& supportChunkHealths = asset->getSupportChunkHealthsArray(); - supportChunkHealths.resize(supportChunkCount); - auto readerSupportChunkHealths = reader.getSupportChunkHealths(); - for (uint32_t i = 0; i < supportChunkCount; ++i) - { - supportChunkHealths[i] = readerSupportChunkHealths[i]; - } - } - - return asset; -} - - -bool ExtPxAssetDTO::deserializeInto(Nv::Blast::Serialization::ExtPxAsset::Reader reader, Nv::Blast::ExtPxAsset * poco) -{ - reader = reader; - poco = nullptr; - //NOTE: Because of the way this is structured, can't do this. - return false; -} - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "ExtPxAssetDTO.h" +#include "TkAssetDTO.h" +#include "ExtPxChunkDTO.h" +#include "ExtPxSubchunkDTO.h" +#include "physics/NvBlastExtPxAssetImpl.h" +#include "NvBlastAssert.h" +#include "NvBlast.h" + + +namespace Nv +{ +namespace Blast +{ + +bool ExtPxAssetDTO::serialize(Nv::Blast::Serialization::ExtPxAsset::Builder builder, const Nv::Blast::ExtPxAsset * poco) +{ + TkAssetDTO::serialize(builder.getAsset(), &poco->getTkAsset()); + + auto chunks = builder.initChunks(poco->getChunkCount()); + + for (uint32_t i = 0; i getChunkCount(); i++) + { + ExtPxChunkDTO::serialize(chunks[i], &poco->getChunks()[i]); + } + + auto subchunks = builder.initSubchunks(poco->getSubchunkCount()); + + for (uint32_t i = 0; i < poco->getSubchunkCount(); i++) + { + ExtPxSubchunkDTO::serialize(subchunks[i], &poco->getSubchunks()[i]); + } + + const NvBlastActorDesc& actorDesc = poco->getDefaultActorDesc(); + + builder.setUniformInitialBondHealth(actorDesc.uniformInitialBondHealth); + + if (actorDesc.initialBondHealths != nullptr) + { + const uint32_t bondCount = poco->getTkAsset().getBondCount(); + kj::ArrayPtr bondHealthArray(actorDesc.initialBondHealths, bondCount); + builder.initBondHealths(bondCount); + builder.setBondHealths(bondHealthArray); + } + + builder.setUniformInitialLowerSupportChunkHealth(actorDesc.uniformInitialLowerSupportChunkHealth); + + if (actorDesc.initialSupportChunkHealths != nullptr) + { + const uint32_t supportChunkCount = NvBlastAssetGetSupportChunkCount(poco->getTkAsset().getAssetLL(), logLL); + kj::ArrayPtr supportChunkHealthArray(actorDesc.initialSupportChunkHealths, supportChunkCount); + builder.initSupportChunkHealths(supportChunkCount); + builder.setSupportChunkHealths(supportChunkHealthArray); + } + + return true; +} + + +Nv::Blast::ExtPxAsset* ExtPxAssetDTO::deserialize(Nv::Blast::Serialization::ExtPxAsset::Reader reader) +{ + auto tkAsset = TkAssetDTO::deserialize(reader.getAsset()); + + Nv::Blast::ExtPxAssetImpl* asset = reinterpret_cast(Nv::Blast::ExtPxAsset::create(tkAsset)); + + NVBLAST_ASSERT(asset != nullptr); + + auto& chunks = asset->getChunksArray(); + const uint32_t chunkCount = reader.getChunks().size(); + chunks.resize(chunkCount); + auto readerChunks = reader.getChunks(); + for (uint32_t i = 0; i < chunkCount; i++) + { + ExtPxChunkDTO::deserializeInto(readerChunks[i], &chunks[i]); + } + + auto& subchunks = asset->getSubchunksArray(); + const uint32_t subChunkCount = reader.getSubchunks().size(); + subchunks.resize(subChunkCount); + auto readerSubchunks = reader.getSubchunks(); + for (uint32_t i = 0; i < subChunkCount; i++) + { + ExtPxSubchunkDTO::deserializeInto(readerSubchunks[i], &subchunks[i]); + } + + NvBlastActorDesc& actorDesc = asset->getDefaultActorDesc(); + + actorDesc.uniformInitialBondHealth = reader.getUniformInitialBondHealth(); + + actorDesc.initialBondHealths = nullptr; + if (reader.hasBondHealths()) + { + const uint32_t bondCount = asset->getTkAsset().getBondCount(); + Nv::Blast::Array::type& bondHealths = asset->getBondHealthsArray(); + bondHealths.resize(bondCount); + auto readerBondHealths = reader.getBondHealths(); + for (uint32_t i = 0; i < bondCount; ++i) + { + bondHealths[i] = readerBondHealths[i]; + } + } + + actorDesc.uniformInitialLowerSupportChunkHealth = reader.getUniformInitialLowerSupportChunkHealth(); + + actorDesc.initialSupportChunkHealths = nullptr; + if (reader.hasSupportChunkHealths()) + { + const uint32_t supportChunkCount = NvBlastAssetGetSupportChunkCount(asset->getTkAsset().getAssetLL(), logLL); + Nv::Blast::Array::type& supportChunkHealths = asset->getSupportChunkHealthsArray(); + supportChunkHealths.resize(supportChunkCount); + auto readerSupportChunkHealths = reader.getSupportChunkHealths(); + for (uint32_t i = 0; i < supportChunkCount; ++i) + { + supportChunkHealths[i] = readerSupportChunkHealths[i]; + } + } + + return asset; +} + + +bool ExtPxAssetDTO::deserializeInto(Nv::Blast::Serialization::ExtPxAsset::Reader reader, Nv::Blast::ExtPxAsset * poco) +{ + reader = reader; + poco = nullptr; + //NOTE: Because of the way this is structured, can't do this. + return false; +} + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.h b/sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.h old mode 100644 new mode 100755 index 3793908..ccb1ab7 --- a/sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.h +++ b/sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.h @@ -1,34 +1,34 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once -#include "NvBlastBondDTO.h" -#include "NvBlastExtPxAsset.h" -#include "generated/NvBlastExtPxSerialization.capn.h" - -DTO_CLASS(ExtPxAsset, Nv::Blast::ExtPxAsset, Nv::Blast::Serialization::ExtPxAsset) +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once +#include "NvBlastBondDTO.h" +#include "NvBlastExtPxAsset.h" +#include "generated/NvBlastExtPxSerialization.capn.h" + +DTO_CLASS(ExtPxAsset, Nv::Blast::ExtPxAsset, Nv::Blast::Serialization::ExtPxAsset) diff --git a/sdk/extensions/serialization/source/DTO/ExtPxChunkDTO.cpp b/sdk/extensions/serialization/source/DTO/ExtPxChunkDTO.cpp old mode 100644 new mode 100755 index f1e5b89..f91a9a6 --- a/sdk/extensions/serialization/source/DTO/ExtPxChunkDTO.cpp +++ b/sdk/extensions/serialization/source/DTO/ExtPxChunkDTO.cpp @@ -1,65 +1,65 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "ExtPxChunkDTO.h" - -namespace Nv -{ -namespace Blast -{ - -bool ExtPxChunkDTO::serialize(Nv::Blast::Serialization::ExtPxChunk::Builder builder, const Nv::Blast::ExtPxChunk * poco) -{ - builder.setFirstSubchunkIndex(poco->firstSubchunkIndex); - builder.setSubchunkCount(poco->subchunkCount); - builder.setIsStatic(poco->isStatic); - - return true; -} - - -Nv::Blast::ExtPxChunk* ExtPxChunkDTO::deserialize(Nv::Blast::Serialization::ExtPxChunk::Reader reader) -{ - reader = reader; - //TODO: Allocate with ExtContext and return - - return nullptr; -} - - -bool ExtPxChunkDTO::deserializeInto(Nv::Blast::Serialization::ExtPxChunk::Reader reader, Nv::Blast::ExtPxChunk * poco) -{ - poco->firstSubchunkIndex = reader.getFirstSubchunkIndex(); - poco->subchunkCount = reader.getSubchunkCount(); - poco->isStatic = reader.getIsStatic(); - - return true; -} - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "ExtPxChunkDTO.h" + +namespace Nv +{ +namespace Blast +{ + +bool ExtPxChunkDTO::serialize(Nv::Blast::Serialization::ExtPxChunk::Builder builder, const Nv::Blast::ExtPxChunk * poco) +{ + builder.setFirstSubchunkIndex(poco->firstSubchunkIndex); + builder.setSubchunkCount(poco->subchunkCount); + builder.setIsStatic(poco->isStatic); + + return true; +} + + +Nv::Blast::ExtPxChunk* ExtPxChunkDTO::deserialize(Nv::Blast::Serialization::ExtPxChunk::Reader reader) +{ + reader = reader; + //TODO: Allocate with ExtContext and return + + return nullptr; +} + + +bool ExtPxChunkDTO::deserializeInto(Nv::Blast::Serialization::ExtPxChunk::Reader reader, Nv::Blast::ExtPxChunk * poco) +{ + poco->firstSubchunkIndex = reader.getFirstSubchunkIndex(); + poco->subchunkCount = reader.getSubchunkCount(); + poco->isStatic = reader.getIsStatic(); + + return true; +} + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/DTO/ExtPxChunkDTO.h b/sdk/extensions/serialization/source/DTO/ExtPxChunkDTO.h old mode 100644 new mode 100755 index 8f5d99e..78e493d --- a/sdk/extensions/serialization/source/DTO/ExtPxChunkDTO.h +++ b/sdk/extensions/serialization/source/DTO/ExtPxChunkDTO.h @@ -1,34 +1,34 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once -#include "DTOMacros.h" -#include "NvBlastExtPxAsset.h" -#include "generated/NvBlastExtPxSerialization.capn.h" - -DTO_CLASS(ExtPxChunk, Nv::Blast::ExtPxChunk, Nv::Blast::Serialization::ExtPxChunk) +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once +#include "DTOMacros.h" +#include "NvBlastExtPxAsset.h" +#include "generated/NvBlastExtPxSerialization.capn.h" + +DTO_CLASS(ExtPxChunk, Nv::Blast::ExtPxChunk, Nv::Blast::Serialization::ExtPxChunk) diff --git a/sdk/extensions/serialization/source/DTO/ExtPxSubchunkDTO.cpp b/sdk/extensions/serialization/source/DTO/ExtPxSubchunkDTO.cpp old mode 100644 new mode 100755 index 09a42b0..a346bf0 --- a/sdk/extensions/serialization/source/DTO/ExtPxSubchunkDTO.cpp +++ b/sdk/extensions/serialization/source/DTO/ExtPxSubchunkDTO.cpp @@ -1,66 +1,66 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "ExtPxSubchunkDTO.h" -#include "PxTransformDTO.h" -#include "PxConvexMeshGeometryDTO.h" - - -namespace Nv -{ -namespace Blast -{ - -bool ExtPxSubchunkDTO::serialize(Nv::Blast::Serialization::ExtPxSubchunk::Builder builder, const Nv::Blast::ExtPxSubchunk * poco) -{ - PxTransformDTO::serialize(builder.getTransform(), &poco->transform); - PxConvexMeshGeometryDTO::serialize(builder.getGeometry(), &poco->geometry); - - return true; -} - - -Nv::Blast::ExtPxSubchunk* ExtPxSubchunkDTO::deserialize(Nv::Blast::Serialization::ExtPxSubchunk::Reader reader) -{ - reader = reader; - //TODO: Allocate with ExtContext and return - - return nullptr; -} - - -bool ExtPxSubchunkDTO::deserializeInto(Nv::Blast::Serialization::ExtPxSubchunk::Reader reader, Nv::Blast::ExtPxSubchunk * poco) -{ - PxTransformDTO::deserializeInto(reader.getTransform(), &poco->transform); - PxConvexMeshGeometryDTO::deserializeInto(reader.getGeometry(), &poco->geometry); - - return true; -} - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "ExtPxSubchunkDTO.h" +#include "PxTransformDTO.h" +#include "PxConvexMeshGeometryDTO.h" + + +namespace Nv +{ +namespace Blast +{ + +bool ExtPxSubchunkDTO::serialize(Nv::Blast::Serialization::ExtPxSubchunk::Builder builder, const Nv::Blast::ExtPxSubchunk * poco) +{ + PxTransformDTO::serialize(builder.getTransform(), &poco->transform); + PxConvexMeshGeometryDTO::serialize(builder.getGeometry(), &poco->geometry); + + return true; +} + + +Nv::Blast::ExtPxSubchunk* ExtPxSubchunkDTO::deserialize(Nv::Blast::Serialization::ExtPxSubchunk::Reader reader) +{ + reader = reader; + //TODO: Allocate with ExtContext and return + + return nullptr; +} + + +bool ExtPxSubchunkDTO::deserializeInto(Nv::Blast::Serialization::ExtPxSubchunk::Reader reader, Nv::Blast::ExtPxSubchunk * poco) +{ + PxTransformDTO::deserializeInto(reader.getTransform(), &poco->transform); + PxConvexMeshGeometryDTO::deserializeInto(reader.getGeometry(), &poco->geometry); + + return true; +} + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/DTO/ExtPxSubchunkDTO.h b/sdk/extensions/serialization/source/DTO/ExtPxSubchunkDTO.h old mode 100644 new mode 100755 index ff13fc8..f2bf76a --- a/sdk/extensions/serialization/source/DTO/ExtPxSubchunkDTO.h +++ b/sdk/extensions/serialization/source/DTO/ExtPxSubchunkDTO.h @@ -1,34 +1,34 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once -#include "NvBlastExtPxAsset.h" -#include "generated/NvBlastExtPxSerialization.capn.h" -#include "DTOMacros.h" - -DTO_CLASS(ExtPxSubchunk, Nv::Blast::ExtPxSubchunk, Nv::Blast::Serialization::ExtPxSubchunk) +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once +#include "NvBlastExtPxAsset.h" +#include "generated/NvBlastExtPxSerialization.capn.h" +#include "DTOMacros.h" + +DTO_CLASS(ExtPxSubchunk, Nv::Blast::ExtPxSubchunk, Nv::Blast::Serialization::ExtPxSubchunk) diff --git a/sdk/extensions/serialization/source/DTO/NvBlastBondDTO.cpp b/sdk/extensions/serialization/source/DTO/NvBlastBondDTO.cpp old mode 100644 new mode 100755 index 4c996dd..c078b0d --- a/sdk/extensions/serialization/source/DTO/NvBlastBondDTO.cpp +++ b/sdk/extensions/serialization/source/DTO/NvBlastBondDTO.cpp @@ -1,86 +1,86 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "NvBlastBondDTO.h" -#include "NvBlastAssert.h" - -namespace Nv -{ -namespace Blast -{ - -bool NvBlastBondDTO::serialize(Nv::Blast::Serialization::NvBlastBond::Builder builder, const NvBlastBond * poco) -{ - NVBLAST_ASSERT(poco != nullptr); - - kj::ArrayPtr normArray(poco->normal, 3); - - builder.setNormal(normArray); - - builder.setArea(poco->area); - - kj::ArrayPtr centArray(poco->centroid, 3); - - builder.setCentroid(centArray); - - builder.setUserData(poco->userData); - - return true; -} - - -NvBlastBond* NvBlastBondDTO::deserialize(Nv::Blast::Serialization::NvBlastBond::Reader reader) -{ - //FIXME - reader = reader; - //TODO: Allocate with ExtContext and return - return nullptr; -} - - -bool NvBlastBondDTO::deserializeInto(Nv::Blast::Serialization::NvBlastBond::Reader reader, NvBlastBond * poco) -{ - poco->area = reader.getArea(); - - auto readerCentroid = reader.getCentroid(); - poco->centroid[0] = readerCentroid[0]; - poco->centroid[1] = readerCentroid[1]; - poco->centroid[2] = readerCentroid[2]; - - auto readerNormal = reader.getNormal(); - poco->normal[0] = readerNormal[0]; - poco->normal[1] = readerNormal[1]; - poco->normal[2] = readerNormal[2]; - - poco->userData = reader.getUserData(); - - return true; -} - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "NvBlastBondDTO.h" +#include "NvBlastAssert.h" + +namespace Nv +{ +namespace Blast +{ + +bool NvBlastBondDTO::serialize(Nv::Blast::Serialization::NvBlastBond::Builder builder, const NvBlastBond * poco) +{ + NVBLAST_ASSERT(poco != nullptr); + + kj::ArrayPtr normArray(poco->normal, 3); + + builder.setNormal(normArray); + + builder.setArea(poco->area); + + kj::ArrayPtr centArray(poco->centroid, 3); + + builder.setCentroid(centArray); + + builder.setUserData(poco->userData); + + return true; +} + + +NvBlastBond* NvBlastBondDTO::deserialize(Nv::Blast::Serialization::NvBlastBond::Reader reader) +{ + //FIXME + reader = reader; + //TODO: Allocate with ExtContext and return + return nullptr; +} + + +bool NvBlastBondDTO::deserializeInto(Nv::Blast::Serialization::NvBlastBond::Reader reader, NvBlastBond * poco) +{ + poco->area = reader.getArea(); + + auto readerCentroid = reader.getCentroid(); + poco->centroid[0] = readerCentroid[0]; + poco->centroid[1] = readerCentroid[1]; + poco->centroid[2] = readerCentroid[2]; + + auto readerNormal = reader.getNormal(); + poco->normal[0] = readerNormal[0]; + poco->normal[1] = readerNormal[1]; + poco->normal[2] = readerNormal[2]; + + poco->userData = reader.getUserData(); + + return true; +} + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/DTO/NvBlastBondDTO.h b/sdk/extensions/serialization/source/DTO/NvBlastBondDTO.h old mode 100644 new mode 100755 index f0423d2..b3f24e7 --- a/sdk/extensions/serialization/source/DTO/NvBlastBondDTO.h +++ b/sdk/extensions/serialization/source/DTO/NvBlastBondDTO.h @@ -1,34 +1,34 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once -#include "DTOMacros.h" -#include "NvBlastTypes.h" -#include "generated/NvBlastExtLlSerialization.capn.h" - -DTO_CLASS(NvBlastBond, NvBlastBond, Nv::Blast::Serialization::NvBlastBond) +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once +#include "DTOMacros.h" +#include "NvBlastTypes.h" +#include "generated/NvBlastExtLlSerialization.capn.h" + +DTO_CLASS(NvBlastBond, NvBlastBond, Nv::Blast::Serialization::NvBlastBond) diff --git a/sdk/extensions/serialization/source/DTO/NvBlastChunkDTO.cpp b/sdk/extensions/serialization/source/DTO/NvBlastChunkDTO.cpp old mode 100644 new mode 100755 index a4fb120..7b57368 --- a/sdk/extensions/serialization/source/DTO/NvBlastChunkDTO.cpp +++ b/sdk/extensions/serialization/source/DTO/NvBlastChunkDTO.cpp @@ -1,83 +1,83 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "NvBlastChunkDTO.h" -#include "NvBlastAssert.h" - -namespace Nv -{ -namespace Blast -{ - -bool NvBlastChunkDTO::serialize(Nv::Blast::Serialization::NvBlastChunk::Builder builder, const NvBlastChunk* poco) -{ - NVBLAST_ASSERT(poco != nullptr); - - kj::ArrayPtr centArray(poco->centroid, 3); - builder.setCentroid(centArray); - - builder.setVolume(poco->volume); - - builder.setParentChunkIndex(poco->parentChunkIndex); - builder.setFirstChildIndex(poco->firstChildIndex); - builder.setChildIndexStop(poco->childIndexStop); - builder.setUserData(poco->userData); - - return true; -} - - -NvBlastChunk* NvBlastChunkDTO::deserialize(Nv::Blast::Serialization::NvBlastChunk::Reader reader) -{ - //FIXME - reader = reader; - - return nullptr; -} - - -bool NvBlastChunkDTO::deserializeInto(Nv::Blast::Serialization::NvBlastChunk::Reader reader, NvBlastChunk* target) -{ - NVBLAST_ASSERT(target != nullptr); - - auto readerCentroid = reader.getCentroid(); - target->centroid[0] = readerCentroid[0]; - target->centroid[1] = readerCentroid[1]; - target->centroid[2] = readerCentroid[2]; - - target->childIndexStop = reader.getChildIndexStop(); - target->firstChildIndex = reader.getFirstChildIndex(); - target->parentChunkIndex = reader.getParentChunkIndex(); - target->userData = reader.getUserData(); - target->volume = reader.getVolume(); - - return true; -} - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "NvBlastChunkDTO.h" +#include "NvBlastAssert.h" + +namespace Nv +{ +namespace Blast +{ + +bool NvBlastChunkDTO::serialize(Nv::Blast::Serialization::NvBlastChunk::Builder builder, const NvBlastChunk* poco) +{ + NVBLAST_ASSERT(poco != nullptr); + + kj::ArrayPtr centArray(poco->centroid, 3); + builder.setCentroid(centArray); + + builder.setVolume(poco->volume); + + builder.setParentChunkIndex(poco->parentChunkIndex); + builder.setFirstChildIndex(poco->firstChildIndex); + builder.setChildIndexStop(poco->childIndexStop); + builder.setUserData(poco->userData); + + return true; +} + + +NvBlastChunk* NvBlastChunkDTO::deserialize(Nv::Blast::Serialization::NvBlastChunk::Reader reader) +{ + //FIXME + reader = reader; + + return nullptr; +} + + +bool NvBlastChunkDTO::deserializeInto(Nv::Blast::Serialization::NvBlastChunk::Reader reader, NvBlastChunk* target) +{ + NVBLAST_ASSERT(target != nullptr); + + auto readerCentroid = reader.getCentroid(); + target->centroid[0] = readerCentroid[0]; + target->centroid[1] = readerCentroid[1]; + target->centroid[2] = readerCentroid[2]; + + target->childIndexStop = reader.getChildIndexStop(); + target->firstChildIndex = reader.getFirstChildIndex(); + target->parentChunkIndex = reader.getParentChunkIndex(); + target->userData = reader.getUserData(); + target->volume = reader.getVolume(); + + return true; +} + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/DTO/NvBlastChunkDTO.h b/sdk/extensions/serialization/source/DTO/NvBlastChunkDTO.h old mode 100644 new mode 100755 index c358bda..fb0bff5 --- a/sdk/extensions/serialization/source/DTO/NvBlastChunkDTO.h +++ b/sdk/extensions/serialization/source/DTO/NvBlastChunkDTO.h @@ -1,36 +1,36 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once -#include "DTOMacros.h" -#include "NvBlastTypes.h" -#include "generated/NvBlastExtLlSerialization.capn.h" - - -DTO_CLASS(NvBlastChunk, NvBlastChunk, Nv::Blast::Serialization::NvBlastChunk) - +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once +#include "DTOMacros.h" +#include "NvBlastTypes.h" +#include "generated/NvBlastExtLlSerialization.capn.h" + + +DTO_CLASS(NvBlastChunk, NvBlastChunk, Nv::Blast::Serialization::NvBlastChunk) + diff --git a/sdk/extensions/serialization/source/DTO/NvBlastIDDTO.cpp b/sdk/extensions/serialization/source/DTO/NvBlastIDDTO.cpp old mode 100644 new mode 100755 index ec358bf..55c2a71 --- a/sdk/extensions/serialization/source/DTO/NvBlastIDDTO.cpp +++ b/sdk/extensions/serialization/source/DTO/NvBlastIDDTO.cpp @@ -1,70 +1,70 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "NvBlastIDDTO.h" -#include "NvBlastTypes.h" -#include "NvBlastAssert.h" -#include "generated/NvBlastExtLlSerialization.capn.h" - - -namespace Nv -{ -namespace Blast -{ - - -bool NvBlastIDDTO::serialize(Nv::Blast::Serialization::UUID::Builder builder, const NvBlastID * poco) -{ - capnp::Data::Reader idArrayReader((unsigned char *)poco->data, 16); - builder.setValue(idArrayReader); - - return true; -} - - -NvBlastID* NvBlastIDDTO::deserialize(Nv::Blast::Serialization::UUID::Reader reader) -{ - //FIXME - reader = reader; - //TODO: Allocate with ExtContext and return - - return nullptr; -} - - -bool NvBlastIDDTO::deserializeInto(Nv::Blast::Serialization::UUID::Reader reader, NvBlastID * poco) -{ - NVBLAST_ASSERT_WITH_MESSAGE(reader.getValue().size() == 16, "BlastID must be 16 bytes"); - - memcpy(poco, reader.getValue().begin(), 16); - - return true; -} - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "NvBlastIDDTO.h" +#include "NvBlastTypes.h" +#include "NvBlastAssert.h" +#include "generated/NvBlastExtLlSerialization.capn.h" + + +namespace Nv +{ +namespace Blast +{ + + +bool NvBlastIDDTO::serialize(Nv::Blast::Serialization::UUID::Builder builder, const NvBlastID * poco) +{ + capnp::Data::Reader idArrayReader((unsigned char *)poco->data, 16); + builder.setValue(idArrayReader); + + return true; +} + + +NvBlastID* NvBlastIDDTO::deserialize(Nv::Blast::Serialization::UUID::Reader reader) +{ + //FIXME + reader = reader; + //TODO: Allocate with ExtContext and return + + return nullptr; +} + + +bool NvBlastIDDTO::deserializeInto(Nv::Blast::Serialization::UUID::Reader reader, NvBlastID * poco) +{ + NVBLAST_ASSERT_WITH_MESSAGE(reader.getValue().size() == 16, "BlastID must be 16 bytes"); + + memcpy(poco, reader.getValue().begin(), 16); + + return true; +} + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/DTO/NvBlastIDDTO.h b/sdk/extensions/serialization/source/DTO/NvBlastIDDTO.h old mode 100644 new mode 100755 index 7b92119..93f70ac --- a/sdk/extensions/serialization/source/DTO/NvBlastIDDTO.h +++ b/sdk/extensions/serialization/source/DTO/NvBlastIDDTO.h @@ -1,34 +1,34 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once -#include "NvBlastTypes.h" -#include "generated/NvBlastExtLlSerialization.capn.h" -#include "DTOMacros.h" - -DTO_CLASS(NvBlastID, NvBlastID, ::Nv::Blast::Serialization::UUID) +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once +#include "NvBlastTypes.h" +#include "generated/NvBlastExtLlSerialization.capn.h" +#include "DTOMacros.h" + +DTO_CLASS(NvBlastID, NvBlastID, ::Nv::Blast::Serialization::UUID) diff --git a/sdk/extensions/serialization/source/DTO/PxConvexMeshGeometryDTO.cpp b/sdk/extensions/serialization/source/DTO/PxConvexMeshGeometryDTO.cpp old mode 100644 new mode 100755 index aaf41cd..67bb934 --- a/sdk/extensions/serialization/source/DTO/PxConvexMeshGeometryDTO.cpp +++ b/sdk/extensions/serialization/source/DTO/PxConvexMeshGeometryDTO.cpp @@ -1,142 +1,142 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "PxConvexMeshGeometryDTO.h" -#include "PxMeshScaleDTO.h" -#include "NvBlastAssert.h" -#include "NvBlastExtKJPxInputStream.h" -#include "NvBlastExtKJPxOutputStream.h" -#include "PxConvexMeshDesc.h" -#include "NvBlastExtSerialization.h" -#include "PxVec3.h" -#include -#include -#include "PxPhysics.h" -#include "NvBlastPxCallbacks.h" -#include "PxDefaultStreams.h" - - -namespace Nv -{ -namespace Blast -{ - -extern physx::PxPhysics* sExtPxSerializerPhysics; -extern physx::PxCooking* sExtPxSerializerCooking; - - -bool PxConvexMeshGeometryDTO::serialize(Nv::Blast::Serialization::PxConvexMeshGeometry::Builder builder, const physx::PxConvexMeshGeometry * poco) -{ - NVBLAST_ASSERT(sExtPxSerializerCooking != nullptr); - - PxMeshScaleDTO::serialize(builder.getScale(), &poco->scale); - - //TODO: Use cooking.cookConvexMesh to cook the mesh to a stream - then get that backing buffer and put it into the Data field - - physx::PxConvexMeshDesc desc; - desc.points.data = poco->convexMesh->getVertices(); - desc.points.count = poco->convexMesh->getNbVertices(); - desc.points.stride = sizeof(physx::PxVec3); - - std::vector indicesScratch; - std::vector hullPolygonsScratch; - - hullPolygonsScratch.resize(poco->convexMesh->getNbPolygons()); - - uint32_t indexCount = 0; - for (uint32_t i = 0; i < hullPolygonsScratch.size(); i++) - { - physx::PxHullPolygon polygon; - poco->convexMesh->getPolygonData(i, polygon); - if (polygon.mNbVerts) - { - indexCount = std::max(indexCount, polygon.mIndexBase + polygon.mNbVerts); - } - } - indicesScratch.resize(indexCount); - - for (uint32_t i = 0; i < hullPolygonsScratch.size(); i++) - { - physx::PxHullPolygon polygon; - poco->convexMesh->getPolygonData(i, polygon); - for (uint32_t j = 0; j < polygon.mNbVerts; j++) - { - indicesScratch[polygon.mIndexBase + j] = poco->convexMesh->getIndexBuffer()[polygon.mIndexBase + j]; - } - - hullPolygonsScratch[i] = polygon; - } - - desc.indices.count = indexCount; - desc.indices.data = indicesScratch.data(); - desc.indices.stride = sizeof(uint32_t); - - desc.polygons.count = poco->convexMesh->getNbPolygons(); - desc.polygons.data = hullPolygonsScratch.data(); - desc.polygons.stride = sizeof(physx::PxHullPolygon); - - physx::PxDefaultMemoryOutputStream outStream(NvBlastGetPxAllocatorCallback()); - if (!sExtPxSerializerCooking->cookConvexMesh(desc, outStream)) - { - return false; - } - - kj::ArrayPtr cookedBuffer(outStream.getData(), outStream.getSize()); - - builder.setConvexMesh(cookedBuffer); - - return true; -} - - -physx::PxConvexMeshGeometry* PxConvexMeshGeometryDTO::deserialize(Nv::Blast::Serialization::PxConvexMeshGeometry::Reader reader) -{ - NVBLAST_ASSERT(sExtPxSerializerCooking != nullptr); - - reader = reader; - - return nullptr; -} - - -bool PxConvexMeshGeometryDTO::deserializeInto(Nv::Blast::Serialization::PxConvexMeshGeometry::Reader reader, physx::PxConvexMeshGeometry * poco) -{ - NVBLAST_ASSERT(sExtPxSerializerPhysics != nullptr); - - PxMeshScaleDTO::deserializeInto(reader.getScale(), &poco->scale); - - Nv::Blast::ExtKJPxInputStream inputStream(reader.getConvexMesh()); - - //NOTE: Naive approach, no shared convex hulls - poco->convexMesh = sExtPxSerializerPhysics->createConvexMesh(inputStream); - - return poco->convexMesh != nullptr; -} - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "PxConvexMeshGeometryDTO.h" +#include "PxMeshScaleDTO.h" +#include "NvBlastAssert.h" +#include "NvBlastExtKJPxInputStream.h" +#include "NvBlastExtKJPxOutputStream.h" +#include "PxConvexMeshDesc.h" +#include "NvBlastExtSerialization.h" +#include "PxVec3.h" +#include +#include +#include "PxPhysics.h" +#include "NvBlastPxCallbacks.h" +#include "PxDefaultStreams.h" + + +namespace Nv +{ +namespace Blast +{ + +extern physx::PxPhysics* sExtPxSerializerPhysics; +extern physx::PxCooking* sExtPxSerializerCooking; + + +bool PxConvexMeshGeometryDTO::serialize(Nv::Blast::Serialization::PxConvexMeshGeometry::Builder builder, const physx::PxConvexMeshGeometry * poco) +{ + NVBLAST_ASSERT(sExtPxSerializerCooking != nullptr); + + PxMeshScaleDTO::serialize(builder.getScale(), &poco->scale); + + //TODO: Use cooking.cookConvexMesh to cook the mesh to a stream - then get that backing buffer and put it into the Data field + + physx::PxConvexMeshDesc desc; + desc.points.data = poco->convexMesh->getVertices(); + desc.points.count = poco->convexMesh->getNbVertices(); + desc.points.stride = sizeof(physx::PxVec3); + + std::vector indicesScratch; + std::vector hullPolygonsScratch; + + hullPolygonsScratch.resize(poco->convexMesh->getNbPolygons()); + + uint32_t indexCount = 0; + for (uint32_t i = 0; i < hullPolygonsScratch.size(); i++) + { + physx::PxHullPolygon polygon; + poco->convexMesh->getPolygonData(i, polygon); + if (polygon.mNbVerts) + { + indexCount = std::max(indexCount, polygon.mIndexBase + polygon.mNbVerts); + } + } + indicesScratch.resize(indexCount); + + for (uint32_t i = 0; i < hullPolygonsScratch.size(); i++) + { + physx::PxHullPolygon polygon; + poco->convexMesh->getPolygonData(i, polygon); + for (uint32_t j = 0; j < polygon.mNbVerts; j++) + { + indicesScratch[polygon.mIndexBase + j] = poco->convexMesh->getIndexBuffer()[polygon.mIndexBase + j]; + } + + hullPolygonsScratch[i] = polygon; + } + + desc.indices.count = indexCount; + desc.indices.data = indicesScratch.data(); + desc.indices.stride = sizeof(uint32_t); + + desc.polygons.count = poco->convexMesh->getNbPolygons(); + desc.polygons.data = hullPolygonsScratch.data(); + desc.polygons.stride = sizeof(physx::PxHullPolygon); + + physx::PxDefaultMemoryOutputStream outStream(NvBlastGetPxAllocatorCallback()); + if (!sExtPxSerializerCooking->cookConvexMesh(desc, outStream)) + { + return false; + } + + kj::ArrayPtr cookedBuffer(outStream.getData(), outStream.getSize()); + + builder.setConvexMesh(cookedBuffer); + + return true; +} + + +physx::PxConvexMeshGeometry* PxConvexMeshGeometryDTO::deserialize(Nv::Blast::Serialization::PxConvexMeshGeometry::Reader reader) +{ + NVBLAST_ASSERT(sExtPxSerializerCooking != nullptr); + + reader = reader; + + return nullptr; +} + + +bool PxConvexMeshGeometryDTO::deserializeInto(Nv::Blast::Serialization::PxConvexMeshGeometry::Reader reader, physx::PxConvexMeshGeometry * poco) +{ + NVBLAST_ASSERT(sExtPxSerializerPhysics != nullptr); + + PxMeshScaleDTO::deserializeInto(reader.getScale(), &poco->scale); + + Nv::Blast::ExtKJPxInputStream inputStream(reader.getConvexMesh()); + + //NOTE: Naive approach, no shared convex hulls + poco->convexMesh = sExtPxSerializerPhysics->createConvexMesh(inputStream); + + return poco->convexMesh != nullptr; +} + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/DTO/PxConvexMeshGeometryDTO.h b/sdk/extensions/serialization/source/DTO/PxConvexMeshGeometryDTO.h old mode 100644 new mode 100755 index 23b838c..236470d --- a/sdk/extensions/serialization/source/DTO/PxConvexMeshGeometryDTO.h +++ b/sdk/extensions/serialization/source/DTO/PxConvexMeshGeometryDTO.h @@ -1,35 +1,35 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once -#include "DTOMacros.h" -#include "generated/NvBlastExtPxSerialization.capn.h" -#include "PxConvexMeshGeometry.h" -#include "PxCooking.h" - -DTO_CLASS(PxConvexMeshGeometry, physx::PxConvexMeshGeometry, Nv::Blast::Serialization::PxConvexMeshGeometry) +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once +#include "DTOMacros.h" +#include "generated/NvBlastExtPxSerialization.capn.h" +#include "PxConvexMeshGeometry.h" +#include "PxCooking.h" + +DTO_CLASS(PxConvexMeshGeometry, physx::PxConvexMeshGeometry, Nv::Blast::Serialization::PxConvexMeshGeometry) diff --git a/sdk/extensions/serialization/source/DTO/PxMeshScaleDTO.cpp b/sdk/extensions/serialization/source/DTO/PxMeshScaleDTO.cpp old mode 100644 new mode 100755 index f2191d5..d7c705a --- a/sdk/extensions/serialization/source/DTO/PxMeshScaleDTO.cpp +++ b/sdk/extensions/serialization/source/DTO/PxMeshScaleDTO.cpp @@ -1,64 +1,64 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "PxMeshScaleDTO.h" -#include "PxVec3DTO.h" -#include "PxQuatDTO.h" - - -namespace Nv -{ -namespace Blast -{ - -bool PxMeshScaleDTO::serialize(Nv::Blast::Serialization::PxMeshScale::Builder builder, const physx::PxMeshScale * poco) -{ - PxVec3DTO::serialize(builder.getScale(), &poco->scale); - PxQuatDTO::serialize(builder.getRotation(), &poco->rotation); - - return true; -} - - -physx::PxMeshScale* PxMeshScaleDTO::deserialize(Nv::Blast::Serialization::PxMeshScale::Reader reader) -{ - reader = reader; - return nullptr; -} - - -bool PxMeshScaleDTO::deserializeInto(Nv::Blast::Serialization::PxMeshScale::Reader reader, physx::PxMeshScale * poco) -{ - PxVec3DTO::deserializeInto(reader.getScale(), &poco->scale); - PxQuatDTO::deserializeInto(reader.getRotation(), &poco->rotation); - - return true; -} - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "PxMeshScaleDTO.h" +#include "PxVec3DTO.h" +#include "PxQuatDTO.h" + + +namespace Nv +{ +namespace Blast +{ + +bool PxMeshScaleDTO::serialize(Nv::Blast::Serialization::PxMeshScale::Builder builder, const physx::PxMeshScale * poco) +{ + PxVec3DTO::serialize(builder.getScale(), &poco->scale); + PxQuatDTO::serialize(builder.getRotation(), &poco->rotation); + + return true; +} + + +physx::PxMeshScale* PxMeshScaleDTO::deserialize(Nv::Blast::Serialization::PxMeshScale::Reader reader) +{ + reader = reader; + return nullptr; +} + + +bool PxMeshScaleDTO::deserializeInto(Nv::Blast::Serialization::PxMeshScale::Reader reader, physx::PxMeshScale * poco) +{ + PxVec3DTO::deserializeInto(reader.getScale(), &poco->scale); + PxQuatDTO::deserializeInto(reader.getRotation(), &poco->rotation); + + return true; +} + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/DTO/PxMeshScaleDTO.h b/sdk/extensions/serialization/source/DTO/PxMeshScaleDTO.h old mode 100644 new mode 100755 index a44a57c..d068a2f --- a/sdk/extensions/serialization/source/DTO/PxMeshScaleDTO.h +++ b/sdk/extensions/serialization/source/DTO/PxMeshScaleDTO.h @@ -1,35 +1,35 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once -#include "DTOMacros.h" -#include "PxMeshScale.h" -#include "generated/NvBlastExtPxSerialization.capn.h" -#include "PxCooking.h" - -DTO_CLASS(PxMeshScale, physx::PxMeshScale, Nv::Blast::Serialization::PxMeshScale) +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once +#include "DTOMacros.h" +#include "PxMeshScale.h" +#include "generated/NvBlastExtPxSerialization.capn.h" +#include "PxCooking.h" + +DTO_CLASS(PxMeshScale, physx::PxMeshScale, Nv::Blast::Serialization::PxMeshScale) diff --git a/sdk/extensions/serialization/source/DTO/PxQuatDTO.cpp b/sdk/extensions/serialization/source/DTO/PxQuatDTO.cpp old mode 100644 new mode 100755 index 38be63b..3847e82 --- a/sdk/extensions/serialization/source/DTO/PxQuatDTO.cpp +++ b/sdk/extensions/serialization/source/DTO/PxQuatDTO.cpp @@ -1,65 +1,65 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "PxQuatDTO.h" - -namespace Nv -{ -namespace Blast -{ - -bool PxQuatDTO::serialize(Nv::Blast::Serialization::PxQuat::Builder builder, const physx::PxQuat * poco) -{ - builder.setX(poco->x); - builder.setY(poco->y); - builder.setZ(poco->z); - builder.setW(poco->w); - - return true; -} - - -physx::PxQuat* PxQuatDTO::deserialize(Nv::Blast::Serialization::PxQuat::Reader reader) -{ - reader = reader; - return nullptr; -} - - -bool PxQuatDTO::deserializeInto(Nv::Blast::Serialization::PxQuat::Reader reader, physx::PxQuat * poco) -{ - poco->x = reader.getX(); - poco->y = reader.getY(); - poco->z = reader.getZ(); - poco->w = reader.getW(); - - return true; -} - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "PxQuatDTO.h" + +namespace Nv +{ +namespace Blast +{ + +bool PxQuatDTO::serialize(Nv::Blast::Serialization::PxQuat::Builder builder, const physx::PxQuat * poco) +{ + builder.setX(poco->x); + builder.setY(poco->y); + builder.setZ(poco->z); + builder.setW(poco->w); + + return true; +} + + +physx::PxQuat* PxQuatDTO::deserialize(Nv::Blast::Serialization::PxQuat::Reader reader) +{ + reader = reader; + return nullptr; +} + + +bool PxQuatDTO::deserializeInto(Nv::Blast::Serialization::PxQuat::Reader reader, physx::PxQuat * poco) +{ + poco->x = reader.getX(); + poco->y = reader.getY(); + poco->z = reader.getZ(); + poco->w = reader.getW(); + + return true; +} + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/DTO/PxQuatDTO.h b/sdk/extensions/serialization/source/DTO/PxQuatDTO.h old mode 100644 new mode 100755 index ee6294d..94ea911 --- a/sdk/extensions/serialization/source/DTO/PxQuatDTO.h +++ b/sdk/extensions/serialization/source/DTO/PxQuatDTO.h @@ -1,35 +1,35 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once -#include "DTOMacros.h" -#include "PxQuat.h" -#include "generated/NvBlastExtPxSerialization.capn.h" -#include "PxCooking.h" - -DTO_CLASS(PxQuat, physx::PxQuat, Nv::Blast::Serialization::PxQuat) +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once +#include "DTOMacros.h" +#include "PxQuat.h" +#include "generated/NvBlastExtPxSerialization.capn.h" +#include "PxCooking.h" + +DTO_CLASS(PxQuat, physx::PxQuat, Nv::Blast::Serialization::PxQuat) diff --git a/sdk/extensions/serialization/source/DTO/PxTransformDTO.cpp b/sdk/extensions/serialization/source/DTO/PxTransformDTO.cpp old mode 100644 new mode 100755 index be36d3b..32f6684 --- a/sdk/extensions/serialization/source/DTO/PxTransformDTO.cpp +++ b/sdk/extensions/serialization/source/DTO/PxTransformDTO.cpp @@ -1,63 +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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "PxTransformDTO.h" -#include "PxQuatDTO.h" -#include "PxVec3DTO.h" - -namespace Nv -{ -namespace Blast -{ - -bool PxTransformDTO::serialize(Nv::Blast::Serialization::PxTransform::Builder builder, const physx::PxTransform * poco) -{ - PxQuatDTO::serialize(builder.getQ(), &poco->q); - PxVec3DTO::serialize(builder.getP(), &poco->p); - - return true; -} - - -physx::PxTransform* PxTransformDTO::deserialize(Nv::Blast::Serialization::PxTransform::Reader reader) -{ - reader = reader; - return nullptr; -} - - -bool PxTransformDTO::deserializeInto(Nv::Blast::Serialization::PxTransform::Reader reader, physx::PxTransform * poco) -{ - PxQuatDTO::deserializeInto(reader.getQ(), &poco->q); - PxVec3DTO::deserializeInto(reader.getP(), &poco->p); - - return true; -} - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "PxTransformDTO.h" +#include "PxQuatDTO.h" +#include "PxVec3DTO.h" + +namespace Nv +{ +namespace Blast +{ + +bool PxTransformDTO::serialize(Nv::Blast::Serialization::PxTransform::Builder builder, const physx::PxTransform * poco) +{ + PxQuatDTO::serialize(builder.getQ(), &poco->q); + PxVec3DTO::serialize(builder.getP(), &poco->p); + + return true; +} + + +physx::PxTransform* PxTransformDTO::deserialize(Nv::Blast::Serialization::PxTransform::Reader reader) +{ + reader = reader; + return nullptr; +} + + +bool PxTransformDTO::deserializeInto(Nv::Blast::Serialization::PxTransform::Reader reader, physx::PxTransform * poco) +{ + PxQuatDTO::deserializeInto(reader.getQ(), &poco->q); + PxVec3DTO::deserializeInto(reader.getP(), &poco->p); + + return true; +} + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/DTO/PxTransformDTO.h b/sdk/extensions/serialization/source/DTO/PxTransformDTO.h old mode 100644 new mode 100755 index 7286ab4..de5a9b5 --- a/sdk/extensions/serialization/source/DTO/PxTransformDTO.h +++ b/sdk/extensions/serialization/source/DTO/PxTransformDTO.h @@ -1,35 +1,35 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once -#include "DTOMacros.h" -#include "PxTransform.h" -#include "generated/NvBlastExtPxSerialization.capn.h" -#include "PxCooking.h" - -DTO_CLASS(PxTransform, physx::PxTransform, Nv::Blast::Serialization::PxTransform) +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once +#include "DTOMacros.h" +#include "PxTransform.h" +#include "generated/NvBlastExtPxSerialization.capn.h" +#include "PxCooking.h" + +DTO_CLASS(PxTransform, physx::PxTransform, Nv::Blast::Serialization::PxTransform) diff --git a/sdk/extensions/serialization/source/DTO/PxVec3DTO.cpp b/sdk/extensions/serialization/source/DTO/PxVec3DTO.cpp old mode 100644 new mode 100755 index 4491ab2..57a33ac --- a/sdk/extensions/serialization/source/DTO/PxVec3DTO.cpp +++ b/sdk/extensions/serialization/source/DTO/PxVec3DTO.cpp @@ -1,65 +1,65 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "PxVec3DTO.h" -#include "NvBlastAssert.h" - -namespace Nv -{ -namespace Blast -{ - -bool PxVec3DTO::serialize(Nv::Blast::Serialization::PxVec3::Builder builder, const physx::PxVec3 * poco) -{ - NVBLAST_ASSERT(poco != nullptr); - - builder.setX(poco->x); - builder.setY(poco->y); - builder.setZ(poco->z); - - return true; -} - -physx::PxVec3* PxVec3DTO::deserialize(Nv::Blast::Serialization::PxVec3::Reader reader) -{ - //TODO: Allocate using ExtContext and return - reader = reader; - return nullptr; -} - -bool PxVec3DTO::deserializeInto(Nv::Blast::Serialization::PxVec3::Reader reader, physx::PxVec3* target) -{ - target->x = reader.getX(); - target->y = reader.getY(); - target->z = reader.getZ(); - - return true; -} - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "PxVec3DTO.h" +#include "NvBlastAssert.h" + +namespace Nv +{ +namespace Blast +{ + +bool PxVec3DTO::serialize(Nv::Blast::Serialization::PxVec3::Builder builder, const physx::PxVec3 * poco) +{ + NVBLAST_ASSERT(poco != nullptr); + + builder.setX(poco->x); + builder.setY(poco->y); + builder.setZ(poco->z); + + return true; +} + +physx::PxVec3* PxVec3DTO::deserialize(Nv::Blast::Serialization::PxVec3::Reader reader) +{ + //TODO: Allocate using ExtContext and return + reader = reader; + return nullptr; +} + +bool PxVec3DTO::deserializeInto(Nv::Blast::Serialization::PxVec3::Reader reader, physx::PxVec3* target) +{ + target->x = reader.getX(); + target->y = reader.getY(); + target->z = reader.getZ(); + + return true; +} + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/DTO/PxVec3DTO.h b/sdk/extensions/serialization/source/DTO/PxVec3DTO.h old mode 100644 new mode 100755 index cfb9206..6331d6a --- a/sdk/extensions/serialization/source/DTO/PxVec3DTO.h +++ b/sdk/extensions/serialization/source/DTO/PxVec3DTO.h @@ -1,34 +1,34 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once -#include "DTOMacros.h" -#include "generated/NvBlastExtTkSerialization.capn.h" -#include "PxVec3.h" - -DTO_CLASS(PxVec3, physx::PxVec3, Nv::Blast::Serialization::PxVec3) +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once +#include "DTOMacros.h" +#include "generated/NvBlastExtTkSerialization.capn.h" +#include "PxVec3.h" + +DTO_CLASS(PxVec3, physx::PxVec3, Nv::Blast::Serialization::PxVec3) diff --git a/sdk/extensions/serialization/source/DTO/TkAssetDTO.cpp b/sdk/extensions/serialization/source/DTO/TkAssetDTO.cpp old mode 100644 new mode 100755 index 7b4d8e3..ab02085 --- a/sdk/extensions/serialization/source/DTO/TkAssetDTO.cpp +++ b/sdk/extensions/serialization/source/DTO/TkAssetDTO.cpp @@ -1,94 +1,94 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "TkAssetDTO.h" -#include "AssetDTO.h" -#include "TkAssetJointDescDTO.h" -#include -#include "NvBlastTkFramework.h" -#include "NvBlastGlobals.h" - - -namespace Nv -{ -namespace Blast -{ - -extern TkFramework* sExtTkSerializerFramework; - - -bool TkAssetDTO::serialize(Nv::Blast::Serialization::TkAsset::Builder builder, const Nv::Blast::TkAsset * poco) -{ - const Asset* assetLL = reinterpret_cast(poco->getAssetLL()); - - Nv::Blast::AssetDTO::serialize(builder.getAssetLL(), assetLL); - - uint32_t jointDescCount = poco->getJointDescCount(); - - capnp::List::Builder jointDescs = builder.initJointDescs(jointDescCount); - - for (uint32_t i = 0; i < jointDescCount; i++) - { - TkAssetJointDescDTO::serialize(jointDescs[i], &poco->getJointDescs()[i]); - } - - return true; -} - - -Nv::Blast::TkAsset* TkAssetDTO::deserialize(Nv::Blast::Serialization::TkAsset::Reader reader) -{ - const NvBlastAsset* assetLL = reinterpret_cast(AssetDTO::deserialize(reader.getAssetLL())); - - std::vector jointDescs; - - const uint32_t jointDescCount = reader.getJointDescs().size(); - jointDescs.resize(jointDescCount); - auto readerJointDescs = reader.getJointDescs(); - for (uint32_t i = 0; i < jointDescCount; i++) - { - TkAssetJointDescDTO::deserializeInto(readerJointDescs[i], &jointDescs[i]); - } - - // Make sure to set ownsAsset to true - this is serialization and no one else owns it. - Nv::Blast::TkAsset* asset = NvBlastTkFrameworkGet()->createAsset(assetLL, jointDescs.data(), jointDescCount, true); - - return asset; -} - - -bool TkAssetDTO::deserializeInto(Nv::Blast::Serialization::TkAsset::Reader reader, Nv::Blast::TkAsset * poco) -{ - reader = reader; - poco = nullptr; - // NOTE: Because of the way TkAsset is currently structured, this won't work. - return false; -} - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "TkAssetDTO.h" +#include "AssetDTO.h" +#include "TkAssetJointDescDTO.h" +#include +#include "NvBlastTkFramework.h" +#include "NvBlastGlobals.h" + + +namespace Nv +{ +namespace Blast +{ + +extern TkFramework* sExtTkSerializerFramework; + + +bool TkAssetDTO::serialize(Nv::Blast::Serialization::TkAsset::Builder builder, const Nv::Blast::TkAsset * poco) +{ + const Asset* assetLL = reinterpret_cast(poco->getAssetLL()); + + Nv::Blast::AssetDTO::serialize(builder.getAssetLL(), assetLL); + + uint32_t jointDescCount = poco->getJointDescCount(); + + capnp::List::Builder jointDescs = builder.initJointDescs(jointDescCount); + + for (uint32_t i = 0; i < jointDescCount; i++) + { + TkAssetJointDescDTO::serialize(jointDescs[i], &poco->getJointDescs()[i]); + } + + return true; +} + + +Nv::Blast::TkAsset* TkAssetDTO::deserialize(Nv::Blast::Serialization::TkAsset::Reader reader) +{ + const NvBlastAsset* assetLL = reinterpret_cast(AssetDTO::deserialize(reader.getAssetLL())); + + std::vector jointDescs; + + const uint32_t jointDescCount = reader.getJointDescs().size(); + jointDescs.resize(jointDescCount); + auto readerJointDescs = reader.getJointDescs(); + for (uint32_t i = 0; i < jointDescCount; i++) + { + TkAssetJointDescDTO::deserializeInto(readerJointDescs[i], &jointDescs[i]); + } + + // Make sure to set ownsAsset to true - this is serialization and no one else owns it. + Nv::Blast::TkAsset* asset = NvBlastTkFrameworkGet()->createAsset(assetLL, jointDescs.data(), jointDescCount, true); + + return asset; +} + + +bool TkAssetDTO::deserializeInto(Nv::Blast::Serialization::TkAsset::Reader reader, Nv::Blast::TkAsset * poco) +{ + reader = reader; + poco = nullptr; + // NOTE: Because of the way TkAsset is currently structured, this won't work. + return false; +} + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/DTO/TkAssetDTO.h b/sdk/extensions/serialization/source/DTO/TkAssetDTO.h old mode 100644 new mode 100755 index 6799295..cc90d0a --- a/sdk/extensions/serialization/source/DTO/TkAssetDTO.h +++ b/sdk/extensions/serialization/source/DTO/TkAssetDTO.h @@ -1,34 +1,34 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once -#include "DTOMacros.h" -#include "NvBlastTkAsset.h" -#include "generated/NvBlastExtTkSerialization.capn.h" - -DTO_CLASS(TkAsset, Nv::Blast::TkAsset, Nv::Blast::Serialization::TkAsset) +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once +#include "DTOMacros.h" +#include "NvBlastTkAsset.h" +#include "generated/NvBlastExtTkSerialization.capn.h" + +DTO_CLASS(TkAsset, Nv::Blast::TkAsset, Nv::Blast::Serialization::TkAsset) diff --git a/sdk/extensions/serialization/source/DTO/TkAssetJointDescDTO.cpp b/sdk/extensions/serialization/source/DTO/TkAssetJointDescDTO.cpp old mode 100644 new mode 100755 index 95c21b3..7e772c7 --- a/sdk/extensions/serialization/source/DTO/TkAssetJointDescDTO.cpp +++ b/sdk/extensions/serialization/source/DTO/TkAssetJointDescDTO.cpp @@ -1,76 +1,76 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "TkAssetJointDescDTO.h" -#include "PxVec3DTO.h" - - -namespace Nv -{ -namespace Blast -{ - -bool TkAssetJointDescDTO::serialize(Nv::Blast::Serialization::TkAssetJointDesc::Builder builder, const Nv::Blast::TkAssetJointDesc * poco) -{ - kj::ArrayPtr nodeIndices(poco->nodeIndices, 2); - builder.setNodeIndices(nodeIndices); - - for (int i = 0; i < 2; i++) - { - PxVec3DTO::serialize(builder.getAttachPositions()[i], &poco->attachPositions[i]); - } - - return true; -} - - -Nv::Blast::TkAssetJointDesc* TkAssetJointDescDTO::deserialize(Nv::Blast::Serialization::TkAssetJointDesc::Reader reader) -{ - //TODO: Allocate with ExtContent and return - - reader = reader; - - return nullptr; -} - - -bool TkAssetJointDescDTO::deserializeInto(Nv::Blast::Serialization::TkAssetJointDesc::Reader reader, Nv::Blast::TkAssetJointDesc * poco) -{ - auto readerAttachPositions = reader.getAttachPositions(); - PxVec3DTO::deserializeInto(readerAttachPositions[0], &poco->attachPositions[0]); - PxVec3DTO::deserializeInto(readerAttachPositions[1], &poco->attachPositions[1]); - - auto readerNodeIndices = reader.getNodeIndices(); - poco->nodeIndices[0] = readerNodeIndices[0]; - poco->nodeIndices[1] = readerNodeIndices[1]; - - return true; -} - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "TkAssetJointDescDTO.h" +#include "PxVec3DTO.h" + + +namespace Nv +{ +namespace Blast +{ + +bool TkAssetJointDescDTO::serialize(Nv::Blast::Serialization::TkAssetJointDesc::Builder builder, const Nv::Blast::TkAssetJointDesc * poco) +{ + kj::ArrayPtr nodeIndices(poco->nodeIndices, 2); + builder.setNodeIndices(nodeIndices); + + for (int i = 0; i < 2; i++) + { + PxVec3DTO::serialize(builder.getAttachPositions()[i], &poco->attachPositions[i]); + } + + return true; +} + + +Nv::Blast::TkAssetJointDesc* TkAssetJointDescDTO::deserialize(Nv::Blast::Serialization::TkAssetJointDesc::Reader reader) +{ + //TODO: Allocate with ExtContent and return + + reader = reader; + + return nullptr; +} + + +bool TkAssetJointDescDTO::deserializeInto(Nv::Blast::Serialization::TkAssetJointDesc::Reader reader, Nv::Blast::TkAssetJointDesc * poco) +{ + auto readerAttachPositions = reader.getAttachPositions(); + PxVec3DTO::deserializeInto(readerAttachPositions[0], &poco->attachPositions[0]); + PxVec3DTO::deserializeInto(readerAttachPositions[1], &poco->attachPositions[1]); + + auto readerNodeIndices = reader.getNodeIndices(); + poco->nodeIndices[0] = readerNodeIndices[0]; + poco->nodeIndices[1] = readerNodeIndices[1]; + + return true; +} + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/DTO/TkAssetJointDescDTO.h b/sdk/extensions/serialization/source/DTO/TkAssetJointDescDTO.h old mode 100644 new mode 100755 index 2611454..311802c --- a/sdk/extensions/serialization/source/DTO/TkAssetJointDescDTO.h +++ b/sdk/extensions/serialization/source/DTO/TkAssetJointDescDTO.h @@ -1,34 +1,34 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once -#include "DTOMacros.h" -#include "NvBlastTkAsset.h" -#include "generated/NvBlastExtTkSerialization.capn.h" - -DTO_CLASS(TkAssetJointDesc, Nv::Blast::TkAssetJointDesc, Nv::Blast::Serialization::TkAssetJointDesc) +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once +#include "DTOMacros.h" +#include "NvBlastTkAsset.h" +#include "generated/NvBlastExtTkSerialization.capn.h" + +DTO_CLASS(TkAssetJointDesc, Nv::Blast::TkAssetJointDesc, Nv::Blast::Serialization::TkAssetJointDesc) diff --git a/sdk/extensions/serialization/source/NvBlastExtInputStream.cpp b/sdk/extensions/serialization/source/NvBlastExtInputStream.cpp old mode 100644 new mode 100755 index 0e12717..6cbe9ae --- a/sdk/extensions/serialization/source/NvBlastExtInputStream.cpp +++ b/sdk/extensions/serialization/source/NvBlastExtInputStream.cpp @@ -1,56 +1,56 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "NvBlastExtInputStream.h" - - -Nv::Blast::ExtInputStream::ExtInputStream(std::istream &inputStream) : - m_inputStream(inputStream) -{ - -} - - -size_t Nv::Blast::ExtInputStream::tryRead(void* buffer, size_t /*minBytes*/, size_t maxBytes) -{ - m_inputStream.read((char *) buffer, maxBytes); - - if (m_inputStream.fail()) - { - // Throw exception, log error -// NVBLAST_LOG_ERROR("Failure when reading from stream"); - } - - // Since we're using a blocking read above, if we don't have maxBytes we're probably done - if ((size_t) m_inputStream.gcount() < maxBytes) - { -// NVBLAST_LOG_ERROR("Failed to read requested number of bytes during blocking read."); - } - - return m_inputStream.gcount(); -} +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "NvBlastExtInputStream.h" + + +Nv::Blast::ExtInputStream::ExtInputStream(std::istream &inputStream) : + m_inputStream(inputStream) +{ + +} + + +size_t Nv::Blast::ExtInputStream::tryRead(void* buffer, size_t /*minBytes*/, size_t maxBytes) +{ + m_inputStream.read((char *) buffer, maxBytes); + + if (m_inputStream.fail()) + { + // Throw exception, log error +// NVBLAST_LOG_ERROR("Failure when reading from stream"); + } + + // Since we're using a blocking read above, if we don't have maxBytes we're probably done + if ((size_t) m_inputStream.gcount() < maxBytes) + { +// NVBLAST_LOG_ERROR("Failed to read requested number of bytes during blocking read."); + } + + return m_inputStream.gcount(); +} diff --git a/sdk/extensions/serialization/source/NvBlastExtInputStream.h b/sdk/extensions/serialization/source/NvBlastExtInputStream.h old mode 100644 new mode 100755 index f82a1eb..c8bfe09 --- a/sdk/extensions/serialization/source/NvBlastExtInputStream.h +++ b/sdk/extensions/serialization/source/NvBlastExtInputStream.h @@ -1,53 +1,53 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once -#include "kj/io.h" -#include - - -namespace Nv -{ -namespace Blast -{ - -class ExtInputStream : public kj::InputStream -{ -public: - ExtInputStream() = delete; - ExtInputStream(std::istream &inputStream); - - // Returns a read of maxBytes. This is supposed to be happy doing partial reads, but currently isn't. - virtual size_t tryRead(void* buffer, size_t minBytes, size_t maxBytes) override; - -private: - std::istream &m_inputStream; -}; - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once +#include "kj/io.h" +#include + + +namespace Nv +{ +namespace Blast +{ + +class ExtInputStream : public kj::InputStream +{ +public: + ExtInputStream() = delete; + ExtInputStream(std::istream &inputStream); + + // Returns a read of maxBytes. This is supposed to be happy doing partial reads, but currently isn't. + virtual size_t tryRead(void* buffer, size_t minBytes, size_t maxBytes) override; + +private: + std::istream &m_inputStream; +}; + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/NvBlastExtKJPxInputStream.cpp b/sdk/extensions/serialization/source/NvBlastExtKJPxInputStream.cpp old mode 100644 new mode 100755 index 3f54bfd..5cdc12c --- a/sdk/extensions/serialization/source/NvBlastExtKJPxInputStream.cpp +++ b/sdk/extensions/serialization/source/NvBlastExtKJPxInputStream.cpp @@ -1,53 +1,53 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "NvBlastExtKJPxInputStream.h" - -namespace Nv -{ -namespace Blast -{ - -ExtKJPxInputStream::ExtKJPxInputStream(capnp::Data::Reader inReader) : -dataReader(inReader), -inputStream(nullptr) -{ - kj::ArrayPtr buffer(inReader.begin(), inReader.size()); - - inputStream = std::make_shared(buffer); -} - - -uint32_t ExtKJPxInputStream::read(void* dest, uint32_t count) -{ - return inputStream->tryRead(dest, count, count); -} - -} // namespace Blast -} // namespace Nv - +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "NvBlastExtKJPxInputStream.h" + +namespace Nv +{ +namespace Blast +{ + +ExtKJPxInputStream::ExtKJPxInputStream(capnp::Data::Reader inReader) : +dataReader(inReader), +inputStream(nullptr) +{ + kj::ArrayPtr buffer(inReader.begin(), inReader.size()); + + inputStream = std::make_shared(buffer); +} + + +uint32_t ExtKJPxInputStream::read(void* dest, uint32_t count) +{ + return inputStream->tryRead(dest, count, count); +} + +} // namespace Blast +} // namespace Nv + diff --git a/sdk/extensions/serialization/source/NvBlastExtKJPxInputStream.h b/sdk/extensions/serialization/source/NvBlastExtKJPxInputStream.h old mode 100644 new mode 100755 index d696d04..be11a26 --- a/sdk/extensions/serialization/source/NvBlastExtKJPxInputStream.h +++ b/sdk/extensions/serialization/source/NvBlastExtKJPxInputStream.h @@ -1,62 +1,62 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once -#include "PxIO.h" -#include "capnp/common.h" -#include "kj/io.h" -#include -#include "generated/NvBlastExtPxSerialization.capn.h" - - -namespace Nv -{ -namespace Blast -{ - -/* -A wrapper around a Capn Proto Data reader. - -Since it needs to behave like a stream, it's internally wrapped in a stream. - -*/ -class ExtKJPxInputStream : public physx::PxInputStream -{ -public: - ExtKJPxInputStream(capnp::Data::Reader inReader); - ~ExtKJPxInputStream() = default; - - virtual uint32_t read(void* dest, uint32_t count) override; - -private: - capnp::Data::Reader dataReader; - std::shared_ptr inputStream; -}; - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once +#include "PxIO.h" +#include "capnp/common.h" +#include "kj/io.h" +#include +#include "generated/NvBlastExtPxSerialization.capn.h" + + +namespace Nv +{ +namespace Blast +{ + +/* +A wrapper around a Capn Proto Data reader. + +Since it needs to behave like a stream, it's internally wrapped in a stream. + +*/ +class ExtKJPxInputStream : public physx::PxInputStream +{ +public: + ExtKJPxInputStream(capnp::Data::Reader inReader); + ~ExtKJPxInputStream() = default; + + virtual uint32_t read(void* dest, uint32_t count) override; + +private: + capnp::Data::Reader dataReader; + std::shared_ptr inputStream; +}; + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/NvBlastExtKJPxOutputStream.cpp b/sdk/extensions/serialization/source/NvBlastExtKJPxOutputStream.cpp old mode 100644 new mode 100755 index 98ad039..82ba297 --- a/sdk/extensions/serialization/source/NvBlastExtKJPxOutputStream.cpp +++ b/sdk/extensions/serialization/source/NvBlastExtKJPxOutputStream.cpp @@ -1,55 +1,55 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "NvBlastExtKJPxOutputStream.h" - -namespace Nv -{ -namespace Blast -{ - -ExtKJPxOutputStream::ExtKJPxOutputStream(kj::ArrayPtr inBuffer) : -writtenBytes(0), -Buffer(inBuffer), -outputStream(nullptr) -{ - outputStream = std::make_shared(inBuffer); -} - - -uint32_t ExtKJPxOutputStream::write(const void* src, uint32_t count) -{ - outputStream->write(src, count); - - writtenBytes += count; - - return count; -} - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "NvBlastExtKJPxOutputStream.h" + +namespace Nv +{ +namespace Blast +{ + +ExtKJPxOutputStream::ExtKJPxOutputStream(kj::ArrayPtr inBuffer) : +writtenBytes(0), +Buffer(inBuffer), +outputStream(nullptr) +{ + outputStream = std::make_shared(inBuffer); +} + + +uint32_t ExtKJPxOutputStream::write(const void* src, uint32_t count) +{ + outputStream->write(src, count); + + writtenBytes += count; + + return count; +} + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/NvBlastExtKJPxOutputStream.h b/sdk/extensions/serialization/source/NvBlastExtKJPxOutputStream.h old mode 100644 new mode 100755 index 8f25cab..ad4f77c --- a/sdk/extensions/serialization/source/NvBlastExtKJPxOutputStream.h +++ b/sdk/extensions/serialization/source/NvBlastExtKJPxOutputStream.h @@ -1,61 +1,61 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once -#include "PxIO.h" -#include "kj/common.h" -#include -#include "kj/io.h" - - -namespace Nv -{ -namespace Blast -{ - -class ExtKJPxOutputStream : public physx::PxOutputStream -{ -public: - ExtKJPxOutputStream(kj::ArrayPtr inBuffer); - ~ExtKJPxOutputStream() = default; - - virtual uint32_t write(const void* src, uint32_t count) override; - - uint32_t getWrittenBytes() { return writtenBytes; } - - kj::ArrayPtr getBuffer() { return Buffer; } - -private: - uint32_t writtenBytes; - - kj::ArrayPtr Buffer; - std::shared_ptr outputStream; -}; - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once +#include "PxIO.h" +#include "kj/common.h" +#include +#include "kj/io.h" + + +namespace Nv +{ +namespace Blast +{ + +class ExtKJPxOutputStream : public physx::PxOutputStream +{ +public: + ExtKJPxOutputStream(kj::ArrayPtr inBuffer); + ~ExtKJPxOutputStream() = default; + + virtual uint32_t write(const void* src, uint32_t count) override; + + uint32_t getWrittenBytes() { return writtenBytes; } + + kj::ArrayPtr getBuffer() { return Buffer; } + +private: + uint32_t writtenBytes; + + kj::ArrayPtr Buffer; + std::shared_ptr outputStream; +}; + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/NvBlastExtLlSerialization.capn b/sdk/extensions/serialization/source/NvBlastExtLlSerialization.capn old mode 100644 new mode 100755 index c388b71..43c7453 --- a/sdk/extensions/serialization/source/NvBlastExtLlSerialization.capn +++ b/sdk/extensions/serialization/source/NvBlastExtLlSerialization.capn @@ -1,108 +1,108 @@ -# 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) 2018 NVIDIA Corporation. All rights reserved. - - -@0x9a4a58fac38375e0; - -using Cxx = import "/capnp/c++.capnp"; - -$Cxx.namespace("Nv::Blast::Serialization"); - -struct Asset -{ - header @0 :NvBlastDataBlock; - - iD @1 :UUID; - - chunkCount @2 :UInt32; - - graph @3 :NvBlastSupportGraph; - - leafChunkCount @4 :UInt32; - - firstSubsupportChunkIndex @5 :UInt32; - - bondCount @6 :UInt32; - - chunks @7: List(NvBlastChunk); - - bonds @8: List(NvBlastBond); - - subtreeLeafChunkCounts @9: List(UInt32); - - chunkToGraphNodeMap @10: List(UInt32); -} - -struct NvBlastDataBlock -{ - enum Type - { - assetDataBlock @0; - instanceDataBlock @1; - } - - dataType @0 :Type; - - formatVersion @1 :UInt32; - - size @2 :UInt32; -} - -struct NvBlastChunk -{ - centroid @0 :List(Float32); - - volume @1 :Float32; - - parentChunkIndex @2 :UInt32; - firstChildIndex @3 :UInt32; - childIndexStop @4 :UInt32; - userData @5 :UInt32; -} - -struct NvBlastBond -{ - normal @0 :List(Float32); - area @1 :Float32; - centroid @2 :List(Float32); - userData @3 :UInt32; -} - -struct NvBlastSupportGraph -{ - nodeCount @0 : UInt32; - - chunkIndices @1 : List(UInt32); - adjacencyPartition @2 : List(UInt32); - adjacentNodeIndices @3 : List(UInt32); - adjacentBondIndices @4 : List(UInt32); -} - -struct UUID -{ - value @0 : Data; -} +# 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) 2018 NVIDIA Corporation. All rights reserved. + + +@0x9a4a58fac38375e0; + +using Cxx = import "/capnp/c++.capnp"; + +$Cxx.namespace("Nv::Blast::Serialization"); + +struct Asset +{ + header @0 :NvBlastDataBlock; + + iD @1 :UUID; + + chunkCount @2 :UInt32; + + graph @3 :NvBlastSupportGraph; + + leafChunkCount @4 :UInt32; + + firstSubsupportChunkIndex @5 :UInt32; + + bondCount @6 :UInt32; + + chunks @7: List(NvBlastChunk); + + bonds @8: List(NvBlastBond); + + subtreeLeafChunkCounts @9: List(UInt32); + + chunkToGraphNodeMap @10: List(UInt32); +} + +struct NvBlastDataBlock +{ + enum Type + { + assetDataBlock @0; + instanceDataBlock @1; + } + + dataType @0 :Type; + + formatVersion @1 :UInt32; + + size @2 :UInt32; +} + +struct NvBlastChunk +{ + centroid @0 :List(Float32); + + volume @1 :Float32; + + parentChunkIndex @2 :UInt32; + firstChildIndex @3 :UInt32; + childIndexStop @4 :UInt32; + userData @5 :UInt32; +} + +struct NvBlastBond +{ + normal @0 :List(Float32); + area @1 :Float32; + centroid @2 :List(Float32); + userData @3 :UInt32; +} + +struct NvBlastSupportGraph +{ + nodeCount @0 : UInt32; + + chunkIndices @1 : List(UInt32); + adjacencyPartition @2 : List(UInt32); + adjacentNodeIndices @3 : List(UInt32); + adjacentBondIndices @4 : List(UInt32); +} + +struct UUID +{ + value @0 : Data; +} diff --git a/sdk/extensions/serialization/source/NvBlastExtLlSerialization.cpp b/sdk/extensions/serialization/source/NvBlastExtLlSerialization.cpp old mode 100644 new mode 100755 index c67c336..a0fa6f2 --- a/sdk/extensions/serialization/source/NvBlastExtLlSerialization.cpp +++ b/sdk/extensions/serialization/source/NvBlastExtLlSerialization.cpp @@ -1,136 +1,136 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "NvBlastExtSerializationInternal.h" -#include "NvBlastExtLlSerialization.h" -#include "NvBlastExtLlSerializerCAPN.h" - - -namespace Nv -{ -namespace Blast -{ - -class ExtLlSerializerAsset_CPNB : public ExtSerializer -{ -public: - ExtSerializerBoilerplate("LLAsset_CPNB", "Blast low-level asset (NvBlastAsset) serialization using Cap'n Proto binary format.", LlObjectTypeID::Asset, ExtSerialization::EncodingID::CapnProtoBinary); - ExtSerializerDefaultFactoryAndRelease(ExtLlSerializerAsset_CPNB); - - virtual void* deserializeFromBuffer(const void* buffer, uint64_t size) override - { - return ExtSerializationCAPN::deserializeFromBuffer(reinterpret_cast(buffer), size); - } - - virtual uint64_t serializeIntoBuffer(void*& buffer, ExtSerialization::BufferProvider& bufferProvider, const void* object, uint64_t offset = 0) override - { - uint64_t usedSize; - if (!ExtSerializationCAPN::serializeIntoBuffer(reinterpret_cast(object), - reinterpret_cast(buffer), usedSize, &bufferProvider, offset)) - { - return 0; - } - return usedSize; - } -}; - - -class ExtLlSerializerObject_RAW : public ExtSerializer -{ -public: - virtual void* deserializeFromBuffer(const void* buffer, uint64_t size) override - { - const NvBlastDataBlock* block = reinterpret_cast(buffer); - if (static_cast(block->size) > size) - { - return nullptr; - } - void* llobject = NVBLAST_ALLOC(block->size); - return memcpy(llobject, block, block->size); - } - - virtual uint64_t serializeIntoBuffer(void*& buffer, ExtSerialization::BufferProvider& bufferProvider, const void* object, uint64_t offset = 0) override - { - const NvBlastDataBlock* block = reinterpret_cast(object); - const uint64_t size = block->size + offset; - buffer = bufferProvider.requestBuffer(size); - if (buffer == nullptr) - { - return 0; - } - memcpy(static_cast(buffer) + offset, object, block->size); - return size; - } -}; - - -class ExtLlSerializerAsset_RAW : public ExtLlSerializerObject_RAW -{ -public: - ExtSerializerBoilerplate("LLAsset_RAW", "Blast low-level asset (NvBlastAsset) serialization using raw memory format.", LlObjectTypeID::Asset, ExtSerialization::EncodingID::RawBinary); - ExtSerializerDefaultFactoryAndRelease(ExtLlSerializerAsset_RAW); -}; - - -class ExtLlSerializerFamily_RAW : public ExtLlSerializerObject_RAW -{ -public: - ExtSerializerBoilerplate("LLFamily_RAW", "Blast low-level family (NvBlastFamily) serialization using raw memory format.", LlObjectTypeID::Family, ExtSerialization::EncodingID::RawBinary); - ExtSerializerDefaultFactoryAndRelease(ExtLlSerializerFamily_RAW); -}; - -} // namespace Blast -} // namespace Nv - - -/////////////////////////////////////// - - -size_t NvBlastExtLlSerializerLoadSet(Nv::Blast::ExtSerialization& serialization) -{ - Nv::Blast::ExtSerializer* (*factories[])() = - { - Nv::Blast::ExtLlSerializerAsset_CPNB::create, - Nv::Blast::ExtLlSerializerAsset_RAW::create, - Nv::Blast::ExtLlSerializerFamily_RAW::create - }; - - return Nv::Blast::ExtSerializationLoadSet(static_cast(serialization), factories); -} - - -uint64_t NvBlastExtSerializationSerializeAssetIntoBuffer(void*& buffer, Nv::Blast::ExtSerialization& serialization, const NvBlastAsset* asset) -{ - return serialization.serializeIntoBuffer(buffer, asset, Nv::Blast::LlObjectTypeID::Asset); -} - - -uint64_t NvBlastExtSerializationSerializeFamilyIntoBuffer(void*& buffer, Nv::Blast::ExtSerialization& serialization, const NvBlastFamily* family) -{ - return serialization.serializeIntoBuffer(buffer, family, Nv::Blast::LlObjectTypeID::Family); -} +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "NvBlastExtSerializationInternal.h" +#include "NvBlastExtLlSerialization.h" +#include "NvBlastExtLlSerializerCAPN.h" + + +namespace Nv +{ +namespace Blast +{ + +class ExtLlSerializerAsset_CPNB : public ExtSerializer +{ +public: + ExtSerializerBoilerplate("LLAsset_CPNB", "Blast low-level asset (NvBlastAsset) serialization using Cap'n Proto binary format.", LlObjectTypeID::Asset, ExtSerialization::EncodingID::CapnProtoBinary); + ExtSerializerDefaultFactoryAndRelease(ExtLlSerializerAsset_CPNB); + + virtual void* deserializeFromBuffer(const void* buffer, uint64_t size) override + { + return ExtSerializationCAPN::deserializeFromBuffer(reinterpret_cast(buffer), size); + } + + virtual uint64_t serializeIntoBuffer(void*& buffer, ExtSerialization::BufferProvider& bufferProvider, const void* object, uint64_t offset = 0) override + { + uint64_t usedSize; + if (!ExtSerializationCAPN::serializeIntoBuffer(reinterpret_cast(object), + reinterpret_cast(buffer), usedSize, &bufferProvider, offset)) + { + return 0; + } + return usedSize; + } +}; + + +class ExtLlSerializerObject_RAW : public ExtSerializer +{ +public: + virtual void* deserializeFromBuffer(const void* buffer, uint64_t size) override + { + const NvBlastDataBlock* block = reinterpret_cast(buffer); + if (static_cast(block->size) > size) + { + return nullptr; + } + void* llobject = NVBLAST_ALLOC(block->size); + return memcpy(llobject, block, block->size); + } + + virtual uint64_t serializeIntoBuffer(void*& buffer, ExtSerialization::BufferProvider& bufferProvider, const void* object, uint64_t offset = 0) override + { + const NvBlastDataBlock* block = reinterpret_cast(object); + const uint64_t size = block->size + offset; + buffer = bufferProvider.requestBuffer(size); + if (buffer == nullptr) + { + return 0; + } + memcpy(static_cast(buffer) + offset, object, block->size); + return size; + } +}; + + +class ExtLlSerializerAsset_RAW : public ExtLlSerializerObject_RAW +{ +public: + ExtSerializerBoilerplate("LLAsset_RAW", "Blast low-level asset (NvBlastAsset) serialization using raw memory format.", LlObjectTypeID::Asset, ExtSerialization::EncodingID::RawBinary); + ExtSerializerDefaultFactoryAndRelease(ExtLlSerializerAsset_RAW); +}; + + +class ExtLlSerializerFamily_RAW : public ExtLlSerializerObject_RAW +{ +public: + ExtSerializerBoilerplate("LLFamily_RAW", "Blast low-level family (NvBlastFamily) serialization using raw memory format.", LlObjectTypeID::Family, ExtSerialization::EncodingID::RawBinary); + ExtSerializerDefaultFactoryAndRelease(ExtLlSerializerFamily_RAW); +}; + +} // namespace Blast +} // namespace Nv + + +/////////////////////////////////////// + + +size_t NvBlastExtLlSerializerLoadSet(Nv::Blast::ExtSerialization& serialization) +{ + Nv::Blast::ExtSerializer* (*factories[])() = + { + Nv::Blast::ExtLlSerializerAsset_CPNB::create, + Nv::Blast::ExtLlSerializerAsset_RAW::create, + Nv::Blast::ExtLlSerializerFamily_RAW::create + }; + + return Nv::Blast::ExtSerializationLoadSet(static_cast(serialization), factories); +} + + +uint64_t NvBlastExtSerializationSerializeAssetIntoBuffer(void*& buffer, Nv::Blast::ExtSerialization& serialization, const NvBlastAsset* asset) +{ + return serialization.serializeIntoBuffer(buffer, asset, Nv::Blast::LlObjectTypeID::Asset); +} + + +uint64_t NvBlastExtSerializationSerializeFamilyIntoBuffer(void*& buffer, Nv::Blast::ExtSerialization& serialization, const NvBlastFamily* family) +{ + return serialization.serializeIntoBuffer(buffer, family, Nv::Blast::LlObjectTypeID::Family); +} diff --git a/sdk/extensions/serialization/source/NvBlastExtLlSerializerCAPN.h b/sdk/extensions/serialization/source/NvBlastExtLlSerializerCAPN.h old mode 100644 new mode 100755 index 7b92093..24c57f4 --- a/sdk/extensions/serialization/source/NvBlastExtLlSerializerCAPN.h +++ b/sdk/extensions/serialization/source/NvBlastExtLlSerializerCAPN.h @@ -1,72 +1,72 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once - -#include "NvBlastExtSerializationCAPN.h" -#include "NvBlastAsset.h" -#include "AssetDTO.h" - - -/** -Specializations of ExtSerializationCAPN for Blast LL -*/ - -namespace Nv -{ -namespace Blast -{ - -//// Nv::Blast::Asset //// - -template<> -NV_INLINE bool ExtSerializationCAPN::serializeIntoBuilder(Serialization::Asset::Builder& assetBuilder, const Asset* asset) -{ - return AssetDTO::serialize(assetBuilder, asset); -} - - -template<> -NV_INLINE bool ExtSerializationCAPN::serializeIntoMessage(capnp::MallocMessageBuilder& message, const Asset* asset) -{ - Serialization::Asset::Builder assetBuilder = message.initRoot(); - - return serializeIntoBuilder(assetBuilder, asset); -} - - -template<> -NV_INLINE Asset* ExtSerializationCAPN::deserializeFromStreamReader(capnp::InputStreamMessageReader &message) -{ - Serialization::Asset::Reader reader = message.getRoot(); - - return AssetDTO::deserialize(reader); -} - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once + +#include "NvBlastExtSerializationCAPN.h" +#include "NvBlastAsset.h" +#include "AssetDTO.h" + + +/** +Specializations of ExtSerializationCAPN for Blast LL +*/ + +namespace Nv +{ +namespace Blast +{ + +//// Nv::Blast::Asset //// + +template<> +NV_INLINE bool ExtSerializationCAPN::serializeIntoBuilder(Serialization::Asset::Builder& assetBuilder, const Asset* asset) +{ + return AssetDTO::serialize(assetBuilder, asset); +} + + +template<> +NV_INLINE bool ExtSerializationCAPN::serializeIntoMessage(capnp::MallocMessageBuilder& message, const Asset* asset) +{ + Serialization::Asset::Builder assetBuilder = message.initRoot(); + + return serializeIntoBuilder(assetBuilder, asset); +} + + +template<> +NV_INLINE Asset* ExtSerializationCAPN::deserializeFromStreamReader(capnp::InputStreamMessageReader &message) +{ + Serialization::Asset::Reader reader = message.getRoot(); + + return AssetDTO::deserialize(reader); +} + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/NvBlastExtOutputStream.cpp b/sdk/extensions/serialization/source/NvBlastExtOutputStream.cpp old mode 100644 new mode 100755 index f6b3de0..d8b3e1d --- a/sdk/extensions/serialization/source/NvBlastExtOutputStream.cpp +++ b/sdk/extensions/serialization/source/NvBlastExtOutputStream.cpp @@ -1,41 +1,41 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "NvBlastExtOutputStream.h" - - -Nv::Blast::ExtOutputStream::ExtOutputStream(std::ostream &outputStream): - m_outputStream(outputStream) -{ - -} - -void Nv::Blast::ExtOutputStream::write(const void* buffer, size_t size) -{ - m_outputStream.write((char *) buffer, size); -} +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "NvBlastExtOutputStream.h" + + +Nv::Blast::ExtOutputStream::ExtOutputStream(std::ostream &outputStream): + m_outputStream(outputStream) +{ + +} + +void Nv::Blast::ExtOutputStream::write(const void* buffer, size_t size) +{ + m_outputStream.write((char *) buffer, size); +} diff --git a/sdk/extensions/serialization/source/NvBlastExtOutputStream.h b/sdk/extensions/serialization/source/NvBlastExtOutputStream.h old mode 100644 new mode 100755 index b211e03..46a6331 --- a/sdk/extensions/serialization/source/NvBlastExtOutputStream.h +++ b/sdk/extensions/serialization/source/NvBlastExtOutputStream.h @@ -1,52 +1,52 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once -#include "kj/io.h" -#include - - -namespace Nv -{ -namespace Blast -{ - -class ExtOutputStream : public kj::OutputStream -{ -public: - ExtOutputStream() = delete; - ExtOutputStream(std::ostream &outputStream); - - virtual void write(const void* buffer, size_t size) override; - -private: - std::ostream &m_outputStream; -}; - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once +#include "kj/io.h" +#include + + +namespace Nv +{ +namespace Blast +{ + +class ExtOutputStream : public kj::OutputStream +{ +public: + ExtOutputStream() = delete; + ExtOutputStream(std::ostream &outputStream); + + virtual void write(const void* buffer, size_t size) override; + +private: + std::ostream &m_outputStream; +}; + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/NvBlastExtPxSerialization.capn b/sdk/extensions/serialization/source/NvBlastExtPxSerialization.capn old mode 100644 new mode 100755 index e0f9b09..83c7713 --- a/sdk/extensions/serialization/source/NvBlastExtPxSerialization.capn +++ b/sdk/extensions/serialization/source/NvBlastExtPxSerialization.capn @@ -1,99 +1,99 @@ -# 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) 2018 NVIDIA Corporation. All rights reserved. - - -@0xf4df9a42d5842b01; - -using Cxx = import "/capnp/c++.capnp"; - -using TK = import "NvBlastExtTkSerialization.capn"; - -$Cxx.namespace("Nv::Blast::Serialization"); - -struct ExtPxAsset -{ - asset @0 :TK.TkAsset; - chunks @1 :List(ExtPxChunk); - subchunks @2 :List(ExtPxSubchunk); - uniformInitialBondHealth @3 :Float32; - bondHealths @4 :List(Float32); - uniformInitialLowerSupportChunkHealth @5 :Float32; - supportChunkHealths @6 :List(Float32); -} - -struct ExtPxChunk -{ - firstSubchunkIndex @0 :UInt32; - subchunkCount @1 :UInt32; - isStatic @2 :Bool; -} - -struct ExtPxSubchunk -{ - transform @0 :PxTransform; - geometry @1 :PxConvexMeshGeometry; -} - -struct PxConvexMeshGeometry -{ - scale @0 :PxMeshScale; - convexMesh @1 :Data; - meshFlags @2 :UInt8; - - enum Type - { - eSPHERE @0; - ePLANE @1; - eCAPSULE @2; - eBOX @3; - eCONVEXMESH @4; - eTRIANGLEMESH @5; - eHEIGHTFIELD @6; - } - - type @3 :Type; -} - -struct PxQuat -{ - x @0 :Float32; - y @1 :Float32; - z @2 :Float32; - w @3 :Float32; -} - -struct PxMeshScale -{ - scale @0 :TK.PxVec3; - rotation @1 :PxQuat; -} - -struct PxTransform -{ - q @0 :PxQuat; - p @1 :TK.PxVec3; -} +# 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) 2018 NVIDIA Corporation. All rights reserved. + + +@0xf4df9a42d5842b01; + +using Cxx = import "/capnp/c++.capnp"; + +using TK = import "NvBlastExtTkSerialization.capn"; + +$Cxx.namespace("Nv::Blast::Serialization"); + +struct ExtPxAsset +{ + asset @0 :TK.TkAsset; + chunks @1 :List(ExtPxChunk); + subchunks @2 :List(ExtPxSubchunk); + uniformInitialBondHealth @3 :Float32; + bondHealths @4 :List(Float32); + uniformInitialLowerSupportChunkHealth @5 :Float32; + supportChunkHealths @6 :List(Float32); +} + +struct ExtPxChunk +{ + firstSubchunkIndex @0 :UInt32; + subchunkCount @1 :UInt32; + isStatic @2 :Bool; +} + +struct ExtPxSubchunk +{ + transform @0 :PxTransform; + geometry @1 :PxConvexMeshGeometry; +} + +struct PxConvexMeshGeometry +{ + scale @0 :PxMeshScale; + convexMesh @1 :Data; + meshFlags @2 :UInt8; + + enum Type + { + eSPHERE @0; + ePLANE @1; + eCAPSULE @2; + eBOX @3; + eCONVEXMESH @4; + eTRIANGLEMESH @5; + eHEIGHTFIELD @6; + } + + type @3 :Type; +} + +struct PxQuat +{ + x @0 :Float32; + y @1 :Float32; + z @2 :Float32; + w @3 :Float32; +} + +struct PxMeshScale +{ + scale @0 :TK.PxVec3; + rotation @1 :PxQuat; +} + +struct PxTransform +{ + q @0 :PxQuat; + p @1 :TK.PxVec3; +} diff --git a/sdk/extensions/serialization/source/NvBlastExtPxSerialization.cpp b/sdk/extensions/serialization/source/NvBlastExtPxSerialization.cpp old mode 100644 new mode 100755 index b8a6a8e..1546acc --- a/sdk/extensions/serialization/source/NvBlastExtPxSerialization.cpp +++ b/sdk/extensions/serialization/source/NvBlastExtPxSerialization.cpp @@ -1,109 +1,109 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "NvBlastExtSerializationInternal.h" -#include "NvBlastExtPxSerialization.h" -#include "NvBlastExtPxSerializerCAPN.h" -#include "NvBlastExtPxSerializerRAW.h" - - -namespace Nv -{ -namespace Blast -{ - -TkFramework* sExtPxSerializerFramework = nullptr; -physx::PxPhysics* sExtPxSerializerPhysics = nullptr; -physx::PxCooking* sExtPxSerializerCooking = nullptr; - - -class ExtPxSerializerAsset_CPNB : public ExtSerializer -{ -public: - ExtSerializerBoilerplate("ExtPxAsset_CPNB", "Blast PhysX extension asset (Nv::Blast::ExtPxAsset) serialization using Cap'n Proto binary format.", ExtPxObjectTypeID::Asset, ExtSerialization::EncodingID::CapnProtoBinary); - ExtSerializerDefaultFactoryAndRelease(ExtPxSerializerAsset_CPNB); - - virtual void* deserializeFromBuffer(const void* buffer, uint64_t size) override - { - return ExtSerializationCAPN::deserializeFromBuffer(reinterpret_cast(buffer), size); - } - - virtual uint64_t serializeIntoBuffer(void*& buffer, ExtSerialization::BufferProvider& bufferProvider, const void* object, uint64_t offset = 0) override - { - uint64_t usedSize; - if (!ExtSerializationCAPN::serializeIntoBuffer(reinterpret_cast(object), - reinterpret_cast(buffer), usedSize, &bufferProvider, offset)) - { - return 0; - } - return usedSize; - } -}; - - -class ExtPxSerializerAsset_RAW : public ExtSerializer -{ -public: - ExtSerializerBoilerplate("ExtPxAsset_RAW", "Blast PhysX extension asset (Nv::Blast::TkAsset) serialization using raw memory format.", ExtPxObjectTypeID::Asset, ExtSerialization::EncodingID::RawBinary); - ExtSerializerDefaultFactoryAndRelease(ExtPxSerializerAsset_RAW); - ExtSerializerReadOnly(ExtPxSerializerAsset_RAW); - - virtual void* deserializeFromBuffer(const void* buffer, uint64_t size) override - { - ExtIStream stream(buffer, size); - return deserializeExtPxAsset(stream, *sExtPxSerializerFramework, *sExtPxSerializerPhysics); - } -}; - -} // namespace Blast -} // namespace Nv - - -/////////////////////////////////////// - - -size_t NvBlastExtPxSerializerLoadSet(Nv::Blast::TkFramework& framework, physx::PxPhysics& physics, physx::PxCooking& cooking, Nv::Blast::ExtSerialization& serialization) -{ - Nv::Blast::sExtPxSerializerFramework = &framework; - Nv::Blast::sExtPxSerializerPhysics = &physics; - Nv::Blast::sExtPxSerializerCooking = &cooking; - - Nv::Blast::ExtSerializer* (*factories[])() = - { - Nv::Blast::ExtPxSerializerAsset_CPNB::create, - Nv::Blast::ExtPxSerializerAsset_RAW::create - }; - - return Nv::Blast::ExtSerializationLoadSet(static_cast(serialization), factories); -} - - -uint64_t NvBlastExtSerializationSerializeExtPxAssetIntoBuffer(void*& buffer, Nv::Blast::ExtSerialization& serialization, const Nv::Blast::ExtPxAsset* asset) -{ - return serialization.serializeIntoBuffer(buffer, asset, Nv::Blast::ExtPxObjectTypeID::Asset); -} +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "NvBlastExtSerializationInternal.h" +#include "NvBlastExtPxSerialization.h" +#include "NvBlastExtPxSerializerCAPN.h" +#include "NvBlastExtPxSerializerRAW.h" + + +namespace Nv +{ +namespace Blast +{ + +TkFramework* sExtPxSerializerFramework = nullptr; +physx::PxPhysics* sExtPxSerializerPhysics = nullptr; +physx::PxCooking* sExtPxSerializerCooking = nullptr; + + +class ExtPxSerializerAsset_CPNB : public ExtSerializer +{ +public: + ExtSerializerBoilerplate("ExtPxAsset_CPNB", "Blast PhysX extension asset (Nv::Blast::ExtPxAsset) serialization using Cap'n Proto binary format.", ExtPxObjectTypeID::Asset, ExtSerialization::EncodingID::CapnProtoBinary); + ExtSerializerDefaultFactoryAndRelease(ExtPxSerializerAsset_CPNB); + + virtual void* deserializeFromBuffer(const void* buffer, uint64_t size) override + { + return ExtSerializationCAPN::deserializeFromBuffer(reinterpret_cast(buffer), size); + } + + virtual uint64_t serializeIntoBuffer(void*& buffer, ExtSerialization::BufferProvider& bufferProvider, const void* object, uint64_t offset = 0) override + { + uint64_t usedSize; + if (!ExtSerializationCAPN::serializeIntoBuffer(reinterpret_cast(object), + reinterpret_cast(buffer), usedSize, &bufferProvider, offset)) + { + return 0; + } + return usedSize; + } +}; + + +class ExtPxSerializerAsset_RAW : public ExtSerializer +{ +public: + ExtSerializerBoilerplate("ExtPxAsset_RAW", "Blast PhysX extension asset (Nv::Blast::TkAsset) serialization using raw memory format.", ExtPxObjectTypeID::Asset, ExtSerialization::EncodingID::RawBinary); + ExtSerializerDefaultFactoryAndRelease(ExtPxSerializerAsset_RAW); + ExtSerializerReadOnly(ExtPxSerializerAsset_RAW); + + virtual void* deserializeFromBuffer(const void* buffer, uint64_t size) override + { + ExtIStream stream(buffer, size); + return deserializeExtPxAsset(stream, *sExtPxSerializerFramework, *sExtPxSerializerPhysics); + } +}; + +} // namespace Blast +} // namespace Nv + + +/////////////////////////////////////// + + +size_t NvBlastExtPxSerializerLoadSet(Nv::Blast::TkFramework& framework, physx::PxPhysics& physics, physx::PxCooking& cooking, Nv::Blast::ExtSerialization& serialization) +{ + Nv::Blast::sExtPxSerializerFramework = &framework; + Nv::Blast::sExtPxSerializerPhysics = &physics; + Nv::Blast::sExtPxSerializerCooking = &cooking; + + Nv::Blast::ExtSerializer* (*factories[])() = + { + Nv::Blast::ExtPxSerializerAsset_CPNB::create, + Nv::Blast::ExtPxSerializerAsset_RAW::create + }; + + return Nv::Blast::ExtSerializationLoadSet(static_cast(serialization), factories); +} + + +uint64_t NvBlastExtSerializationSerializeExtPxAssetIntoBuffer(void*& buffer, Nv::Blast::ExtSerialization& serialization, const Nv::Blast::ExtPxAsset* asset) +{ + return serialization.serializeIntoBuffer(buffer, asset, Nv::Blast::ExtPxObjectTypeID::Asset); +} diff --git a/sdk/extensions/serialization/source/NvBlastExtPxSerializerCAPN.h b/sdk/extensions/serialization/source/NvBlastExtPxSerializerCAPN.h old mode 100644 new mode 100755 index 2f00590..bf89e1d --- a/sdk/extensions/serialization/source/NvBlastExtPxSerializerCAPN.h +++ b/sdk/extensions/serialization/source/NvBlastExtPxSerializerCAPN.h @@ -1,70 +1,70 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once - -#include "NvBlastExtSerializationCAPN.h" -#include "NvBlastExtPxAsset.h" -#include "ExtPxAssetDTO.h" - - -/** -Specializations of ExtSerializationCAPN for BlastExtPx -*/ - -namespace Nv -{ -namespace Blast -{ - -//// Nv::Blast::ExtPxAsset //// - -template<> -NV_INLINE bool ExtSerializationCAPN::serializeIntoBuilder(Serialization::ExtPxAsset::Builder& assetBuilder, const ExtPxAsset* asset) -{ - return ExtPxAssetDTO::serialize(assetBuilder, asset); -} - -template<> -NV_INLINE ExtPxAsset* ExtSerializationCAPN::deserializeFromStreamReader(capnp::InputStreamMessageReader &message) -{ - Serialization::ExtPxAsset::Reader reader = message.getRoot(); - - return ExtPxAssetDTO::deserialize(reader); -} - -template<> -NV_INLINE bool ExtSerializationCAPN::serializeIntoMessage(capnp::MallocMessageBuilder& message, const ExtPxAsset* asset) -{ - Serialization::ExtPxAsset::Builder assetBuilder = message.initRoot(); - - return serializeIntoBuilder(assetBuilder, asset); -} - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once + +#include "NvBlastExtSerializationCAPN.h" +#include "NvBlastExtPxAsset.h" +#include "ExtPxAssetDTO.h" + + +/** +Specializations of ExtSerializationCAPN for BlastExtPx +*/ + +namespace Nv +{ +namespace Blast +{ + +//// Nv::Blast::ExtPxAsset //// + +template<> +NV_INLINE bool ExtSerializationCAPN::serializeIntoBuilder(Serialization::ExtPxAsset::Builder& assetBuilder, const ExtPxAsset* asset) +{ + return ExtPxAssetDTO::serialize(assetBuilder, asset); +} + +template<> +NV_INLINE ExtPxAsset* ExtSerializationCAPN::deserializeFromStreamReader(capnp::InputStreamMessageReader &message) +{ + Serialization::ExtPxAsset::Reader reader = message.getRoot(); + + return ExtPxAssetDTO::deserialize(reader); +} + +template<> +NV_INLINE bool ExtSerializationCAPN::serializeIntoMessage(capnp::MallocMessageBuilder& message, const ExtPxAsset* asset) +{ + Serialization::ExtPxAsset::Builder assetBuilder = message.initRoot(); + + return serializeIntoBuilder(assetBuilder, asset); +} + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/NvBlastExtPxSerializerRAW.cpp b/sdk/extensions/serialization/source/NvBlastExtPxSerializerRAW.cpp old mode 100644 new mode 100755 index f0e51d2..064f34a --- a/sdk/extensions/serialization/source/NvBlastExtPxSerializerRAW.cpp +++ b/sdk/extensions/serialization/source/NvBlastExtPxSerializerRAW.cpp @@ -1,221 +1,221 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "NvBlastExtSerialization.h" -#include "NvBlastExtTkSerializerRAW.h" -#include "NvBlastExtPxAsset.h" -#include "NvBlastTkAsset.h" -#include "physics/NvBlastExtPxAssetImpl.h" -#include "NvBlastIndexFns.h" -#include "NvBlastAssert.h" -#include "NvBlastExtSerializationInternal.h" - -#include "PxPhysics.h" -#include "PsMemoryBuffer.h" -#include "PxIO.h" - - -namespace Nv -{ -namespace Blast -{ - -// Legacy IDs -struct ExtPxSerializationLegacyID -{ - enum Enum - { - Asset = NVBLAST_FOURCC('B', 'P', 'X', 'A'), //!< ExtPxAsset identifier token, used in serialization - }; -}; - - -// Legacy object format versions -struct ExtPxSerializationLegacyAssetVersion -{ - enum Enum - { - /** Initial version */ - Initial, - - // New formats must come before Count. They should be given descriptive names with more information in comments. - - /** The number of serialized formats. */ - Count, - - /** The current version. This should always be Count-1 */ - Current = Count - 1 - }; -}; - - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Helpers/Wrappers -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -class FileBufToPxInputStream final : public PxInputStream -{ -public: - FileBufToPxInputStream(PxFileBuf& filebuf) : m_filebuf(filebuf) {} - - virtual uint32_t read(void* dest, uint32_t count) - { - return m_filebuf.read(dest, count); - } - -private: - FileBufToPxInputStream& operator=(const FileBufToPxInputStream&); - - PxFileBuf& m_filebuf; -}; - - -class FileBufToPxOutputStream final : public PxOutputStream -{ -public: - FileBufToPxOutputStream(PxFileBuf& filebuf) : m_filebuf(filebuf) {} - - virtual uint32_t write(const void* src, uint32_t count) override - { - return m_filebuf.write(src, count); - } - -private: - FileBufToPxOutputStream& operator=(const FileBufToPxOutputStream&); - - PxFileBuf& m_filebuf; -}; - - -ExtPxAsset* deserializeExtPxAsset(ExtIStream& stream, TkFramework& framework, physx::PxPhysics& physics) -{ - // Read header - struct LegacyAssetDataHeader - { - LegacyAssetDataHeader() : dataType(0), version(0) {} - uint32_t dataType; - uint32_t version; - }; - LegacyAssetDataHeader header; - stream >> header.dataType; - stream >> header.version; - NVBLAST_CHECK_ERROR(header.dataType == ExtPxSerializationLegacyID::Asset, "deserializeExtPxAsset: wrong data type in filebuf stream.", return nullptr); - NVBLAST_CHECK_ERROR(header.version == ExtPxSerializationLegacyAssetVersion::Current, "deserializeExtPxAsset: wrong data version in filebuf stream.", return nullptr); - - // Read initial TkAsset - TkAsset* tkAsset = deserializeTkAsset(stream, framework); - NVBLAST_CHECK_ERROR(tkAsset != nullptr, "ExtPxAsset::deserialize: failed to deserialize TkAsset.", return nullptr); - - // Create ExtPxAsset - ExtPxAssetImpl* asset = reinterpret_cast(ExtPxAsset::create(tkAsset)); - - // Fill arrays - auto& chunks = asset->getChunksArray(); - chunks.resize(tkAsset->getChunkCount()); - const uint32_t chunkCount = chunks.size(); - for (uint32_t i = 0; i < chunkCount; ++i) - { - ExtPxChunk& chunk = chunks[i]; - stream >> chunk.firstSubchunkIndex; - stream >> chunk.subchunkCount; - uint32_t val; - stream >> val; - chunk.isStatic = 0 != val; - } - - auto& subchunks = asset->getSubchunksArray(); - uint32_t subchunkCount; - stream >> subchunkCount; - subchunks.resize(subchunkCount); - for (uint32_t i = 0; i < subchunkCount; ++i) - { - ExtPxSubchunk& subchunk = subchunks[i]; - - // Subchunk transform - stream >> subchunk.transform.q.x >> subchunk.transform.q.y >> subchunk.transform.q.z >> subchunk.transform.q.w; - stream >> subchunk.transform.p.x >> subchunk.transform.p.y >> subchunk.transform.p.z; - - // Subchunk scale - stream >> subchunk.geometry.scale.scale.x >> subchunk.geometry.scale.scale.y >> subchunk.geometry.scale.scale.z; - stream >> subchunk.geometry.scale.rotation.x >> subchunk.geometry.scale.rotation.y >> subchunk.geometry.scale.rotation.z >> subchunk.geometry.scale.rotation.w; - - uint32_t convexReuseIndex; - stream >> convexReuseIndex; - if (isInvalidIndex(convexReuseIndex)) - { - physx::PsMemoryBuffer memBuf(stream.view(), stream.left()); - FileBufToPxInputStream inputStream(memBuf); - subchunk.geometry.convexMesh = physics.createConvexMesh(inputStream); - stream.advance(memBuf.tellRead()); - } - else - { - NVBLAST_ASSERT_WITH_MESSAGE(convexReuseIndex < i, "ExtPxAsset::deserialize: wrong convexReuseIndex."); - subchunk.geometry.convexMesh = subchunks[convexReuseIndex].geometry.convexMesh; - } - if (!subchunk.geometry.convexMesh) - { - NVBLAST_LOG_ERROR("ExtPxAsset::deserialize: failed to deserialize convex mesh."); - return nullptr; - } - } - - // checking if it's the end, so it will be binary compatible with asset before m_defaultActorDesc was added - if (!stream.eof()) - { - auto& defaultActorDesc = asset->getDefaultActorDesc(); - - stream >> defaultActorDesc.uniformInitialBondHealth; - stream >> defaultActorDesc.uniformInitialLowerSupportChunkHealth; - - auto& bondHealths = asset->getBondHealthsArray(); - uint32_t bondHealthCount; - stream >> bondHealthCount; - bondHealths.resize(bondHealthCount); - for (uint32_t i = 0; i < bondHealths.size(); ++i) - { - stream >> bondHealths[i]; - } - defaultActorDesc.initialBondHealths = bondHealthCount ? bondHealths.begin() : nullptr; - - auto& supportChunkHealths = asset->getSupportChunkHealthsArray(); - uint32_t supportChunkHealthCount; - stream >> supportChunkHealthCount; - supportChunkHealths.resize(supportChunkHealthCount); - for (uint32_t i = 0; i < supportChunkHealths.size(); ++i) - { - stream >> supportChunkHealths[i]; - } - defaultActorDesc.initialSupportChunkHealths = supportChunkHealthCount ? supportChunkHealths.begin() : nullptr; - } - - return asset; -} - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "NvBlastExtSerialization.h" +#include "NvBlastExtTkSerializerRAW.h" +#include "NvBlastExtPxAsset.h" +#include "NvBlastTkAsset.h" +#include "physics/NvBlastExtPxAssetImpl.h" +#include "NvBlastIndexFns.h" +#include "NvBlastAssert.h" +#include "NvBlastExtSerializationInternal.h" + +#include "PxPhysics.h" +#include "PsMemoryBuffer.h" +#include "PxIO.h" + + +namespace Nv +{ +namespace Blast +{ + +// Legacy IDs +struct ExtPxSerializationLegacyID +{ + enum Enum + { + Asset = NVBLAST_FOURCC('B', 'P', 'X', 'A'), //!< ExtPxAsset identifier token, used in serialization + }; +}; + + +// Legacy object format versions +struct ExtPxSerializationLegacyAssetVersion +{ + enum Enum + { + /** Initial version */ + Initial, + + // New formats must come before Count. They should be given descriptive names with more information in comments. + + /** The number of serialized formats. */ + Count, + + /** The current version. This should always be Count-1 */ + Current = Count - 1 + }; +}; + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Helpers/Wrappers +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +class FileBufToPxInputStream final : public PxInputStream +{ +public: + FileBufToPxInputStream(PxFileBuf& filebuf) : m_filebuf(filebuf) {} + + virtual uint32_t read(void* dest, uint32_t count) + { + return m_filebuf.read(dest, count); + } + +private: + FileBufToPxInputStream& operator=(const FileBufToPxInputStream&); + + PxFileBuf& m_filebuf; +}; + + +class FileBufToPxOutputStream final : public PxOutputStream +{ +public: + FileBufToPxOutputStream(PxFileBuf& filebuf) : m_filebuf(filebuf) {} + + virtual uint32_t write(const void* src, uint32_t count) override + { + return m_filebuf.write(src, count); + } + +private: + FileBufToPxOutputStream& operator=(const FileBufToPxOutputStream&); + + PxFileBuf& m_filebuf; +}; + + +ExtPxAsset* deserializeExtPxAsset(ExtIStream& stream, TkFramework& framework, physx::PxPhysics& physics) +{ + // Read header + struct LegacyAssetDataHeader + { + LegacyAssetDataHeader() : dataType(0), version(0) {} + uint32_t dataType; + uint32_t version; + }; + LegacyAssetDataHeader header; + stream >> header.dataType; + stream >> header.version; + NVBLAST_CHECK_ERROR(header.dataType == ExtPxSerializationLegacyID::Asset, "deserializeExtPxAsset: wrong data type in filebuf stream.", return nullptr); + NVBLAST_CHECK_ERROR(header.version == ExtPxSerializationLegacyAssetVersion::Current, "deserializeExtPxAsset: wrong data version in filebuf stream.", return nullptr); + + // Read initial TkAsset + TkAsset* tkAsset = deserializeTkAsset(stream, framework); + NVBLAST_CHECK_ERROR(tkAsset != nullptr, "ExtPxAsset::deserialize: failed to deserialize TkAsset.", return nullptr); + + // Create ExtPxAsset + ExtPxAssetImpl* asset = reinterpret_cast(ExtPxAsset::create(tkAsset)); + + // Fill arrays + auto& chunks = asset->getChunksArray(); + chunks.resize(tkAsset->getChunkCount()); + const uint32_t chunkCount = chunks.size(); + for (uint32_t i = 0; i < chunkCount; ++i) + { + ExtPxChunk& chunk = chunks[i]; + stream >> chunk.firstSubchunkIndex; + stream >> chunk.subchunkCount; + uint32_t val; + stream >> val; + chunk.isStatic = 0 != val; + } + + auto& subchunks = asset->getSubchunksArray(); + uint32_t subchunkCount; + stream >> subchunkCount; + subchunks.resize(subchunkCount); + for (uint32_t i = 0; i < subchunkCount; ++i) + { + ExtPxSubchunk& subchunk = subchunks[i]; + + // Subchunk transform + stream >> subchunk.transform.q.x >> subchunk.transform.q.y >> subchunk.transform.q.z >> subchunk.transform.q.w; + stream >> subchunk.transform.p.x >> subchunk.transform.p.y >> subchunk.transform.p.z; + + // Subchunk scale + stream >> subchunk.geometry.scale.scale.x >> subchunk.geometry.scale.scale.y >> subchunk.geometry.scale.scale.z; + stream >> subchunk.geometry.scale.rotation.x >> subchunk.geometry.scale.rotation.y >> subchunk.geometry.scale.rotation.z >> subchunk.geometry.scale.rotation.w; + + uint32_t convexReuseIndex; + stream >> convexReuseIndex; + if (isInvalidIndex(convexReuseIndex)) + { + physx::PsMemoryBuffer memBuf(stream.view(), stream.left()); + FileBufToPxInputStream inputStream(memBuf); + subchunk.geometry.convexMesh = physics.createConvexMesh(inputStream); + stream.advance(memBuf.tellRead()); + } + else + { + NVBLAST_ASSERT_WITH_MESSAGE(convexReuseIndex < i, "ExtPxAsset::deserialize: wrong convexReuseIndex."); + subchunk.geometry.convexMesh = subchunks[convexReuseIndex].geometry.convexMesh; + } + if (!subchunk.geometry.convexMesh) + { + NVBLAST_LOG_ERROR("ExtPxAsset::deserialize: failed to deserialize convex mesh."); + return nullptr; + } + } + + // checking if it's the end, so it will be binary compatible with asset before m_defaultActorDesc was added + if (!stream.eof()) + { + auto& defaultActorDesc = asset->getDefaultActorDesc(); + + stream >> defaultActorDesc.uniformInitialBondHealth; + stream >> defaultActorDesc.uniformInitialLowerSupportChunkHealth; + + auto& bondHealths = asset->getBondHealthsArray(); + uint32_t bondHealthCount; + stream >> bondHealthCount; + bondHealths.resize(bondHealthCount); + for (uint32_t i = 0; i < bondHealths.size(); ++i) + { + stream >> bondHealths[i]; + } + defaultActorDesc.initialBondHealths = bondHealthCount ? bondHealths.begin() : nullptr; + + auto& supportChunkHealths = asset->getSupportChunkHealthsArray(); + uint32_t supportChunkHealthCount; + stream >> supportChunkHealthCount; + supportChunkHealths.resize(supportChunkHealthCount); + for (uint32_t i = 0; i < supportChunkHealths.size(); ++i) + { + stream >> supportChunkHealths[i]; + } + defaultActorDesc.initialSupportChunkHealths = supportChunkHealthCount ? supportChunkHealths.begin() : nullptr; + } + + return asset; +} + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/NvBlastExtPxSerializerRAW.h b/sdk/extensions/serialization/source/NvBlastExtPxSerializerRAW.h old mode 100644 new mode 100755 index a6bbf8b..f5a0263 --- a/sdk/extensions/serialization/source/NvBlastExtPxSerializerRAW.h +++ b/sdk/extensions/serialization/source/NvBlastExtPxSerializerRAW.h @@ -1,61 +1,61 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once - - -/** -Raw serialization function declarations for BlastExtPx -*/ - -#include - - -// Forward declarations -namespace physx -{ -class PxPhysics; -} - -namespace Nv -{ -namespace Blast -{ - -// Forward declarations -class ExtPxAsset; -class TkFramework; -class ExtIStream; - - -//// Nv::Blast::TkAsset //// - -ExtPxAsset* deserializeExtPxAsset(ExtIStream& stream, TkFramework& framework, physx::PxPhysics& physics); - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once + + +/** +Raw serialization function declarations for BlastExtPx +*/ + +#include + + +// Forward declarations +namespace physx +{ +class PxPhysics; +} + +namespace Nv +{ +namespace Blast +{ + +// Forward declarations +class ExtPxAsset; +class TkFramework; +class ExtIStream; + + +//// Nv::Blast::TkAsset //// + +ExtPxAsset* deserializeExtPxAsset(ExtIStream& stream, TkFramework& framework, physx::PxPhysics& physics); + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/NvBlastExtSerialization.cpp b/sdk/extensions/serialization/source/NvBlastExtSerialization.cpp old mode 100644 new mode 100755 index cae8f46..6d86358 --- a/sdk/extensions/serialization/source/NvBlastExtSerialization.cpp +++ b/sdk/extensions/serialization/source/NvBlastExtSerialization.cpp @@ -1,401 +1,401 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "NvBlastExtSerialization.h" -#include "NvBlastExtLlSerialization.h" -#include "NvBlastHashMap.h" -#include "NvBlastExtSerializationInternal.h" - - -namespace Nv -{ -namespace Blast -{ - -class ExtSerializationImpl : public ExtSerializationInternal -{ -public: - // Default buffer provider - class AllocBufferProvider : public ExtSerialization::BufferProvider - { - public: - virtual void* requestBuffer(size_t size) override; - }; - - - ExtSerializationImpl(); - ~ExtSerializationImpl(); - - // ExtSerialization interface begin - virtual bool setSerializationEncoding(uint32_t encodingID) override; - virtual uint32_t getSerializationEncoding() const override; - - virtual void setBufferProvider(BufferProvider* bufferProvider) override; - - virtual bool peekHeader(uint32_t* objectTypeID, uint32_t* encodingID, uint64_t* dataSize, const void* buffer, uint64_t bufferSize) override; - virtual const void* skipObject(uint64_t& bufferSize, const void* buffer) override; - - virtual void* deserializeFromBuffer(const void* buffer, uint64_t size, uint32_t* objectTypeIDPtr = nullptr) override; - virtual uint64_t serializeIntoBuffer(void*& buffer, const void* object, uint32_t objectTypeID) override; - - virtual void release() override; - // ExtSerialization interface end - - // ExtSerializationInternal interface begin - virtual bool registerSerializer(ExtSerializer& serializer) override; - virtual bool unregisterSerializer(ExtSerializer& serializer) override; - - virtual ExtSerializer* findSerializer(uint32_t objectTypeID, uint32_t encodingID) override; - // ExtSerializationInternal interface end - -private: - char* writeHeaderIntoBuffer(char* buffer, uint64_t bufferSize, uint32_t objectTypeID, uint32_t encodingID, uint64_t dataSize) const; - const char* readHeaderFromBuffer(uint32_t* objectTypeID, uint32_t* encodingID, uint64_t* dataSize, const char* buffer, uint64_t bufferSize) const; - - //// Static data //// - static const char* s_identifier; - static const char* s_version; - static AllocBufferProvider s_defaultBufferProvider; - - //// Member data //// - HashMap::type m_serializers; - uint32_t m_serializationEncoding; - BufferProvider* m_bufferProvider; -}; - - -//////// ExtSerializationImpl static member variables //////// - -/** Module identifying header. This should never change. */ -const char* ExtSerializationImpl::s_identifier = "NVidia(r) GameWorks Blast(tm) v."; - -const char* ExtSerializationImpl::s_version = "1"; - -ExtSerializationImpl::AllocBufferProvider ExtSerializationImpl::s_defaultBufferProvider; - - -//////// Local utility functions //////// - -static NV_INLINE uint64_t generateKey(uint32_t objectTypeID, uint32_t encodingID) -{ - return static_cast(encodingID) << 32 | static_cast(objectTypeID); -} - - -static NV_INLINE uint64_t generateKey(const ExtSerializer& serializer) -{ - return generateKey(serializer.getObjectTypeID(), serializer.getEncodingID()); -} - - -static NV_INLINE void writeIDToBuffer(char* buffer, uint32_t id) -{ - for (int i = 0; i < 4; ++i, id >>= 8) - { - *buffer++ = static_cast(id & 0xFF); - } -} - - -static NV_INLINE uint32_t readIDFromBuffer(const char* buffer) -{ - return NVBLAST_FOURCC(buffer[0], buffer[1], buffer[2], buffer[3]); -} - - -static NV_INLINE void writeU64InHexToBuffer(char* buffer, uint64_t val) -{ - for (char* curr = buffer + 16; curr-- > buffer; val >>= 4) - { - *curr = "0123456789ABCDEF"[val & 0xF]; - } -} - - -static NV_INLINE uint64_t readU64InHexFromBuffer(const char* buffer) -{ - uint64_t val = 0; - for (const char* curr = buffer; curr < buffer + 16; ++curr) - { - const char c = *curr; - const char msn = c >> 4; - const char mask = ((88 >> msn) & 1) - 1; - const unsigned char digit = "\x0\x1\x2\x3\x4\x5\x6\x7\x8\x9\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xA\xB\xC\xD\xE\xF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"[((msn - 3) & 1) << 4 | (c & 0xF)] | mask; - if (digit == 0xFF) - { - return 0; // Not a hexidecimal digit - } - val = val << 4 | digit; - } - return val; -} - - -//////// ExtSerialization member functions //////// - -ExtSerializationImpl::ExtSerializationImpl() : m_serializationEncoding(EncodingID::CapnProtoBinary), m_bufferProvider(&s_defaultBufferProvider) -{ -} - - -ExtSerializationImpl::~ExtSerializationImpl() -{ - // Release and remove all registered serializers - auto it = m_serializers.getEraseIterator(); - while (auto entry = it.eraseCurrentGetNext(true)) - { - entry->second->release(); - } -} - - -char* ExtSerializationImpl::writeHeaderIntoBuffer(char* buffer, uint64_t bufferSize, uint32_t objectTypeID, uint32_t encodingID, uint64_t dataSize) const -{ - if (bufferSize < HeaderSize) - { - return nullptr; - } - - char* stop = buffer + HeaderSize; - - size_t versionLen = strlen(s_version); - if (versionLen > 63) - { - versionLen = 63; - } - - memset(buffer, ' ', HeaderSize); - memcpy(buffer, s_identifier, 32); buffer += 32; - memcpy(buffer, s_version, versionLen); buffer += 64; - writeIDToBuffer(buffer, objectTypeID); buffer += 5; - writeIDToBuffer(buffer, encodingID); buffer += 5; - writeU64InHexToBuffer(buffer, dataSize); buffer += 16; - *(stop - 1) = '\n'; - - return stop; -} - - -const char* ExtSerializationImpl::readHeaderFromBuffer(uint32_t* objectTypeID, uint32_t* encodingID, uint64_t* dataSize, const char* buffer, uint64_t bufferSize) const -{ - if (bufferSize < HeaderSize) - { - NVBLAST_LOG_ERROR("ExtSerializationImpl::readHeaderFromBuffer: header terminator not found."); - return nullptr; - } - - const char* stop = buffer + HeaderSize; - - if (memcmp(buffer, s_identifier, 32)) - { - NVBLAST_LOG_ERROR("ExtSerializationImpl::readHeaderFromBuffer: file identifier does not match expected value."); - return nullptr; - } - buffer += 32; - - const char* s = strchr(buffer, ' '); - if (s == nullptr) - { - NVBLAST_LOG_ERROR("ExtSerializationImpl::readHeaderFromBuffer: file format error reading serializer library version."); - } - if (memcmp(buffer, s_version, s - buffer)) - { - NVBLAST_LOG_ERROR("ExtSerializationImpl::readHeaderFromBuffer: file version does not match serializer library version."); - return nullptr; - } - buffer += 64; - - if (objectTypeID != nullptr) - { - *objectTypeID = readIDFromBuffer(buffer); - } - buffer += 5; - - if (encodingID != nullptr) - { - *encodingID = readIDFromBuffer(buffer); - } - buffer += 5; - - if (dataSize != nullptr) - { - *dataSize = readU64InHexFromBuffer(buffer); - } - buffer += 16; - - return stop; -} - - -bool ExtSerializationImpl::registerSerializer(ExtSerializer& serializer) -{ - return m_serializers.insert(generateKey(serializer), &serializer); -} - - -bool ExtSerializationImpl::unregisterSerializer(ExtSerializer& serializer) -{ - const uint64_t key = generateKey(serializer); - const auto entry = m_serializers.find(key); - if (entry == nullptr) - { - return false; - } - entry->second->release(); - return m_serializers.erase(key); -} - - -ExtSerializer* ExtSerializationImpl::findSerializer(uint32_t objectTypeID, uint32_t encodingID) -{ - auto entry = m_serializers.find(generateKey(objectTypeID, encodingID)); - return entry != nullptr ? entry->second : nullptr; -} - - -bool ExtSerializationImpl::setSerializationEncoding(uint32_t encodingID) -{ - m_serializationEncoding = encodingID; - - return true; -} - - -uint32_t ExtSerializationImpl::getSerializationEncoding() const -{ - return m_serializationEncoding; -} - - -void ExtSerializationImpl::setBufferProvider(BufferProvider* bufferProvider) -{ - m_bufferProvider = bufferProvider != nullptr ? bufferProvider : &s_defaultBufferProvider; -} - - -bool ExtSerializationImpl::peekHeader(uint32_t* objectTypeID, uint32_t* encodingID, uint64_t* dataSize, const void* buffer, uint64_t bufferSize) -{ - return nullptr != readHeaderFromBuffer(objectTypeID, encodingID, dataSize, reinterpret_cast(buffer), bufferSize); -} - - -const void* ExtSerializationImpl::skipObject(uint64_t& bufferSize, const void* buffer) -{ - uint64_t dataSize; - const char* next = readHeaderFromBuffer(nullptr, nullptr, &dataSize, static_cast(buffer), bufferSize); - if (next == nullptr) - { - return nullptr; - } - next += dataSize; - const uint64_t skipSize = next - static_cast(buffer); - NVBLAST_CHECK_ERROR(skipSize <= bufferSize, "Object size in buffer is too large for given buffer size.", return nullptr); - bufferSize -= skipSize; - return next; -} - - -void* ExtSerializationImpl::deserializeFromBuffer(const void* buffer, uint64_t bufferSize, uint32_t* objectTypeIDPtr) -{ - uint32_t objectTypeID; - uint32_t encodingID; - uint64_t dataSize; - void* result = nullptr; - - buffer = readHeaderFromBuffer(&objectTypeID, &encodingID, &dataSize, reinterpret_cast(buffer), bufferSize); - if (buffer != nullptr) - { - auto entry = m_serializers.find(generateKey(objectTypeID, encodingID)); - if (entry != nullptr && entry->second != nullptr) - { - result = entry->second->deserializeFromBuffer(buffer, dataSize); - } - } - - if (objectTypeIDPtr != nullptr) - { - *objectTypeIDPtr = result != nullptr ? objectTypeID : 0; - } - - return result; -} - - -uint64_t ExtSerializationImpl::serializeIntoBuffer(void*& buffer, const void* object, uint32_t objectTypeID) -{ - if (!m_serializationEncoding) - { - NVBLAST_LOG_ERROR("ExtSerializationImpl::serializeIntoBuffer: no serialization encoding has been set."); - return false; // No encoding available - } - - auto entry = m_serializers.find(generateKey(objectTypeID, m_serializationEncoding)); - if (entry == nullptr || entry->second == nullptr) - { - return false; - } - - const uint64_t size = entry->second->serializeIntoBuffer(buffer, *m_bufferProvider, object, HeaderSize); - if (size < HeaderSize) - { - NVBLAST_LOG_ERROR("ExtSerializationImpl::serializeIntoBuffer: failed to write data to buffer."); - return 0; - } - - writeHeaderIntoBuffer(reinterpret_cast(buffer), HeaderSize, objectTypeID, m_serializationEncoding, size - HeaderSize); - - return size; -} - - -void ExtSerializationImpl::release() -{ - NVBLAST_DELETE(this, ExtSerializationImpl); -} - - -//////// ExtSerializationImpl::AllocBufferProvider member functions //////// - -void* ExtSerializationImpl::AllocBufferProvider::requestBuffer(size_t size) -{ - return NVBLAST_ALLOC(size); -} - -} // namespace Blast -} // namespace Nv - - -Nv::Blast::ExtSerialization* NvBlastExtSerializationCreate() -{ - Nv::Blast::ExtSerializationImpl* serialization = NVBLAST_NEW(Nv::Blast::ExtSerializationImpl) (); - - // Automatically load LL serializers - NvBlastExtLlSerializerLoadSet(*serialization); - - return serialization; -} +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "NvBlastExtSerialization.h" +#include "NvBlastExtLlSerialization.h" +#include "NvBlastHashMap.h" +#include "NvBlastExtSerializationInternal.h" + + +namespace Nv +{ +namespace Blast +{ + +class ExtSerializationImpl : public ExtSerializationInternal +{ +public: + // Default buffer provider + class AllocBufferProvider : public ExtSerialization::BufferProvider + { + public: + virtual void* requestBuffer(size_t size) override; + }; + + + ExtSerializationImpl(); + ~ExtSerializationImpl(); + + // ExtSerialization interface begin + virtual bool setSerializationEncoding(uint32_t encodingID) override; + virtual uint32_t getSerializationEncoding() const override; + + virtual void setBufferProvider(BufferProvider* bufferProvider) override; + + virtual bool peekHeader(uint32_t* objectTypeID, uint32_t* encodingID, uint64_t* dataSize, const void* buffer, uint64_t bufferSize) override; + virtual const void* skipObject(uint64_t& bufferSize, const void* buffer) override; + + virtual void* deserializeFromBuffer(const void* buffer, uint64_t size, uint32_t* objectTypeIDPtr = nullptr) override; + virtual uint64_t serializeIntoBuffer(void*& buffer, const void* object, uint32_t objectTypeID) override; + + virtual void release() override; + // ExtSerialization interface end + + // ExtSerializationInternal interface begin + virtual bool registerSerializer(ExtSerializer& serializer) override; + virtual bool unregisterSerializer(ExtSerializer& serializer) override; + + virtual ExtSerializer* findSerializer(uint32_t objectTypeID, uint32_t encodingID) override; + // ExtSerializationInternal interface end + +private: + char* writeHeaderIntoBuffer(char* buffer, uint64_t bufferSize, uint32_t objectTypeID, uint32_t encodingID, uint64_t dataSize) const; + const char* readHeaderFromBuffer(uint32_t* objectTypeID, uint32_t* encodingID, uint64_t* dataSize, const char* buffer, uint64_t bufferSize) const; + + //// Static data //// + static const char* s_identifier; + static const char* s_version; + static AllocBufferProvider s_defaultBufferProvider; + + //// Member data //// + HashMap::type m_serializers; + uint32_t m_serializationEncoding; + BufferProvider* m_bufferProvider; +}; + + +//////// ExtSerializationImpl static member variables //////// + +/** Module identifying header. This should never change. */ +const char* ExtSerializationImpl::s_identifier = "NVidia(r) GameWorks Blast(tm) v."; + +const char* ExtSerializationImpl::s_version = "1"; + +ExtSerializationImpl::AllocBufferProvider ExtSerializationImpl::s_defaultBufferProvider; + + +//////// Local utility functions //////// + +static NV_INLINE uint64_t generateKey(uint32_t objectTypeID, uint32_t encodingID) +{ + return static_cast(encodingID) << 32 | static_cast(objectTypeID); +} + + +static NV_INLINE uint64_t generateKey(const ExtSerializer& serializer) +{ + return generateKey(serializer.getObjectTypeID(), serializer.getEncodingID()); +} + + +static NV_INLINE void writeIDToBuffer(char* buffer, uint32_t id) +{ + for (int i = 0; i < 4; ++i, id >>= 8) + { + *buffer++ = static_cast(id & 0xFF); + } +} + + +static NV_INLINE uint32_t readIDFromBuffer(const char* buffer) +{ + return NVBLAST_FOURCC(buffer[0], buffer[1], buffer[2], buffer[3]); +} + + +static NV_INLINE void writeU64InHexToBuffer(char* buffer, uint64_t val) +{ + for (char* curr = buffer + 16; curr-- > buffer; val >>= 4) + { + *curr = "0123456789ABCDEF"[val & 0xF]; + } +} + + +static NV_INLINE uint64_t readU64InHexFromBuffer(const char* buffer) +{ + uint64_t val = 0; + for (const char* curr = buffer; curr < buffer + 16; ++curr) + { + const char c = *curr; + const char msn = c >> 4; + const char mask = ((88 >> msn) & 1) - 1; + const unsigned char digit = "\x0\x1\x2\x3\x4\x5\x6\x7\x8\x9\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xA\xB\xC\xD\xE\xF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"[((msn - 3) & 1) << 4 | (c & 0xF)] | mask; + if (digit == 0xFF) + { + return 0; // Not a hexidecimal digit + } + val = val << 4 | digit; + } + return val; +} + + +//////// ExtSerialization member functions //////// + +ExtSerializationImpl::ExtSerializationImpl() : m_serializationEncoding(EncodingID::CapnProtoBinary), m_bufferProvider(&s_defaultBufferProvider) +{ +} + + +ExtSerializationImpl::~ExtSerializationImpl() +{ + // Release and remove all registered serializers + auto it = m_serializers.getEraseIterator(); + while (auto entry = it.eraseCurrentGetNext(true)) + { + entry->second->release(); + } +} + + +char* ExtSerializationImpl::writeHeaderIntoBuffer(char* buffer, uint64_t bufferSize, uint32_t objectTypeID, uint32_t encodingID, uint64_t dataSize) const +{ + if (bufferSize < HeaderSize) + { + return nullptr; + } + + char* stop = buffer + HeaderSize; + + size_t versionLen = strlen(s_version); + if (versionLen > 63) + { + versionLen = 63; + } + + memset(buffer, ' ', HeaderSize); + memcpy(buffer, s_identifier, 32); buffer += 32; + memcpy(buffer, s_version, versionLen); buffer += 64; + writeIDToBuffer(buffer, objectTypeID); buffer += 5; + writeIDToBuffer(buffer, encodingID); buffer += 5; + writeU64InHexToBuffer(buffer, dataSize); buffer += 16; + *(stop - 1) = '\n'; + + return stop; +} + + +const char* ExtSerializationImpl::readHeaderFromBuffer(uint32_t* objectTypeID, uint32_t* encodingID, uint64_t* dataSize, const char* buffer, uint64_t bufferSize) const +{ + if (bufferSize < HeaderSize) + { + NVBLAST_LOG_ERROR("ExtSerializationImpl::readHeaderFromBuffer: header terminator not found."); + return nullptr; + } + + const char* stop = buffer + HeaderSize; + + if (memcmp(buffer, s_identifier, 32)) + { + NVBLAST_LOG_ERROR("ExtSerializationImpl::readHeaderFromBuffer: file identifier does not match expected value."); + return nullptr; + } + buffer += 32; + + const char* s = strchr(buffer, ' '); + if (s == nullptr) + { + NVBLAST_LOG_ERROR("ExtSerializationImpl::readHeaderFromBuffer: file format error reading serializer library version."); + } + if (memcmp(buffer, s_version, s - buffer)) + { + NVBLAST_LOG_ERROR("ExtSerializationImpl::readHeaderFromBuffer: file version does not match serializer library version."); + return nullptr; + } + buffer += 64; + + if (objectTypeID != nullptr) + { + *objectTypeID = readIDFromBuffer(buffer); + } + buffer += 5; + + if (encodingID != nullptr) + { + *encodingID = readIDFromBuffer(buffer); + } + buffer += 5; + + if (dataSize != nullptr) + { + *dataSize = readU64InHexFromBuffer(buffer); + } + buffer += 16; + + return stop; +} + + +bool ExtSerializationImpl::registerSerializer(ExtSerializer& serializer) +{ + return m_serializers.insert(generateKey(serializer), &serializer); +} + + +bool ExtSerializationImpl::unregisterSerializer(ExtSerializer& serializer) +{ + const uint64_t key = generateKey(serializer); + const auto entry = m_serializers.find(key); + if (entry == nullptr) + { + return false; + } + entry->second->release(); + return m_serializers.erase(key); +} + + +ExtSerializer* ExtSerializationImpl::findSerializer(uint32_t objectTypeID, uint32_t encodingID) +{ + auto entry = m_serializers.find(generateKey(objectTypeID, encodingID)); + return entry != nullptr ? entry->second : nullptr; +} + + +bool ExtSerializationImpl::setSerializationEncoding(uint32_t encodingID) +{ + m_serializationEncoding = encodingID; + + return true; +} + + +uint32_t ExtSerializationImpl::getSerializationEncoding() const +{ + return m_serializationEncoding; +} + + +void ExtSerializationImpl::setBufferProvider(BufferProvider* bufferProvider) +{ + m_bufferProvider = bufferProvider != nullptr ? bufferProvider : &s_defaultBufferProvider; +} + + +bool ExtSerializationImpl::peekHeader(uint32_t* objectTypeID, uint32_t* encodingID, uint64_t* dataSize, const void* buffer, uint64_t bufferSize) +{ + return nullptr != readHeaderFromBuffer(objectTypeID, encodingID, dataSize, reinterpret_cast(buffer), bufferSize); +} + + +const void* ExtSerializationImpl::skipObject(uint64_t& bufferSize, const void* buffer) +{ + uint64_t dataSize; + const char* next = readHeaderFromBuffer(nullptr, nullptr, &dataSize, static_cast(buffer), bufferSize); + if (next == nullptr) + { + return nullptr; + } + next += dataSize; + const uint64_t skipSize = next - static_cast(buffer); + NVBLAST_CHECK_ERROR(skipSize <= bufferSize, "Object size in buffer is too large for given buffer size.", return nullptr); + bufferSize -= skipSize; + return next; +} + + +void* ExtSerializationImpl::deserializeFromBuffer(const void* buffer, uint64_t bufferSize, uint32_t* objectTypeIDPtr) +{ + uint32_t objectTypeID; + uint32_t encodingID; + uint64_t dataSize; + void* result = nullptr; + + buffer = readHeaderFromBuffer(&objectTypeID, &encodingID, &dataSize, reinterpret_cast(buffer), bufferSize); + if (buffer != nullptr) + { + auto entry = m_serializers.find(generateKey(objectTypeID, encodingID)); + if (entry != nullptr && entry->second != nullptr) + { + result = entry->second->deserializeFromBuffer(buffer, dataSize); + } + } + + if (objectTypeIDPtr != nullptr) + { + *objectTypeIDPtr = result != nullptr ? objectTypeID : 0; + } + + return result; +} + + +uint64_t ExtSerializationImpl::serializeIntoBuffer(void*& buffer, const void* object, uint32_t objectTypeID) +{ + if (!m_serializationEncoding) + { + NVBLAST_LOG_ERROR("ExtSerializationImpl::serializeIntoBuffer: no serialization encoding has been set."); + return false; // No encoding available + } + + auto entry = m_serializers.find(generateKey(objectTypeID, m_serializationEncoding)); + if (entry == nullptr || entry->second == nullptr) + { + return false; + } + + const uint64_t size = entry->second->serializeIntoBuffer(buffer, *m_bufferProvider, object, HeaderSize); + if (size < HeaderSize) + { + NVBLAST_LOG_ERROR("ExtSerializationImpl::serializeIntoBuffer: failed to write data to buffer."); + return 0; + } + + writeHeaderIntoBuffer(reinterpret_cast(buffer), HeaderSize, objectTypeID, m_serializationEncoding, size - HeaderSize); + + return size; +} + + +void ExtSerializationImpl::release() +{ + NVBLAST_DELETE(this, ExtSerializationImpl); +} + + +//////// ExtSerializationImpl::AllocBufferProvider member functions //////// + +void* ExtSerializationImpl::AllocBufferProvider::requestBuffer(size_t size) +{ + return NVBLAST_ALLOC(size); +} + +} // namespace Blast +} // namespace Nv + + +Nv::Blast::ExtSerialization* NvBlastExtSerializationCreate() +{ + Nv::Blast::ExtSerializationImpl* serialization = NVBLAST_NEW(Nv::Blast::ExtSerializationImpl) (); + + // Automatically load LL serializers + NvBlastExtLlSerializerLoadSet(*serialization); + + return serialization; +} diff --git a/sdk/extensions/serialization/source/NvBlastExtSerializationCAPN.h b/sdk/extensions/serialization/source/NvBlastExtSerializationCAPN.h old mode 100644 new mode 100755 index 9d486f6..2125a7c --- a/sdk/extensions/serialization/source/NvBlastExtSerializationCAPN.h +++ b/sdk/extensions/serialization/source/NvBlastExtSerializationCAPN.h @@ -1,188 +1,188 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once - -#include "capnp/serialize.h" -#include "NvBlastExtInputStream.h" -#include "NvBlastExtOutputStream.h" -#include "NvBlastArray.h" -#include "NvBlastExtSerialization.h" - - -namespace Nv -{ -namespace Blast -{ - -template -class ExtSerializationCAPN -{ -public: - static TObject* deserializeFromBuffer(const unsigned char* input, uint64_t size); - static TObject* deserializeFromStream(std::istream& inputStream); - - static uint64_t serializationBufferSize(const TObject* object); - - static bool serializeIntoBuffer(const TObject* object, unsigned char* buffer, uint64_t maxSize, uint64_t& usedSize); - static bool serializeIntoBuffer(const TObject *object, unsigned char*& buffer, uint64_t& size, ExtSerialization::BufferProvider* bufferProvider = nullptr, uint64_t offset = 0); - static bool serializeIntoStream(const TObject* object, std::ostream& outputStream); - -private: - // Specialized - static bool serializeIntoBuilder(TSerializationBuilder& objectBuilder, const TObject* object); - static bool serializeIntoMessage(capnp::MallocMessageBuilder& message, const TObject* object); - static TObject* deserializeFromStreamReader(capnp::InputStreamMessageReader& message); -}; - - -template -TObject* ExtSerializationCAPN::deserializeFromBuffer(const unsigned char* input, uint64_t size) -{ - kj::ArrayPtr source(input, size); - - kj::ArrayInputStream inputStream(source); - - Nv::Blast::Array::type scratch(static_cast(size)); - kj::ArrayPtr scratchArray((capnp::word*) scratch.begin(), size); - - capnp::InputStreamMessageReader message(inputStream, capnp::ReaderOptions(), scratchArray); - - return deserializeFromStreamReader(message); -} - - -template -TObject* ExtSerializationCAPN::deserializeFromStream(std::istream& inputStream) -{ - ExtInputStream readStream(inputStream); - - capnp::InputStreamMessageReader message(readStream); - - return deserializeFromStreamReader(message); -} - - -template -uint64_t ExtSerializationCAPN::serializationBufferSize(const TObject* object) -{ - capnp::MallocMessageBuilder message; - - bool result = serializeIntoMessage(message, object); - - if (result == false) - { - return 0; - } - - return computeSerializedSizeInWords(message) * sizeof(uint64_t); -} - - -template -bool ExtSerializationCAPN::serializeIntoBuffer(const TObject* object, unsigned char* buffer, uint64_t maxSize, uint64_t& usedSize) -{ - capnp::MallocMessageBuilder message; - - bool result = serializeIntoMessage(message, object); - - if (result == false) - { - usedSize = 0; - return false; - } - - uint64_t messageSize = computeSerializedSizeInWords(message) * sizeof(uint64_t); - - if (maxSize < messageSize) - { - NVBLAST_LOG_ERROR("When attempting to serialize into an existing buffer, the provided buffer was too small."); - usedSize = 0; - return false; - } - - kj::ArrayPtr outputBuffer(buffer, maxSize); - kj::ArrayOutputStream outputStream(outputBuffer); - - capnp::writeMessage(outputStream, message); - - usedSize = messageSize; - return true; -} - - -template -bool ExtSerializationCAPN::serializeIntoBuffer(const TObject *object, unsigned char*& buffer, uint64_t& size, ExtSerialization::BufferProvider* bufferProvider, uint64_t offset) -{ - capnp::MallocMessageBuilder message; - - bool result = serializeIntoMessage(message, object); - - if (result == false) - { - buffer = nullptr; - size = 0; - return false; - } - - const uint64_t blockSize = computeSerializedSizeInWords(message) * sizeof(uint64_t); - - size = blockSize + offset; - - buffer = static_cast(bufferProvider != nullptr ? bufferProvider->requestBuffer(size) : NVBLAST_ALLOC(size)); - - kj::ArrayPtr outputBuffer(buffer + offset, blockSize); - kj::ArrayOutputStream outputStream(outputBuffer); - - capnp::writeMessage(outputStream, message); - - return true; -} - - -template -bool ExtSerializationCAPN::serializeIntoStream(const TObject* object, std::ostream& outputStream) -{ - capnp::MallocMessageBuilder message; - - bool result = serializeIntoMessage(message, object); - - if (result == false) - { - return false; - } - - ExtOutputStream blastOutputStream(outputStream); - - writeMessage(blastOutputStream, message); - - return true; -} - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once + +#include "capnp/serialize.h" +#include "NvBlastExtInputStream.h" +#include "NvBlastExtOutputStream.h" +#include "NvBlastArray.h" +#include "NvBlastExtSerialization.h" + + +namespace Nv +{ +namespace Blast +{ + +template +class ExtSerializationCAPN +{ +public: + static TObject* deserializeFromBuffer(const unsigned char* input, uint64_t size); + static TObject* deserializeFromStream(std::istream& inputStream); + + static uint64_t serializationBufferSize(const TObject* object); + + static bool serializeIntoBuffer(const TObject* object, unsigned char* buffer, uint64_t maxSize, uint64_t& usedSize); + static bool serializeIntoBuffer(const TObject *object, unsigned char*& buffer, uint64_t& size, ExtSerialization::BufferProvider* bufferProvider = nullptr, uint64_t offset = 0); + static bool serializeIntoStream(const TObject* object, std::ostream& outputStream); + +private: + // Specialized + static bool serializeIntoBuilder(TSerializationBuilder& objectBuilder, const TObject* object); + static bool serializeIntoMessage(capnp::MallocMessageBuilder& message, const TObject* object); + static TObject* deserializeFromStreamReader(capnp::InputStreamMessageReader& message); +}; + + +template +TObject* ExtSerializationCAPN::deserializeFromBuffer(const unsigned char* input, uint64_t size) +{ + kj::ArrayPtr source(input, size); + + kj::ArrayInputStream inputStream(source); + + Nv::Blast::Array::type scratch(static_cast(size)); + kj::ArrayPtr scratchArray((capnp::word*) scratch.begin(), size); + + capnp::InputStreamMessageReader message(inputStream, capnp::ReaderOptions(), scratchArray); + + return deserializeFromStreamReader(message); +} + + +template +TObject* ExtSerializationCAPN::deserializeFromStream(std::istream& inputStream) +{ + ExtInputStream readStream(inputStream); + + capnp::InputStreamMessageReader message(readStream); + + return deserializeFromStreamReader(message); +} + + +template +uint64_t ExtSerializationCAPN::serializationBufferSize(const TObject* object) +{ + capnp::MallocMessageBuilder message; + + bool result = serializeIntoMessage(message, object); + + if (result == false) + { + return 0; + } + + return computeSerializedSizeInWords(message) * sizeof(uint64_t); +} + + +template +bool ExtSerializationCAPN::serializeIntoBuffer(const TObject* object, unsigned char* buffer, uint64_t maxSize, uint64_t& usedSize) +{ + capnp::MallocMessageBuilder message; + + bool result = serializeIntoMessage(message, object); + + if (result == false) + { + usedSize = 0; + return false; + } + + uint64_t messageSize = computeSerializedSizeInWords(message) * sizeof(uint64_t); + + if (maxSize < messageSize) + { + NVBLAST_LOG_ERROR("When attempting to serialize into an existing buffer, the provided buffer was too small."); + usedSize = 0; + return false; + } + + kj::ArrayPtr outputBuffer(buffer, maxSize); + kj::ArrayOutputStream outputStream(outputBuffer); + + capnp::writeMessage(outputStream, message); + + usedSize = messageSize; + return true; +} + + +template +bool ExtSerializationCAPN::serializeIntoBuffer(const TObject *object, unsigned char*& buffer, uint64_t& size, ExtSerialization::BufferProvider* bufferProvider, uint64_t offset) +{ + capnp::MallocMessageBuilder message; + + bool result = serializeIntoMessage(message, object); + + if (result == false) + { + buffer = nullptr; + size = 0; + return false; + } + + const uint64_t blockSize = computeSerializedSizeInWords(message) * sizeof(uint64_t); + + size = blockSize + offset; + + buffer = static_cast(bufferProvider != nullptr ? bufferProvider->requestBuffer(size) : NVBLAST_ALLOC(size)); + + kj::ArrayPtr outputBuffer(buffer + offset, blockSize); + kj::ArrayOutputStream outputStream(outputBuffer); + + capnp::writeMessage(outputStream, message); + + return true; +} + + +template +bool ExtSerializationCAPN::serializeIntoStream(const TObject* object, std::ostream& outputStream) +{ + capnp::MallocMessageBuilder message; + + bool result = serializeIntoMessage(message, object); + + if (result == false) + { + return false; + } + + ExtOutputStream blastOutputStream(outputStream); + + writeMessage(blastOutputStream, message); + + return true; +} + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/NvBlastExtSerializationInternal.h b/sdk/extensions/serialization/source/NvBlastExtSerializationInternal.h old mode 100644 new mode 100755 index ae10de4..1b765f6 --- a/sdk/extensions/serialization/source/NvBlastExtSerializationInternal.h +++ b/sdk/extensions/serialization/source/NvBlastExtSerializationInternal.h @@ -1,291 +1,291 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once - -#include "NvBlastExtSerialization.h" - -#include - -#define ExtSerializerBoilerplate(_name, _description, _objectTypeID, _encodingID) \ -virtual const char* getName() const override { return _name; } \ -virtual const char* getDescription() const override { return _description; } \ -virtual uint32_t getObjectTypeID() const override { return _objectTypeID; } \ -virtual uint32_t getEncodingID() const override { return _encodingID; } - - -#define ExtSerializerReadOnly(_name) \ -virtual bool isReadOnly() const override { return true; } \ -virtual uint64_t serializeIntoBuffer \ -( \ - void*& buffer, \ - ExtSerialization::BufferProvider& bufferProvider, \ - const void* object, \ - uint64_t offset = 0 \ -) override \ -{ \ - NVBLAST_LOG_WARNING(#_name "::serializeIntoBuffer: ExtPxAsset_RAW serializer is read-only."); \ - NV_UNUSED(buffer); \ - NV_UNUSED(bufferProvider); \ - NV_UNUSED(object); \ - NV_UNUSED(offset); \ - return 0; \ -} - - -#define ExtSerializerDefaultFactoryAndRelease(_classname) \ -static ExtSerializer* create() \ -{ \ - return NVBLAST_NEW(_classname) (); \ -} \ -virtual void release() override \ -{ \ - NVBLAST_DELETE(this, _classname); \ -} - - -namespace Nv -{ -namespace Blast -{ - -/** -Serializer internal interface -*/ -class ExtSerializer -{ -public: - virtual ~ExtSerializer() {} - - /** - return the name of this serializer. - */ - virtual const char* getName() const = 0; - - /** - return a description of this serializer. - */ - virtual const char* getDescription() const = 0; - - /** - return an identifier for the type of object handled. - */ - virtual uint32_t getObjectTypeID() const = 0; - - /** - return an identifier for serialization format. - */ - virtual uint32_t getEncodingID() const = 0; - - /** - Whether or not this serializer supports writing. Legacy formats, for example, may not. - - \return true iff this serialization does not support writing. - */ - virtual bool isReadOnly() const { return false; } - - /** - Deserialize from a buffer into a newly allocated object. - - \param[in] buffer Pointer to the buffer to read. - \param[in] size Size of the buffer to read. - \return object pointer; returns null if failed to deserialize. - */ - virtual void* deserializeFromBuffer(const void* buffer, uint64_t size) = 0; - - /** - Serialize into a buffer. Allocates the buffer internally using the ExtSerialization::BufferProvider callack interface. - - \param[out] buffer Pointer to the buffer created. - \param[in] bufferProvider The buffer provider callback interface to use. - \param[in] object Object pointer. - - \return the number of bytes serialized into the buffer (zero if unsuccessful). - */ - virtual uint64_t serializeIntoBuffer(void*& buffer, ExtSerialization::BufferProvider& bufferProvider, const void* object, uint64_t offset = 0) = 0; - - /** - Release the serializer and free associated memory. - */ - virtual void release() = 0; -}; - - -/** -Internal serialization manager interface -*/ -class ExtSerializationInternal : public ExtSerialization -{ -public: - /** - Internal interfaces to register and unregister a serializer, used by modules to automatically - register all of their serializers with a serialization manager. - */ - virtual bool registerSerializer(ExtSerializer& serializer) = 0; - virtual bool unregisterSerializer(ExtSerializer& serializer) = 0; - - /** - Find a registered serializer for the given object type and encoding. - - \param[in] objectTypeID ID for the requested object type. - \param[in] encodingID ID for the requested encoding (see EncodingID). - - \return a registered serializer if found, NULL otherwise. - */ - virtual ExtSerializer* findSerializer(uint32_t objectTypeID, uint32_t encodingID) = 0; - - //// Enums //// - enum { HeaderSize = 128 }; -}; - - -template -size_t ExtSerializationLoadSet(Nv::Blast::ExtSerializationInternal& serialization, Factory(&factories)[N]) -{ - size_t count = 0; - - for (auto f : factories) - { - Nv::Blast::ExtSerializer* serializer = f(); - if (serializer != nullptr) - { - if (serialization.registerSerializer(*serializer)) - { - ++count; - } - else - { - NVBLAST_LOG_ERROR("Nv::Blast::ExtSerializationLoadSet: failed to register serailizer:"); - NVBLAST_LOG_ERROR(serializer->getName()); - serializer->release(); - } - } - else - { - NVBLAST_LOG_ERROR("Nv::Blast::ExtSerializationLoadSet: failed to create serailizer."); - } - } - - return count; -} - - -class ExtIStream -{ -public: - enum Flags - { - LittleEndian = (1 << 0), - Fail = (1 << 1) - }; - - ExtIStream(const void* buffer, size_t size) : m_buf(reinterpret_cast(buffer)), m_flags(0) - { - m_cur = m_buf; - m_end = m_buf + size; - const uint16_t x = LittleEndian; - m_flags = *reinterpret_cast(&x); - } - - bool advance(ptrdiff_t diff) - { - m_cur += diff; - if (m_cur < m_buf) - { - m_cur = m_buf; - m_flags |= Fail; - return false; - } - else - if (m_cur > m_end) - { - m_cur = m_end; - m_flags |= Fail; - return false; - } - return true; - } - - const void* view() - { - return m_cur; - } - - bool read(void* buffer, size_t size) - { - if (!canRead(size)) return false; - std::memcpy(buffer, m_cur, size); - m_cur += size; - return true; - } - - size_t tellg() const { return m_cur - m_buf; } - size_t left() const { return m_end - m_cur; } - - bool eof() const { return m_cur >= m_end; } - bool fail() const { return (m_flags & Fail) != 0; } - -private: - const char* m_buf; - const char* m_cur; - const char* m_end; - uint32_t m_flags; - - bool isLittleEndian() const { return (m_flags & LittleEndian) != 0; } - - bool canRead(size_t size) const { return m_cur + size <= m_end; } - - template - friend ExtIStream& operator >> (ExtIStream& s, T& x); -}; - -template -NV_INLINE ExtIStream& operator >> (ExtIStream& s, T& x) -{ - if (s.canRead(sizeof(T))) - { - if (s.isLittleEndian()) - { - x = *reinterpret_cast(s.m_cur); - s.m_cur += sizeof(T); - } - else - { - char* b = reinterpret_cast(&x) + sizeof(T); - for (size_t n = sizeof(T); n--;) *--b = *s.m_cur++; - } - } - else - { - s.m_flags |= ExtIStream::Fail; - } - return s; -} - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once + +#include "NvBlastExtSerialization.h" + +#include + +#define ExtSerializerBoilerplate(_name, _description, _objectTypeID, _encodingID) \ +virtual const char* getName() const override { return _name; } \ +virtual const char* getDescription() const override { return _description; } \ +virtual uint32_t getObjectTypeID() const override { return _objectTypeID; } \ +virtual uint32_t getEncodingID() const override { return _encodingID; } + + +#define ExtSerializerReadOnly(_name) \ +virtual bool isReadOnly() const override { return true; } \ +virtual uint64_t serializeIntoBuffer \ +( \ + void*& buffer, \ + ExtSerialization::BufferProvider& bufferProvider, \ + const void* object, \ + uint64_t offset = 0 \ +) override \ +{ \ + NVBLAST_LOG_WARNING(#_name "::serializeIntoBuffer: ExtPxAsset_RAW serializer is read-only."); \ + NV_UNUSED(buffer); \ + NV_UNUSED(bufferProvider); \ + NV_UNUSED(object); \ + NV_UNUSED(offset); \ + return 0; \ +} + + +#define ExtSerializerDefaultFactoryAndRelease(_classname) \ +static ExtSerializer* create() \ +{ \ + return NVBLAST_NEW(_classname) (); \ +} \ +virtual void release() override \ +{ \ + NVBLAST_DELETE(this, _classname); \ +} + + +namespace Nv +{ +namespace Blast +{ + +/** +Serializer internal interface +*/ +class ExtSerializer +{ +public: + virtual ~ExtSerializer() {} + + /** + return the name of this serializer. + */ + virtual const char* getName() const = 0; + + /** + return a description of this serializer. + */ + virtual const char* getDescription() const = 0; + + /** + return an identifier for the type of object handled. + */ + virtual uint32_t getObjectTypeID() const = 0; + + /** + return an identifier for serialization format. + */ + virtual uint32_t getEncodingID() const = 0; + + /** + Whether or not this serializer supports writing. Legacy formats, for example, may not. + + \return true iff this serialization does not support writing. + */ + virtual bool isReadOnly() const { return false; } + + /** + Deserialize from a buffer into a newly allocated object. + + \param[in] buffer Pointer to the buffer to read. + \param[in] size Size of the buffer to read. + \return object pointer; returns null if failed to deserialize. + */ + virtual void* deserializeFromBuffer(const void* buffer, uint64_t size) = 0; + + /** + Serialize into a buffer. Allocates the buffer internally using the ExtSerialization::BufferProvider callack interface. + + \param[out] buffer Pointer to the buffer created. + \param[in] bufferProvider The buffer provider callback interface to use. + \param[in] object Object pointer. + + \return the number of bytes serialized into the buffer (zero if unsuccessful). + */ + virtual uint64_t serializeIntoBuffer(void*& buffer, ExtSerialization::BufferProvider& bufferProvider, const void* object, uint64_t offset = 0) = 0; + + /** + Release the serializer and free associated memory. + */ + virtual void release() = 0; +}; + + +/** +Internal serialization manager interface +*/ +class ExtSerializationInternal : public ExtSerialization +{ +public: + /** + Internal interfaces to register and unregister a serializer, used by modules to automatically + register all of their serializers with a serialization manager. + */ + virtual bool registerSerializer(ExtSerializer& serializer) = 0; + virtual bool unregisterSerializer(ExtSerializer& serializer) = 0; + + /** + Find a registered serializer for the given object type and encoding. + + \param[in] objectTypeID ID for the requested object type. + \param[in] encodingID ID for the requested encoding (see EncodingID). + + \return a registered serializer if found, NULL otherwise. + */ + virtual ExtSerializer* findSerializer(uint32_t objectTypeID, uint32_t encodingID) = 0; + + //// Enums //// + enum { HeaderSize = 128 }; +}; + + +template +size_t ExtSerializationLoadSet(Nv::Blast::ExtSerializationInternal& serialization, Factory(&factories)[N]) +{ + size_t count = 0; + + for (auto f : factories) + { + Nv::Blast::ExtSerializer* serializer = f(); + if (serializer != nullptr) + { + if (serialization.registerSerializer(*serializer)) + { + ++count; + } + else + { + NVBLAST_LOG_ERROR("Nv::Blast::ExtSerializationLoadSet: failed to register serailizer:"); + NVBLAST_LOG_ERROR(serializer->getName()); + serializer->release(); + } + } + else + { + NVBLAST_LOG_ERROR("Nv::Blast::ExtSerializationLoadSet: failed to create serailizer."); + } + } + + return count; +} + + +class ExtIStream +{ +public: + enum Flags + { + LittleEndian = (1 << 0), + Fail = (1 << 1) + }; + + ExtIStream(const void* buffer, size_t size) : m_buf(reinterpret_cast(buffer)), m_flags(0) + { + m_cur = m_buf; + m_end = m_buf + size; + const uint16_t x = LittleEndian; + m_flags = *reinterpret_cast(&x); + } + + bool advance(ptrdiff_t diff) + { + m_cur += diff; + if (m_cur < m_buf) + { + m_cur = m_buf; + m_flags |= Fail; + return false; + } + else + if (m_cur > m_end) + { + m_cur = m_end; + m_flags |= Fail; + return false; + } + return true; + } + + const void* view() + { + return m_cur; + } + + bool read(void* buffer, size_t size) + { + if (!canRead(size)) return false; + std::memcpy(buffer, m_cur, size); + m_cur += size; + return true; + } + + size_t tellg() const { return m_cur - m_buf; } + size_t left() const { return m_end - m_cur; } + + bool eof() const { return m_cur >= m_end; } + bool fail() const { return (m_flags & Fail) != 0; } + +private: + const char* m_buf; + const char* m_cur; + const char* m_end; + uint32_t m_flags; + + bool isLittleEndian() const { return (m_flags & LittleEndian) != 0; } + + bool canRead(size_t size) const { return m_cur + size <= m_end; } + + template + friend ExtIStream& operator >> (ExtIStream& s, T& x); +}; + +template +NV_INLINE ExtIStream& operator >> (ExtIStream& s, T& x) +{ + if (s.canRead(sizeof(T))) + { + if (s.isLittleEndian()) + { + x = *reinterpret_cast(s.m_cur); + s.m_cur += sizeof(T); + } + else + { + char* b = reinterpret_cast(&x) + sizeof(T); + for (size_t n = sizeof(T); n--;) *--b = *s.m_cur++; + } + } + else + { + s.m_flags |= ExtIStream::Fail; + } + return s; +} + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/NvBlastExtTkSerialization.capn b/sdk/extensions/serialization/source/NvBlastExtTkSerialization.capn old mode 100644 new mode 100755 index a67539f..f54dd86 --- a/sdk/extensions/serialization/source/NvBlastExtTkSerialization.capn +++ b/sdk/extensions/serialization/source/NvBlastExtTkSerialization.capn @@ -1,55 +1,55 @@ -# 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) 2018 NVIDIA Corporation. All rights reserved. - - -@0xaffe4498f275ee58; - -using Cxx = import "/capnp/c++.capnp"; - -using LL = import "NvBlastExtLlSerialization.capn"; - -$Cxx.namespace("Nv::Blast::Serialization"); - -struct TkAsset -{ - assetLL @0 :LL.Asset; - - jointDescs @1 :List(TkAssetJointDesc); -} - -struct TkAssetJointDesc -{ - nodeIndices @0 :List(UInt32); - attachPositions @1 :List(PxVec3); -} - -struct PxVec3 -{ - x @0 :Float32; - y @1 :Float32; - z @2 :Float32; -} +# 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) 2018 NVIDIA Corporation. All rights reserved. + + +@0xaffe4498f275ee58; + +using Cxx = import "/capnp/c++.capnp"; + +using LL = import "NvBlastExtLlSerialization.capn"; + +$Cxx.namespace("Nv::Blast::Serialization"); + +struct TkAsset +{ + assetLL @0 :LL.Asset; + + jointDescs @1 :List(TkAssetJointDesc); +} + +struct TkAssetJointDesc +{ + nodeIndices @0 :List(UInt32); + attachPositions @1 :List(PxVec3); +} + +struct PxVec3 +{ + x @0 :Float32; + y @1 :Float32; + z @2 :Float32; +} diff --git a/sdk/extensions/serialization/source/NvBlastExtTkSerialization.cpp b/sdk/extensions/serialization/source/NvBlastExtTkSerialization.cpp old mode 100644 new mode 100755 index a86f015..cab99be --- a/sdk/extensions/serialization/source/NvBlastExtTkSerialization.cpp +++ b/sdk/extensions/serialization/source/NvBlastExtTkSerialization.cpp @@ -1,105 +1,105 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "NvBlastExtSerializationInternal.h" -#include "NvBlastExtTkSerialization.h" -#include "NvBlastExtTkSerializerCAPN.h" -#include "NvBlastExtTkSerializerRAW.h" - - -namespace Nv -{ -namespace Blast -{ - -TkFramework* sExtTkSerializerFramework = nullptr; - - -class ExtTkSerializerAsset_CPNB : public ExtSerializer -{ -public: - ExtSerializerBoilerplate("TkAsset_CPNB", "Blast high-level asset (Nv::Blast::TkAsset) serialization using Cap'n Proto binary format.", TkObjectTypeID::Asset, ExtSerialization::EncodingID::CapnProtoBinary); - ExtSerializerDefaultFactoryAndRelease(ExtTkSerializerAsset_CPNB); - - virtual void* deserializeFromBuffer(const void* buffer, uint64_t size) override - { - return ExtSerializationCAPN::deserializeFromBuffer(reinterpret_cast(buffer), size); - } - - virtual uint64_t serializeIntoBuffer(void*& buffer, ExtSerialization::BufferProvider& bufferProvider, const void* object, uint64_t offset = 0) override - { - uint64_t usedSize; - if (!ExtSerializationCAPN::serializeIntoBuffer(reinterpret_cast(object), - reinterpret_cast(buffer), usedSize, &bufferProvider, offset)) - { - return 0; - } - return usedSize; - } -}; - - -class ExTkSerializerAsset_RAW : public ExtSerializer -{ -public: - ExtSerializerBoilerplate("TkAsset_RAW", "Blast high-level asset (Nv::Blast::TkAsset) serialization using raw memory format.", TkObjectTypeID::Asset, ExtSerialization::EncodingID::RawBinary); - ExtSerializerDefaultFactoryAndRelease(ExTkSerializerAsset_RAW); - ExtSerializerReadOnly(ExTkSerializerAsset_RAW); - - virtual void* deserializeFromBuffer(const void* buffer, uint64_t size) override - { - ExtIStream stream(buffer, size); - return deserializeTkAsset(stream, *sExtTkSerializerFramework); - } -}; - -} // namespace Blast -} // namespace Nv - - -/////////////////////////////////////// - - -size_t NvBlastExtTkSerializerLoadSet(Nv::Blast::TkFramework& framework, Nv::Blast::ExtSerialization& serialization) -{ - Nv::Blast::sExtTkSerializerFramework = &framework; - - Nv::Blast::ExtSerializer* (*factories[])() = - { - Nv::Blast::ExtTkSerializerAsset_CPNB::create, - Nv::Blast::ExTkSerializerAsset_RAW::create - }; - - return Nv::Blast::ExtSerializationLoadSet(static_cast(serialization), factories); -} - - -uint64_t NvBlastExtSerializationSerializeTkAssetIntoBuffer(void*& buffer, Nv::Blast::ExtSerialization& serialization, const Nv::Blast::TkAsset* asset) -{ - return serialization.serializeIntoBuffer(buffer, asset, Nv::Blast::TkObjectTypeID::Asset); -} +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "NvBlastExtSerializationInternal.h" +#include "NvBlastExtTkSerialization.h" +#include "NvBlastExtTkSerializerCAPN.h" +#include "NvBlastExtTkSerializerRAW.h" + + +namespace Nv +{ +namespace Blast +{ + +TkFramework* sExtTkSerializerFramework = nullptr; + + +class ExtTkSerializerAsset_CPNB : public ExtSerializer +{ +public: + ExtSerializerBoilerplate("TkAsset_CPNB", "Blast high-level asset (Nv::Blast::TkAsset) serialization using Cap'n Proto binary format.", TkObjectTypeID::Asset, ExtSerialization::EncodingID::CapnProtoBinary); + ExtSerializerDefaultFactoryAndRelease(ExtTkSerializerAsset_CPNB); + + virtual void* deserializeFromBuffer(const void* buffer, uint64_t size) override + { + return ExtSerializationCAPN::deserializeFromBuffer(reinterpret_cast(buffer), size); + } + + virtual uint64_t serializeIntoBuffer(void*& buffer, ExtSerialization::BufferProvider& bufferProvider, const void* object, uint64_t offset = 0) override + { + uint64_t usedSize; + if (!ExtSerializationCAPN::serializeIntoBuffer(reinterpret_cast(object), + reinterpret_cast(buffer), usedSize, &bufferProvider, offset)) + { + return 0; + } + return usedSize; + } +}; + + +class ExTkSerializerAsset_RAW : public ExtSerializer +{ +public: + ExtSerializerBoilerplate("TkAsset_RAW", "Blast high-level asset (Nv::Blast::TkAsset) serialization using raw memory format.", TkObjectTypeID::Asset, ExtSerialization::EncodingID::RawBinary); + ExtSerializerDefaultFactoryAndRelease(ExTkSerializerAsset_RAW); + ExtSerializerReadOnly(ExTkSerializerAsset_RAW); + + virtual void* deserializeFromBuffer(const void* buffer, uint64_t size) override + { + ExtIStream stream(buffer, size); + return deserializeTkAsset(stream, *sExtTkSerializerFramework); + } +}; + +} // namespace Blast +} // namespace Nv + + +/////////////////////////////////////// + + +size_t NvBlastExtTkSerializerLoadSet(Nv::Blast::TkFramework& framework, Nv::Blast::ExtSerialization& serialization) +{ + Nv::Blast::sExtTkSerializerFramework = &framework; + + Nv::Blast::ExtSerializer* (*factories[])() = + { + Nv::Blast::ExtTkSerializerAsset_CPNB::create, + Nv::Blast::ExTkSerializerAsset_RAW::create + }; + + return Nv::Blast::ExtSerializationLoadSet(static_cast(serialization), factories); +} + + +uint64_t NvBlastExtSerializationSerializeTkAssetIntoBuffer(void*& buffer, Nv::Blast::ExtSerialization& serialization, const Nv::Blast::TkAsset* asset) +{ + return serialization.serializeIntoBuffer(buffer, asset, Nv::Blast::TkObjectTypeID::Asset); +} diff --git a/sdk/extensions/serialization/source/NvBlastExtTkSerializerCAPN.h b/sdk/extensions/serialization/source/NvBlastExtTkSerializerCAPN.h old mode 100644 new mode 100755 index 7e2c0b7..513b3e6 --- a/sdk/extensions/serialization/source/NvBlastExtTkSerializerCAPN.h +++ b/sdk/extensions/serialization/source/NvBlastExtTkSerializerCAPN.h @@ -1,70 +1,70 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once - -#include "NvBlastExtSerializationCAPN.h" -#include "NvBlastTkAsset.h" -#include "TkAssetDTO.h" - - -/** -Specializations of ExtSerializationCAPN for BlastTk -*/ - -namespace Nv -{ -namespace Blast -{ - -//// Nv::Blast::TkAsset //// - -template<> -NV_INLINE bool ExtSerializationCAPN::serializeIntoBuilder(Serialization::TkAsset::Builder& assetBuilder, const TkAsset* asset) -{ - return TkAssetDTO::serialize(assetBuilder, asset); -} - -template<> -NV_INLINE TkAsset* ExtSerializationCAPN::deserializeFromStreamReader(capnp::InputStreamMessageReader &message) -{ - Serialization::TkAsset::Reader reader = message.getRoot(); - - return TkAssetDTO::deserialize(reader); -} - -template<> -NV_INLINE bool ExtSerializationCAPN::serializeIntoMessage(capnp::MallocMessageBuilder& message, const TkAsset* asset) -{ - Serialization::TkAsset::Builder assetBuilder = message.initRoot(); - - return serializeIntoBuilder(assetBuilder, asset); -} - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once + +#include "NvBlastExtSerializationCAPN.h" +#include "NvBlastTkAsset.h" +#include "TkAssetDTO.h" + + +/** +Specializations of ExtSerializationCAPN for BlastTk +*/ + +namespace Nv +{ +namespace Blast +{ + +//// Nv::Blast::TkAsset //// + +template<> +NV_INLINE bool ExtSerializationCAPN::serializeIntoBuilder(Serialization::TkAsset::Builder& assetBuilder, const TkAsset* asset) +{ + return TkAssetDTO::serialize(assetBuilder, asset); +} + +template<> +NV_INLINE TkAsset* ExtSerializationCAPN::deserializeFromStreamReader(capnp::InputStreamMessageReader &message) +{ + Serialization::TkAsset::Reader reader = message.getRoot(); + + return TkAssetDTO::deserialize(reader); +} + +template<> +NV_INLINE bool ExtSerializationCAPN::serializeIntoMessage(capnp::MallocMessageBuilder& message, const TkAsset* asset) +{ + Serialization::TkAsset::Builder assetBuilder = message.initRoot(); + + return serializeIntoBuilder(assetBuilder, asset); +} + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/NvBlastExtTkSerializerRAW.cpp b/sdk/extensions/serialization/source/NvBlastExtTkSerializerRAW.cpp old mode 100644 new mode 100755 index 0baef08..7a98f94 --- a/sdk/extensions/serialization/source/NvBlastExtTkSerializerRAW.cpp +++ b/sdk/extensions/serialization/source/NvBlastExtTkSerializerRAW.cpp @@ -1,184 +1,184 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#include "NvBlastExtSerializationInternal.h" -#include "NvBlastTkFramework.h" -#include "NvBlastTkAsset.h" -#include "NvBlast.h" - - -namespace Nv -{ -namespace Blast -{ - -// Legacy IDs -struct ExtTkSerializationLegacyID -{ - enum Enum - { - Framework = NVBLAST_FOURCC('T', 'K', 'F', 'W'), //!< TkFramework identifier token, used in serialization - Asset = NVBLAST_FOURCC('A', 'S', 'S', 'T'), //!< TkAsset identifier token, used in serialization - Family = NVBLAST_FOURCC('A', 'C', 'T', 'F'), //!< TkFamily identifier token, used in serialization - }; -}; - - -// Legacy object format versions -struct ExtTkSerializationLegacyAssetVersion -{ - enum Enum - { - /** Initial version */ - Initial, - - // New formats must come before Count. They should be given descriptive names with more information in comments. - - /** The number of serialized formats. */ - Count, - - /** The current version. This should always be Count-1 */ - Current = Count - 1 - }; -}; - -struct ExtTkSerializationLegacyFamilyVersion -{ - enum Enum - { - /** Initial version */ - Initial, - - // New formats must come before Count. They should be given descriptive names with more information in comments. - - /** The number of serialized formats. */ - Count, - - /** The current version. This should always be Count-1 */ - Current = Count - 1 - }; -}; - - -static bool deserializeTkObjectHeader(uint32_t& legacyTypeID, uint32_t& legacyVersion, NvBlastID& objID, uint64_t& userIntData, ExtIStream& stream) -{ - // Read framework ID - uint32_t fwkID; - stream >> fwkID; - if (fwkID != ExtTkSerializationLegacyID::Framework) - { - NVBLAST_LOG_ERROR("deserializeTkObjectHeader: stream does not contain a BlastTk legacy object."); - return false; - } - - // Read object class ID - stream >> legacyTypeID; - - // Read object class version and ensure it's current - stream >> legacyVersion; - - // Object ID - stream.read(objID.data, sizeof(NvBlastID)); - - // Serializable user data - uint32_t lsd, msd; - stream >> lsd >> msd; - userIntData = static_cast(msd) << 32 | static_cast(lsd); - - return !stream.fail(); -} - - -TkAsset* deserializeTkAsset(ExtIStream& stream, TkFramework& framework) -{ - // Deserializer header - uint32_t legacyTypeID; - uint32_t legacyVersion; - NvBlastID objID; - uint64_t userIntData; - if (!deserializeTkObjectHeader(legacyTypeID, legacyVersion, objID, userIntData, stream)) - { - return nullptr; - } - - if (legacyTypeID != ExtTkSerializationLegacyID::Asset) - { - NVBLAST_LOG_ERROR("deserializeTkAsset: stream does not contain a BlastTk legacy asset."); - return nullptr; - } - - if (legacyVersion > ExtTkSerializationLegacyAssetVersion::Current) - { - NVBLAST_LOG_ERROR("deserializeTkAsset: stream contains a BlastTk legacy asset which is in an unknown version."); - return nullptr; - } - - // LL asset - uint32_t assetSize; - stream >> assetSize; - NvBlastAsset* llAsset = static_cast(NVBLAST_ALLOC_NAMED(assetSize, "deserializeTkAsset")); - stream.read(reinterpret_cast(llAsset), assetSize); - - // Joint descs - uint32_t jointDescCount; - stream >> jointDescCount; - std::vector jointDescs(jointDescCount); - for (uint32_t i = 0; i < jointDescs.size(); ++i) - { - TkAssetJointDesc& jointDesc = jointDescs[i]; - stream >> jointDesc.nodeIndices[0]; - stream >> jointDesc.nodeIndices[1]; - stream >> jointDesc.attachPositions[0].x; - stream >> jointDesc.attachPositions[0].y; - stream >> jointDesc.attachPositions[0].z; - stream >> jointDesc.attachPositions[1].x; - stream >> jointDesc.attachPositions[1].y; - stream >> jointDesc.attachPositions[1].z; - } - - if (stream.fail()) - { - NVBLAST_FREE(llAsset); - return nullptr; - } - - TkAsset* asset = framework.createAsset(llAsset, jointDescs.data(), (uint32_t)jointDescs.size(), true); - - NvBlastID zeroID; - memset(zeroID.data, 0, sizeof(zeroID)); - if (!memcmp(zeroID.data, objID.data, sizeof(NvBlastID))) - { - asset->setID(objID); - } - asset->userIntData = userIntData; - - return asset; -} - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#include "NvBlastExtSerializationInternal.h" +#include "NvBlastTkFramework.h" +#include "NvBlastTkAsset.h" +#include "NvBlast.h" + + +namespace Nv +{ +namespace Blast +{ + +// Legacy IDs +struct ExtTkSerializationLegacyID +{ + enum Enum + { + Framework = NVBLAST_FOURCC('T', 'K', 'F', 'W'), //!< TkFramework identifier token, used in serialization + Asset = NVBLAST_FOURCC('A', 'S', 'S', 'T'), //!< TkAsset identifier token, used in serialization + Family = NVBLAST_FOURCC('A', 'C', 'T', 'F'), //!< TkFamily identifier token, used in serialization + }; +}; + + +// Legacy object format versions +struct ExtTkSerializationLegacyAssetVersion +{ + enum Enum + { + /** Initial version */ + Initial, + + // New formats must come before Count. They should be given descriptive names with more information in comments. + + /** The number of serialized formats. */ + Count, + + /** The current version. This should always be Count-1 */ + Current = Count - 1 + }; +}; + +struct ExtTkSerializationLegacyFamilyVersion +{ + enum Enum + { + /** Initial version */ + Initial, + + // New formats must come before Count. They should be given descriptive names with more information in comments. + + /** The number of serialized formats. */ + Count, + + /** The current version. This should always be Count-1 */ + Current = Count - 1 + }; +}; + + +static bool deserializeTkObjectHeader(uint32_t& legacyTypeID, uint32_t& legacyVersion, NvBlastID& objID, uint64_t& userIntData, ExtIStream& stream) +{ + // Read framework ID + uint32_t fwkID; + stream >> fwkID; + if (fwkID != ExtTkSerializationLegacyID::Framework) + { + NVBLAST_LOG_ERROR("deserializeTkObjectHeader: stream does not contain a BlastTk legacy object."); + return false; + } + + // Read object class ID + stream >> legacyTypeID; + + // Read object class version and ensure it's current + stream >> legacyVersion; + + // Object ID + stream.read(objID.data, sizeof(NvBlastID)); + + // Serializable user data + uint32_t lsd, msd; + stream >> lsd >> msd; + userIntData = static_cast(msd) << 32 | static_cast(lsd); + + return !stream.fail(); +} + + +TkAsset* deserializeTkAsset(ExtIStream& stream, TkFramework& framework) +{ + // Deserializer header + uint32_t legacyTypeID; + uint32_t legacyVersion; + NvBlastID objID; + uint64_t userIntData; + if (!deserializeTkObjectHeader(legacyTypeID, legacyVersion, objID, userIntData, stream)) + { + return nullptr; + } + + if (legacyTypeID != ExtTkSerializationLegacyID::Asset) + { + NVBLAST_LOG_ERROR("deserializeTkAsset: stream does not contain a BlastTk legacy asset."); + return nullptr; + } + + if (legacyVersion > ExtTkSerializationLegacyAssetVersion::Current) + { + NVBLAST_LOG_ERROR("deserializeTkAsset: stream contains a BlastTk legacy asset which is in an unknown version."); + return nullptr; + } + + // LL asset + uint32_t assetSize; + stream >> assetSize; + NvBlastAsset* llAsset = static_cast(NVBLAST_ALLOC_NAMED(assetSize, "deserializeTkAsset")); + stream.read(reinterpret_cast(llAsset), assetSize); + + // Joint descs + uint32_t jointDescCount; + stream >> jointDescCount; + std::vector jointDescs(jointDescCount); + for (uint32_t i = 0; i < jointDescs.size(); ++i) + { + TkAssetJointDesc& jointDesc = jointDescs[i]; + stream >> jointDesc.nodeIndices[0]; + stream >> jointDesc.nodeIndices[1]; + stream >> jointDesc.attachPositions[0].x; + stream >> jointDesc.attachPositions[0].y; + stream >> jointDesc.attachPositions[0].z; + stream >> jointDesc.attachPositions[1].x; + stream >> jointDesc.attachPositions[1].y; + stream >> jointDesc.attachPositions[1].z; + } + + if (stream.fail()) + { + NVBLAST_FREE(llAsset); + return nullptr; + } + + TkAsset* asset = framework.createAsset(llAsset, jointDescs.data(), (uint32_t)jointDescs.size(), true); + + NvBlastID zeroID; + memset(zeroID.data, 0, sizeof(zeroID)); + if (!memcmp(zeroID.data, objID.data, sizeof(NvBlastID))) + { + asset->setID(objID); + } + asset->userIntData = userIntData; + + return asset; +} + +} // namespace Blast +} // namespace Nv diff --git a/sdk/extensions/serialization/source/NvBlastExtTkSerializerRAW.h b/sdk/extensions/serialization/source/NvBlastExtTkSerializerRAW.h old mode 100644 new mode 100755 index 03b0092..7911c6a --- a/sdk/extensions/serialization/source/NvBlastExtTkSerializerRAW.h +++ b/sdk/extensions/serialization/source/NvBlastExtTkSerializerRAW.h @@ -1,54 +1,54 @@ -// 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) 2018 NVIDIA Corporation. All rights reserved. - - -#pragma once - - -/** -Raw serialization function declarations for BlastTk -*/ - -#include - - -namespace Nv -{ -namespace Blast -{ - -// Forward declarations -class TkAsset; -class TkFramework; -class ExtIStream; - -//// Nv::Blast::TkAsset //// - -TkAsset* deserializeTkAsset(ExtIStream& stream, TkFramework& framework); - -} // namespace Blast -} // namespace Nv +// 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) 2018 NVIDIA Corporation. All rights reserved. + + +#pragma once + + +/** +Raw serialization function declarations for BlastTk +*/ + +#include + + +namespace Nv +{ +namespace Blast +{ + +// Forward declarations +class TkAsset; +class TkFramework; +class ExtIStream; + +//// Nv::Blast::TkAsset //// + +TkAsset* deserializeTkAsset(ExtIStream& stream, TkFramework& framework); + +} // namespace Blast +} // namespace Nv -- cgit v1.2.3