diff --git a/GlitchLog/src/DebugLogger.bf b/GlitchLog/src/DebugLogger.bf index 056e6bf..3c36a86 100644 --- a/GlitchLog/src/DebugLogger.bf +++ b/GlitchLog/src/DebugLogger.bf @@ -53,7 +53,7 @@ namespace GlitchLog //Debug.Assert(Debug.IsDebuggerPresent, "The DebugLogger requires a debugger to be present."); } -#if GL_NOLOG || GL_NOTRACE +#if GL_NOLOG || GL_LOG_NOTRACE [SkipCall] #endif [Inline] @@ -62,7 +62,7 @@ namespace GlitchLog InternalLog(.Trace, format, params args); } -#if GL_NOLOG || GL_NOINFO +#if GL_NOLOG || GL_LOG_NOINFO [SkipCall] #endif [Inline] @@ -71,7 +71,7 @@ namespace GlitchLog InternalLog(.Info, format, params args); } -#if GL_NOLOG || GL_NOWARNING +#if GL_NOLOG || GL_LOG_NOWARNING [SkipCall] #endif [Inline] @@ -80,7 +80,7 @@ namespace GlitchLog InternalLog(.Warning, format, params args); } -#if GL_NOLOG || GL_NOERROR +#if GL_NOLOG || GL_LOG_NOERROR [SkipCall] #endif [Inline] @@ -89,7 +89,7 @@ namespace GlitchLog InternalLog(.Error, format, params args); } -#if GL_NOLOG || GL_NOCRITICAL +#if GL_NOLOG || GL_LOG_NOCRITICAL [SkipCall] #endif [Inline] diff --git a/GlitchyEngine/BeefProj.toml b/GlitchyEngine/BeefProj.toml index c24ad3b..c93ac82 100644 --- a/GlitchyEngine/BeefProj.toml +++ b/GlitchyEngine/BeefProj.toml @@ -1,21 +1,12 @@ FileVersion = 1 -Dependencies = {GlitchLog = "*", corlib = "*", DirectX = "*", DirectXTK = "*", FreeType = "*", cgltf-beef = "*", msdfgen-beef = "*", ImGui = "*", ImGuiImplDX11 = "*", ImGuiImplWin32 = "*", ImGuizmo = "*"} +Dependencies = {GlitchLog = "*", corlib = "*", DirectX = "*", DirectXTK = "*", FreeType = "*", cgltf-beef = "*", msdfgen-beef = "*", ImGui = "*", ImGuiImplDX11 = "*", ImGuiImplWin32 = "*", ImGuizmo = "*", Beefy2D = "*"} [Project] Name = "GlitchyEngine" ProcessorMacros = ["GE_ERROR_SHADER_MATRIX_MISMATCH", "GE_ERROR_SHADER_VAR_TYPE_MISMATCH"] -[Configs.Debug.Win32] -PreprocessorMacros = ["DEBUG", "GE_WINDOWS"] - [Configs.Debug.Win64] -PreprocessorMacros = ["DEBUG", "GE_WINDOWS", "GE_D3D11"] - -[Configs.Release.Win32] -PreprocessorMacros = ["RELEASE", "GE_WINDOWS"] - -[Configs.Release.Win64] -PreprocessorMacros = ["RELEASE", "GE_WINDOWS"] +PreprocessorMacros = ["DEBUG", "GE_GRAPHICS_DX11", "GE_PROFILE"] [Configs.Paranoid.Win32] PreprocessorMacros = ["DEBUG", "PARANOID", "GE_WINDOWS"] @@ -23,6 +14,12 @@ PreprocessorMacros = ["DEBUG", "PARANOID", "GE_WINDOWS"] [Configs.Paranoid.Win64] PreprocessorMacros = ["DEBUG", "PARANOID", "GE_WINDOWS"] +[Configs.Release.Win32] +PreprocessorMacros = ["RELEASE", "GE_WINDOWS"] + +[Configs.Release.Win64] +PreprocessorMacros = ["RELEASE", "GE_WINDOWS"] + [Configs.Test.Win32] PreprocessorMacros = ["TEST", "GE_WINDOWS"] diff --git a/GlitchyEngine/src/Application.bf b/GlitchyEngine/src/Application.bf index 26ade29..dcfe24b 100644 --- a/GlitchyEngine/src/Application.bf +++ b/GlitchyEngine/src/Application.bf @@ -81,7 +81,7 @@ namespace GlitchyEngine } } -#if APP_SINGLESTEP +#if GE_APP_SINGLESTEP bool allowFrame = false; bool disableSingleFrame = false; #else @@ -99,7 +99,7 @@ namespace GlitchyEngine Input.NewFrame(); -#if APP_SINGLESTEP +#if GE_APP_SINGLESTEP allowFrame = disableSingleFrame || Input.IsKeyPressing(Key.F10); if(Input.IsKeyPressing(Key.F11)) diff --git a/GlitchyEngine/src/Debug/Profiler.bf b/GlitchyEngine/src/Debug/Profiler.bf new file mode 100644 index 0000000..5b6571c --- /dev/null +++ b/GlitchyEngine/src/Debug/Profiler.bf @@ -0,0 +1,61 @@ +using System; +using Beefy.utils; + +namespace GlitchyEngine.Debug +{ + public static class Profiler + { +#if !GE_PROFILE + [SkipCall] +#endif + public static void BeginProfiling(StringView serverName = "127.0.0.1", StringView sessionName = "GlitchyEngine") + { + BeefPerf.Init(serverName, sessionName); + } + +#if !GE_PROFILE + [SkipCall] +#endif + public static void EndProfiling() + { + BeefPerf.Shutdown(); + } + +#if !GE_PROFILE + [SkipCall] +#endif + public static mixin ProfileFunction() + { + scope:mixin PerformanceTimer() + } + +#if !GE_PROFILE + [SkipCall] +#endif + public static mixin ProfileScope(char8* scopeName) + { + scope:mixin PerformanceTimer(scopeName) + } + } + + class PerformanceTimer + { + [Inline] + public this(char8* name = Compiler.CallerMemberName) + { +#if GE_PROFILE + [Inline] + BeefPerf.Enter(name); +#endif + } + + [Inline] + public ~this() + { +#if GE_PROFILE + [Inline] + BeefPerf.Leave(); +#endif + } + } +} diff --git a/GlitchyEngine/src/ImGui/ImGuiLayer.bf b/GlitchyEngine/src/ImGui/ImGuiLayer.bf index 70ab886..a2ebbe6 100644 --- a/GlitchyEngine/src/ImGui/ImGuiLayer.bf +++ b/GlitchyEngine/src/ImGui/ImGuiLayer.bf @@ -5,7 +5,7 @@ using ImGuizmo; using internal ImGui; -#if GE_D3D11 +#if GE_GRAPHICS_DX11 using GlitchyEngine.Platform.DX11; using internal GlitchyEngine.Platform.DX11; @@ -44,12 +44,12 @@ namespace GlitchyEngine.ImGui style.Colors[(int)ImGui.Col.WindowBg].w = 1.0f; } -#if GE_WINDOWS +#if BF_PLATFORM_WINDOWS // Todo: temporary, needs to be platform independent ImGuiImplWin32.Init((void*)(uint)(Windows.HWnd)(int)Application.Get().Window.NativeWindow); #endif -#if GE_D3D11 +#if GE_GRAPHICS_DX11 ImGuiImplDX11.Init(NativeDevice, NativeContext); #endif } diff --git a/GlitchyEngine/src/Platform/DX11/Dx11Platform.bf b/GlitchyEngine/src/Platform/DX11/Dx11Platform.bf index d1c04ff..90cbe1f 100644 --- a/GlitchyEngine/src/Platform/DX11/Dx11Platform.bf +++ b/GlitchyEngine/src/Platform/DX11/Dx11Platform.bf @@ -1,3 +1,9 @@ +#if GE_GRAPHICS_DX11 + +#if !BF_PLATFORM_WINDOWS +#error DirectX 11 (GE_GRAPHICS_DX11) can on be used on Windows. +#endif + using DirectX.Common; using DirectX.D3D11; using DirectX.D3D11.SDKLayers; @@ -64,3 +70,5 @@ namespace GlitchyEngine.Platform.DX11 } } } + +#endif diff --git a/GlitchyEngine/src/Platform/DX11/ImGui/ImGui.bf b/GlitchyEngine/src/Platform/DX11/ImGui/ImGui.bf index 99d637c..ae4c04d 100644 --- a/GlitchyEngine/src/Platform/DX11/ImGui/ImGui.bf +++ b/GlitchyEngine/src/Platform/DX11/ImGui/ImGui.bf @@ -1,4 +1,4 @@ -#if GE_D3D11 +#if GE_GRAPHICS_DX11 using GlitchyEngine.Renderer; using System.Collections; diff --git a/GlitchyEngine/src/Platform/DX11/Math/Vector.bf b/GlitchyEngine/src/Platform/DX11/Math/Vector.bf index 322901d..18cd634 100644 --- a/GlitchyEngine/src/Platform/DX11/Math/Vector.bf +++ b/GlitchyEngine/src/Platform/DX11/Math/Vector.bf @@ -1,4 +1,4 @@ -#if GE_D3D11 +#if GE_GRAPHICS_DX11 // Disable warning when taking pointer of in-Parameter #pragma warning disable 4204 diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11BlendState.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11BlendState.bf index b68e070..192b32f 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11BlendState.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11BlendState.bf @@ -1,4 +1,4 @@ -#if GE_D3D11 +#if GE_GRAPHICS_DX11 using DirectX.D3D11; using DirectX.Common; diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Buffer.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Buffer.bf index dc612df..2a590b2 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Buffer.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Buffer.bf @@ -1,4 +1,4 @@ -#if GE_D3D11 +#if GE_GRAPHICS_DX11 using System.Diagnostics; using System; diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11BufferCollection.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11BufferCollection.bf index 050430e..b5d3165 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11BufferCollection.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11BufferCollection.bf @@ -1,4 +1,4 @@ -#if GE_D3D11 +#if GE_GRAPHICS_DX11 using DirectX.D3D11; diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11CPUAccessFlags.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11CPUAccessFlags.bf index 6b48d6a..fffa60e 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11CPUAccessFlags.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11CPUAccessFlags.bf @@ -1,4 +1,4 @@ -#if GE_D3D11 +#if GE_GRAPHICS_DX11 namespace GlitchyEngine.Renderer { diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11ConstantBuffer.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11ConstantBuffer.bf index 2508943..16fbc1f 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11ConstantBuffer.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11ConstantBuffer.bf @@ -1,4 +1,4 @@ -#if GE_D3D11 +#if GE_GRAPHICS_DX11 using DirectX.Common; using DirectX.D3D11Shader; diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11DepthStencilTarget.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11DepthStencilTarget.bf index 17660bd..e84f4d0 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11DepthStencilTarget.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11DepthStencilTarget.bf @@ -1,4 +1,4 @@ -#if GE_D3D11 +#if GE_GRAPHICS_DX11 using DirectX.D3D11; using internal GlitchyEngine.Renderer; diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Effect.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Effect.bf index e8e5d1f..ef32e98 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Effect.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Effect.bf @@ -1,4 +1,4 @@ -#if GE_D3D11 +#if GE_GRAPHICS_DX11 using System; using DirectX; diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11GeometryBinding.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11GeometryBinding.bf index 5ad3189..f9f4e52 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11GeometryBinding.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11GeometryBinding.bf @@ -1,4 +1,4 @@ -#if GE_D3D11 +#if GE_GRAPHICS_DX11 using System; using DirectX.D3D11; diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11GraphicsContext.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11GraphicsContext.bf index 747f5bf..fbfaf89 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11GraphicsContext.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11GraphicsContext.bf @@ -1,4 +1,4 @@ -#if GE_D3D11 +#if GE_GRAPHICS_DX11 using System; using System.Diagnostics; diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11PixelShader.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11PixelShader.bf index 8d1b25a..2bf15a6 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11PixelShader.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11PixelShader.bf @@ -1,4 +1,4 @@ -#if GE_D3D11 +#if GE_GRAPHICS_DX11 using System; using DirectX.D3D11; diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11RasterizerState.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11RasterizerState.bf index 7c3ddc5..2182eb3 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11RasterizerState.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11RasterizerState.bf @@ -1,4 +1,4 @@ -#if GE_D3D11 +#if GE_GRAPHICS_DX11 using DirectX.D3D11; using GlitchyEngine.Platform.DX11; diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11RenderTarget.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11RenderTarget.bf index cee7c93..aa9c3ad 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11RenderTarget.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11RenderTarget.bf @@ -1,4 +1,4 @@ -#if GE_D3D11 +#if GE_GRAPHICS_DX11 using DirectX.Common; using DirectX.D3D11; diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11RendererAPI.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11RendererAPI.bf index 2e8085c..3c4bfae 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11RendererAPI.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11RendererAPI.bf @@ -1,4 +1,4 @@ -#if GE_D3D11 +#if GE_GRAPHICS_DX11 using GlitchyEngine.Math; using GlitchyEngine.Platform.DX11; diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11SamplerState.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11SamplerState.bf index 2986f5f..982c73e 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11SamplerState.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11SamplerState.bf @@ -1,4 +1,4 @@ -#if GE_D3D11 +#if GE_GRAPHICS_DX11 using DirectX.Common; using DirectX.D3D11; diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Shader.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Shader.bf index 5e8d179..17cb370 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Shader.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Shader.bf @@ -1,4 +1,4 @@ -#if GE_D3D11 +#if GE_GRAPHICS_DX11 using System; using GlitchyEngine.Renderer; diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11SwapChain.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11SwapChain.bf index 0468ccb..3841fe8 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11SwapChain.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11SwapChain.bf @@ -1,4 +1,4 @@ -#if GE_D3D11 +#if GE_GRAPHICS_DX11 using DirectX.D3D11; using DirectX.DXGI.DXGI1_2; diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Texture.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Texture.bf index e85affd..8115c88 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Texture.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Texture.bf @@ -1,4 +1,4 @@ -#if GE_D3D11 +#if GE_GRAPHICS_DX11 using System; using DirectX.D3D11; diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11VertexLayout.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11VertexLayout.bf index 3a646ce..2eaf345 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11VertexLayout.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11VertexLayout.bf @@ -1,4 +1,4 @@ -#if GE_D3D11 +#if GE_GRAPHICS_DX11 using System; using System.Diagnostics; diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11VertexShader.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11VertexShader.bf index 8023abb..bb68426 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11VertexShader.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11VertexShader.bf @@ -1,4 +1,4 @@ -#if GE_D3D11 +#if GE_GRAPHICS_DX11 using System; using GlitchyEngine.Renderer; diff --git a/GlitchyEngine/src/Platform/Windows/WindowsInput.bf b/GlitchyEngine/src/Platform/Windows/WindowsInput.bf index 95259eb..04426b7 100644 --- a/GlitchyEngine/src/Platform/Windows/WindowsInput.bf +++ b/GlitchyEngine/src/Platform/Windows/WindowsInput.bf @@ -1,3 +1,5 @@ +#if BF_PLATFORM_WINDOWS + using System; using GlitchyEngine.Events; using DirectX.Windows.VirtualKeyCodes; @@ -7,8 +9,6 @@ using static System.Windows; namespace GlitchyEngine { - -#if GE_WINDOWS /// Windows (WinApi) specific implementation of the Input-class extension Input { @@ -192,5 +192,6 @@ namespace GlitchyEngine CurrentState.CursorPositionDifference = CurrentState.CursorPosition - LastState.CursorPosition; } } -#endif } + +#endif diff --git a/GlitchyEngine/src/Platform/Windows/WindowsWindow.bf b/GlitchyEngine/src/Platform/Windows/WindowsWindow.bf index e1e7f5e..dea5a76 100644 --- a/GlitchyEngine/src/Platform/Windows/WindowsWindow.bf +++ b/GlitchyEngine/src/Platform/Windows/WindowsWindow.bf @@ -1,4 +1,5 @@ -#if GE_WINDOWS +#if BF_PLATFORM_WINDOWS + using System; using DirectX.Common; using DirectX.Windows; @@ -539,4 +540,5 @@ namespace GlitchyEngine } } } + #endif \ No newline at end of file diff --git a/GlitchyEngine/src/Renderer/BufferVariable.bf b/GlitchyEngine/src/Renderer/BufferVariable.bf index 8573bd9..f68a9bd 100644 --- a/GlitchyEngine/src/Renderer/BufferVariable.bf +++ b/GlitchyEngine/src/Renderer/BufferVariable.bf @@ -49,16 +49,16 @@ namespace GlitchyEngine.Renderer public void EnsureTypeMatch(int rows, int cols, ShaderVariableType type) { -#if GE_ERROR_SHADER_MATRIX_MISMATCH +#if GE_SHADER_MATRIX_MISMATCH_IS_ERROR Log.EngineLogger.Assert(rows == _rows || cols == _columns, scope $"The matrix-dimensions do not match: Expected {_rows} rows and {_rows} columns but Received {rows} rows and {cols} columns instead. Variable: \"{_name}\" of buffer: \"{_constantBuffer.Name}\""); -#elif GE_WARN_SHADER_MATRIX_MISMATCH +#elif GE_SHADER_MATRIX_MISMATCH_IS_WARNING if (rows != _rows || cols != _columns) Log.EngineLogger.Warning($"The matrix-dimensions do not match: Expected {_rows} rows and {_rows} columns but Received {rows} rows and {cols} columns instead. Variable: \"{_name}\" of buffer: \"{_constantBuffer.Name}\""); #endif -#if GE_ERROR_SHADER_VAR_TYPE_MISMATCH +#if GE_SHADER_VAR_TYPE_MISMATCH_IS_ERROR Log.EngineLogger.Assert(type == _type, scope $"The types do not match: Expected \"{_type}\" but Received \"{type}\" instead. Variable: \"{_name}\" of buffer: \"{_constantBuffer.Name}\""); -#elif GE_WARN_SHADER_VAR_TYPE_MISMATCH +#elif GE_SHADER_VAR_TYPE_MISMATCH_IS_WARNING if (type != _type) Log.EngineLogger.Warning($"The types do not match: Expected \"{_type}\" but Received \"{type}\" instead. Variable: \"{_name}\" of buffer: \"{_constantBuffer.Name}\""); #endif @@ -187,7 +187,9 @@ namespace GlitchyEngine.Renderer */ internal void SetRawData(void* rawData) { -#if DEBUG && !GE_IGNORE_UNUSED_VARIABLE +#if GE_SHADER_UNUSED_VARIABLE_IS_ERROR + Log.EngineLogger.Assert(_isUsed, scope $"Setting data for unused Variable \"{_name}\" of constant buffer \"{_constantBuffer.Name}\"."); +#elif GE_SHADER_UNUSED_VARIABLE_IS_WARNING if(!_isUsed) { Log.EngineLogger.Warning($"Setting data for unused Variable \"{_name}\" of constant buffer \"{_constantBuffer.Name}\".");