From 3dfe2108cfab31ba3ee5527e217d0d8e99a51162 Mon Sep 17 00:00:00 2001 From: git perforce import user Date: Tue, 25 Oct 2016 12:29:14 -0600 Subject: Initial commit: PhysX 3.4.0 Update @ 21294896 APEX 1.4.0 Update @ 21275617 [CL 21300167] --- PxShared/src/pvd/include/PxPvdDataStream.h | 272 +++++++++++++++++++++++++++++ 1 file changed, 272 insertions(+) create mode 100644 PxShared/src/pvd/include/PxPvdDataStream.h (limited to 'PxShared/src/pvd/include/PxPvdDataStream.h') diff --git a/PxShared/src/pvd/include/PxPvdDataStream.h b/PxShared/src/pvd/include/PxPvdDataStream.h new file mode 100644 index 00000000..870e5973 --- /dev/null +++ b/PxShared/src/pvd/include/PxPvdDataStream.h @@ -0,0 +1,272 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef PXPVDSDK_PXPVDDATASTREAM_H +#define PXPVDSDK_PXPVDDATASTREAM_H + +/** \addtogroup pvd +@{ +*/ +#include "pvd/PxPvd.h" +#include "PxPvdErrorCodes.h" +#include "PxPvdObjectModelBaseTypes.h" + +#if !PX_DOXYGEN +namespace physx +{ +namespace pvdsdk +{ +#endif + +class PvdPropertyDefinitionHelper; + +class PvdMetaDataStream +{ + protected: + virtual ~PvdMetaDataStream() + { + } + + public: + virtual PvdError createClass(const NamespacedName& nm) = 0; + template + PvdError createClass() + { + return createClass(getPvdNamespacedNameForType()); + } + + virtual PvdError deriveClass(const NamespacedName& parent, const NamespacedName& child) = 0; + template + PvdError deriveClass() + { + return deriveClass(getPvdNamespacedNameForType(), getPvdNamespacedNameForType()); + } + + virtual bool isClassExist(const NamespacedName& nm) = 0; + template + bool isClassExist() + { + return isClassExist(getPvdNamespacedNameForType()); + } + + virtual PvdError createProperty(const NamespacedName& clsName, const char* name, const char* semantic, + const NamespacedName& dtypeName, PropertyType::Enum propertyType, + DataRef values = DataRef()) = 0; + template + PvdError createProperty(String name, String semantic = "", PropertyType::Enum propertyType = PropertyType::Scalar, + DataRef values = DataRef()) + { + return createProperty(getPvdNamespacedNameForType(), name, semantic, + getPvdNamespacedNameForType(), propertyType, values); + } + + virtual PvdError createPropertyMessage(const NamespacedName& cls, const NamespacedName& msgName, + DataRef entries, uint32_t messageSizeInBytes) = 0; + + template + PvdError createPropertyMessage(DataRef entries) + { + return createPropertyMessage(getPvdNamespacedNameForType(), getPvdNamespacedNameForType(), + entries, sizeof(TMsgType)); + } +}; + +class PvdInstanceDataStream +{ + protected: + virtual ~PvdInstanceDataStream() + { + } + + public: + virtual PvdError createInstance(const NamespacedName& cls, const void* instance) = 0; + + template + PvdError createInstance(const TDataType* inst) + { + return createInstance(getPvdNamespacedNameForType(), inst); + } + virtual bool isInstanceValid(const void* instance) = 0; + + // If the property will fit or is already completely in memory + virtual PvdError setPropertyValue(const void* instance, String name, DataRef data, + const NamespacedName& incomingTypeName) = 0; + template + PvdError setPropertyValue(const void* instance, String name, const TDataType& value) + { + const uint8_t* dataStart = reinterpret_cast(&value); + return setPropertyValue(instance, name, DataRef(dataStart, dataStart + sizeof(TDataType)), + getPvdNamespacedNameForType()); + } + + template + PvdError setPropertyValue(const void* instance, String name, const TDataType* value, uint32_t numItems) + { + const uint8_t* dataStart = reinterpret_cast(value); + return setPropertyValue(instance, name, + DataRef(dataStart, dataStart + sizeof(TDataType) * numItems), + getPvdNamespacedNameForType()); + } + + // Else if the property is very large (contact reports) you can send it in chunks. + virtual PvdError beginSetPropertyValue(const void* instance, String name, const NamespacedName& incomingTypeName) = 0; + + template + PvdError beginSetPropertyValue(const void* instance, String name) + { + return beginSetPropertyValue(instance, name, getPvdNamespacedNameForType()); + } + virtual PvdError appendPropertyValueData(DataRef data) = 0; + + template + PvdError appendPropertyValueData(const TDataType* value, uint32_t numItems) + { + const uint8_t* dataStart = reinterpret_cast(value); + return appendPropertyValueData(DataRef(dataStart, dataStart + numItems * sizeof(TDataType))); + } + + virtual PvdError endSetPropertyValue() = 0; + + // Set a set of properties to various values on an object. + + virtual PvdError setPropertyMessage(const void* instance, const NamespacedName& msgName, + DataRef data) = 0; + + template + PvdError setPropertyMessage(const void* instance, const TDataType& value) + { + const uint8_t* dataStart = reinterpret_cast(&value); + return setPropertyMessage(instance, getPvdNamespacedNameForType(), + DataRef(dataStart, sizeof(TDataType))); + } + // If you need to send of lot of identical messages, this avoids a hashtable lookup per message. + virtual PvdError beginPropertyMessageGroup(const NamespacedName& msgName) = 0; + + template + PvdError beginPropertyMessageGroup() + { + return beginPropertyMessageGroup(getPvdNamespacedNameForType()); + } + virtual PvdError sendPropertyMessageFromGroup(const void* instance, DataRef data) = 0; + + template + PvdError sendPropertyMessageFromGroup(const void* instance, const TDataType& value) + { + const uint8_t* dataStart = reinterpret_cast(&value); + return sendPropertyMessageFromGroup(instance, DataRef(dataStart, sizeof(TDataType))); + } + + virtual PvdError endPropertyMessageGroup() = 0; + + // These functions ensure the target array doesn't contain duplicates + virtual PvdError pushBackObjectRef(const void* instId, String propName, const void* objRef) = 0; + virtual PvdError removeObjectRef(const void* instId, String propName, const void* objRef) = 0; + + // Instance elimination. + virtual PvdError destroyInstance(const void* key) = 0; + + // Profiling hooks + virtual PvdError beginSection(const void* instance, String name) = 0; + virtual PvdError endSection(const void* instance, String name) = 0; + + // Origin Shift + virtual PvdError originShift(const void* scene, PxVec3 shift) = 0; + + public: + /*For some cases, pvd command cannot be run immediately. For example, when create joints, while the actors may still + *pending for insert, the joints update commands can be run deffered. + */ + class PvdCommand + { + public: + // Assigned is needed for copying + PvdCommand(const PvdCommand&) + { + } + PvdCommand& operator=(const PvdCommand&) + { + return *this; + } + + public: + PvdCommand() + { + } + virtual ~PvdCommand() + { + } + + // Not pure virtual so can have default PvdCommand obj + virtual bool canRun(PvdInstanceDataStream&) + { + return false; + } + virtual void run(PvdInstanceDataStream&) + { + } + }; + + // PVD SDK provide this helper function to allocate cmd's memory and release them at after flush the command queue + virtual void* allocateMemForCmd(uint32_t length) = 0; + + // PVD will call the destructor of PvdCommand object at the end fo flushPvdCommand + virtual void pushPvdCommand(PvdCommand& cmd) = 0; + virtual void flushPvdCommand() = 0; +}; + +class PvdDataStream : public PvdInstanceDataStream, public PvdMetaDataStream +{ + protected: + virtual ~PvdDataStream() + { + } + + public: + virtual void release() = 0; + virtual bool isConnected() = 0; + + virtual void addProfileZone(void* zone, const char* name) = 0; + virtual void addProfileZoneEvent(void* zone, const char* name, uint16_t eventId, bool compileTimeEnabled) = 0; + + virtual PvdPropertyDefinitionHelper& getPropertyDefinitionHelper() = 0; + + virtual void setIsTopLevelUIElement(const void* instance, bool topLevel) = 0; + virtual void sendErrorMessage(uint32_t code, const char* message, const char* file, uint32_t line) = 0; + virtual void updateCamera(const char* name, const PxVec3& origin, const PxVec3& up, const PxVec3& target) = 0; + +/** + \brief Create a new PvdDataStream. + \param pvd A pointer to a valid PxPvd instance. This must be non-null. +*/ + PX_PVDSDK_API static PvdDataStream* create(PxPvd* pvd); +}; +#if !PX_DOXYGEN +} // pvdsdk +} // physx +#endif + +/** @} */ +#endif // PXPVDSDK_PXPVDDATASTREAM_H -- cgit v1.2.3