[Improvement] (HeaderSystem): Optimize header system, highly improving performance.

This commit is contained in:
BZLZHH
2025-07-10 14:01:09 +08:00
parent 833679e58a
commit 59e0291f9e
56 changed files with 52 additions and 199 deletions
+32 -82
View File
@@ -1,90 +1,9 @@
//
// Created by BZLZHH on 2025/3/15.
//
#pragma once
#include "Constants.h"
#define BACKEND_TYPE BACKEND_DILIGENT
#include "Global.h"
#ifndef MOBILEGL_GLES_LOADER_H
#include "MG_GL/BackendLoader/GLES/Loader.h"
#endif
#ifndef MOBILEGL_GL_FRAMEBUFFER_H
#include "MG_GL/Implementations/GL/Framebuffer/GL_Framebuffer.h"
#endif
#ifndef MOBILEGL_GL_GETTER_H
#include "MG_GL/Implementations/GL/Getter/GL_Getter.h"
#endif
#ifndef MOBILEGL_BACKENDINFO_H
#include "MG_GL/Implementations/GL/Getter/BackendInfo.h"
#endif
#ifndef MOBILEGL_GL_BUFFER_H
#include "MG_GL/Implementations/GL/Buffer/GL_Buffer.h"
#endif
#ifndef MOBILEGL_GL_DRAWING_H
#include "MG_GL/Implementations/GL/Drawing/GL_Drawing.h"
#endif
#ifndef MOBILEGL_GL_PROGRAM_H
#include "MG_GL/Implementations/GL/Program/GL_Program.h"
#endif
#ifndef MOBILEGL_GL_TEXTURE_H
#include "MG_GL/Implementations/GL/Texture/GL_Texture.h"
#endif
#ifndef MOBILEGL_GL_VERTEXARRAY_H
#include "MG_GL/Implementations/GL/VertexArray/GL_VertexArray.h"
#endif
#ifndef MOBILEGL_DILIGENT_EGL_IMPL_H
#include "MG_GL/Implementations/EGL/Diligent/EGL_impl.h"
#endif
#ifndef MOBILEGL_GLSTATE_H
#include "MG_GL/State/Core/GLState.h"
#endif
#ifndef MOBILEGL_COMMONSTATE_H
#include "MG_GL/State/Common/CommonState.h"
#endif
#ifndef MOBILEGL_TEXTURESTATE_H
#include "MG_GL/State/Texture/TextureState.h"
#endif
#ifndef MOBILEGL_VERTEXARRAYSTATE_H
#include "MG_GL/State/VertexArray/VertexArrayState.h"
#endif
#ifndef MOBILEGL_BUFFERSTATE_H
#include "MG_GL/State/Buffer/BufferState.h"
#endif
#ifndef MOBILEGL_SHADEROBJECT_H
#include "MG_GL/State/Program/ShaderObject.h"
#endif
#ifndef MOBILEGL_PROGRAMSTATE_H
#include "MG_GL/State/Program/ProgramState.h"
#endif
#ifndef MOBILEGL_FRAMEBUFFERSTATE_H
#include "MG_GL/State/Framebuffer/FramebufferState.h"
#endif
#ifndef MOBILEGL_LOOKUP_H
#include "MG_GL/Implementations/GLX/LookUp/LookUp.h"
#endif
#ifndef MOBILEGL_DEBUG_H
#include "MG_UTIL/Debug/Debug.h"
#endif
#ifndef MOBILEGL_GLSLTOOL_H
#include "MG_UTIL/Program/GLSLTool.h"
#endif
#ifndef MOBILEGL_PROGRAM_DEBUGTOOL_H
#include "MG_UTIL/Program/DebugTool.h"
#endif
#ifndef MOBILEGL_GL_COMMON_H
#include "MG_GL/Implementations/GL/Common/GL_Common.h"
#endif
#ifndef MOBILEGL_EGL_VK_EMU_H
#include "MG_GL/Implementations/EGL/VK/EGL_EMU.h"
#endif
#ifndef MOBILEGL_EGL_GLES_EGL_WRAP_H
#include "MG_GL/Implementations/EGL/GLES/EGL_WRAP.h"
#endif
#ifndef MOBILEGL_TESTDRAWING_H
#include "MG_RHI/GLES/Test/TestDrawing.h"
#endif
#include "MG_GL/Implementations/EGL/Diligent/DiligentConfig.h"
#include <cstring>
#include <iostream>
@@ -157,3 +76,34 @@
#include "GraphicsTypes.h"
#include "DeviceContext.h"
#endif
#include "Constants.h"
#include "Global.h"
#include "MG_GL/Implementations/EGL/Diligent/DiligentConfig.h"
#include "MG_GL/BackendLoader/GLES/Loader.h"
#include "MG_GL/Implementations/GL/Framebuffer/GL_Framebuffer.h"
#include "MG_GL/Implementations/GL/Getter/GL_Getter.h"
#include "MG_GL/Implementations/GL/Getter/BackendInfo.h"
#include "MG_GL/Implementations/GL/Buffer/GL_Buffer.h"
#include "MG_GL/Implementations/GL/Drawing/GL_Drawing.h"
#include "MG_GL/Implementations/GL/Program/GL_Program.h"
#include "MG_GL/Implementations/GL/Texture/GL_Texture.h"
#include "MG_GL/Implementations/GL/VertexArray/GL_VertexArray.h"
#include "MG_GL/State/Common/CommonState.h"
#include "MG_GL/State/Texture/TextureState.h"
#include "MG_GL/State/VertexArray/VertexArrayState.h"
#include "MG_GL/State/Buffer/BufferState.h"
#include "MG_GL/State/Program/ShaderObject.h"
#include "MG_GL/State/Program/ProgramState.h"
#include "MG_GL/State/Framebuffer/FramebufferState.h"
#include "MG_GL/State/Core/GLState.h"
#include "MG_GL/Implementations/EGL/Diligent/EGL_impl.h"
#include "MG_GL/Implementations/GLX/LookUp/LookUp.h"
#include "MG_UTIL/Debug/Debug.h"
#include "MG_UTIL/Program/GLSLTool.h"
#include "MG_UTIL/Program/DebugTool.h"
#include "MG_GL/Implementations/GL/Common/GL_Common.h"
#include "MG_GL/Implementations/EGL/VK/EGL_EMU.h"
#include "MG_GL/Implementations/EGL/GLES/EGL_WRAP.h"
#include "MG_RHI/GLES/Test/TestDrawing.h"
+1 -1
View File
@@ -2,7 +2,7 @@
// Created by BZLZHH on 2025/4/26.
//
#include "Loader.h"
#include "../../../Includes.h"
#if BACKEND_TYPE == BACKEND_GLES
-2
View File
@@ -5,8 +5,6 @@
#ifndef MOBILEGL_GLES_LOADER_H
#define MOBILEGL_GLES_LOADER_H
#include "../../../Includes.h"
#if BACKEND_TYPE == BACKEND_GLES
#define APIENTRY_GLES
@@ -3,7 +3,6 @@
//
#pragma once
#include "../../../../Includes.h"
namespace MG_Diligent {
inline const int DILIGENT_BACKEND_TYPE = MG_Constants::Backend::BACKEND_DILIGENT_VULKAN;
@@ -2,10 +2,6 @@
// Created by Swung 0x48 on 2025-05-18.
//
#include "EGL_impl.h"
#undef MOBILEGL_GLSLTOOL_H
#undef MOBILEGL_PROGRAM_DEBUGTOOL_H
#include "../../../../Includes.h"
typedef Diligent::IEngineFactoryVk* (*Diligent_GetEngineFactoryVk_t)();
@@ -5,8 +5,6 @@
#ifndef MOBILEGL_DILIGENT_EGL_IMPL_H
#define MOBILEGL_DILIGENT_EGL_IMPL_H
#include "../../../../Includes.h"
#if BACKEND_TYPE == BACKEND_DILIGENT
namespace MG_Diligent {
@@ -2,7 +2,7 @@
// Created by BZLZHH on 2025/4/26.
//
#include "EGL_WRAP.h"
#include "../../../../Includes.h"
#if BACKEND_TYPE == BACKEND_GLES
@@ -5,8 +5,6 @@
#ifndef MOBILEGL_EGL_GLES_EGL_WRAP_H
#define MOBILEGL_EGL_GLES_EGL_WRAP_H
#include "../../../../Includes.h"
#if BACKEND_TYPE == BACKEND_GLES
+1 -1
View File
@@ -2,7 +2,7 @@
// Created by BZLZHH on 2025/3/30.
//
#include "EGL_EMU.h"
#include "../../../../Includes.h"
#if BACKEND_TYPE == BACKEND_VULKAN
@@ -5,8 +5,6 @@
#ifndef MOBILEGL_EGL_VK_EMU_H
#define MOBILEGL_EGL_VK_EMU_H
#include "../../../../Includes.h"
#if BACKEND_TYPE == BACKEND_VULKAN
struct EGLInternalConfig {
@@ -2,7 +2,7 @@
// Created by BZLZHH on 2025/3/15.
//
#include "GL_Buffer.h"
#include "../../../../Includes.h"
namespace MG_GL::GL {
Diligent::VALUE_TYPE ConvertGLIndexTypeToDiligent(GLenum type) {
@@ -5,8 +5,6 @@
#ifndef MOBILEGL_GL_BUFFER_H
#define MOBILEGL_GL_BUFFER_H
#include "../../../../Includes.h"
namespace MG_GL::GL {
void* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length);
@@ -2,7 +2,7 @@
// Created by BZLZHH on 2025/3/15.
//
#include "GL_Common.h"
#include "../../../../Includes.h"
namespace MG_GL::GL {
void CreateRenderPassAndFramebuffer(GLuint framebuffer,
@@ -5,8 +5,6 @@
#ifndef MOBILEGL_GL_COMMON_H
#define MOBILEGL_GL_COMMON_H
#include "../../../../Includes.h"
namespace MG_GL::GL {
void ClearDepth(GLdouble depth);
void ClearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
@@ -2,7 +2,7 @@
// Created by BZLZHH on 2025/3/15.
//
#include "GL_Drawing.h"
#include "../../../../Includes.h"
namespace MG_GL::GL {
// void CreateRenderPassAndFramebuffer(GLuint framebuffer,
@@ -4,7 +4,6 @@
#ifndef MOBILEGL_GL_DRAWING_H
#define MOBILEGL_GL_DRAWING_H
#include "../../../../Includes.h"
namespace MG_GL::GL {
bool IsSamplerType(GLenum type);
@@ -2,7 +2,7 @@
// Created by BZLZHH on 2025/3/15.
//
#include "GL_Framebuffer.h"
#include "../../../../Includes.h"
namespace MG_GL::GL {
void ReleaseFramebufferResources(MG_Diligent::GLFramebufferInfo& fbInfo) {
@@ -5,8 +5,6 @@
#ifndef MOBILEGL_GL_FRAMEBUFFER_H
#define MOBILEGL_GL_FRAMEBUFFER_H
#include "../../../../Includes.h"
namespace MG_GL::GL {
void UpdateDefaultFramebuffer();
@@ -2,7 +2,7 @@
// Created by BZLZHH on 2025/3/15.
//
#include "GLFuncsDefinitions.h"
#include "../../../../Includes.h"
#define DECLARE_GL_FUNCTION_STUB_HEAD(type,name,...) \
MG_EXPORT type gl##name(__VA_ARGS__) {
@@ -5,6 +5,4 @@
#ifndef MOBILEGL_GL_FUNCS_DEFINITIONS_H
#define MOBILEGL_GL_FUNCS_DEFINITIONS_H
#include "../../../../Includes.h"
#endif //MOBILEGL_GL_FUNCS_DEFINITIONS_H
@@ -2,7 +2,7 @@
// Created by BZLZHH on 2025/3/15.
//
#include "BackendInfo.h"
#include "../../../../Includes.h"
namespace MG_GL::Getter {
const std::string GetBackendName() {
@@ -5,8 +5,6 @@
#ifndef MOBILEGL_BACKENDINFO_H
#define MOBILEGL_BACKENDINFO_H
#include "../../../../Includes.h"
namespace MG_GL::Getter {
const std::string GetGPUName();
const std::string GetBackendName();
@@ -2,7 +2,7 @@
// Created by BZLZHH on 2025/3/15.
//
#include "GL_Getter.h"
#include "../../../../Includes.h"
namespace MG_GL::GL {
static std::string rendererString;
@@ -5,8 +5,6 @@
#ifndef MOBILEGL_GL_GETTER_H
#define MOBILEGL_GL_GETTER_H
#include "../../../../Includes.h"
namespace MG_GL::GL {
const GLubyte* GetString(GLenum name);
const GLubyte* GetStringi(GLenum name, GLuint index);
@@ -2,9 +2,6 @@
// Created by BZLZHH on 2025/3/15.
//
#include "GL_Program.h"
#undef MOBILEGL_GLSLTOOL_H
#include "../../../../Includes.h"
namespace MG_GL::GL {
@@ -5,8 +5,6 @@
#ifndef MOBILEGL_GL_PROGRAM_H
#define MOBILEGL_GL_PROGRAM_H
#include "../../../../Includes.h"
namespace MG_GL::GL {
Diligent::VALUE_TYPE ConvertGLTypeToDiligent(GLenum type);
@@ -2,7 +2,7 @@
// Created by BZLZHH on 2025/3/15.
//
#include "GL_Texture.h"
#include "../../../../Includes.h"
namespace MG_GL::GL {
@@ -5,8 +5,6 @@
#ifndef MOBILEGL_GL_TEXTURE_H
#define MOBILEGL_GL_TEXTURE_H
#include "../../../../Includes.h"
namespace MG_GL::GL {
void ActiveTexture(GLenum texture);
void BindTexture(GLenum target, GLuint texture);
@@ -2,7 +2,7 @@
// Created by BZLZHH on 2025/3/15.
//
#include "GL_VertexArray.h"
#include "../../../../Includes.h"
namespace MG_GL::GL {
void GenVertexArrays(GLsizei n, GLuint* arrays) {
@@ -5,8 +5,6 @@
#ifndef MOBILEGL_GL_VERTEXARRAY_H
#define MOBILEGL_GL_VERTEXARRAY_H
#include "../../../../Includes.h"
namespace MG_GL::GL {
void GenVertexArrays(GLsizei n, GLuint* arrays);
void BindVertexArray(GLuint array);
@@ -2,7 +2,7 @@
// Created by Swung 0x48 on 2025/6/20.
//
#include "GLXFuncsDefinitions.h"
#include "../../../../Includes.h"
MG_EXPORT void* glXGetProcAddress(const char *name) {
return MG_GL::GLX::GetProcAddress(name);
@@ -5,6 +5,4 @@
#ifndef MOBILEGL_GLX_FUNCS_DEFINITIONS_H
#define MOBILEGL_GLX_FUNCS_DEFINITIONS_H
#include "../../../../Includes.h"
#endif //MOBILEGL_GLX_FUNCS_DEFINITIONS_H
+1 -1
View File
@@ -4,7 +4,7 @@
// TODO: Add more gl error check for buffer state manager.
#include "BufferState.h"
#include "../../../Includes.h"
//GLenum BufferState::GenName(GLuint *buffer) {
// MG_Util::Debug::LogD("MG_State: Buffer: GenName");
-4
View File
@@ -4,10 +4,6 @@
#ifndef MOBILEGL_BUFFERSTATE_H
#define MOBILEGL_BUFFERSTATE_H
#define MOBILEGL_GLSTATE_H
#define MOBILEGL_DILIGENT_EGL_IMPL_H
#include "../../../Includes.h"
class BufferState {
public:
+1 -1
View File
@@ -2,7 +2,7 @@
// Created by BZLZHH on 2025/4/30.
//
#include "CommonState.h"
#include "../../../Includes.h"
CommonState::CommonState() {
pixelStoreParams[GL_PACK_ALIGNMENT] = 4;
-4
View File
@@ -4,10 +4,6 @@
#ifndef MOBILEGL_COMMONSTATE_H
#define MOBILEGL_COMMONSTATE_H
#define MOBILEGL_GLSTATE_H
#define MOBILEGL_DILIGENT_EGL_IMPL_H
#include "../../../Includes.h"
class CommonState {
public:
+1 -1
View File
@@ -2,7 +2,7 @@
// Created by BZLZHH on 2025/4/4.
//
#include "GLState.h"
#include "../../../Includes.h"
std::queue<GLenum> MG_State_T::glErrorQueue;
TextureState* MG_State_T::textureState = nullptr;
-3
View File
@@ -4,9 +4,6 @@
#ifndef MOBILEGL_GLSTATE_H
#define MOBILEGL_GLSTATE_H
#define MOBILEGL_DILIGENT_EGL_IMPL_H
#include "../../../Includes.h"
struct MG_State_T {
static std::queue<GLenum> glErrorQueue;
@@ -5,10 +5,6 @@
// TODO: Add more gl error check for framebuffer state manager.
// TODO: Check if the state machine really meets up to OpenGL 3 standard.
#include "FramebufferState.h"
// Re-Include Includes.h, cuz of the absence of GLState.h
#undef MOBILEGL_GLSTATE_H
#include "../../../Includes.h"
GLenum FramebufferState::Create(GLuint* framebuffer) {
@@ -4,10 +4,6 @@
#ifndef MOBILEGL_FRAMEBUFFERSTATE_H
#define MOBILEGL_FRAMEBUFFERSTATE_H
#define MOBILEGL_GLSTATE_H
#define MOBILEGL_DILIGENT_EGL_IMPL_H
#include "../../../Includes.h"
struct FramebufferAttachment {
GLenum type = GL_NONE;
-5
View File
@@ -4,11 +4,6 @@
// TODO: Add more gl error check for buffer state manager.
// TODO: Check if the state machine really meets up to OpenGL 3 standard.
#include "ProgramState.h"
// Re-Include Includes.h, cuz of the absence of Program/DebugTool.h and Program/GLSLTool.cpp.
#undef MOBILEGL_GLSLTOOL_H
#undef MOBILEGL_PROGRAM_DEBUGTOOL_H
#include "../../../Includes.h"
ProgramState::ProgramState() {
-6
View File
@@ -4,12 +4,6 @@
#ifndef MOBILEGL_PROGRAMSTATE_H
#define MOBILEGL_PROGRAMSTATE_H
#define MOBILEGL_GLSTATE_H
#define MOBILEGL_DILIGENT_EGL_IMPL_H
#define MOBILEGL_PROGRAM_DEBUGTOOL_H
#define MOBILEGL_GLSLTOOL_H
#include "../../../Includes.h"
struct ShaderObject {
GLenum type;
-5
View File
@@ -2,11 +2,6 @@
// Created by BZLZHH on 2025/5/3.
//
#include "ShaderObject.h"
// Re-Include Includes.h, cuz of the absence of Program/DebugTool.h and Program/GLSLTool.cpp.
#undef MOBILEGL_GLSLTOOL_H
#undef MOBILEGL_PROGRAM_DEBUGTOOL_H
#include "../../../Includes.h"
GLenum ProgramState::CreateShader(GLenum type, GLuint* shader) {
-5
View File
@@ -5,9 +5,4 @@
#ifndef MOBILEGL_SHADEROBJECT_H
#define MOBILEGL_SHADEROBJECT_H
#define MOBILEGL_GLSTATE_H
#define MOBILEGL_DILIGENT_EGL_IMPL_H
#include "../../../Includes.h"
#endif //MOBILEGL_SHADEROBJECT_H
-4
View File
@@ -2,10 +2,6 @@
// Created by BZLZHH on 2025/4/4.
//
#include "TextureState.h"
// Re-Include Includes.h, cuz of the absence of GLState.h
#undef MOBILEGL_GLSTATE_H
#include "../../../Includes.h"
// TextureObject
-4
View File
@@ -4,10 +4,6 @@
#ifndef MOBILEGL_TEXTURESTATE_H
#define MOBILEGL_TEXTURESTATE_H
#define MOBILEGL_GLSTATE_H
#define MOBILEGL_DILIGENT_EGL_IMPL_H
#include "../../../Includes.h"
struct ComponentSizes {
GLint red = 0;
@@ -4,7 +4,7 @@
// TODO: Add more gl error check for vertex array state manager.
#include "VertexArrayState.h"
#include "../../../Includes.h"
VertexArrayState::VertexArrayState() {
vaos_[0];
@@ -4,10 +4,6 @@
#ifndef MOBILEGL_VERTEXARRAYSTATE_H
#define MOBILEGL_VERTEXARRAYSTATE_H
#define MOBILEGL_GLSTATE_H
#define MOBILEGL_DILIGENT_EGL_IMPL_H
#include "../../../Includes.h"
struct VertexAttribState {
bool enabled = false;
+1 -1
View File
@@ -2,7 +2,7 @@
// Created by BZLZHH on 2025/4/26.
//
#include "TestDrawing.h"
#include "../../../Includes.h"
namespace MG_RHI::GLES::Test {
constexpr int DISPLAY_COLUMNS = 8;
-2
View File
@@ -5,8 +5,6 @@
#ifndef MOBILEGL_TESTDRAWING_H
#define MOBILEGL_TESTDRAWING_H
#include "../../../Includes.h"
namespace MG_RHI::GLES::Test {
void DrawAllTextures();
}
-1
View File
@@ -2,7 +2,6 @@
// Created by BZLZHH on 2025/3/15.
//
#include "Debug.h"
#include "../../Includes.h"
#include "BlendState.h"
-2
View File
@@ -5,8 +5,6 @@
#ifndef MOBILEGL_DEBUG_H
#define MOBILEGL_DEBUG_H
#include "../../Includes.h"
#define FORCE_SYNC_WITH_LOG_FILE 0
namespace MG_Util {
+1 -1
View File
@@ -2,7 +2,7 @@
// Created by BZLZHH on 2025/5/3.
//
#include "DebugTool.h"
#include "../../Includes.h"
namespace MG_Util::Program {
std::string GLTypeToString(GLenum type) {
-1
View File
@@ -4,7 +4,6 @@
#ifndef MOBILEGL_PROGRAM_DEBUGTOOL_H
#define MOBILEGL_PROGRAM_DEBUGTOOL_H
#include "../../Includes.h"
namespace MG_Util::Program {
std::string GLTypeToString(GLenum type);
+1 -1
View File
@@ -2,7 +2,7 @@
// Created by BZLZHH on 2025/5/3.
//
#include "GLSLTool.h"
#include "../../Includes.h"
namespace MG_Util::Program {
void RenameGLSLBuiltinsForVulkan(std::string &src) {
-2
View File
@@ -5,8 +5,6 @@
#ifndef MOBILEGL_GLSLTOOL_H
#define MOBILEGL_GLSLTOOL_H
#include "../../Includes.h"
namespace MG_Util::Program {
inline static TBuiltInResource InitResources()
{