diff options
Diffstat (limited to 'Runtime/Graphics/GpuDataBuffer.h')
-rw-r--r-- | Runtime/Graphics/GpuDataBuffer.h | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/Runtime/Graphics/GpuDataBuffer.h b/Runtime/Graphics/GpuDataBuffer.h deleted file mode 100644 index 0d65d3d..0000000 --- a/Runtime/Graphics/GpuDataBuffer.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef GPU_DATABUFFER_H -#define GPU_DATABUFFER_H - -#include <vector> - -#include "../Utilities/Type.h" -#include "../Utilities/Singleton.h" -#include "../Utilities/UtilMacros.h" -#include "../Utilities/Assert.h" -#include "OpenGL.h" - -namespace GPU -{ - - class DataBuffer - { - public: - void Upload(int offset, int size, const void* data); - void* Map(uint32 access); - void* MapRange(int offset, int size, uint32 access); // best performance - void FlushMapedRange(int offset, int size); - - void UnMap(); - - void Orphan(); - - // claim storage of size - void Restore(int size, GLenum usage); - // claim storage of size and fill it - void RestoreWithData(int size, GLenum usage, const void* data); - - GET(int, Size, m_Size); - GET(GLenum, Usage, m_Usage); - GET(GLuint, Handle, m_Handle); - - private: - friend class BufferPool; - - DataBuffer(); - ~DataBuffer(); - - GLuint m_Handle; - int m_Size; - GLenum m_Usage; - }; - - // recycle data buffer - class BufferPool : public Singleton<BufferPool> - { - public: - BufferPool(); - ~BufferPool(); - - void Initialize(); - - DataBuffer* ClaimBuffer(int size, GLenum usage); - void ReleaseBuffer(DataBuffer* buffer); - - void OnEndFrame(); - - private: - - inline int GetSizeClassLimit(int classNdx); - - void UpdatePendingBuffersArray(); - void InsertToLive(DataBuffer* buffer); - uint GetSizeClass(uint bufferSize); - - enum { - kSizeClassBaseLog2 = 10, - kSizeClassStepLog2 = 1, - kSizeClassCount = 7 - }; - - std::vector<DataBuffer*> m_LiveBuffers[kSizeClassCount]; - - }; - - inline int BufferPool::GetSizeClassLimit(int classNdx) - { - // (0, 2^10] 2^11 2^12 2^13 2^14 2^15 INT_MAX - return classNdx + 1 < kSizeClassCount ? (1 << (classNdx*kSizeClassStepLog2 + kSizeClassBaseLog2)) : INT_MAX; - } - - DataBuffer* ClaimBuffer(int size = 0, GLenum usage = GL_ARRAY_BUFFER); - void ReleaseBuffer(DataBuffer* buffer); - -} - -#endif
\ No newline at end of file |