NxUserRenderInstanceBufferDesc.h
Go to the documentation of this file.
00001 // This code contains NVIDIA Confidential Information and is disclosed to you
00002 // under a form of NVIDIA software license agreement provided separately to you.
00003 //
00004 // Notice
00005 // NVIDIA Corporation and its licensors retain all intellectual property and
00006 // proprietary rights in and to this software and related documentation and
00007 // any modifications thereto. Any use, reproduction, disclosure, or
00008 // distribution of this software and related documentation without an express
00009 // license agreement from NVIDIA Corporation is strictly prohibited.
00010 //
00011 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
00012 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
00013 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
00014 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
00015 //
00016 // Information and code furnished is believed to be accurate and reliable.
00017 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
00018 // information or for any infringement of patents or other rights of third parties that may
00019 // result from its use. No license is granted by implication or otherwise under any patent
00020 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
00021 // This code supersedes and replaces all information previously supplied.
00022 // NVIDIA Corporation products are not authorized for use as critical
00023 // components in life support devices or systems without express written approval of
00024 // NVIDIA Corporation.
00025 //
00026 // Copyright (c) 2008-2014 NVIDIA Corporation. All rights reserved.
00027 
00028 #ifndef NX_USER_RENDER_INSTANCE_BUFFER_DESC_H
00029 #define NX_USER_RENDER_INSTANCE_BUFFER_DESC_H
00030 
00036 #include "NxUserRenderResourceManager.h"
00037 #include "NxApexRenderDataFormat.h"
00038 
00039 namespace physx
00040 {
00041 class PxCudaContextManager;
00042 };
00043 
00044 namespace physx
00045 {
00046 namespace apex
00047 {
00048 
00049 PX_PUSH_PACK_DEFAULT
00050 
00051 #if !defined(PX_PS4)
00052     #pragma warning(push)
00053     #pragma warning(disable:4121)
00054 #endif  //!PX_PS4
00055 
00059 struct NxRenderInstanceSemantic
00060 {
00064     enum Enum
00065     {
00066         POSITION = 0,   
00067         ROTATION_SCALE, 
00068         VELOCITY_LIFE,  
00069         DENSITY,        
00070         COLOR,          
00071         UV_OFFSET,      
00072         LOCAL_OFFSET,   
00073 
00074         USER_DATA,      
00075 
00076         NUM_SEMANTICS   
00077     };
00078 
00082     static PX_INLINE NxRenderDataFormat::Enum getSemanticFormat(Enum semantic)
00083     {
00084         switch (semantic)
00085         {
00086         case POSITION:
00087             return NxRenderDataFormat::FLOAT3;
00088         case ROTATION_SCALE:
00089             return NxRenderDataFormat::FLOAT3x3;
00090         case VELOCITY_LIFE:
00091             return NxRenderDataFormat::FLOAT4;
00092         case DENSITY:
00093             return NxRenderDataFormat::FLOAT1;
00094         case COLOR:
00095             return NxRenderDataFormat::B8G8R8A8;
00096         case UV_OFFSET:
00097             return NxRenderDataFormat::FLOAT2;
00098         case LOCAL_OFFSET:
00099             return NxRenderDataFormat::FLOAT3;
00100         case USER_DATA:
00101             return NxRenderDataFormat::UINT1;
00102         default:
00103             PX_ALWAYS_ASSERT();
00104             return NxRenderDataFormat::NUM_FORMATS;
00105         }
00106     }
00107 };
00108 
00112 struct NxRenderInstanceLayoutElement
00113 {
00117     enum Enum
00118     {
00119         POSITION_FLOAT3,
00120         ROTATION_SCALE_FLOAT3x3,
00121         VELOCITY_LIFE_FLOAT4,
00122         DENSITY_FLOAT1,
00123         COLOR_RGBA8,
00124         COLOR_BGRA8,
00125         COLOR_FLOAT4,
00126         UV_OFFSET_FLOAT2,
00127         LOCAL_OFFSET_FLOAT3,
00128         USER_DATA_UINT1,
00129 
00130         NUM_SEMANTICS
00131     };
00132 
00136     static PX_INLINE NxRenderDataFormat::Enum getSemanticFormat(Enum semantic)
00137     {
00138         switch (semantic)
00139         {
00140         case POSITION_FLOAT3:
00141             return NxRenderDataFormat::FLOAT3;      
00142         case ROTATION_SCALE_FLOAT3x3:
00143             return NxRenderDataFormat::FLOAT3x3;
00144         case VELOCITY_LIFE_FLOAT4:
00145             return NxRenderDataFormat::FLOAT4;
00146         case DENSITY_FLOAT1:
00147             return NxRenderDataFormat::FLOAT1;
00148         case COLOR_RGBA8:
00149             return NxRenderDataFormat::R8G8B8A8;
00150         case COLOR_BGRA8:
00151             return NxRenderDataFormat::B8G8R8A8;
00152         case COLOR_FLOAT4:
00153             return NxRenderDataFormat::FLOAT4;
00154         case UV_OFFSET_FLOAT2:
00155             return NxRenderDataFormat::FLOAT2;
00156         case LOCAL_OFFSET_FLOAT3:
00157             return NxRenderDataFormat::FLOAT3;
00158         case USER_DATA_UINT1:
00159             return NxRenderDataFormat::UINT1;
00160         default:
00161             PX_ALWAYS_ASSERT();
00162             return NxRenderDataFormat::NUM_FORMATS;
00163         }
00164     }
00168     static PX_INLINE NxRenderInstanceSemantic::Enum getSemantic(Enum semantic)
00169     {
00170         switch (semantic)
00171         {
00172         case POSITION_FLOAT3:
00173             return NxRenderInstanceSemantic::POSITION;      
00174         case ROTATION_SCALE_FLOAT3x3:
00175             return NxRenderInstanceSemantic::ROTATION_SCALE;
00176         case VELOCITY_LIFE_FLOAT4:
00177             return NxRenderInstanceSemantic::VELOCITY_LIFE;
00178         case DENSITY_FLOAT1:
00179             return NxRenderInstanceSemantic::DENSITY;
00180         case COLOR_RGBA8:
00181         case COLOR_BGRA8:
00182         case COLOR_FLOAT4:
00183             return NxRenderInstanceSemantic::COLOR;
00184         case UV_OFFSET_FLOAT2:
00185             return NxRenderInstanceSemantic::UV_OFFSET;
00186         case LOCAL_OFFSET_FLOAT3:
00187             return NxRenderInstanceSemantic::LOCAL_OFFSET;
00188         case USER_DATA_UINT1:
00189             return NxRenderInstanceSemantic::USER_DATA;
00190         default:
00191             PX_ALWAYS_ASSERT();
00192             return NxRenderInstanceSemantic::NUM_SEMANTICS;
00193         }
00194     }
00195 };
00196 
00200 class NxUserRenderInstanceBufferDesc
00201 {
00202 public:
00203     NxUserRenderInstanceBufferDesc(void)
00204     {
00205         setDefaults();
00206     }
00207 
00211     void setDefaults()
00212     {
00213         registerInCUDA = false;
00214         interopContext = 0;
00215         maxInstances = 0;
00216         hint         = NxRenderBufferHint::STATIC;
00217         for (physx::PxU32 i = 0; i < NxRenderInstanceSemantic::NUM_SEMANTICS; i++)
00218         {
00219             semanticFormats[i] = NxRenderDataFormat::UNSPECIFIED;
00220         }
00221         for (physx::PxU32 i = 0; i < NxRenderInstanceLayoutElement::NUM_SEMANTICS; i++)
00222         {
00223             semanticOffsets[i] = physx::PxU32(-1);
00224         }
00225         stride = 0;
00226     }
00227 
00231     bool isValid(void) const
00232     {
00233         physx::PxU32 numFailed = 0;
00234 
00235         numFailed += (maxInstances == 0);
00236         numFailed += (stride == 0);
00237         numFailed += (semanticOffsets[NxRenderInstanceSemantic::POSITION] == physx::PxU32(-1));
00238         numFailed += registerInCUDA && (interopContext == 0);
00239 
00240         return (numFailed == 0);
00241     }
00242 
00243 public:
00244     physx::PxU32                    maxInstances; 
00245     NxRenderBufferHint::Enum        hint; 
00246     
00252     NxRenderDataFormat::Enum        semanticFormats[NxRenderInstanceSemantic::NUM_SEMANTICS];
00256     physx::PxU32                    semanticOffsets[NxRenderInstanceLayoutElement::NUM_SEMANTICS];
00257 
00258     physx::PxU32                    stride; 
00259 
00260     bool                            registerInCUDA; 
00261 
00266     physx::PxCudaContextManager*   interopContext;
00267 };
00268 
00269 #if !defined(PX_PS4)
00270     #pragma warning(pop)
00271 #endif  //!PX_PS4
00272 
00273 PX_POP_PACK
00274 
00275 }
00276 } // end namespace physx::apex
00277 
00278 #endif // NX_USER_RENDER_INSTANCE_BUFFER_DESC_H

Generated on Mon Apr 28 2014 08:01:35

Copyright © 2012-2014 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved.