From 42f26ac59e1e8c8c23e609c228105dcd30919c55 Mon Sep 17 00:00:00 2001 From: Light Date: Sun, 1 Aug 2021 11:57:51 +0430 Subject: [PATCH] Maintenance - Added LIGHT_OPENGL_ENABLE_SHADER_INFO_LOG to config.h - Some maintenance --- Engine/src/Engine/Base/Base.h | 18 +++++++---- Engine/src/Engine/Base/Config.h | 14 +++++++-- Engine/src/Engine/Base/Portables/DebugTrap.h | 7 +++-- Engine/src/Engine/Core/Application.cpp | 1 + Engine/src/Engine/Debug/Exceptions.h | 4 ++- Engine/src/Engine/Debug/Instrumentor.h | 9 +++++- Engine/src/Engine/Debug/Logger.h | 4 ++- Engine/src/Engine/Utility/Stringifier.h | 6 +++- .../GraphicsAPI/DirectX/dxGraphicsContext.cpp | 2 -- .../Platform/GraphicsAPI/OpenGL/glShader.cpp | 30 ++++++++++++++++++- Mirror/src/Panels/SceneHierarchyPanel.cpp | 4 ++- 11 files changed, 82 insertions(+), 17 deletions(-) diff --git a/Engine/src/Engine/Base/Base.h b/Engine/src/Engine/Base/Base.h index 1dcc817..7e9f5bb 100644 --- a/Engine/src/Engine/Base/Base.h +++ b/Engine/src/Engine/Base/Base.h @@ -76,16 +76,24 @@ namespace Light { //====================================================================== OPERATIONS ======================================================================// //========== ESSENTIAL_HEADERS ==========// +/* config */ +#ifndef LIGHT_CONFIG_H + #include "Base/Config.h" +#endif + /* debug */ -#ifndef LT_LOGGER_H -#include "Debug/Logger.h" -#define LT_LOGGER_H +#ifndef LIGHT_LOGGER_H + #include "Debug/Logger.h" #endif #include "Debug/Exceptions.h" /* portables */ -#include "Base/Portables/DebugTrap.h" +#ifndef LIGHT_DEBUG_TRAP_H + #include "Base/Portables/DebugTrap.h" +#endif /* utility */ -#include "Utility/Stringifier.h" +#ifndef LIGHT_STRINGIFIER_H + #include "Utility/Stringifier.h" +#endif //========== ESSENTIAL_HEADERS ==========// \ No newline at end of file diff --git a/Engine/src/Engine/Base/Config.h b/Engine/src/Engine/Base/Config.h index e646ddb..e697914 100644 --- a/Engine/src/Engine/Base/Config.h +++ b/Engine/src/Engine/Base/Config.h @@ -1,5 +1,15 @@ #pragma once +#ifndef LIGHT_CONFIG_H +#define LIGHT_CONFIG_H -// #todo: add project config stuff +// +// you can uncomment any of these definitions to config the project to your liking +// -// #define LIGHT_IGNORE_UNDEFINED_DEBUG_BREAK \ No newline at end of file +// suppress undefined debug trap +// #define LIGHT_IGNORE_UNDEFINED_DEBUG_TRAP + +// log opengl shader compile info +// #define LIGHT_OPENGL_ENABLE_SHADER_INFO_LOG + +#endif \ No newline at end of file diff --git a/Engine/src/Engine/Base/Portables/DebugTrap.h b/Engine/src/Engine/Base/Portables/DebugTrap.h index 3e3789b..0e736c2 100644 --- a/Engine/src/Engine/Base/Portables/DebugTrap.h +++ b/Engine/src/Engine/Base/Portables/DebugTrap.h @@ -1,4 +1,6 @@ #pragma once +#ifndef LIGHT_DEBUG_TRAP_H +#define LIGHT_DEBUG_TRAP_H // https://github.com/nemequ/portable-snippets/tree/master/debug-trap @@ -80,8 +82,8 @@ #endif #if !defined(LT_DEBUG_TRAP) - #if !defined(LIGHT_IGNORE_UNDEFINED_DEBUG_BREAK) - #error "failed to define LT_BREAK, define LIGHT_IGNORE_UNDEFINED_DEBUG_BREAK to disable this error" + #if !defined(LIGHT_IGNORE_UNDEFINED_DEBUG_TRAP) + #error "failed to define LT_BREAK, define LIGHT_IGNORE_UNDEFINED_DEBUG_TRAP in Config.h to disable this error" #elif defined(LIGHT_DIST) #ifdef _MSC_VER @@ -100,4 +102,5 @@ #endif #endif +#endif #endif \ No newline at end of file diff --git a/Engine/src/Engine/Core/Application.cpp b/Engine/src/Engine/Core/Application.cpp index 0760b31..6a1115b 100644 --- a/Engine/src/Engine/Core/Application.cpp +++ b/Engine/src/Engine/Core/Application.cpp @@ -66,6 +66,7 @@ namespace Light { { // update layers LT_PROFILE_SCOPE("GameLoop::Update"); + LT_PROFILE_SCOPE("GameLoop::Updated"); for (auto it = m_LayerStack->begin(); it != m_LayerStack->end(); it++) (*it)->OnUpdate(deltaTimer.GetDeltaTime()); diff --git a/Engine/src/Engine/Debug/Exceptions.h b/Engine/src/Engine/Debug/Exceptions.h index e8537fc..f4a192e 100644 --- a/Engine/src/Engine/Debug/Exceptions.h +++ b/Engine/src/Engine/Debug/Exceptions.h @@ -1,6 +1,8 @@ #pragma once -#define DXC(x) if(FAILED(hr = x)) throw dxException(hr, __FILE__, __LINE__) +#define DXC(x) DXC_NO_REDIFINITION(x, __LINE__) +#define DXC_NO_REDIFINITION(x, line) DXC_NO_REDIFINITION2(x, line) +#define DXC_NO_REDIFINITION2(x, line) HRESULT hr##line; if(FAILED(hr##line = x)) throw dxException(hr##line, __FILE__, line) namespace Light { diff --git a/Engine/src/Engine/Debug/Instrumentor.h b/Engine/src/Engine/Debug/Instrumentor.h index a95d0b2..f76d5f3 100644 --- a/Engine/src/Engine/Debug/Instrumentor.h +++ b/Engine/src/Engine/Debug/Instrumentor.h @@ -56,7 +56,14 @@ namespace Light { } -#define LT_PROFILE_SCOPE(name) InstrumentorTimer timer##__LINE__ (name) +/* scope */ +#define LT_PROFILE_SCOPE(name) LT_PROFILE_SCOPE_NO_REDIFINITION(name, __LINE__) +#define LT_PROFILE_SCOPE_NO_REDIFINITION(name, line) LT_PROFILE_SCOPE_NO_REDIFINITION2(name, line) +#define LT_PROFILE_SCOPE_NO_REDIFINITION2(name, line) InstrumentorTimer timer##line(name) + +/* function */ #define LT_PROFILE_FUNCTION LT_PROFILE_SCOPE(__FUNCSIG__) + +/* session */ #define LT_PROFILE_BEGIN_SESSION(outputPath) ::Light::Instrumentor::BeginSession(outputPath) #define LT_PROFILE_END_SESSION() ::Light::Instrumentor::EndSession() diff --git a/Engine/src/Engine/Debug/Logger.h b/Engine/src/Engine/Debug/Logger.h index 9b12ce1..197e989 100644 --- a/Engine/src/Engine/Debug/Logger.h +++ b/Engine/src/Engine/Debug/Logger.h @@ -1,6 +1,7 @@ #pragma once +#ifndef LIGHT_LOGGER_H +#define LIGHT_LOGGER_H -#define LT_LOGGER_H #include "Base/Base.h" #include @@ -68,3 +69,4 @@ namespace Light { } +#endif \ No newline at end of file diff --git a/Engine/src/Engine/Utility/Stringifier.h b/Engine/src/Engine/Utility/Stringifier.h index 7d5152b..fa74c18 100644 --- a/Engine/src/Engine/Utility/Stringifier.h +++ b/Engine/src/Engine/Utility/Stringifier.h @@ -1,4 +1,6 @@ #pragma once +#ifndef LIGHT_STRINGIFIER_H +#define LIGHT_STRINGIFIER_H #include "Base/Base.h" @@ -18,4 +20,6 @@ namespace Light { static std::string GraphicsAPIToString(GraphicsAPI api); }; -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Engine/src/Platform/GraphicsAPI/DirectX/dxGraphicsContext.cpp b/Engine/src/Platform/GraphicsAPI/DirectX/dxGraphicsContext.cpp index 97a4e0b..642f4ec 100644 --- a/Engine/src/Platform/GraphicsAPI/DirectX/dxGraphicsContext.cpp +++ b/Engine/src/Platform/GraphicsAPI/DirectX/dxGraphicsContext.cpp @@ -73,7 +73,6 @@ namespace Light { #endif // create device and swap chain - HRESULT hr; DXC(D3D11CreateDeviceAndSwapChain(nullptr, D3D_DRIVER_TYPE_HARDWARE, NULL, @@ -99,7 +98,6 @@ namespace Light { // create render target view Microsoft::WRL::ComPtr backBuffer; - HRESULT hr; DXC(context->GetSwapChain()->GetBuffer(0u, __uuidof(ID3D11Resource), &backBuffer)); DXC(context->GetDevice()->CreateRenderTargetView(backBuffer.Get(), nullptr, &context->GetRenderTargetViewRef())); diff --git a/Engine/src/Platform/GraphicsAPI/OpenGL/glShader.cpp b/Engine/src/Platform/GraphicsAPI/OpenGL/glShader.cpp index f93c503..0f7db90 100644 --- a/Engine/src/Platform/GraphicsAPI/OpenGL/glShader.cpp +++ b/Engine/src/Platform/GraphicsAPI/OpenGL/glShader.cpp @@ -67,13 +67,41 @@ namespace Light { } /* #TEMP_HANDLE_SHADER_COMPILE_FAILURE# */ + +#ifdef LIGHT_OPENGL_ENABLE_SHADER_INFO_LOG + { + int logLength = 0; + glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &logLength); + if(logLength) + { + char* infoLog = (char*)alloca(logLength); + glGetShaderInfoLog(vertexShader, logLength, &logLength, &infoLog[0]); + + LT_ENGINE_TRACE(infoLog); + } + } + + { + int logLength = 0; + glGetShaderiv(fragmentShader, GL_INFO_LOG_LENGTH, &logLength); + if (logLength) + { + char* infoLog = (char*)alloca(logLength); + glGetShaderInfoLog(fragmentShader, logLength, &logLength, &infoLog[0]); + + LT_ENGINE_TRACE(infoLog); + } + } +#endif + + // attach shaders glAttachShader(m_ShaderID, vertexShader); glAttachShader(m_ShaderID, fragmentShader); // link shader program glLinkProgram(m_ShaderID); - + // delete shaders (free memory) glDeleteShader(vertexShader); glDeleteShader(fragmentShader); diff --git a/Mirror/src/Panels/SceneHierarchyPanel.cpp b/Mirror/src/Panels/SceneHierarchyPanel.cpp index e6b7e1e..2522402 100644 --- a/Mirror/src/Panels/SceneHierarchyPanel.cpp +++ b/Mirror/src/Panels/SceneHierarchyPanel.cpp @@ -36,7 +36,9 @@ namespace Light { void SceneHierarchyPanel::DrawNode(Entity entity, const std::string& label) { - ImGuiTreeNodeFlags flags = (m_SelectionContext == entity ? ImGuiTreeNodeFlags_Selected : NULL) | ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_SpanFullWidth; + ImGuiTreeNodeFlags flags = (m_SelectionContext == entity ? ImGuiTreeNodeFlags_Selected : NULL) | + ImGuiTreeNodeFlags_OpenOnArrow | + ImGuiTreeNodeFlags_SpanFullWidth ; bool expanded = ImGui::TreeNodeEx((void*)(uint64_t)(uint32_t)(entity), flags, label.c_str());