00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef neo_render_buffer_h
00022 #define neo_render_buffer_h
00023
00027 #include "../core/platform.h"
00028 #include "../core/refcount.h"
00029 #include "../core/exception.h"
00030 #include "../core/util.h"
00031
00032 namespace neo {
00033 namespace render {
00034
00035 class Buffer;
00036
00043 class BufferLockException : public core::Exception
00044 {
00045 public:
00046
00048 BufferLockException( const char *p_msg );
00049 };
00050
00057 class BufferReadLock
00058 {
00059 public:
00060
00062
00063 BufferReadLock( Buffer* p_buffer );
00064
00066 ~BufferReadLock();
00067
00068
00069 private:
00070
00072 Buffer* _p_buffer;
00073
00075 bool _ownLock;
00076 };
00077
00121 class Buffer : public core::Noncopyable, public core::RefCount
00122 {
00123 public:
00124
00130 enum Type
00131 {
00133 DYNAMIC = 0x00000001,
00134
00136 STATIC = 0x00000002,
00137
00139 READPRI = 0x00000004,
00140
00142 WRITEPRI = 0x00000008,
00143
00145 NOREADWRITE = 0x00000010,
00146
00148 NORENDER = 0x00000020,
00149
00151 NOSYSRAM = 0x00000040,
00152
00154 DEFAULTTYPE = ( DYNAMIC | READPRI | WRITEPRI )
00155 };
00156
00162 enum UploadPolicy
00163 {
00165 ONUNLOCK,
00166
00168 ONRENDER,
00169
00171 ONFLUSH
00172 };
00173
00178 enum Lock
00179 {
00181 READ = 0x00000001,
00182
00184 WRITE = 0x00000002,
00185
00187 NOUPLOAD = 0x00000004,
00188
00190 FORCEUPLOAD = 0x00000008
00191 };
00192
00194
00196 Buffer( unsigned int type = DEFAULTTYPE );
00197
00199
00202 void lock( unsigned int lock );
00203
00205
00206 inline void unlock();
00207
00209
00210 virtual void upload();
00211
00213
00215 inline bool isLocked() const;
00216
00218
00220 inline bool isDirty() const;
00221
00223
00227 inline void* getElement( unsigned int element = 0 );
00228
00230
00231 inline unsigned int getElementSize() const;
00232
00234
00235 inline unsigned int getType() const;
00236
00238
00239 inline unsigned int getNumAllocated() const;
00240
00242
00245 inline unsigned int getNumElements() const;
00246
00248
00250 inline void setNumElements( unsigned int elements );
00251
00253 inline bool getStaticSort() const;
00254
00256
00257 static inline UploadPolicy getUploadPolicy();
00258
00260
00261 static void setUploadPolicy( UploadPolicy policy );
00262
00264
00266 static void enforceNoRW( bool enforce );
00267
00268 protected:
00269
00271 static UploadPolicy _uploadpolicy;
00272
00274 static bool _enforceNoRW;
00275
00277 unsigned int _type;
00278
00280 unsigned int _lock;
00281
00283 bool _dirty;
00284
00286 unsigned int _allocated;
00287
00289 unsigned int _current;
00290
00292 unsigned int _size;
00293
00295 unsigned char* _p_buffer;
00296
00298 unsigned char* _p_rw;
00299
00301 bool _staticsort;
00302
00304
00305 virtual ~Buffer();
00306
00311 virtual void acquireLock() = 0;
00312
00317 virtual void releaseLock() = 0;
00318 };
00319
00320 #include "buffer.inl"
00321
00322 }
00323 }
00324
00325 #endif