summaryrefslogtreecommitdiff
path: root/Runner/Graphics/GpuDataBuffer.h
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-10-17 16:01:30 +0800
committerchai <chaifix@163.com>2021-10-17 16:01:30 +0800
commit6e73ca6ada8a41692809dae5db89c8db0675ce1e (patch)
tree3ca6f06b29b3e2c183750ddcff8d7a09d0785e6b /Runner/Graphics/GpuDataBuffer.h
parente13f699ee5f575198552d94ada1167305c82bb2f (diff)
-Runner
Diffstat (limited to 'Runner/Graphics/GpuDataBuffer.h')
-rw-r--r--Runner/Graphics/GpuDataBuffer.h90
1 files changed, 0 insertions, 90 deletions
diff --git a/Runner/Graphics/GpuDataBuffer.h b/Runner/Graphics/GpuDataBuffer.h
deleted file mode 100644
index 0d65d3d..0000000
--- a/Runner/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