diff options
author | chai <chaifix@163.com> | 2021-10-28 00:47:35 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-10-28 00:47:35 +0800 |
commit | 1b6f71b2777bdc74d63f988346a8cfee766718b0 (patch) | |
tree | ae710ba057f4841e7d0911eb4d3e0c346f79a524 /Runtime/Graphics/DefaultVertexLayout.h | |
parent | 305ca0a09d4e750186b5190432de47f3493e806a (diff) |
+DefaultVertexLayout
Diffstat (limited to 'Runtime/Graphics/DefaultVertexLayout.h')
-rw-r--r-- | Runtime/Graphics/DefaultVertexLayout.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Runtime/Graphics/DefaultVertexLayout.h b/Runtime/Graphics/DefaultVertexLayout.h new file mode 100644 index 0000000..2d78518 --- /dev/null +++ b/Runtime/Graphics/DefaultVertexLayout.h @@ -0,0 +1,52 @@ +#pragma once + +#include <vector> +#include "../Utilities/UtilMacros.h" +#include "../Shaders/ShaderChannel.h" +#include "OpenGL.h" +#include "GPUDataBuffer.h" +#include "VertexAttribute.h" + +// 默认的顶点布局,适用于Mesh导入的结果,保持shader的一致性 +// 如果需要修改布局,比如编辑器UI中,用CustomVertexLayout + +// 默认的顶点属性以及顺序 +enum EVertexAttr +{ + VertexAttr_Position = 0, + VertexAttr_Normal, + VertexAttr_Tangent, + VertexAttr_Color, + VertexAttr_UV, + VertexAttr_UV2, + VertexAttr_UV3, + VertexAttr_UV4, + + VertexAttr_Count +}; + +// GPU侧的默认顶点属性 +struct DefaultVertexLayout +{ + uint32 enableMask; + GLuint buffer; // vbo或者0(pinned memory) + VertexAttributeDescriptor attributes[VertexAttr_Count]; +}; + +namespace VertexLayout +{ + extern uint GetDefaultIndexSize(); + extern GLenum GetDefaultIndexFormat(); + + extern uint32 GetDynamicChunkStride(uint32 vertexAttrMask); + extern bool IsGLVertexAttrNeedNormalized(uint attr); + extern uint GetDefaultShaderChannelFormat(uint attr); + extern uint32 GetDefaultVertexAttrSize(int attr); + extern uint GetDefaultVertexAttrDimension(uint attr); + extern uint GetDefaultShaderChannelDimension(uint attr); + extern GLenum GetDefaultVertexAttrComponentType(uint attr); + + void SetupDefaultVertexLayout(const DefaultVertexLayout& info); + void InvalidateVertexInputCache(); + +} |