diff options
Diffstat (limited to 'Runtime/Graphics')
-rw-r--r-- | Runtime/Graphics/Device.cpp | 4 | ||||
-rw-r--r-- | Runtime/Graphics/Device.h | 4 | ||||
-rw-r--r-- | Runtime/Graphics/GPUDataBuffers.cpp | 42 | ||||
-rw-r--r-- | Runtime/Graphics/GPUDataBuffers.h | 160 | ||||
-rw-r--r-- | Runtime/Graphics/GpuDataBuffer.cpp | 206 | ||||
-rw-r--r-- | Runtime/Graphics/GpuDataBuffer.h | 90 | ||||
-rw-r--r-- | Runtime/Graphics/ImageData.h | 23 | ||||
-rw-r--r-- | Runtime/Graphics/OpenGL.h | 25 | ||||
-rw-r--r-- | Runtime/Graphics/Quad.cpp | 104 | ||||
-rw-r--r-- | Runtime/Graphics/Quad.h | 50 | ||||
-rw-r--r-- | Runtime/Graphics/ShaderCompiler.cpp | 7 | ||||
-rw-r--r-- | Runtime/Graphics/ShaderCompiler.h | 33 | ||||
-rw-r--r-- | Runtime/Graphics/VertexBuffer.h | 8 |
13 files changed, 345 insertions, 411 deletions
diff --git a/Runtime/Graphics/Device.cpp b/Runtime/Graphics/Device.cpp index 8136a54..9ba2e23 100644 --- a/Runtime/Graphics/Device.cpp +++ b/Runtime/Graphics/Device.cpp @@ -16,7 +16,7 @@ Device::~Device() void Device::Initialize(DeviceSetting& setting) { - GPU::BufferPool::Instance()->Initialize(); + //GPU::BufferPool::Instance()->Initialize(); } void Device::Enable(DeviceEnable enabled) @@ -72,7 +72,7 @@ void Device::BeginFrame() void Device::EndFrame() { - GPU::BufferPool::Instance()->OnEndFrame(); + //GPU::BufferPool::Instance()->OnEndFrame(); m_IsInsideFrame = false; } diff --git a/Runtime/Graphics/Device.h b/Runtime/Graphics/Device.h index c7a059e..56cb197 100644 --- a/Runtime/Graphics/Device.h +++ b/Runtime/Graphics/Device.h @@ -42,7 +42,7 @@ public: void PresentFrame(); //GET(SharedVertexBuffer*, SharedVBO, m_SharedVBO); - SharedVertexBuffer* GetSharedVBO() { return &m_SharedVBO; } + //SharedVertexBuffer* GetSharedVBO() { return &m_SharedVBO; } GET_SET(Color, ClearColor, m_ClearColor); @@ -65,7 +65,7 @@ private: StencilOp m_StencilOp; byte m_StencilMask; - SharedVertexBuffer m_SharedVBO; + //SharedVertexBuffer m_SharedVBO; bool m_IsInsideFrame; diff --git a/Runtime/Graphics/GPUDataBuffers.cpp b/Runtime/Graphics/GPUDataBuffers.cpp new file mode 100644 index 0000000..9e8df9f --- /dev/null +++ b/Runtime/Graphics/GPUDataBuffers.cpp @@ -0,0 +1,42 @@ +#include "GPUDataBuffers.h"
+
+void foo()
+{
+ GPUDataBuffer<float> buf = GPUDataBuffer<float>(GL_ARRAY_BUFFER, GL_STATIC_DRAW);
+ int n = buf.GetComponentSize();
+}
+
+VBO::VBO() + : GPUDataBuffer<float>(GL_ARRAY_BUFFER, GL_STATIC_DRAW) +{ +} +VBO::VBO(GLenum usage) + : GPUDataBuffer<float>(GL_ARRAY_BUFFER, usage) +{ +} +
+VBO::~VBO() +{ +} + +void VBO::AddVertexAttribute(int index, int numOfComps, int stride) +{ + VertexAttributeDescriptor attribute = VertexAttributeDescriptor();
+ attribute.index = index;
+ attribute.numOfComponents = numOfComps;
+ attribute.stride = stride;
+ m_Layout.attributes.push_back(attribute);
+} +void VBO::AddVertexAttribute(VertexAttributeDescriptor& attribute) +{ + m_Layout.attributes.push_back(attribute);
+} +int VBO::GetVertexAttributesCount() +{ + return m_Layout.attributes.size(); +} +void VBO::ClearVertexAttribute() +{ + m_Layout.attributes.clear();
+} + diff --git a/Runtime/Graphics/GPUDataBuffers.h b/Runtime/Graphics/GPUDataBuffers.h new file mode 100644 index 0000000..62e0413 --- /dev/null +++ b/Runtime/Graphics/GPUDataBuffers.h @@ -0,0 +1,160 @@ +#pragma once + +#include <vector> + +#include "Runtime/Lua/LuaHelper.h" +#include "../Utilities/Type.h" +#include "../Utilities/Singleton.h" +#include "../Utilities/UtilMacros.h" +#include "../Utilities/Assert.h" +#include "OpenGL.h" + +template<typename T> +// GPU侧的通用缓冲区,最底层的实现 +class GPUDataBuffer +{ +public: + GPUDataBuffer(GLenum target, GLenum usage)/*throw GLException*/ + : m_Target(target) + , m_Usage(usage) + { + glGenBuffers(1, &m_Handle); + + CheckGLError( + glDeleteBuffers(1, &m_Handle); + throw GLException(error); + ); + } + virtual ~GPUDataBuffer() + { + glDeleteBuffers(1, &m_Handle); + } + + // 提交\更新缓冲区数据 + void Upload(int offset, int size, const T* data) + { + glBindBuffer(m_Target, m_Handle); + glBufferSubData(m_Target, offset, size, data); + glBindBuffer(m_Target, 0); + } + + // 更新缓冲区数据(性能优于Upload) + T* Map(uint32 access) + { + glBindBuffer(m_Target, m_Handle); + void* ptr = glMapBuffer(m_Target, access); + glBindBuffer(m_Target, 0); + return ptr; + } + T* MapRange(int offset, int size, uint32 access) // 性能最佳 + { + glBindBuffer(m_Target, m_Handle); + void* ptr = glMapBufferRange(m_Target, offset, size, access); + glBindBuffer(m_Target, 0); + return ptr; + } + void FlushMapedRange(int offset, int size) + { + glBindBuffer(m_Target, m_Handle); + glFlushMappedBufferRange(m_Target, offset, size); + glBindBuffer(m_Target, 0); + } + void UnMap() + { + glBindBuffer(m_Target, m_Handle); + glUnmapBuffer(m_Target); + glBindBuffer(m_Target, 0); + } + + // 重置缓冲区 + void Restore(int size, GLenum usage) + { + RestoreWithData(size, usage, 0); + } + void RestoreWithData(int size, GLenum usage, const T* data) + { + glBindBuffer(m_Target, m_Handle); + glBufferData(m_Target, size, data, usage); + glBindBuffer(m_Target, 0); + m_Size = size; + m_Usage = usage; + } + + void Orphan() + { + glBindBuffer(m_Target, m_Handle); + glBufferData(m_Target, 0, 0, GL_STREAM_DRAW); + glBindBuffer(m_Target, 0); + } + + int GetComponentSize() + { + return sizeof(T); + } + + GET(int, Size, m_Size); + GET(GLenum, Usage, m_Usage); + GET(GLuint, Handle, m_Handle); + +protected: + GLuint m_Handle; + + GLenum m_Target; + GLenum m_Usage; + + int m_Size; + +}; + +struct VertexAttributeDescriptor +{ + int index; // attribute layout index //glBindAttribLocation + int numOfComponents; // 1,2,3,4 + int stride; +}; + +struct VertexDataLayout +{ + std::vector<VertexAttributeDescriptor> attributes; +}; + +class DynamicVBO; +//顶点数据流 +class VBO : public GPUDataBuffer<float> +{ +public: + VBO(); + virtual ~VBO(); + + void AddVertexAttribute(int index, int numOfComps, int stride); + void AddVertexAttribute(VertexAttributeDescriptor& attribute); + int GetVertexAttributesCount(); + void ClearVertexAttribute(); + + static const GLenum componentType = GL_FLOAT; + +protected: + friend class DynamicVBO; + VBO(GLenum usage); + + VertexDataLayout m_Layout; + +}; + +// 频繁读写的共享vbo +class DynamicVBO : public VBO +{ +public: + DynamicVBO(); + ~DynamicVBO(); + +}; + +// 索引数据流 +class IBO : GPUDataBuffer<UInt16> +{ +public: + static const GLenum componentType = GL_UNSIGNED_SHORT; + + +};
\ No newline at end of file diff --git a/Runtime/Graphics/GpuDataBuffer.cpp b/Runtime/Graphics/GpuDataBuffer.cpp deleted file mode 100644 index d20be65..0000000 --- a/Runtime/Graphics/GpuDataBuffer.cpp +++ /dev/null @@ -1,206 +0,0 @@ -#include <math.h> - -#include "GpuDataBuffer.h" - -namespace GPU -{ - - // 修改buffer数据要绑定到这个目标上,其他情况下用GetHandle()绑定到其他目标 - // GL_COPY_READ_BUFFER - static const GLenum kBufferTarget = GL_COPY_WRITE_BUFFER; - - DataBuffer::DataBuffer() - { - glGenBuffers(1, &m_Handle); - } - - DataBuffer::~DataBuffer() - { - glDeleteBuffers(1, &m_Handle); - } - - void DataBuffer::Restore(int size, GLenum usage) - { - RestoreWithData(size, usage, 0); - } - - void DataBuffer::RestoreWithData(int size, GLenum usage, const void* data) - { - glBindBuffer(kBufferTarget, m_Handle); - glBufferData(kBufferTarget, size, data, usage); - glBindBuffer(kBufferTarget, 0); - m_Size = size; - m_Usage = usage; - } - - // glBufferSubData - // glMapBuffer - // glMapBufferRange (best one) - - void DataBuffer::Upload(int offset, int size, const void* data) - { - glBindBuffer(kBufferTarget, m_Handle); - glBufferSubData(kBufferTarget, offset, size, data); - glBindBuffer(kBufferTarget, 0); - } - - void* DataBuffer::Map(uint32 access) - { - glBindBuffer(kBufferTarget, m_Handle); - void* ptr = glMapBuffer(kBufferTarget, access); - glBindBuffer(kBufferTarget, 0); - return ptr; - } - - void* DataBuffer::MapRange(int offset, int size, uint32 access) - { - glBindBuffer(kBufferTarget, m_Handle); - void* ptr = glMapBufferRange(kBufferTarget, offset, size, access); - glBindBuffer(kBufferTarget, 0); - return ptr; - } - - void DataBuffer::FlushMapedRange(int offset, int size) - { - glBindBuffer(kBufferTarget, m_Handle); - glFlushMappedBufferRange(kBufferTarget, offset, size); - glBindBuffer(kBufferTarget, 0); - } - - void DataBuffer::UnMap() - { - glBindBuffer(kBufferTarget, m_Handle); - glUnmapBuffer(kBufferTarget); - glBindBuffer(kBufferTarget, 0); - } - - void DataBuffer::Orphan() - { - glBindBuffer(kBufferTarget, m_Handle); - glBufferData(kBufferTarget, 0, 0, GL_STREAM_DRAW); - glBindBuffer(kBufferTarget, 0); - } - - static bool IsBufferPoolCreated = false; - - BufferPool::BufferPool() - :m_LiveBuffers() - { - Assert(!IsBufferPoolCreated); - IsBufferPoolCreated = true; - } - - BufferPool::~BufferPool() - { - - } - - void BufferPool::Initialize() - { - for(int i = 0; i < kSizeClassCount; ++i) - m_LiveBuffers[i].clear(); - } - - static const float kBufferAllocateWeight = 10.0f; //! Default weight for buffer allocation from scratch. - static const float kBufferSizeWeightFactor = 1.f / 8096.f; //!< Weight factor for size difference. - static const float kBufferUsageDiffWeight = 8.f; //!< Weight factor for usage difference. - - static int ComputeBufferWeight(DataBuffer* buffer, int desiredSize, GLenum desiredUsage) - { - const int bufferSize = buffer->GetSize(); - const GLenum bufferUsage = buffer->GetUsage(); - - if(bufferSize == 0) - return kBufferAllocateWeight; - - const int sizeDiff = std::abs(bufferSize - desiredSize); - - return float(sizeDiff)*kBufferSizeWeightFactor + ((bufferUsage != desiredUsage) ? kBufferUsageDiffWeight : 0.f); - } - - DataBuffer* BufferPool::ClaimBuffer(int size, GLenum usage) - { - const float maxWeight = kBufferAllocateWeight; - const int maxCandidates = 5; // Number of potential candidates to consider actually. - - const int sizeClass = GetSizeClass(size); - int numCandidates = 0; // Number of potential candidates considered - int bestBufferNdx = -1; - float bestWeight = std::numeric_limits<float>::infinity(); - - for (int idx = 0; idx < m_LiveBuffers[sizeClass].size(); ++idx) - { - DataBuffer* buffer = m_LiveBuffers[sizeClass][idx]; - const float weight = ComputeBufferWeight(buffer, size, usage); - - if (weight < maxWeight && weight < bestWeight) - { - bestWeight = weight; - bestBufferNdx = idx; - ++numCandidates; - } - - if(numCandidates >= maxCandidates) - break; // Do not try other buffers, sorry. - } - - if (bestBufferNdx >= 0) - { - DataBuffer* selectedBuffer = m_LiveBuffers[sizeClass][bestBufferNdx]; - - if (bestBufferNdx + 1 != m_LiveBuffers[sizeClass].size()) - std::swap(m_LiveBuffers[sizeClass][bestBufferNdx], m_LiveBuffers[sizeClass].back()); - m_LiveBuffers[sizeClass].pop_back(); - - return selectedBuffer; - } - else - return new DataBuffer(); - - } - - void BufferPool::ReleaseBuffer(DataBuffer* buffer) - { - InsertToLive(buffer); - } - - void BufferPool::OnEndFrame() - { - UpdatePendingBuffersArray(); - } - - void BufferPool::UpdatePendingBuffersArray() - { - - } - - void BufferPool::InsertToLive(DataBuffer* buffer) - { - const int bufferSize = buffer->GetSize(); - const int sizeClass = GetSizeClass(bufferSize); - - m_LiveBuffers[sizeClass].push_back(buffer); - } - - uint BufferPool::GetSizeClass(uint bufferSize) - { - for (int idx = 0; idx < kSizeClassCount; ++idx) - { - if(bufferSize < GetSizeClassLimit(idx)) - return idx; - } - Assert(false); // never reach here - return 0; - } - - DataBuffer* ClaimBuffer(int size, GLenum usage ) - { - return BufferPool::Instance()->ClaimBuffer(size, usage); - } - - void ReleaseBuffer(DataBuffer* buffer) - { - BufferPool::Instance()->ReleaseBuffer(buffer); - } - -} 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 diff --git a/Runtime/Graphics/ImageData.h b/Runtime/Graphics/ImageData.h index 4525ee3..7bf0335 100644 --- a/Runtime/Graphics/ImageData.h +++ b/Runtime/Graphics/ImageData.h @@ -46,27 +46,4 @@ private: LUA_BIND_DECL_METHOD(_GetSize); }; -enum EImageDataAsyncError -{ - NoFile = 1, - ParseFailed = 2, - InvalidFormat = 3, -}; - -struct ImageDataRequest -{ - bool isDone, hasError; - int error; - int progress, all; - ImageData* result; - std::vector<ImageData*> results; -}; - -namespace ImageDataUtil -{ - ImageData* Load(const char* path); - ImageDataRequest* LoadAsync(const char* path); - ImageDataRequest* LoadAsync(std::vector<const char*> paths); -} - #endif
\ No newline at end of file diff --git a/Runtime/Graphics/OpenGL.h b/Runtime/Graphics/OpenGL.h index 69755e1..b1b777e 100644 --- a/Runtime/Graphics/OpenGL.h +++ b/Runtime/Graphics/OpenGL.h @@ -8,17 +8,26 @@ //http://docs.gl/gl3/glClear #define CheckGLError(action)\ -if(true){ \ - GLenum error; \ +if(true){ \ + GLenum error; \ while ((error = glGetError()) != GL_NO_ERROR) { \ - action \ - } \ + action \ + } \ } -class GLException : std::exception +extern std::string g_sharedGLErrorMsg; + +class GLException : public std::exception { +public: + GLException(const char* what) + : std::exception(what) + {} + GLException(int glError) + { + g_sharedGLErrorMsg = std::to_string(glError); + std::exception(g_sharedGLErrorMsg.c_str()); + } }; -extern std::string g_sharedGLErrorMsg; - -#endif +#endif
\ No newline at end of file diff --git a/Runtime/Graphics/Quad.cpp b/Runtime/Graphics/Quad.cpp index cbe8b74..aa4c9f5 100644 --- a/Runtime/Graphics/Quad.cpp +++ b/Runtime/Graphics/Quad.cpp @@ -1,52 +1,52 @@ -#include "../Math/Vector2.h" -#include "../Math/Vector3.h" -#include "Quad.h" -#include "Device.h" - -struct QuadVBOLayout -{ - Vector3 position; - Vector2 uv; -}; - -void Quad::Draw() -{ - const int nVerts = 4; - const int nIndices = 6; - - float pos[] = { - m_Left, m_Bottom, 0, // left-bottom - m_Right, m_Bottom, 0, // right-bottom - m_Right, m_Top, 0, // right-top - m_Left, m_Top, 0, // top-left - }; - float uv[] = { - 0, 0, - 1, 0, - 1, 1, - 0, 1, - }; - int indices[] = { - 0, 1, 3, // right-top - 1, 2, 3, // left-bottom - }; - - uint8* vb; - uint16* ib; - - uint attrs = Mask(VertexAttr_Position) | Mask(VertexAttr_TexCoord0); - g_SharedVBO.GetChunk(attrs, 4, 6, RenderMode_Triangle, (void**)&vb, (void**)&ib); - - QuadVBOLayout* dst = (QuadVBOLayout*)vb; - for (int i = 0; i < nVerts; ++i) - { - dst[i].position.Set(pos[3 * i], pos[3 * i + 1], pos[3 * i + 2]); - dst[i].uv.Set(uv[2 * i], uv[2 * i + 1]); - } - - for (int i = 0; i < nIndices; ++i) - ib[i] = indices[i]; - - g_SharedVBO.ReleaseChunk(4, 6); - g_SharedVBO.DrawChunk(); -}
\ No newline at end of file +//#include "../Math/Vector2.h" +//#include "../Math/Vector3.h" +//#include "Quad.h" +//#include "Device.h" +// +//struct QuadVBOLayout +//{ +// Vector3 position; +// Vector2 uv; +//}; +// +//void Quad::Draw() +//{ +// const int nVerts = 4; +// const int nIndices = 6; +// +// float pos[] = { +// m_Left, m_Bottom, 0, // left-bottom +// m_Right, m_Bottom, 0, // right-bottom +// m_Right, m_Top, 0, // right-top +// m_Left, m_Top, 0, // top-left +// }; +// float uv[] = { +// 0, 0, +// 1, 0, +// 1, 1, +// 0, 1, +// }; +// int indices[] = { +// 0, 1, 3, // right-top +// 1, 2, 3, // left-bottom +// }; +// +// uint8* vb; +// uint16* ib; +// +// uint attrs = Mask(VertexAttr_Position) | Mask(VertexAttr_TexCoord0); +// g_SharedVBO.GetChunk(attrs, 4, 6, RenderMode_Triangle, (void**)&vb, (void**)&ib); +// +// QuadVBOLayout* dst = (QuadVBOLayout*)vb; +// for (int i = 0; i < nVerts; ++i) +// { +// dst[i].position.Set(pos[3 * i], pos[3 * i + 1], pos[3 * i + 2]); +// dst[i].uv.Set(uv[2 * i], uv[2 * i + 1]); +// } +// +// for (int i = 0; i < nIndices; ++i) +// ib[i] = indices[i]; +// +// g_SharedVBO.ReleaseChunk(4, 6); +// g_SharedVBO.DrawChunk(); +//}
\ No newline at end of file diff --git a/Runtime/Graphics/Quad.h b/Runtime/Graphics/Quad.h index 0e38ec4..58db95a 100644 --- a/Runtime/Graphics/Quad.h +++ b/Runtime/Graphics/Quad.h @@ -1,25 +1,25 @@ -#ifndef QUAD_H -#define QUAD_H - -#include "../Utilities/UtilMacros.h" - -class Quad -{ -public: - Quad(float l, float r, float t, float b); - - void Set(float l, float r, float t, float b); - - GET_SET(float, Left, m_Left); - GET_SET(float, Right, m_Right); - GET_SET(float, Top, m_Top); - GET_SET(float, Bottom, m_Bottom); - - void Draw(); - -private: - float m_Left, m_Right, m_Top, m_Bottom; - -}; - -#endif
\ No newline at end of file +//#ifndef QUAD_H +//#define QUAD_H +// +//#include "../Utilities/UtilMacros.h" +// +//class Quad +//{ +//public: +// Quad(float l, float r, float t, float b); +// +// void Set(float l, float r, float t, float b); +// +// GET_SET(float, Left, m_Left); +// GET_SET(float, Right, m_Right); +// GET_SET(float, Top, m_Top); +// GET_SET(float, Bottom, m_Bottom); +// +// void Draw(); +// +//private: +// float m_Left, m_Right, m_Top, m_Bottom; +// +//}; +// +//#endif
\ No newline at end of file diff --git a/Runtime/Graphics/ShaderCompiler.cpp b/Runtime/Graphics/ShaderCompiler.cpp new file mode 100644 index 0000000..d68b64e --- /dev/null +++ b/Runtime/Graphics/ShaderCompiler.cpp @@ -0,0 +1,7 @@ +#include "ShaderCompiler.h"
+
+int GLSLCompiler::Compile(std::string& src, std::string& vsh, std::string& fsh)
+{
+
+ return 0;
+}
diff --git a/Runtime/Graphics/ShaderCompiler.h b/Runtime/Graphics/ShaderCompiler.h new file mode 100644 index 0000000..2917cf4 --- /dev/null +++ b/Runtime/Graphics/ShaderCompiler.h @@ -0,0 +1,33 @@ +#pragma once
+
+#include <string>
+#include "Runtime/Threading/Mutex.h"
+#include "Runtime/Threading/Job.h"
+
+// 编译GLSL(GameLab Shading Language)
+
+// in: .glsl path
+// out: vsh & fsh
+class CompileGLSLJob : public Job
+{
+
+};
+
+// in: glsl shader
+// out: vsh & fsh
+class CompileGLSLShaderJob : public Job
+{
+
+};
+
+enum EGLSLCompileErrorCode
+{
+ Success = 0,
+};
+
+class GLSLCompiler
+{
+public:
+ static int Compile(std::string& src, std::string& vsh, std::string& fsh);
+
+};
diff --git a/Runtime/Graphics/VertexBuffer.h b/Runtime/Graphics/VertexBuffer.h index 9179e0d..cf33cc5 100644 --- a/Runtime/Graphics/VertexBuffer.h +++ b/Runtime/Graphics/VertexBuffer.h @@ -7,7 +7,7 @@ #include "../Shaders/ShaderChannel.h" #include "OpenGL.h" -#include "GpuDataBuffer.h" +#include "GPUDataBuffers.h" enum VertexAttr { @@ -62,7 +62,8 @@ public: private: VertexBufferType m_Type; - GPU::DataBuffer *m_VB, *m_IB;// vertex buffer and index buffer + VBO *m_VB; + IBO *m_IB;// vertex buffer and index buffer }; @@ -87,7 +88,8 @@ private: enum { DataBufferThreshold = 1024 }; // shared vbo and ibo - GPU::DataBuffer *m_CurVB, *m_CurIB; + VBO *m_CurVB; + IBO *m_CurIB; // restore vbo and ibo data if not using pinned memory mapping std::vector<byte> m_CurVBData; |