00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined SOCUDABUFFEROBJECT_H
00024 #define SOCUDABUFFEROBJECT_H
00025
00026 #include <Inventor/devices/SoBufferObject.h>
00027 #include <Inventor/devices/SoCudaContext.h>
00028 #include <Inventor/cuda/SoCudaDefs.h>
00029
00030 class SoCpuBufferObject;
00031 class SoGLBufferObject;
00032
00052 class SoCudaBufferObject : public SoBufferObject
00053 {
00054 SO_TYPED_CLASS_HEADER();
00055
00056 public:
00057
00061 SoCudaBufferObject();
00062
00074 virtual bool setSize( size_t size );
00075
00090 virtual void memcpy( SoBufferObject* sourceBufferObject, size_t destOffset = 0, size_t sourceOffset = 0, size_t copySize = SO_BUFFER_SIZE_ALL );
00091
00098 virtual void memcpy( SoCpuBufferObject* sourceBufferObject, size_t destOffset = 0, size_t sourceOffset = 0, size_t copySize = SO_BUFFER_SIZE_ALL );
00099
00108 virtual void memcpy( SoCudaBufferObject* sourceBufferObject, size_t destOffset = 0, size_t sourceOffset = 0, size_t copySize = SO_BUFFER_SIZE_ALL );
00109
00115 virtual void memcpy( SoGLBufferObject* sourceBufferObject, size_t destOffset = 0, size_t sourceOffset = 0, size_t copySize = SO_BUFFER_SIZE_ALL );
00116
00120 virtual void memset( void* value, size_t valueSize = 1, size_t offset = 0, size_t count = SO_BUFFER_SIZE_ALL );
00121
00135 virtual void map( SoBufferObject* targetBufferObject, AccessMode accessMode, size_t startPosition = 0, size_t mappingSize = SO_BUFFER_SIZE_ALL );
00136
00143 virtual void map( SoCudaBufferObject* targetBufferObject, AccessMode accessMode, size_t startPosition = 0, size_t mappingSize = SO_BUFFER_SIZE_ALL );
00144
00151 virtual void map( SoCpuBufferObject* targetBufferObject, AccessMode accessMode, size_t startPosition = 0, size_t mappingSize = SO_BUFFER_SIZE_ALL );
00152
00159 virtual void map( SoGLBufferObject* targetBufferObject, AccessMode accessMode, size_t startPosition = 0, size_t mappingSize = SO_BUFFER_SIZE_ALL );
00160
00164 virtual void unmap( SoBufferObject* bufferObject );
00165
00172 virtual void unmap( SoCudaBufferObject* bufferObject );
00173
00180 virtual void unmap( SoCpuBufferObject* bufferObject );
00181
00188 virtual void unmap( SoGLBufferObject* bufferObject );
00189
00197 virtual void* getLocation();
00198
00204 virtual SoBufferObject* createInstance() const;
00205
00206 virtual void clearInstance();
00207
00208
00209
00210 private:
00211
00212 virtual void copyToCpuBuffer( SoCpuBufferObject* targetBufferObject, size_t destOffset = 0, size_t sourceOffset = 0, size_t copySize = SO_BUFFER_SIZE_ALL );
00213
00214 SoCpuBufferObject* createFastCpuBufferObject( size_t size, bool copyData );
00215
00216 void destroyFastCpuBufferObject( SoCpuBufferObject* cpuBufferObject, bool copyData );
00217
00218 void copyToGLBuffer( SoGLBufferObject* targetBufferObject, size_t destOffset = 0, size_t sourceOffset = 0, size_t copySize = SO_BUFFER_SIZE_ALL );
00219
00220
00221 private:
00223 virtual ~SoCudaBufferObject();
00224
00228 virtual void copyHostToDevice( void* sourceBuffer, size_t sourceOffset, size_t destOffset, size_t copySize );
00229
00233 virtual void copyDeviceToHost( void* targetBuffer, size_t targetOffset, size_t sourceOffset, size_t copySize );
00234
00235 private:
00236
00238 void setBuffer( void *buffer, size_t size );
00239
00240 void* m_buffer;
00241
00242 bool m_isOwner;
00243 };
00244
00245
00246 #endif //SOCUDABUFFEROBJECT_H
00247
00248
00249