diff options
author | chai <chaifix@163.com> | 2021-10-27 23:37:24 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-10-27 23:37:24 +0800 |
commit | 305ca0a09d4e750186b5190432de47f3493e806a (patch) | |
tree | d82f9ef73191abc2acbcbfdca4b184a28e6c381b /Runtime/Graphics/VertexBuffer.h | |
parent | 51ced5a191078ce4ef08d57e343e91db007f556f (diff) |
*GfxDevice
Diffstat (limited to 'Runtime/Graphics/VertexBuffer.h')
-rw-r--r-- | Runtime/Graphics/VertexBuffer.h | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/Runtime/Graphics/VertexBuffer.h b/Runtime/Graphics/VertexBuffer.h index cf33cc5..b38b0b6 100644 --- a/Runtime/Graphics/VertexBuffer.h +++ b/Runtime/Graphics/VertexBuffer.h @@ -7,41 +7,44 @@ #include "../Shaders/ShaderChannel.h" #include "OpenGL.h" -#include "GPUDataBuffers.h" +#include "GPUDataBuffer.h" -enum VertexAttr +// 默认的顶点属性,够用了 +enum EVertexAttr { VertexAttr_Position = 0, - VertexAttr_Normal = 1, - VertexAttr_Tangent = 2, - VertexAttr_Color = 3, - VertexAttr_TexCoord0 = 4, - VertexAttr_TexCoord1 = 5, - - VertexAttr_Count = 6 + VertexAttr_Normal, + VertexAttr_Tangent, + VertexAttr_Color, + VertexAttr_UV, + VertexAttr_UV2, + VertexAttr_UV3, + VertexAttr_UV4, + + VertexAttr_Count }; -enum RenderMode +enum EPrimitive { - RenderMode_Triangle = 1, - RenderMode_Line = 2, - RenderMode_Point = 3, + Primitive_Triangle = 1, + Primitive_Line = 2, + Primitive_Point = 3, }; -struct VertexInputInfo +struct VertexAttributeDescriptor { - const void* pointer; // either cpu memory or gpu memory - uint componentType; // one of VertexAttrFormat + const void* pointer; // 内存或显存 + uint componentType; uint componentNum; uint16 stride; }; -// gpu side vertex attributes array -struct VertexArrayInfo +// GPU侧的顶点属性 +struct VertexDataInfo { uint32 enableMask; - GLuint buffers[VertexAttr_Count]; - VertexInputInfo attributes[VertexAttr_Count]; + GLuint buffer; + VertexAttributeDescriptor attributes[VertexAttr_Count]; }; class VertexBuffer @@ -62,8 +65,8 @@ public: private: VertexBufferType m_Type; - VBO *m_VB; - IBO *m_IB;// vertex buffer and index buffer + GPU::DataBuffer *m_VB; + GPU::DataBuffer *m_IB;// vertex buffer and index buffer }; @@ -73,14 +76,14 @@ public: SharedVertexBuffer(); ~SharedVertexBuffer(); - void GetChunk(uint attrs, int maxVerts, int maxIndices, RenderMode mode, void **out_vb, void **out_ib); + void GetChunk(uint attrs, int maxVerts, int maxIndices, EPrimitive primitive, void **out_vb, void **out_ib); void ReleaseChunk(int actualVerts, int actualIndices); void DrawChunk(); private: - void FillVertexArrayInfo(VertexArrayInfo& dst); + void FillVertexArrayInfo(VertexDataInfo& dst); void Clean(); @@ -88,14 +91,14 @@ private: enum { DataBufferThreshold = 1024 }; // shared vbo and ibo - VBO *m_CurVB; - IBO *m_CurIB; + GPU::DataBuffer *m_CurVB; + GPU::DataBuffer *m_CurIB; // restore vbo and ibo data if not using pinned memory mapping std::vector<byte> m_CurVBData; std::vector<uint16> m_CurIBData; - RenderMode m_CurRenderMode; + EPrimitive m_CurPrimitive; uint m_CurAttrMask; uint m_CurStride; |