![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 TAPsCUDA_VetexListPLHM.cu 00003 ******************************************************************************/ 00008 /****************************************************************************** 00009 SUKITTI PUNAK (09/18/2009) 00010 UPDATE (09/21/2009) 00011 ******************************************************************************/ 00012 #ifndef TAPs_CUDA_VERTEX_LIST_PLHM_HPP 00013 #define TAPs_CUDA_VERTEX_LIST_PLHM_HPP 00014 00015 #include "TAPsCUDA_GlobalTextureRef.cu" 00016 00017 BEGIN_NAMESPACE_TAPs__CUDA 00018 //============================================================================= 00019 //----------------------------------------------------------------------------- 00020 class DATA_Vertex_ListPLHM 00021 { 00022 public: 00023 00025 DATA_Vertex_ListPLHM ( 00026 unsigned int numOfVertices, 00027 bool bIncludeHomeVertices, 00028 unsigned int maxVextexConnection, 00029 bool bIncludeSimFlagsConstraint, 00030 bool bIncludeOrientations = false, 00031 bool bIncludePrevOrientations = false, 00032 bool bIncludeForces_1 = false, 00033 bool bIncludeForces_2 = false 00034 ); 00035 00037 ~DATA_Vertex_ListPLHM (); 00038 00040 float * GetVertexList () { return m_Ptr_Mem_VertexList; } 00042 float * GetPrevVertexList () { return m_Ptr_Mem_PrevVertexList; } 00043 // //! Get list of next vertices 00044 // float * GetNextVertexList () { return m_Ptr_Mem_NextVertexList; } 00046 float * GetHomeVertexList () { return m_Ptr_Mem_HomeVertexList; } 00048 int * GetVertexConnectionList () { return m_Ptr_Mem_VertexConnectionList; } 00050 unsigned int * GetSimFlagsList () { return m_Ptr_Mem_SimFlagsList; } 00052 float * GetPosConstraintList () { return m_Ptr_Mem_PosConstraintList; } 00054 float * GetOrientationList () { return m_Ptr_Mem_OrientationList; } 00056 float * GetPrevOrientationList () { return m_Ptr_Mem_PrevOrientationList; } 00057 // //! Get list of next orientations 00058 // float * GetNextOrientationList () { return m_Ptr_Mem_NextOrientationList; } 00060 float * GetForceList_1 () { return m_Ptr_Mem_ForceList_1; } 00062 float * GetForceList_2 () { return m_Ptr_Mem_ForceList_2; } 00063 00065 float * GetDevVertexList () { return m_Ptr_DevMem_VertexList; } 00067 float * GetDevPrevVertexList () { return m_Ptr_DevMem_PrevVertexList; } 00068 // //! Get list of next vertices stored in the device 00069 // float * GetDevNextVertexList () { return m_Ptr_DevMem_NextVertexList; } 00071 float * GetDevHomeVertexList () { return m_Ptr_DevMem_HomeVertexList; } 00073 int * GetDevVertexConnectionList () { return m_Ptr_DevMem_VertexConnectionList; } 00075 unsigned int * GetDevSimFlagsList () { return m_Ptr_DevMem_SimFlagsList; } 00077 float * GetDevPosConstraintList () { return m_Ptr_DevMem_PosConstraintList; } 00079 float * GetDevOrientationList () { return m_Ptr_DevMem_OrientationList; } 00081 float * GetDevPrevOrientationList () { return m_Ptr_DevMem_PrevOrientationList; } 00082 // //! Get list of next orientations stored in the device 00083 // float * GetDevNextOrientationList () { return m_Ptr_DevMem_NextOrientationList; } 00085 float * GetDevForceList_1 () { return m_Ptr_DevMem_ForceList_1; } 00087 float * GetDevForceList_2 () { return m_Ptr_DevMem_ForceList_2; } 00088 00089 // Swap pointers between Vertex List and Previous Vertex List 00090 void SwapVertexList () 00091 { 00092 // curr --> next --> prev --> curr 00093 // float * tmpPtr = m_Ptr_Mem_VertexList; 00094 // m_Ptr_Mem_VertexList = m_Ptr_Mem_NextVertexList; 00095 // m_Ptr_Mem_NextVertexList = m_Ptr_Mem_PrevVertexList; 00096 // m_Ptr_Mem_PrevVertexList = tmpPtr; 00097 00098 // tmpPtr = m_Ptr_DevMem_VertexList; 00099 // m_Ptr_DevMem_VertexList = m_Ptr_DevMem_NextVertexList; 00100 // m_Ptr_DevMem_NextVertexList = m_Ptr_DevMem_PrevVertexList; 00101 // m_Ptr_DevMem_PrevVertexList = tmpPtr; 00102 00103 float * tmpPtr = m_Ptr_Mem_VertexList; 00104 m_Ptr_Mem_VertexList = m_Ptr_Mem_PrevVertexList; 00105 m_Ptr_Mem_PrevVertexList = tmpPtr; 00106 00107 tmpPtr = m_Ptr_DevMem_VertexList; 00108 m_Ptr_DevMem_VertexList = m_Ptr_DevMem_PrevVertexList; 00109 m_Ptr_DevMem_PrevVertexList = tmpPtr; 00110 00111 if ( m_bIncludePrevOrientations ) { 00112 // float * tmpPtr = m_Ptr_Mem_OrientationList; 00113 // m_Ptr_Mem_OrientationList = m_Ptr_Mem_NextOrientationList; 00114 // m_Ptr_Mem_NextOrientationList = m_Ptr_Mem_PrevOrientationList; 00115 // m_Ptr_Mem_PrevOrientationList = tmpPtr; 00116 00117 // tmpPtr = m_Ptr_DevMem_OrientationList; 00118 // m_Ptr_DevMem_OrientationList = m_Ptr_DevMem_NextOrientationList; 00119 // m_Ptr_DevMem_NextOrientationList = m_Ptr_DevMem_PrevOrientationList; 00120 // m_Ptr_DevMem_PrevOrientationList = tmpPtr; 00121 00122 float * tmpPtr = m_Ptr_Mem_OrientationList; 00123 m_Ptr_Mem_OrientationList = m_Ptr_Mem_PrevOrientationList; 00124 m_Ptr_Mem_PrevOrientationList = tmpPtr; 00125 00126 tmpPtr = m_Ptr_DevMem_OrientationList; 00127 m_Ptr_DevMem_OrientationList = m_Ptr_DevMem_PrevOrientationList; 00128 m_Ptr_DevMem_PrevOrientationList = tmpPtr; 00129 } 00130 } 00131 00133 void BindVertexList ( int numOfVertices ) 00134 { 00135 CUDA_SAFE_CALL( cudaBindTexture( 0, CudaTexVertexList, m_Ptr_Mem_VertexList, numOfVertices*sizeof(float4) ) ); 00136 CUT_CHECK_ERROR( "Binding Vertex List Failed!" ); 00137 } 00139 void BindPrevVertexList ( int numOfVertices ) 00140 { 00141 CUDA_SAFE_CALL( cudaBindTexture( 0, CudaTexPrevVertexList, m_Ptr_Mem_PrevVertexList, numOfVertices*sizeof(float4) ) ); 00142 CUT_CHECK_ERROR( "Binding Previous Vertex List Failed!" ); 00143 } 00145 void BindHomeVertexList ( int numOfVertices ) 00146 { 00147 CUDA_SAFE_CALL( cudaBindTexture( 0, CudaTexHomeVertexList, m_Ptr_Mem_HomeVertexList, numOfVertices*sizeof(float4) ) ); 00148 CUT_CHECK_ERROR( "Binding Home Vertex List Failed!" ); 00149 } 00151 void BindVertexConnectionList ( int numOfVertices, int maxConnectionSize ) 00152 { 00153 CUDA_SAFE_CALL( cudaBindTexture( 0, CudaTexVertexConnectionList, m_Ptr_Mem_VertexConnectionList, numOfVertices*maxConnectionSize*sizeof(int1) ) ); 00154 CUT_CHECK_ERROR( "Binding Vertex Connection List Failed!" ); 00155 } 00157 void BindSimFlagsList ( int numOfVertices ) 00158 { 00159 CUDA_SAFE_CALL( cudaBindTexture( 0, CudaTexSimFlagsList, m_Ptr_Mem_SimFlagsList, numOfVertices*sizeof(uint1) ) ); 00160 CUT_CHECK_ERROR( "Binding Simulation Flags List Failed!" ); 00161 } 00163 void BindPosConstraintList ( int numOfVertices ) 00164 { 00165 CUDA_SAFE_CALL( cudaBindTexture( 0, CudaTexPosConstraintList, m_Ptr_Mem_PosConstraintList, numOfVertices*sizeof(float4) ) ); 00166 CUT_CHECK_ERROR( "Binding Position Constraint List Failed!" ); 00167 } 00169 void BindOrientationList ( int numOfVertices ) 00170 { 00171 CUDA_SAFE_CALL( cudaBindTexture( 0, CudaTexOrientationList, m_Ptr_Mem_OrientationList, numOfVertices*sizeof(float4) ) ); 00172 CUT_CHECK_ERROR( "Binding Orientation List Failed!" ); 00173 } 00175 void BindPrevOrientationList ( int numOfVertices ) 00176 { 00177 CUDA_SAFE_CALL( cudaBindTexture( 0, CudaTexPrevOrientationList, m_Ptr_Mem_PrevOrientationList, numOfVertices*sizeof(float4) ) ); 00178 CUT_CHECK_ERROR( "Binding Previous Orientation List Failed!" ); 00179 } 00181 void BindForceList_1 ( int numOfVertices ) 00182 { 00183 CUDA_SAFE_CALL( cudaBindTexture( 0, CudaTexForceList_1, m_Ptr_Mem_ForceList_1, numOfVertices*sizeof(float4) ) ); 00184 CUT_CHECK_ERROR( "Binding Force List Set 1 Failed!" ); 00185 } 00187 void BindForceList_2 ( int numOfVertices ) 00188 { 00189 CUDA_SAFE_CALL( cudaBindTexture( 0, CudaTexForceList_2, m_Ptr_Mem_ForceList_2, numOfVertices*sizeof(float4) ) ); 00190 CUT_CHECK_ERROR( "Binding Force List Set 2 Failed!" ); 00191 } 00192 00194 void UnbindVertexList () { CUDA_SAFE_CALL( cudaUnbindTexture( CudaTexVertexList ) ); } 00196 void UnbindPrevVertexList () { CUDA_SAFE_CALL( cudaUnbindTexture( CudaTexPrevVertexList ) ); } 00198 void UnbindHomeVertexList () { CUDA_SAFE_CALL( cudaUnbindTexture( CudaTexHomeVertexList ) ); } 00200 void UnbindVertexConnectionList () { CUDA_SAFE_CALL( cudaUnbindTexture( CudaTexVertexConnectionList ) ); } 00202 void UnbindSimFlagsList () { CUDA_SAFE_CALL( cudaUnbindTexture( CudaTexSimFlagsList ) ); } 00204 void UnbindPosConstraintList () { CUDA_SAFE_CALL( cudaUnbindTexture( CudaTexPosConstraintList ) ); } 00206 void UnbindOrientationList () { CUDA_SAFE_CALL( cudaUnbindTexture( CudaTexOrientationList ) ); } 00208 void UnbindPrevOrientationList () { CUDA_SAFE_CALL( cudaUnbindTexture( CudaTexPrevOrientationList ) ); } 00210 void UnbindForceList_1 () { CUDA_SAFE_CALL( cudaUnbindTexture( CudaTexForceList_1 ) ); } 00212 void UnbindForceList_2 () { CUDA_SAFE_CALL( cudaUnbindTexture( CudaTexForceList_2 ) ); } 00213 00214 protected: 00215 00216 #ifdef TAPs_CUDA_DATA_VERTEX_LIST_TEXTURE_FROM_LIN_MEM 00217 bool AllocateTextures (); 00218 bool DeallocateTextures (); 00219 #endif//TAPs_CUDA_DATA_VERTEX_LIST_TEXTURE_FROM_LIN_MEM 00220 00221 #ifdef TAPs_CUDA_DATA_VERTEX_LIST_TEXTURE_FROM_ARRAY 00222 #endif//TAPs_CUDA_DATA_VERTEX_LIST_TEXTURE_FROM_ARRAY 00223 00224 #ifdef TAPs_CUDA_DATA_VERTEX_LIST_TEXTURE_MIXED 00225 #endif//TAPs_CUDA_DATA_VERTEX_LIST_TEXTURE_MIXED 00226 00230 float * m_Ptr_Mem_VertexList; 00231 float * m_Ptr_Mem_PrevVertexList; 00232 //float * m_Ptr_Mem_NextVertexList; //!< pointer to memory location for the list of next vertices 00233 float * m_Ptr_Mem_HomeVertexList; 00234 int * m_Ptr_Mem_VertexConnectionList; 00235 float * m_Ptr_Mem_OrientationList; 00236 float * m_Ptr_Mem_PrevOrientationList; 00237 //float * m_Ptr_Mem_NextOrientationList; //!< pointer to memory location for the list of next orientations 00238 float * m_Ptr_Mem_ForceList_1; 00239 float * m_Ptr_Mem_ForceList_2; 00240 00242 float * m_Ptr_DevMem_VertexList; 00243 float * m_Ptr_DevMem_PrevVertexList; 00244 //float * m_Ptr_DevMem_NextVertexList; //!< pointer to device's memory location for the list of next vertices 00245 float * m_Ptr_DevMem_HomeVertexList; 00246 int * m_Ptr_DevMem_VertexConnectionList; 00247 float * m_Ptr_DevMem_OrientationList; 00248 float * m_Ptr_DevMem_PrevOrientationList; 00249 //float * m_Ptr_DevMem_NextOrientationList; //!< pointer to device's memory location for the list of next orientations 00250 float * m_Ptr_DevMem_ForceList_1; 00251 float * m_Ptr_DevMem_ForceList_2; 00252 00253 // Extra resources for strand model (CPU) 00254 unsigned int * m_Ptr_Mem_SimFlagsList; 00255 float * m_Ptr_Mem_PosConstraintList; 00256 00257 // Extra resources for strand model (GPU) 00258 unsigned int * m_Ptr_DevMem_SimFlagsList; 00259 float * m_Ptr_DevMem_PosConstraintList; 00260 00261 unsigned int m_uiNumOfVertices; 00262 bool m_bIncludeHomeVertices; 00263 unsigned int m_uiMaxConnectionSize; 00264 bool m_bIncludeSimFlagsConstraint; 00265 bool m_bIncludeOrientations; 00266 bool m_bIncludePrevOrientations; 00267 bool m_bIncludeForces_1; 00268 bool m_bIncludeForces_2; 00269 00270 private: 00271 }; // END: class DATA_Vertex_List 00272 //============================================================================= 00273 END_NAMESPACE_TAPs__CUDA 00274 //----------------------------------------------------------------------------- 00275 00276 #include "TAPsCUDA_VertexListPLHM_Def.cu" 00277 00278 #endif 00279 //34567890123456789012345678901234567890123456789012345678901234567890123456789 00280 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----