Added debug renderer + imgui renderer

All code made by gemini with some help
This commit is contained in:
2026-01-20 22:46:10 -05:00
parent 0687ce5af1
commit 891c404889
31 changed files with 2023 additions and 237 deletions

View File

@@ -5,6 +5,9 @@
.ProjectPath = 'Juliet'
.JulietIncludePath = ' "-IJuliet/include"'
+ ' "-IJuliet/src"'
+ ' "-IExternal/imgui"'
+ ' "-IExternal/imgui/backends"'
// Library
//--------------------------------------------------------------------------
@@ -44,12 +47,19 @@
// --- DLL BUILD ---
DLL( '$ProjectName$-Lib-$Platform$-$BuildConfigName$' )
{
.Libraries = { '$ProjectName$-Objs-$Platform$-$BuildConfigName$' }
.Libraries = { '$ProjectName$-Objs-$Platform$-$BuildConfigName$',
'ImGui-Lib-$Platform$-$BuildConfigName$' }
.LinkerOutput = '$BinPath$/$Platform$-$BuildConfigName$/$ProjectName$.dll' // Output .dll to Bin
#if __WINDOWS__
.LinkerOptions + ' /DLL'
.LinkerOptions + .CommonWinLibs
+ ' imm32.lib'
+ ' shell32.lib'
+ ' dwmapi.lib'
+ ' d3dcompiler.lib'
.CRTLibs = .CRTLibs_Dynamic
If ( .BuildConfigName == 'Debug' )

View File

@@ -25,6 +25,30 @@
<Configuration>x64Clang-Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="x64-Debug|x64">
<Configuration>x64-Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="x64-Profile|x64">
<Configuration>x64-Profile</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="x64-Release|x64">
<Configuration>x64-Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="x64Clang-Debug|x64">
<Configuration>x64Clang-Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="x64Clang-Profile|x64">
<Configuration>x64Clang-Profile</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="x64Clang-Release|x64">
<Configuration>x64Clang-Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="include\Core\Application\ApplicationManager.h" />
@@ -49,6 +73,8 @@
<CustomBuild Include="include\Core\HAL\Keyboard\ScanCode.h" />
<CustomBuild Include="include\Core\HAL\Mouse\Mouse.h" />
<CustomBuild Include="include\Core\HotReload\HotReload.h" />
<CustomBuild Include="include\Core\ImGui\ImGuiService.h" />
<CustomBuild Include="include\Core\ImGui\ImGuiTests.h" />
<CustomBuild Include="include\Core\JulietInit.h" />
<CustomBuild Include="include\Core\Logging\LogManager.h" />
<CustomBuild Include="include\Core\Logging\LogTypes.h" />
@@ -69,6 +95,7 @@
<CustomBuild Include="include\Core\Thread\Mutex.h" />
<CustomBuild Include="include\Core\Thread\Thread.h" />
<CustomBuild Include="include\Engine\Class.h" />
<CustomBuild Include="include\Engine\Debug\MemoryDebugger.h" />
<CustomBuild Include="include\Engine\Engine.h" />
<CustomBuild Include="include\Graphics\Camera.h" />
<CustomBuild Include="include\Graphics\Colors.h" />
@@ -77,6 +104,7 @@
<CustomBuild Include="include\Graphics\GraphicsBuffer.h" />
<CustomBuild Include="include\Graphics\GraphicsConfig.h" />
<CustomBuild Include="include\Graphics\GraphicsPipeline.h" />
<CustomBuild Include="include\Graphics\ImGuiRenderer.h" />
<CustomBuild Include="include\Graphics\RenderPass.h" />
<CustomBuild Include="include\Graphics\Shader.h" />
<CustomBuild Include="include\Graphics\Texture.h" />
@@ -115,6 +143,8 @@
<CustomBuild Include="src\Core\HAL\Win32.h" />
<CustomBuild Include="src\Core\HotReload\HotReload.cpp" />
<CustomBuild Include="src\Core\HotReload\Win32\Win32HotReload.cpp" />
<CustomBuild Include="src\Core\ImGui\ImGuiService.cpp" />
<CustomBuild Include="src\Core\ImGui\ImGuiTests.cpp" />
<CustomBuild Include="src\Core\Juliet.cpp" />
<CustomBuild Include="src\Core\Logging\LogManager.cpp" />
<CustomBuild Include="src\Core\Math\Math_Private.h" />
@@ -130,6 +160,7 @@
<CustomBuild Include="src\Core\Networking\TcpListener.cpp" />
<CustomBuild Include="src\Core\Networking\TcpSocket.cpp" />
<CustomBuild Include="src\Core\Networking\Win32\Win32SocketPlatformImpl.cpp" />
<CustomBuild Include="src\Engine\Debug\MemoryDebugger.cpp" />
<CustomBuild Include="src\Engine\Engine.cpp" />
<CustomBuild Include="src\Graphics\D3D12\AgilitySDK\d3d12.h" />
<CustomBuild Include="src\Graphics\D3D12\AgilitySDK\d3d12compatibility.h" />
@@ -181,6 +212,7 @@
<CustomBuild Include="src\Graphics\DebugDisplayRenderer.cpp" />
<CustomBuild Include="src\Graphics\Graphics.cpp" />
<CustomBuild Include="src\Graphics\GraphicsDevice.h" />
<CustomBuild Include="src\Graphics\ImGuiRenderer.cpp" />
</ItemGroup>
<ItemGroup>
</ItemGroup>
@@ -225,6 +257,42 @@
<PlatformToolset>v143</PlatformToolset>
<LocalDebuggerCommand>$(SolutionDir)\bin\$(Configuration)\$(ProjectName).exe</LocalDebuggerCommand>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x64-Debug|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<LocalDebuggerCommand>$(SolutionDir)\bin\$(Configuration)\$(ProjectName).exe</LocalDebuggerCommand>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x64-Profile|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<LocalDebuggerCommand>$(SolutionDir)\bin\$(Configuration)\$(ProjectName).exe</LocalDebuggerCommand>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x64-Release|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<LocalDebuggerCommand>$(SolutionDir)\bin\$(Configuration)\$(ProjectName).exe</LocalDebuggerCommand>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x64Clang-Debug|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<LocalDebuggerCommand>$(SolutionDir)\bin\$(Configuration)\$(ProjectName).exe</LocalDebuggerCommand>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x64Clang-Profile|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<LocalDebuggerCommand>$(SolutionDir)\bin\$(Configuration)\$(ProjectName).exe</LocalDebuggerCommand>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x64Clang-Release|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<LocalDebuggerCommand>$(SolutionDir)\bin\$(Configuration)\$(ProjectName).exe</LocalDebuggerCommand>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
@@ -246,12 +314,90 @@
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='x64Clang-Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='x64-Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='x64-Profile|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='x64-Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='x64Clang-Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='x64Clang-Profile|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='x64Clang-Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x64-Debug|x64'">
<NMakeBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache $(ProjectName)-$(Configuration)</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache -clean $(ProjectName)-$(Configuration)</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;WIN32_LEAN_AND_MEAN;WIN32;_WIN32;__WINDOWS__;_HAS_EXCEPTIONS=0;WIN64;DEBUG;PROFILING_ENABLED;JULIET_EXPORT;JULIET_WIN32;</NMakePreprocessorDefinitions>
<NMakeIncludeSearchPath>..\;include;src;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared;</NMakeIncludeSearchPath>
<NMakePreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;WIN32_LEAN_AND_MEAN;WIN32;_WIN32;__WINDOWS__;_HAS_EXCEPTIONS=0;WIN64;DEBUG;PROFILING_ENABLED;JULIET_ENABLE_IMGUI;_CRT_SECURE_NO_WARNINGS;</NMakePreprocessorDefinitions>
<NMakeIncludeSearchPath>..\;..\External\imgui;..\External\imgui\backends;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared;</NMakeIncludeSearchPath>
<AdditionalOptions>/std:c++20 /wd5267 /wd4061 /wd4505 /wd4514 /wd4577 /wd4625 /wd4710 /wd4711 /wd4746 /wd4820 /wd5045 /wd5220 /wd5245 </AdditionalOptions>
<LocalDebuggerWorkingDirectory>$(SolutionDir)\bin\$(Configuration)\</LocalDebuggerWorkingDirectory>
<IntDir>$(SolutionDir)\Intermediate</IntDir>
<OutDir>$(SolutionDir)\bin</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x64-Profile|x64'">
<NMakeBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache $(ProjectName)-$(Configuration)</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache -clean $(ProjectName)-$(Configuration)</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;WIN32_LEAN_AND_MEAN;WIN32;_WIN32;__WINDOWS__;_HAS_EXCEPTIONS=0;WIN64;RELEASE;PROFILING_ENABLED;_CRT_SECURE_NO_WARNINGS;</NMakePreprocessorDefinitions>
<NMakeIncludeSearchPath>..\;..\External\imgui;..\External\imgui\backends;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared;</NMakeIncludeSearchPath>
<AdditionalOptions>/std:c++20 /wd5267 /wd4061 /wd4505 /wd4514 /wd4577 /wd4625 /wd4710 /wd4711 /wd4746 /wd4820 /wd5045 /wd5220 /wd5245 </AdditionalOptions>
<LocalDebuggerWorkingDirectory>$(SolutionDir)\bin\$(Configuration)\</LocalDebuggerWorkingDirectory>
<IntDir>$(SolutionDir)\Intermediate</IntDir>
<OutDir>$(SolutionDir)\bin</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x64-Release|x64'">
<NMakeBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache $(ProjectName)-$(Configuration)</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache -clean $(ProjectName)-$(Configuration)</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;WIN32_LEAN_AND_MEAN;WIN32;_WIN32;__WINDOWS__;_HAS_EXCEPTIONS=0;WIN64;RELEASE;_CRT_SECURE_NO_WARNINGS;</NMakePreprocessorDefinitions>
<NMakeIncludeSearchPath>..\;..\External\imgui;..\External\imgui\backends;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared;</NMakeIncludeSearchPath>
<AdditionalOptions>/std:c++20 /wd5267 /wd4061 /wd4505 /wd4514 /wd4577 /wd4625 /wd4710 /wd4711 /wd4746 /wd4820 /wd5045 /wd5220 /wd5245 </AdditionalOptions>
<LocalDebuggerWorkingDirectory>$(SolutionDir)\bin\$(Configuration)\</LocalDebuggerWorkingDirectory>
<IntDir>$(SolutionDir)\Intermediate</IntDir>
<OutDir>$(SolutionDir)\bin</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x64Clang-Debug|x64'">
<NMakeBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache $(ProjectName)-$(Configuration)</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache -clean $(ProjectName)-$(Configuration)</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;WIN32_LEAN_AND_MEAN;WIN32;_WIN32;__WINDOWS__;_HAS_EXCEPTIONS=0;WIN64;DEBUG;PROFILING_ENABLED;JULIET_ENABLE_IMGUI;_CRT_SECURE_NO_WARNINGS;</NMakePreprocessorDefinitions>
<NMakeIncludeSearchPath>..\;..\External\imgui;..\External\imgui\backends;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared;</NMakeIncludeSearchPath>
<AdditionalOptions>/std:c++20 /wd5267 /wd4061 /wd4505 /wd4514 /wd4577 /wd4625 /wd4710 /wd4711 /wd4746 /wd4820 /wd5045 /wd5220 /wd5245 </AdditionalOptions>
<LocalDebuggerWorkingDirectory>$(SolutionDir)\bin\$(Configuration)\</LocalDebuggerWorkingDirectory>
<IntDir>$(SolutionDir)\Intermediate</IntDir>
<OutDir>$(SolutionDir)\bin</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x64Clang-Profile|x64'">
<NMakeBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache $(ProjectName)-$(Configuration)</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache -clean $(ProjectName)-$(Configuration)</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;WIN32_LEAN_AND_MEAN;WIN32;_WIN32;__WINDOWS__;_HAS_EXCEPTIONS=0;WIN64;RELEASE;PROFILING_ENABLED;_CRT_SECURE_NO_WARNINGS;</NMakePreprocessorDefinitions>
<NMakeIncludeSearchPath>..\;..\External\imgui;..\External\imgui\backends;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared;</NMakeIncludeSearchPath>
<AdditionalOptions>/std:c++20 /wd5267 /wd4061 /wd4505 /wd4514 /wd4577 /wd4625 /wd4710 /wd4711 /wd4746 /wd4820 /wd5045 /wd5220 /wd5245 </AdditionalOptions>
<LocalDebuggerWorkingDirectory>$(SolutionDir)\bin\$(Configuration)\</LocalDebuggerWorkingDirectory>
<IntDir>$(SolutionDir)\Intermediate</IntDir>
<OutDir>$(SolutionDir)\bin</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x64Clang-Release|x64'">
<NMakeBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache $(ProjectName)-$(Configuration)</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache -clean $(ProjectName)-$(Configuration)</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;WIN32_LEAN_AND_MEAN;WIN32;_WIN32;__WINDOWS__;_HAS_EXCEPTIONS=0;WIN64;RELEASE;_CRT_SECURE_NO_WARNINGS;</NMakePreprocessorDefinitions>
<NMakeIncludeSearchPath>..\;..\External\imgui;..\External\imgui\backends;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared;</NMakeIncludeSearchPath>
<AdditionalOptions>/std:c++20 /wd5267 /wd4061 /wd4505 /wd4514 /wd4577 /wd4625 /wd4710 /wd4711 /wd4746 /wd4820 /wd5045 /wd5220 /wd5245 </AdditionalOptions>
<LocalDebuggerWorkingDirectory>$(SolutionDir)\bin\$(Configuration)\</LocalDebuggerWorkingDirectory>
<IntDir>$(SolutionDir)\Intermediate</IntDir>
<OutDir>$(SolutionDir)\bin</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x64-Debug|x64'">
<NMakeBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache $(ProjectName)-$(Configuration)</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache -clean $(ProjectName)-$(Configuration)</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;WIN32_LEAN_AND_MEAN;WIN32;_WIN32;__WINDOWS__;_HAS_EXCEPTIONS=0;WIN64;DEBUG;PROFILING_ENABLED;JULIET_ENABLE_IMGUI;JULIET_EXPORT;JULIET_WIN32;</NMakePreprocessorDefinitions>
<NMakeIncludeSearchPath>..\;include;src;..\External\imgui;..\External\imgui\backends;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared;</NMakeIncludeSearchPath>
<AdditionalOptions>/std:c++20 /wd5267 /wd4061 /wd4505 /wd4514 /wd4577 /wd4625 /wd4710 /wd4711 /wd4746 /wd4820 /wd5045 /wd5220 /wd5245 </AdditionalOptions>
<LocalDebuggerWorkingDirectory>$(SolutionDir)\bin\$(Configuration)\</LocalDebuggerWorkingDirectory>
<IntDir>$(SolutionDir)\Intermediate</IntDir>
@@ -261,7 +407,7 @@
<NMakeBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache $(ProjectName)-$(Configuration)</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache -clean $(ProjectName)-$(Configuration)</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;WIN32_LEAN_AND_MEAN;WIN32;_WIN32;__WINDOWS__;_HAS_EXCEPTIONS=0;WIN64;RELEASE;PROFILING_ENABLED;JULIET_EXPORT;JULIET_WIN32;</NMakePreprocessorDefinitions>
<NMakeIncludeSearchPath>..\;include;src;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared;</NMakeIncludeSearchPath>
<NMakeIncludeSearchPath>..\;include;src;..\External\imgui;..\External\imgui\backends;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared;</NMakeIncludeSearchPath>
<AdditionalOptions>/std:c++20 /wd5267 /wd4061 /wd4505 /wd4514 /wd4577 /wd4625 /wd4710 /wd4711 /wd4746 /wd4820 /wd5045 /wd5220 /wd5245 </AdditionalOptions>
<LocalDebuggerWorkingDirectory>$(SolutionDir)\bin\$(Configuration)\</LocalDebuggerWorkingDirectory>
<IntDir>$(SolutionDir)\Intermediate</IntDir>
@@ -271,7 +417,7 @@
<NMakeBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache $(ProjectName)-$(Configuration)</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache -clean $(ProjectName)-$(Configuration)</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;WIN32_LEAN_AND_MEAN;WIN32;_WIN32;__WINDOWS__;_HAS_EXCEPTIONS=0;WIN64;RELEASE;JULIET_EXPORT;JULIET_WIN32;</NMakePreprocessorDefinitions>
<NMakeIncludeSearchPath>..\;include;src;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared;</NMakeIncludeSearchPath>
<NMakeIncludeSearchPath>..\;include;src;..\External\imgui;..\External\imgui\backends;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared;</NMakeIncludeSearchPath>
<AdditionalOptions>/std:c++20 /wd5267 /wd4061 /wd4505 /wd4514 /wd4577 /wd4625 /wd4710 /wd4711 /wd4746 /wd4820 /wd5045 /wd5220 /wd5245 </AdditionalOptions>
<LocalDebuggerWorkingDirectory>$(SolutionDir)\bin\$(Configuration)\</LocalDebuggerWorkingDirectory>
<IntDir>$(SolutionDir)\Intermediate</IntDir>
@@ -280,8 +426,8 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x64Clang-Debug|x64'">
<NMakeBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache $(ProjectName)-$(Configuration)</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache -clean $(ProjectName)-$(Configuration)</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;WIN32_LEAN_AND_MEAN;WIN32;_WIN32;__WINDOWS__;_HAS_EXCEPTIONS=0;WIN64;DEBUG;PROFILING_ENABLED;JULIET_EXPORT;JULIET_WIN32;</NMakePreprocessorDefinitions>
<NMakeIncludeSearchPath>..\;include;src;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared;</NMakeIncludeSearchPath>
<NMakePreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;WIN32_LEAN_AND_MEAN;WIN32;_WIN32;__WINDOWS__;_HAS_EXCEPTIONS=0;WIN64;DEBUG;PROFILING_ENABLED;JULIET_ENABLE_IMGUI;JULIET_EXPORT;JULIET_WIN32;</NMakePreprocessorDefinitions>
<NMakeIncludeSearchPath>..\;include;src;..\External\imgui;..\External\imgui\backends;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared;</NMakeIncludeSearchPath>
<AdditionalOptions>/std:c++20 /wd5267 /wd4061 /wd4505 /wd4514 /wd4577 /wd4625 /wd4710 /wd4711 /wd4746 /wd4820 /wd5045 /wd5220 /wd5245 </AdditionalOptions>
<LocalDebuggerWorkingDirectory>$(SolutionDir)\bin\$(Configuration)\</LocalDebuggerWorkingDirectory>
<IntDir>$(SolutionDir)\Intermediate</IntDir>
@@ -291,7 +437,7 @@
<NMakeBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache $(ProjectName)-$(Configuration)</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache -clean $(ProjectName)-$(Configuration)</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;WIN32_LEAN_AND_MEAN;WIN32;_WIN32;__WINDOWS__;_HAS_EXCEPTIONS=0;WIN64;RELEASE;PROFILING_ENABLED;JULIET_EXPORT;JULIET_WIN32;</NMakePreprocessorDefinitions>
<NMakeIncludeSearchPath>..\;include;src;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared;</NMakeIncludeSearchPath>
<NMakeIncludeSearchPath>..\;include;src;..\External\imgui;..\External\imgui\backends;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared;</NMakeIncludeSearchPath>
<AdditionalOptions>/std:c++20 /wd5267 /wd4061 /wd4505 /wd4514 /wd4577 /wd4625 /wd4710 /wd4711 /wd4746 /wd4820 /wd5045 /wd5220 /wd5245 </AdditionalOptions>
<LocalDebuggerWorkingDirectory>$(SolutionDir)\bin\$(Configuration)\</LocalDebuggerWorkingDirectory>
<IntDir>$(SolutionDir)\Intermediate</IntDir>
@@ -301,7 +447,7 @@
<NMakeBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache $(ProjectName)-$(Configuration)</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>cd $(SolutionDir) &amp; misc\fbuild -ide -dist -monitor -cache -clean $(ProjectName)-$(Configuration)</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;WIN32_LEAN_AND_MEAN;WIN32;_WIN32;__WINDOWS__;_HAS_EXCEPTIONS=0;WIN64;RELEASE;JULIET_EXPORT;JULIET_WIN32;</NMakePreprocessorDefinitions>
<NMakeIncludeSearchPath>..\;include;src;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared;</NMakeIncludeSearchPath>
<NMakeIncludeSearchPath>..\;include;src;..\External\imgui;..\External\imgui\backends;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared;</NMakeIncludeSearchPath>
<AdditionalOptions>/std:c++20 /wd5267 /wd4061 /wd4505 /wd4514 /wd4577 /wd4625 /wd4710 /wd4711 /wd4746 /wd4820 /wd5045 /wd5220 /wd5245 </AdditionalOptions>
<LocalDebuggerWorkingDirectory>$(SolutionDir)\bin\$(Configuration)\</LocalDebuggerWorkingDirectory>
<IntDir>$(SolutionDir)\Intermediate</IntDir>
@@ -337,6 +483,36 @@
<Path>$(SolutionDir)\Intermediate\$(ProjectName)-$(Configuration).log</Path>
</BuildLog>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='x64-Debug|x64'">
<BuildLog>
<Path>$(SolutionDir)\Intermediate\$(ProjectName)-$(Configuration).log</Path>
</BuildLog>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='x64-Profile|x64'">
<BuildLog>
<Path>$(SolutionDir)\Intermediate\$(ProjectName)-$(Configuration).log</Path>
</BuildLog>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='x64-Release|x64'">
<BuildLog>
<Path>$(SolutionDir)\Intermediate\$(ProjectName)-$(Configuration).log</Path>
</BuildLog>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='x64Clang-Debug|x64'">
<BuildLog>
<Path>$(SolutionDir)\Intermediate\$(ProjectName)-$(Configuration).log</Path>
</BuildLog>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='x64Clang-Profile|x64'">
<BuildLog>
<Path>$(SolutionDir)\Intermediate\$(ProjectName)-$(Configuration).log</Path>
</BuildLog>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='x64Clang-Release|x64'">
<BuildLog>
<Path>$(SolutionDir)\Intermediate\$(ProjectName)-$(Configuration).log</Path>
</BuildLog>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

View File

@@ -67,6 +67,12 @@
<CustomBuild Include="include\Core\HotReload\HotReload.h">
<Filter>include\Core\HotReload</Filter>
</CustomBuild>
<CustomBuild Include="include\Core\ImGui\ImGuiService.h">
<Filter>include\Core\ImGui</Filter>
</CustomBuild>
<CustomBuild Include="include\Core\ImGui\ImGuiTests.h">
<Filter>include\Core\ImGui</Filter>
</CustomBuild>
<CustomBuild Include="include\Core\JulietInit.h">
<Filter>include\Core</Filter>
</CustomBuild>
@@ -127,6 +133,9 @@
<CustomBuild Include="include\Engine\Class.h">
<Filter>include\Engine</Filter>
</CustomBuild>
<CustomBuild Include="include\Engine\Debug\MemoryDebugger.h">
<Filter>include\Engine\Debug</Filter>
</CustomBuild>
<CustomBuild Include="include\Engine\Engine.h">
<Filter>include\Engine</Filter>
</CustomBuild>
@@ -151,6 +160,9 @@
<CustomBuild Include="include\Graphics\GraphicsPipeline.h">
<Filter>include\Graphics</Filter>
</CustomBuild>
<CustomBuild Include="include\Graphics\ImGuiRenderer.h">
<Filter>include\Graphics</Filter>
</CustomBuild>
<CustomBuild Include="include\Graphics\RenderPass.h">
<Filter>include\Graphics</Filter>
</CustomBuild>
@@ -264,6 +276,12 @@
<CustomBuild Include="src\Core\HotReload\Win32\Win32HotReload.cpp">
<Filter>src\Core\HotReload\Win32</Filter>
</CustomBuild>
<CustomBuild Include="src\Core\ImGui\ImGuiService.cpp">
<Filter>src\Core\ImGui</Filter>
</CustomBuild>
<CustomBuild Include="src\Core\ImGui\ImGuiTests.cpp">
<Filter>src\Core\ImGui</Filter>
</CustomBuild>
<CustomBuild Include="src\Core\Juliet.cpp">
<Filter>src\Core</Filter>
</CustomBuild>
@@ -309,6 +327,9 @@
<CustomBuild Include="src\Core\Networking\Win32\Win32SocketPlatformImpl.cpp">
<Filter>src\Core\Networking\Win32</Filter>
</CustomBuild>
<CustomBuild Include="src\Engine\Debug\MemoryDebugger.cpp">
<Filter>src\Engine\Debug</Filter>
</CustomBuild>
<CustomBuild Include="src\Engine\Engine.cpp">
<Filter>src\Engine</Filter>
</CustomBuild>
@@ -462,6 +483,9 @@
<CustomBuild Include="src\Graphics\GraphicsDevice.h">
<Filter>src\Graphics</Filter>
</CustomBuild>
<CustomBuild Include="src\Graphics\ImGuiRenderer.cpp">
<Filter>src\Graphics</Filter>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<Filter Include="include\Core\Application">
@@ -533,6 +557,11 @@
<UniqueIdentifier>{fe4e9898-6c94-4f93-bc2a-7f5284b7d434}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<Filter Include="include\Core\ImGui">
<UniqueIdentifier>{f0573de7-6c94-4f93-bc2a-7f5284b7d434}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<Filter Include="include\Core\Logging">
<UniqueIdentifier>{02138187-6c94-4f93-bc2a-7f5284b7d434}</UniqueIdentifier>
@@ -563,6 +592,11 @@
<UniqueIdentifier>{d881a52c-6c94-4f93-bc2a-7f5284b7d434}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<Filter Include="include\Engine\Debug">
<UniqueIdentifier>{c6a2048a-6c94-4f93-bc2a-7f5284b7d434}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<Filter Include="include\Graphics">
<UniqueIdentifier>{20496e7b-6c94-4f93-bc2a-7f5284b7d434}</UniqueIdentifier>
@@ -648,6 +682,11 @@
<UniqueIdentifier>{849dd795-6c94-4f93-bc2a-7f5284b7d434}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<Filter Include="src\Core\ImGui">
<UniqueIdentifier>{04960ca3-6c94-4f93-bc2a-7f5284b7d434}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<Filter Include="src\Core\Logging">
<UniqueIdentifier>{574d127d-6c94-4f93-bc2a-7f5284b7d434}</UniqueIdentifier>
@@ -673,6 +712,11 @@
<UniqueIdentifier>{43aa9349-6c94-4f93-bc2a-7f5284b7d434}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<Filter Include="src\Engine\Debug">
<UniqueIdentifier>{8e9855ac-6c94-4f93-bc2a-7f5284b7d434}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<Filter Include="src\Engine">
<UniqueIdentifier>{602a4b6b-6c94-4f93-bc2a-7f5284b7d434}</UniqueIdentifier>

View File

@@ -2,6 +2,12 @@
namespace Juliet
{
struct RenderPass;
struct CommandList;
struct Texture;
struct ColorTargetInfo;
struct DepthStencilTargetInfo;
class IApplication
{
public:
@@ -10,5 +16,16 @@ namespace Juliet
virtual void Shutdown() = 0;
virtual void Update() = 0;
virtual bool IsRunning() = 0;
// Accessors for Engine Systems
virtual struct Window* GetPlatformWindow() = 0;
virtual struct GraphicsDevice* GetGraphicsDevice() = 0;
// Render Lifecycle (Engine-Managed Render Loop)
virtual void OnPreRender(CommandList* cmd) = 0;
virtual void OnRender(RenderPass* pass, CommandList* cmd) = 0;
virtual ColorTargetInfo GetColorTargetInfo(Texture* swapchainTexture) = 0;
virtual DepthStencilTargetInfo* GetDepthTargetInfo() = 0;
virtual struct Camera GetDebugCamera() = 0;
};
} // namespace Juliet

View File

@@ -0,0 +1,27 @@
#pragma once
#include <Core/Common/CoreTypes.h>
#include <Core/Common/NonNullPtr.h>
struct ImGuiContext;
namespace Juliet
{
struct Window;
struct GraphicsDevice;
namespace ImGuiService
{
JULIET_API void Initialize(NonNullPtr<Window> window);
JULIET_API void Shutdown();
JULIET_API void NewFrame();
JULIET_API void Render();
JULIET_API bool IsInitialized();
JULIET_API ImGuiContext* GetContext();
// Run internal unit tests
JULIET_API void RunTests(NonNullPtr<GraphicsDevice> device, NonNullPtr<Window> window);
}
}

View File

@@ -0,0 +1,12 @@
#pragma once
#include <Core/Common/NonNullPtr.h>
#include <Core/HAL/Display/Window.h>
#include <Graphics/GraphicsDevice.h>
#include <Juliet.h>
namespace Juliet::UnitTest
{
void TestImGui(NonNullPtr<GraphicsDevice> device, NonNullPtr<Window> window);
}

View File

@@ -0,0 +1,13 @@
#pragma once
#include <Juliet.h>
#include <Core/Memory/MemoryArena.h>
namespace Juliet
{
class JULIET_API MemoryDebugger
{
public:
static void DrawMemoryArena(const char* name, const MemoryArena& arena);
static void DrawGlobalArenas();
};
}

View File

@@ -60,6 +60,12 @@ namespace Juliet
Count
};
enum class IndexFormat : uint8
{
UInt16,
UInt32
};
enum struct SwapChainComposition : uint8
{
SDR,
@@ -128,6 +134,14 @@ namespace Juliet
extern JULIET_API void BindGraphicsPipeline(NonNullPtr<RenderPass> renderPass, NonNullPtr<GraphicsPipeline> graphicsPipeline);
extern JULIET_API void DrawPrimitives(NonNullPtr<RenderPass> renderPass, uint32 numVertices, uint32 numInstances,
uint32 firstVertex, uint32 firstInstance);
extern JULIET_API void DrawIndexedPrimitives(NonNullPtr<RenderPass> renderPass, uint32 numIndices,
uint32 numInstances, uint32 firstIndex, uint32 vertexOffset,
uint32 firstInstance);
extern JULIET_API void SetIndexBuffer(NonNullPtr<CommandList> commandList, NonNullPtr<GraphicsBuffer> buffer, IndexFormat format);
extern JULIET_API void SetPushConstants(NonNullPtr<CommandList> commandList, ShaderStage stage,
uint32 rootParameterIndex, uint32 numConstants, const void* constants);
@@ -157,8 +171,13 @@ namespace Juliet
extern JULIET_API void CopyBuffer(NonNullPtr<CommandList> commandList, NonNullPtr<GraphicsBuffer> dst,
NonNullPtr<GraphicsTransferBuffer> src, size_t size, size_t dstOffset = 0,
size_t srcOffset = 0);
extern JULIET_API void CopyBufferToTexture(NonNullPtr<CommandList> commandList, NonNullPtr<Texture> dst,
NonNullPtr<GraphicsTransferBuffer> src);
extern JULIET_API void TransitionBufferToReadable(NonNullPtr<CommandList> commandList, NonNullPtr<GraphicsBuffer> buffer);
extern JULIET_API uint32 GetDescriptorIndex(NonNullPtr<GraphicsDevice> device, NonNullPtr<GraphicsBuffer> buffer);
extern JULIET_API uint32 GetDescriptorIndex(NonNullPtr<GraphicsDevice> device, NonNullPtr<Texture> texture);
extern JULIET_API void DestroyGraphicsBuffer(NonNullPtr<GraphicsDevice> device, NonNullPtr<GraphicsBuffer> buffer);
extern JULIET_API void DestroyGraphicsTransferBuffer(NonNullPtr<GraphicsDevice> device, NonNullPtr<GraphicsTransferBuffer> buffer);
} // namespace Juliet

View File

@@ -8,6 +8,7 @@ namespace Juliet
IndexBuffer = 1 << 0,
ConstantBuffer = 1 << 1,
StructuredBuffer = 1 << 2,
VertexBuffer = 1 << 3,
};
enum class TransferBufferUsage : uint8

View File

@@ -0,0 +1,12 @@
#pragma once
#include <Graphics/Graphics.h>
#include <Juliet.h>
namespace Juliet
{
extern bool ImGuiRenderer_Initialize(GraphicsDevice* device);
extern void ImGuiRenderer_Shutdown(GraphicsDevice* device);
extern void ImGuiRenderer_NewFrame();
extern JULIET_API void ImGuiRenderer_Render(CommandList* cmdList, RenderPass* renderPass);
} // namespace Juliet

View File

@@ -24,4 +24,12 @@
#else
#define JULIET_DEBUG 0
#endif
// Manual override to disable ImGui
// #define JULIET_DISABLE_IMGUI
#if defined(JULIET_DISABLE_IMGUI) && defined(JULIET_ENABLE_IMGUI)
#undef JULIET_ENABLE_IMGUI
#endif
// clang-format on

View File

@@ -0,0 +1,122 @@
#include <cstdio>
#include <Core/HAL/Display/Win32/Win32Window.h>
#include <Core/HAL/Display/Window.h>
#include <Core/ImGui/ImGuiService.h>
#include <Core/ImGui/ImGuiTests.h>
#include <Core/Logging/LogManager.h>
#include <Core/Memory/MemoryArena.h>
#include <Graphics/D3D12/D3D12Includes.h>
#include <imgui.h>
#include <backends/imgui_impl_dx12.h>
#include <backends/imgui_impl_win32.h>
// Forward declare implementation functions from backends
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
namespace Juliet::ImGuiService
{
namespace
{
ImGuiContext* g_ImGuiContext = nullptr;
bool g_Initialized = false;
void* ImGuiAllocWrapper(size_t size, void* /*user_data*/)
{
return ArenaPush(GetGameArena(), size, 16, "ImGui");
}
void ImGuiFreeWrapper(void* /*ptr*/, void* /*user_data*/)
{
// No-op free for linear allocator.
}
} // namespace
void Initialize(NonNullPtr<Window> window)
{
if (g_Initialized)
{
return;
}
// Setup Allocator
ImGui::SetAllocatorFunctions(ImGuiAllocWrapper, ImGuiFreeWrapper, nullptr);
IMGUI_CHECKVERSION();
g_ImGuiContext = ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
(void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
// io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
ImGui::StyleColorsDark();
// Platform Init
auto* win32State = static_cast<Win32::Window32State*>(window->State);
ImGui_ImplWin32_Init(win32State->Handle);
// Renderer Init is done later or here?
// We need the ID3D12Device, which is in GraphicsDevice.
// We should probably split Init.
// For now, let's assume we do Renderer Init in GraphicsDevice.
g_Initialized = true;
}
void Shutdown()
{
if (!g_Initialized) return;
ImGui_ImplWin32_Shutdown();
ImGui::DestroyContext(g_ImGuiContext);
g_ImGuiContext = nullptr;
g_Initialized = false;
}
void NewFrame()
{
if (!g_Initialized) return;
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
}
void Render()
{
if (!g_Initialized) return;
ImGui::Render();
}
bool IsInitialized()
{
return g_Initialized;
}
ImGuiContext* GetContext()
{
return g_ImGuiContext;
}
void RunTests(NonNullPtr<GraphicsDevice> device, NonNullPtr<Window> window)
{
printf("ImGuiService: Running Unit Tests...\n");
Juliet::UnitTest::TestImGui(device, window);
// Also run internal Dear ImGui validation
if (g_ImGuiContext)
{
// Verify version and data layout (Basic internal check)
bool result = ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx));
if (result)
{
printf("ImGuiService: DebugCheckVersionAndDataLayout Passed.\n");
}
else
{
printf("ImGuiService: DebugCheckVersionAndDataLayout FAILED!\n");
}
}
}
} // namespace Juliet::ImGuiService

View File

@@ -0,0 +1,89 @@
#include <Core/HAL/Display/Display.h>
#include <Core/ImGui/ImGuiService.h>
#include <Core/Memory/MemoryArena.h>
#include <Graphics/Graphics.h>
#include <imgui.h>
#include <Juliet.h>
#include <cstdio>
namespace Juliet::UnitTest
{
// Mocking window creation is hard because it needs real OS calls.
// We will assume the test runner has created a window or we create a headless one?
// Win32Window requires RegisterClass etc.
// Let's rely on the fact that if we run this test in "App" mode it works,
// but in CI headless it might fail if we don't handle it.
// For now, let's skip the Platform Init part if we can't create a window,
// or try to create a dummy window.
void TestImGui(NonNullPtr<GraphicsDevice> device, NonNullPtr<Window> window)
{
(void)device;
// 1. Verify Allocator Hook
// Initialize (Idempotent safe)
ImGuiService::Initialize(window);
ImGuiContext* ctx = ImGuiService::GetContext();
if (ImGui::GetCurrentContext() != ctx)
{
printf("WARN: Context Mismatch! Service=%p, Current=%p. Fixing...\n", (void*)ctx, (void*)ImGui::GetCurrentContext());
ImGui::SetCurrentContext(ctx);
}
Assert(ImGui::GetCurrentContext() == ctx);
(void)ctx;
printf("TestImGui: Context Verified.\n");
// 3. Verify IO
ImGuiIO& io = ImGui::GetIO();
Assert(io.BackendPlatformName != nullptr);
printf("TestImGui: IO Verified. Backend: %s\n", io.BackendPlatformName);
// 4. Verify Version
Assert(ImGui::GetVersion() != nullptr);
printf("TestImGui: Version Verified: %s\n", ImGui::GetVersion());
// 5. Verify Fonts
Assert(io.Fonts != nullptr);
printf("TestImGui: Fonts Verified.\n");
bool built = io.Fonts->IsBuilt();
printf("TestImGui: Fonts Built Status: %d\n", built);
// Assert(io.Fonts->IsBuilt() == false); // Disabled as Renderer might have built it
unsigned char* pixels;
int width, height;
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
Assert(pixels != nullptr);
Assert(width > 0 && height > 0);
Assert(io.Fonts->IsBuilt() == true);
(void)pixels; (void)width; (void)height;
printf("TestImGui: Font Atlas Verified.\n");
// 6. Verify Style
ImGuiStyle& style = ImGui::GetStyle();
Assert(style.Alpha > 0.0f);
(void)style;
printf("TestImGui: Style Verified.\n");
// 7. Test New Frame
Assert(ImGuiService::IsInitialized());
// Simulate a frame
if (io.DisplaySize.x <= 0.0f || io.DisplaySize.y <= 0.0f) {
io.DisplaySize = ImVec2(1920, 1080);
}
io.DeltaTime = 1.0f / 60.0f;
printf("TestImGui: About to DrawList check.\n");
// 8. Check Draw List Access
ImDrawList* drawList = ImGui::GetForegroundDrawList();
Assert(drawList != nullptr);
(void)drawList;
printf("ImGui tests passed (Exhaustive).\n");
}
} // namespace Juliet::UnitTest

View File

@@ -0,0 +1,68 @@
#include <Engine/Debug/MemoryDebugger.h>
#include <imgui.h>
#include <cstdio>
namespace Juliet
{
void MemoryDebugger::DrawMemoryArena(const char* name, const MemoryArena& arena)
{
if (ImGui::CollapsingHeader(name, ImGuiTreeNodeFlags_DefaultOpen))
{
float progress = 0.0f;
if (arena.Size > 0)
{
progress = (float)arena.Offset / (float)arena.Size;
}
char overlay[64];
sprintf_s(overlay, "%zu / %zu bytes", arena.Offset, arena.Size);
ImGui::ProgressBar(progress, ImVec2(0.0f, 0.0f), overlay);
#if JULIET_DEBUG
if (ImGui::TreeNode("Allocations"))
{
size_t displayedSize = 0;
// Draw allocations as a list for now
if (ImGui::BeginTable("AllocationsTable", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_Resizable))
{
ImGui::TableSetupColumn("Tag");
ImGui::TableSetupColumn("Size");
ImGui::TableSetupColumn("Offset");
ImGui::TableHeadersRow();
for (size_t i = 0; i < arena.AllocationCount; ++i)
{
const auto& alloc = arena.Allocations[i];
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::Text("%s", alloc.Tag);
ImGui::TableSetColumnIndex(1);
ImGui::Text("%zu", alloc.Size);
ImGui::TableSetColumnIndex(2);
ImGui::Text("%zu", alloc.Offset);
displayedSize += alloc.Size;
}
ImGui::EndTable();
}
ImGui::Text("Total Tracked Size: %zu", displayedSize);
ImGui::Text("Untracked/Padding: %zu", arena.Offset - displayedSize);
ImGui::TreePop();
}
#else
ImGui::Text("Detailed allocation tracking disabled in Release build.");
#endif
}
}
void MemoryDebugger::DrawGlobalArenas()
{
if (ImGui::Begin("Memory Debugger"))
{
DrawMemoryArena("Scratch Arena", *GetScratchArena());
DrawMemoryArena("Game Arena", *GetGameArena());
}
ImGui::End();
}
}

View File

@@ -1,15 +1,132 @@
#include <Core/Logging/LogManager.h>
#include <Engine/Engine.h>
#include <Core/Common/CoreUtils.h>
#include <Core/JulietInit.h>
#include <Core/Memory/MemoryArena.h>
#include <Graphics/DebugDisplay.h>
#include <Graphics/Graphics.h>
#include <Graphics/RenderPass.h>
#include <time.h>
#ifdef JULIET_ENABLE_IMGUI
#include <Core/ImGui/ImGuiService.h>
#include <Graphics/ImGuiRenderer.h>
#include <imgui.h>
#endif
namespace Juliet
{
namespace
{
Engine EngineInstance;
}
// Initialize systems that depend on graphics/window (after App::Init)
void InitializeDependentSystems()
{
GraphicsDevice* device = EngineInstance.Application->GetGraphicsDevice();
// DebugDisplay system
if (device)
{
DebugDisplay_Initialize(device);
}
#ifdef JULIET_ENABLE_IMGUI
Window* window = EngineInstance.Application->GetPlatformWindow();
if (window)
{
ImGuiService::Initialize(window);
ImGui::SetCurrentContext(ImGuiService::GetContext());
if (device)
{
ImGuiRenderer_Initialize(device);
// Run Unit Tests automatically
ImGuiService::RunTests(device, window);
}
}
#endif
}
// Shutdown systems that were initialized in InitializeDependentSystems
void ShutdownDependentSystems()
{
GraphicsDevice* device = EngineInstance.Application->GetGraphicsDevice();
#ifdef JULIET_ENABLE_IMGUI
if (device)
{
ImGuiRenderer_Shutdown(device);
}
ImGuiService::Shutdown();
#endif
// DebugDisplay system
if (device)
{
DebugDisplay_Shutdown(device);
}
}
// Render one frame
void RenderFrame()
{
GraphicsDevice* device = EngineInstance.Application->GetGraphicsDevice();
Window* window = EngineInstance.Application->GetPlatformWindow();
if (!device || !window)
{
return;
}
CommandList* cmdList = AcquireCommandList(device, QueueType::Graphics);
if (!cmdList)
{
return;
}
Texture* swapChainTexture = nullptr;
if (!WaitAndAcquireSwapChainTexture(cmdList, window, &swapChainTexture))
{
// Swapchain might need resize, submit empty and try again next frame
SubmitCommandLists(cmdList);
return;
}
if (swapChainTexture)
{
// Pre-render phase (buffer uploads, etc.)
EngineInstance.Application->OnPreRender(cmdList);
// Prepare debug display data (before render pass)
DebugDisplay_Prepare(cmdList);
// Get render targets from application
ColorTargetInfo colorInfo = EngineInstance.Application->GetColorTargetInfo(swapChainTexture);
DepthStencilTargetInfo* depthInfo = EngineInstance.Application->GetDepthTargetInfo();
RenderPass* pass = BeginRenderPass(cmdList, colorInfo, depthInfo);
// Application rendering
EngineInstance.Application->OnRender(pass, cmdList);
// Debug display flush (inside render pass)
Camera debugCamera = EngineInstance.Application->GetDebugCamera();
DebugDisplay_Flush(cmdList, pass, debugCamera);
#ifdef JULIET_ENABLE_IMGUI
// ImGui rendering (always last before EndRenderPass)
ImGuiRenderer_Render(cmdList, pass);
#endif
EndRenderPass(pass);
}
SubmitCommandLists(cmdList);
}
} // namespace
void InitializeEngine(JulietInit_Flags flags)
{
@@ -27,10 +144,16 @@ namespace Juliet
{
EngineInstance.Application = &app;
EngineInstance.Application->Init();
// Systems depending on Window/GraphicsDevice
InitializeDependentSystems();
}
void UnloadApplication()
{
// Shutdown dependent systems before app shutdown
ShutdownDependentSystems();
EngineInstance.Application->Shutdown();
EngineInstance.Application = nullptr;
}
@@ -39,7 +162,18 @@ namespace Juliet
{
while (EngineInstance.Application->IsRunning())
{
#ifdef JULIET_ENABLE_IMGUI
ImGuiRenderer_NewFrame();
#endif
// Logic tick
EngineInstance.Application->Update();
// Render tick
RenderFrame();
// Reset scratch arena at end of frame
ScratchArenaReset();
}
}
} // namespace Juliet

View File

@@ -9,7 +9,7 @@ namespace Juliet
{
namespace
{
constexpr uint32 kMaxDebugVertices = 65536;
constexpr uint32 kMaxDebugVertices = 16384; // 16K vertices = ~450KB per buffer
struct DebugVertex
{
@@ -25,18 +25,14 @@ namespace Juliet
GraphicsPipeline* DepthTestedPipeline;
GraphicsPipeline* OverlayPipeline;
// Vertex data
DebugVertex* DepthTestedVertices;
// Vertex data (CPU side - single array with two regions)
DebugVertex* Vertices; // Single allocation for all vertices
uint32 DepthTestedVertexCount;
DebugVertex* OverlayVertices;
uint32 OverlayVertexCount;
// GPU buffers
GraphicsBuffer* DepthTestedBuffer;
GraphicsBuffer* OverlayBuffer;
GraphicsTransferBuffer* DepthTestedTransfer;
GraphicsTransferBuffer* OverlayTransfer;
// GPU buffers (consolidated - single buffer pair)
GraphicsBuffer* VertexBuffer;
GraphicsTransferBuffer* TransferBuffer;
bool Initialized;
};
@@ -163,26 +159,23 @@ namespace Juliet
g_DebugState.Device = device;
// Allocate CPU vertex arrays
g_DebugState.DepthTestedVertices = static_cast<DebugVertex*>(Malloc(kMaxDebugVertices * sizeof(DebugVertex)));
g_DebugState.OverlayVertices = static_cast<DebugVertex*>(Malloc(kMaxDebugVertices * sizeof(DebugVertex)));
// Allocate single CPU vertex array (depth-tested in first half, overlay in second half)
g_DebugState.Vertices = static_cast<DebugVertex*>(Malloc(kMaxDebugVertices * sizeof(DebugVertex)));
g_DebugState.DepthTestedVertexCount = 0;
g_DebugState.OverlayVertexCount = 0;
// Create GPU buffers
// Create single GPU buffer pair (consolidated)
BufferCreateInfo bufferCI = {};
bufferCI.Size = kMaxDebugVertices * sizeof(DebugVertex);
bufferCI.Usage = BufferUsage::StructuredBuffer;
g_DebugState.DepthTestedBuffer = CreateGraphicsBuffer(device, bufferCI);
g_DebugState.OverlayBuffer = CreateGraphicsBuffer(device, bufferCI);
g_DebugState.VertexBuffer = CreateGraphicsBuffer(device, bufferCI);
TransferBufferCreateInfo transferCI = {};
transferCI.Size = kMaxDebugVertices * sizeof(DebugVertex);
transferCI.Usage = TransferBufferUsage::Upload;
g_DebugState.DepthTestedTransfer = CreateGraphicsTransferBuffer(device, transferCI);
g_DebugState.OverlayTransfer = CreateGraphicsTransferBuffer(device, transferCI);
g_DebugState.TransferBuffer = CreateGraphicsTransferBuffer(device, transferCI);
g_DebugState.Initialized = true;
}
@@ -203,38 +196,33 @@ namespace Juliet
DestroyGraphicsPipeline(device, g_DebugState.OverlayPipeline);
}
if (g_DebugState.DepthTestedBuffer)
if (g_DebugState.VertexBuffer)
{
DestroyGraphicsBuffer(device, g_DebugState.DepthTestedBuffer);
DestroyGraphicsBuffer(device, g_DebugState.VertexBuffer);
}
if (g_DebugState.OverlayBuffer)
if (g_DebugState.TransferBuffer)
{
DestroyGraphicsBuffer(device, g_DebugState.OverlayBuffer);
}
if (g_DebugState.DepthTestedTransfer)
{
DestroyGraphicsTransferBuffer(device, g_DebugState.DepthTestedTransfer);
}
if (g_DebugState.OverlayTransfer)
{
DestroyGraphicsTransferBuffer(device, g_DebugState.OverlayTransfer);
DestroyGraphicsTransferBuffer(device, g_DebugState.TransferBuffer);
}
SafeFree(g_DebugState.DepthTestedVertices);
SafeFree(g_DebugState.OverlayVertices);
SafeFree(g_DebugState.Vertices);
g_DebugState = {};
}
void DebugDisplay_DrawLine(const Vector3& start, const Vector3& end, const FColor& color, bool overlay)
{
// Depth-tested vertices at beginning, overlay vertices at end (growing backward)
if (overlay)
{
AddLine(g_DebugState.OverlayVertices, g_DebugState.OverlayVertexCount, start, end, color);
// Overlay vertices grow from end of buffer backward
uint32 halfMax = kMaxDebugVertices / 2;
AddLine(g_DebugState.Vertices + halfMax, g_DebugState.OverlayVertexCount, start, end, color);
}
else
{
AddLine(g_DebugState.DepthTestedVertices, g_DebugState.DepthTestedVertexCount, start, end, color);
// Depth-tested vertices grow from start of buffer forward
AddLine(g_DebugState.Vertices, g_DebugState.DepthTestedVertexCount, start, end, color);
}
}
@@ -242,11 +230,12 @@ namespace Juliet
{
if (overlay)
{
AddSphereWireframe(g_DebugState.OverlayVertices, g_DebugState.OverlayVertexCount, center, radius, color);
uint32 halfMax = kMaxDebugVertices / 2;
AddSphereWireframe(g_DebugState.Vertices + halfMax, g_DebugState.OverlayVertexCount, center, radius, color);
}
else
{
AddSphereWireframe(g_DebugState.DepthTestedVertices, g_DebugState.DepthTestedVertexCount, center, radius, color);
AddSphereWireframe(g_DebugState.Vertices, g_DebugState.DepthTestedVertexCount, center, radius, color);
}
}
@@ -257,36 +246,35 @@ namespace Juliet
return;
}
// Render depth-tested primitives
if (g_DebugState.DepthTestedVertexCount > 0 && g_DebugState.DepthTestedBuffer)
uint32 totalVertices = g_DebugState.DepthTestedVertexCount + g_DebugState.OverlayVertexCount;
if (totalVertices == 0 || !g_DebugState.VertexBuffer)
{
// Upload vertex data
void* ptr = MapGraphicsTransferBuffer(g_DebugState.Device, g_DebugState.DepthTestedTransfer);
if (ptr)
{
MemCopy(ptr, g_DebugState.DepthTestedVertices, g_DebugState.DepthTestedVertexCount * sizeof(DebugVertex));
UnmapGraphicsTransferBuffer(g_DebugState.Device, g_DebugState.DepthTestedTransfer);
CopyBuffer(cmdList, g_DebugState.DepthTestedBuffer, g_DebugState.DepthTestedTransfer,
g_DebugState.DepthTestedVertexCount * sizeof(DebugVertex));
TransitionBufferToReadable(cmdList, g_DebugState.DepthTestedBuffer);
}
return;
}
// Render overlay primitives
if (g_DebugState.OverlayVertexCount > 0 && g_DebugState.OverlayBuffer)
// Upload all vertex data in one copy (depth-tested at start, overlay at kMaxDebugVertices/2)
void* ptr = MapGraphicsTransferBuffer(g_DebugState.Device, g_DebugState.TransferBuffer);
if (ptr)
{
// Upload vertex data
void* ptr = MapGraphicsTransferBuffer(g_DebugState.Device, g_DebugState.OverlayTransfer);
if (ptr)
// Copy depth-tested vertices (at start)
if (g_DebugState.DepthTestedVertexCount > 0)
{
MemCopy(ptr, g_DebugState.OverlayVertices, g_DebugState.OverlayVertexCount * sizeof(DebugVertex));
UnmapGraphicsTransferBuffer(g_DebugState.Device, g_DebugState.OverlayTransfer);
CopyBuffer(cmdList, g_DebugState.OverlayBuffer, g_DebugState.OverlayTransfer,
g_DebugState.OverlayVertexCount * sizeof(DebugVertex));
TransitionBufferToReadable(cmdList, g_DebugState.OverlayBuffer);
MemCopy(ptr, g_DebugState.Vertices, g_DebugState.DepthTestedVertexCount * sizeof(DebugVertex));
}
// Copy overlay vertices (at kMaxDebugVertices/2 offset)
if (g_DebugState.OverlayVertexCount > 0)
{
uint32 halfMax = kMaxDebugVertices / 2;
auto* overlayDest = static_cast<uint8*>(ptr) + halfMax * sizeof(DebugVertex);
auto* overlaySrc = g_DebugState.Vertices + halfMax;
MemCopy(overlayDest, overlaySrc, g_DebugState.OverlayVertexCount * sizeof(DebugVertex));
}
UnmapGraphicsTransferBuffer(g_DebugState.Device, g_DebugState.TransferBuffer);
// Single buffer copy (full buffer to ensure both regions are uploaded)
size_t copySize = kMaxDebugVertices * sizeof(DebugVertex);
CopyBuffer(cmdList, g_DebugState.VertexBuffer, g_DebugState.TransferBuffer, copySize);
TransitionBufferToReadable(cmdList, g_DebugState.VertexBuffer);
}
}
@@ -306,8 +294,10 @@ namespace Juliet
g_DebugState.OverlayPipeline = CreateDebugPipeline(g_DebugState.Device, TextureFormat::B8G8R8A8_UNORM, false);
}
// Render depth-tested primitives
if (g_DebugState.DepthTestedVertexCount > 0 && g_DebugState.DepthTestedPipeline && g_DebugState.DepthTestedBuffer)
uint32 bufferIndex = GetDescriptorIndex(g_DebugState.Device, g_DebugState.VertexBuffer);
// Render depth-tested primitives (vertices at offset 0 in buffer)
if (g_DebugState.DepthTestedVertexCount > 0 && g_DebugState.DepthTestedPipeline && g_DebugState.VertexBuffer)
{
BindGraphicsPipeline(renderPass, g_DebugState.DepthTestedPipeline);
@@ -315,17 +305,19 @@ namespace Juliet
struct {
Matrix vp;
uint32 bufferIndex;
uint32 padding[3];
uint32 vertexOffset; // Offset in vertices (not bytes)
uint32 padding[2];
} pushData;
pushData.vp = Camera_GetViewProjectionMatrix(camera);
pushData.bufferIndex = GetDescriptorIndex(g_DebugState.Device, g_DebugState.DepthTestedBuffer);
pushData.vp = Camera_GetViewProjectionMatrix(camera);
pushData.bufferIndex = bufferIndex;
pushData.vertexOffset = 0; // Depth-tested vertices start at 0
SetPushConstants(cmdList, ShaderStage::Vertex, 0, sizeof(pushData) / sizeof(uint32), &pushData);
DrawPrimitives(renderPass, g_DebugState.DepthTestedVertexCount, 1, 0, 0);
}
// Render overlay primitives
if (g_DebugState.OverlayVertexCount > 0 && g_DebugState.OverlayPipeline && g_DebugState.OverlayBuffer)
// Render overlay primitives (vertices at offset kMaxDebugVertices/2 in buffer)
if (g_DebugState.OverlayVertexCount > 0 && g_DebugState.OverlayPipeline && g_DebugState.VertexBuffer)
{
BindGraphicsPipeline(renderPass, g_DebugState.OverlayPipeline);
@@ -333,10 +325,12 @@ namespace Juliet
struct {
Matrix vp;
uint32 bufferIndex;
uint32 padding[3];
uint32 vertexOffset; // Offset in vertices (not bytes)
uint32 padding[2];
} pushData;
pushData.vp = Camera_GetViewProjectionMatrix(camera);
pushData.bufferIndex = GetDescriptorIndex(g_DebugState.Device, g_DebugState.OverlayBuffer);
pushData.vp = Camera_GetViewProjectionMatrix(camera);
pushData.bufferIndex = bufferIndex;
pushData.vertexOffset = kMaxDebugVertices / 2; // Overlay vertices start at half
SetPushConstants(cmdList, ShaderStage::Vertex, 0, sizeof(pushData) / sizeof(uint32), &pushData);
DrawPrimitives(renderPass, g_DebugState.OverlayVertexCount, 1, 0, 0);

View File

@@ -0,0 +1,442 @@
#include <Juliet.h>
#ifdef JULIET_ENABLE_IMGUI
#include <Graphics/ImGuiRenderer.h>
#include <Core/Logging/LogManager.h>
#include <Core/Logging/LogTypes.h>
#include <Core/Memory/Allocator.h>
#include <Core/Memory/MemoryArena.h>
#include <Graphics/GraphicsPipeline.h>
#include <imgui.h>
namespace Juliet
{
namespace
{
constexpr uint32 kMaxFramesInFlight = 2;
struct FrameResources
{
GraphicsBuffer* VertexBuffer = nullptr;
GraphicsBuffer* IndexBuffer = nullptr;
GraphicsTransferBuffer* VertexUpload = nullptr;
GraphicsTransferBuffer* IndexUpload = nullptr;
uint32 VertexBufferSize = 0; // In bytes
uint32 IndexBufferSize = 0; // In bytes
};
struct ImGuiRendererState
{
GraphicsDevice* Device;
GraphicsPipeline* Pipeline;
// Resources
Texture* FontTexture;
Shader* VertexShader;
Shader* FragmentShader;
// Frame Data
FrameResources Frames[kMaxFramesInFlight];
uint32 FrameIndex;
bool Initialized;
};
ImGuiRendererState g_ImGuiState = {};
// Helper to resize buffers for a specific frame
void EnsureBufferSize(FrameResources& frame, uint32 requiredVertexBytes, uint32 requiredIndexBytes)
{
bool needVertexRealloc = requiredVertexBytes > frame.VertexBufferSize;
bool needIndexRealloc = requiredIndexBytes > frame.IndexBufferSize;
// If any buffer needs reallocation, wait for GPU to finish using everybody to be safe.
// Ideally we only wait for this specific frame's fence, but we don't have that granularity easily exposed
// here. Resizing is rare, so global wait is acceptable.
if (needVertexRealloc || needIndexRealloc)
{
WaitUntilGPUIsIdle(g_ImGuiState.Device);
}
if (needVertexRealloc)
{
if (frame.VertexBuffer)
{
DestroyGraphicsBuffer(g_ImGuiState.Device, frame.VertexBuffer);
}
if (frame.VertexUpload)
{
DestroyGraphicsTransferBuffer(g_ImGuiState.Device, frame.VertexUpload);
}
frame.VertexBufferSize = requiredVertexBytes + 5000 * sizeof(ImDrawVert); // Growth factor
BufferCreateInfo vci = {};
vci.Size = frame.VertexBufferSize;
vci.Usage = BufferUsage::StructuredBuffer;
frame.VertexBuffer = CreateGraphicsBuffer(g_ImGuiState.Device, vci);
TransferBufferCreateInfo tvci = {};
tvci.Size = frame.VertexBufferSize;
tvci.Usage = TransferBufferUsage::Upload;
frame.VertexUpload = CreateGraphicsTransferBuffer(g_ImGuiState.Device, tvci);
}
if (needIndexRealloc)
{
if (frame.IndexBuffer)
{
DestroyGraphicsBuffer(g_ImGuiState.Device, frame.IndexBuffer);
}
if (frame.IndexUpload)
{
DestroyGraphicsTransferBuffer(g_ImGuiState.Device, frame.IndexUpload);
}
frame.IndexBufferSize = requiredIndexBytes + 10000 * sizeof(ImDrawIdx);
BufferCreateInfo ici = {};
ici.Size = frame.IndexBufferSize;
ici.Usage = BufferUsage::IndexBuffer;
frame.IndexBuffer = CreateGraphicsBuffer(g_ImGuiState.Device, ici);
TransferBufferCreateInfo tici = {};
tici.Size = frame.IndexBufferSize;
tici.Usage = TransferBufferUsage::Upload;
frame.IndexUpload = CreateGraphicsTransferBuffer(g_ImGuiState.Device, tici);
}
}
} // namespace
bool ImGuiRenderer_Initialize(GraphicsDevice* device)
{
printf("ImGuiRenderer_Initialize: device=%p, g_ImGuiState=%p, Initialized=%d\n", (void*)device,
(void*)&g_ImGuiState, g_ImGuiState.Initialized);
if (g_ImGuiState.Initialized)
{
return true;
}
g_ImGuiState.Device = device;
// Load Shaders
String entryPoint = WrapString("main");
ShaderCreateInfo shaderCI = {};
shaderCI.EntryPoint = entryPoint;
String vertPath = WrapString("../../Assets/compiled/ImGui.vert.dxil");
shaderCI.Stage = ShaderStage::Vertex;
g_ImGuiState.VertexShader = CreateShader(device, vertPath, shaderCI);
String fragPath = WrapString("../../Assets/compiled/ImGui.frag.dxil");
shaderCI.Stage = ShaderStage::Fragment;
g_ImGuiState.FragmentShader = CreateShader(device, fragPath, shaderCI);
if (!g_ImGuiState.VertexShader || !g_ImGuiState.FragmentShader)
{
LogError(LogCategory::Graphics, "Failed to load ImGui shaders");
return false;
}
// Build Font Texture
ImGuiIO& io = ImGui::GetIO();
unsigned char* pixels;
int width, height;
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
TextureCreateInfo texCI = {};
texCI.Type = TextureType::Texture_2D;
texCI.Width = (uint32)width;
texCI.Height = (uint32)height;
texCI.Format = TextureFormat::R8G8B8A8_UNORM;
texCI.Flags = TextureUsageFlag::Sampler;
texCI.LayerCount = 1;
texCI.MipLevelCount = 1;
texCI.SampleCount = TextureSampleCount::One;
g_ImGuiState.FontTexture = CreateTexture(device, texCI);
io.Fonts->SetTexID((ImTextureID)g_ImGuiState.FontTexture);
// Upload data
uint32 rowPitch = (uint32)width * 4u;
uint32 alignedRowPitch = (rowPitch + 255u) & ~255u;
uint32 textureSize = alignedRowPitch * static_cast<uint32>(height);
TransferBufferCreateInfo tbci = {};
tbci.Size = textureSize;
tbci.Usage = TransferBufferUsage::Upload;
GraphicsTransferBuffer* tb = CreateGraphicsTransferBuffer(device, tbci);
if (!tb)
{
Log(LogLevel::Error, LogCategory::Graphics, "ImGuiRenderer: Failed to create font upload buffer");
return false;
}
auto dst = (uint8*)MapGraphicsTransferBuffer(device, tb);
for (uint32 y = 0; y < static_cast<uint32>(height); ++y)
{
MemCopy(dst + y * alignedRowPitch, pixels + y * rowPitch, rowPitch);
}
UnmapGraphicsTransferBuffer(device, tb);
CommandList* cmd = AcquireCommandList(device);
CopyBufferToTexture(cmd, g_ImGuiState.FontTexture, tb);
SubmitCommandLists(cmd);
WaitUntilGPUIsIdle(device);
DestroyGraphicsTransferBuffer(device, tb);
// Init Frame Data
g_ImGuiState.FrameIndex = 0;
for (uint32 i = 0; i < kMaxFramesInFlight; ++i)
{
g_ImGuiState.Frames[i] = {};
}
g_ImGuiState.Initialized = true;
return true;
}
void ImGuiRenderer_Shutdown(GraphicsDevice* device)
{
if (!g_ImGuiState.Initialized)
{
return;
}
WaitUntilGPUIsIdle(device);
if (g_ImGuiState.Pipeline)
{
DestroyGraphicsPipeline(device, g_ImGuiState.Pipeline);
}
if (g_ImGuiState.VertexShader)
{
DestroyShader(device, g_ImGuiState.VertexShader);
}
if (g_ImGuiState.FragmentShader)
{
DestroyShader(device, g_ImGuiState.FragmentShader);
}
if (g_ImGuiState.FontTexture)
{
DestroyTexture(device, g_ImGuiState.FontTexture);
}
for (uint32 i = 0; i < kMaxFramesInFlight; ++i)
{
FrameResources& frame = g_ImGuiState.Frames[i];
if (frame.VertexBuffer)
{
DestroyGraphicsBuffer(device, frame.VertexBuffer);
}
if (frame.IndexBuffer)
{
DestroyGraphicsBuffer(device, frame.IndexBuffer);
}
if (frame.VertexUpload)
{
DestroyGraphicsTransferBuffer(device, frame.VertexUpload);
}
if (frame.IndexUpload)
{
DestroyGraphicsTransferBuffer(device, frame.IndexUpload);
}
frame = {};
}
g_ImGuiState = {};
}
void ImGuiRenderer_NewFrame()
{
ImGui_ImplWin32_NewFrame(); // Assumes Win32 initialized elsewhere
ImGui::NewFrame();
}
void ImGuiRenderer_Render(CommandList* cmdList, RenderPass* renderPass)
{
if (!g_ImGuiState.Initialized)
{
return;
}
ImGui::Render();
ImDrawData* drawData = ImGui::GetDrawData();
if (!drawData || drawData->CmdListsCount == 0)
{
return;
}
// Lazy create pipeline
if (!g_ImGuiState.Pipeline)
{
// Assume B8G8R8A8_UNORM for SwapChain
GraphicsPipelineCreateInfo pci = {};
pci.VertexShader = g_ImGuiState.VertexShader;
pci.FragmentShader = g_ImGuiState.FragmentShader;
pci.PrimitiveType = PrimitiveType::TriangleList;
pci.RasterizerState.FillMode = FillMode::Solid;
pci.RasterizerState.CullMode = CullMode::None;
ColorTargetDescription colorDesc = {};
colorDesc.Format = TextureFormat::B8G8R8A8_UNORM; // Match SwapChain
// Blend State
colorDesc.BlendState.EnableBlend = true;
colorDesc.BlendState.SourceColorBlendFactor = BlendFactor::Src_Alpha;
colorDesc.BlendState.DestinationColorBlendFactor = BlendFactor::One_Minus_Src_Alpha;
colorDesc.BlendState.ColorBlendOperation = BlendOperation::Add;
colorDesc.BlendState.SourceAlphaBlendFactor = BlendFactor::One;
colorDesc.BlendState.DestinationAlphaBlendFactor = BlendFactor::One_Minus_Src_Alpha;
colorDesc.BlendState.AlphaBlendOperation = BlendOperation::Add;
colorDesc.BlendState.EnableColorWriteMask = true;
colorDesc.BlendState.ColorWriteMask =
ColorComponentFlags::R | ColorComponentFlags::G | ColorComponentFlags::B | ColorComponentFlags::A;
pci.TargetInfo.ColorTargetDescriptions = &colorDesc;
pci.TargetInfo.NumColorTargets = 1;
g_ImGuiState.Pipeline = CreateGraphicsPipeline(g_ImGuiState.Device, pci);
}
// Cycle Frame
g_ImGuiState.FrameIndex = (g_ImGuiState.FrameIndex + 1) % kMaxFramesInFlight;
FrameResources& currentFrame = g_ImGuiState.Frames[g_ImGuiState.FrameIndex];
// Upload Buffers
uint32 totalVtx = (uint32)drawData->TotalVtxCount;
uint32 totalIdx = (uint32)drawData->TotalIdxCount;
EnsureBufferSize(currentFrame, totalVtx * sizeof(ImDrawVert), totalIdx * sizeof(ImDrawIdx));
auto vtxDst = (ImDrawVert*)MapGraphicsTransferBuffer(g_ImGuiState.Device, currentFrame.VertexUpload);
auto idxDst = (ImDrawIdx*)MapGraphicsTransferBuffer(g_ImGuiState.Device, currentFrame.IndexUpload);
for (int n = 0; n < drawData->CmdListsCount; n++)
{
const ImDrawList* cmd_list = drawData->CmdLists[n];
MemCopy(vtxDst, cmd_list->VtxBuffer.Data, static_cast<size_t>(cmd_list->VtxBuffer.Size) * sizeof(ImDrawVert));
MemCopy(idxDst, cmd_list->IdxBuffer.Data, static_cast<size_t>(cmd_list->IdxBuffer.Size) * sizeof(ImDrawIdx));
vtxDst += cmd_list->VtxBuffer.Size;
idxDst += cmd_list->IdxBuffer.Size;
}
UnmapGraphicsTransferBuffer(g_ImGuiState.Device, currentFrame.VertexUpload);
UnmapGraphicsTransferBuffer(g_ImGuiState.Device, currentFrame.IndexUpload);
// Copy both vertex and index buffers to GPU
CopyBuffer(cmdList, currentFrame.VertexBuffer, currentFrame.VertexUpload, totalVtx * sizeof(ImDrawVert));
CopyBuffer(cmdList, currentFrame.IndexBuffer, currentFrame.IndexUpload, totalIdx * sizeof(ImDrawIdx));
// Transition vertex buffer to SRV state (this barrier waits for copy to complete)
TransitionBufferToReadable(cmdList, currentFrame.VertexBuffer);
// SetIndexBuffer transitions from COPY_DEST to INDEX_BUFFER (barrier waits for copy to complete)
SetIndexBuffer(cmdList, currentFrame.IndexBuffer, IndexFormat::UInt16);
// Render
BindGraphicsPipeline(renderPass, g_ImGuiState.Pipeline);
// Setup Viewport / Scale
float L = drawData->DisplayPos.x;
float R = drawData->DisplayPos.x + drawData->DisplaySize.x;
float T = drawData->DisplayPos.y;
float B = drawData->DisplayPos.y + drawData->DisplaySize.y;
float scale[2];
scale[0] = 2.0f / (R - L);
scale[1] = -2.0f / (B - T);
float translate[2];
translate[0] = -1.0f - L * scale[0];
translate[1] = 1.0f - T * scale[1];
// Global State (Display Size, etc)
uint32 globalVtxOffset = 0;
uint32 globalIdxOffset = 0;
ImVec2 clip_off = drawData->DisplayPos;
ImVec2 clip_scale = drawData->FramebufferScale;
for (int n = 0; n < drawData->CmdListsCount; n++)
{
const ImDrawList* cmd_list = drawData->CmdLists[n];
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback != nullptr)
{
// pcmd->UserCallback(cmd_list, pcmd);
}
else
{
// Project scissor/clipping rectangles into framebuffer space
ImVec2 clip_min((pcmd->ClipRect.x - clip_off.x) * clip_scale.x,
(pcmd->ClipRect.y - clip_off.y) * clip_scale.y);
ImVec2 clip_max((pcmd->ClipRect.z - clip_off.x) * clip_scale.x,
(pcmd->ClipRect.w - clip_off.y) * clip_scale.y);
// Skip draw commands with zero-sized scissor rectangles
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
{
continue;
}
// Set scissor rect (clipping rectangle)
Rectangle scissorRect = {};
scissorRect.X = static_cast<int32>(clip_min.x);
scissorRect.Y = static_cast<int32>(clip_min.y);
scissorRect.Width = static_cast<int32>(clip_max.x - clip_min.x);
scissorRect.Height = static_cast<int32>(clip_max.y - clip_min.y);
SetScissorRect(renderPass, scissorRect);
// Bind Texture
uint32 textureIndex = GetDescriptorIndex(g_ImGuiState.Device, (Texture*)pcmd->GetTexID());
// Push Constants
// Layout: ViewProjection(64) + BufferIndex(4) + TextureIndex(4) + VertexOffset(4) + Padding(4) + Scale(8) + Translate(8)
struct
{
float dummyVP[16]; // Occupy VP slot
uint32 bufferIndex;
uint32 textureIndex;
uint32 vertexOffset; // Base vertex for indexed bindless drawing
uint32 padding; // Alignment padding
float scale[2];
float translate[2];
} pushData = {}; // Zero-initialize all fields
pushData.bufferIndex = GetDescriptorIndex(g_ImGuiState.Device, currentFrame.VertexBuffer);
pushData.textureIndex = textureIndex;
pushData.vertexOffset = pcmd->VtxOffset + globalVtxOffset; // Pass vertex offset for bindless
pushData.scale[0] = scale[0];
pushData.scale[1] = scale[1];
pushData.translate[0] = translate[0];
pushData.translate[1] = translate[1];
SetPushConstants(cmdList, ShaderStage::Vertex, 0, sizeof(pushData) / 4, &pushData);
// Draw - pass 0 for vertexOffset since shader handles it via push constants
DrawIndexedPrimitives(renderPass, pcmd->ElemCount, 1, pcmd->IdxOffset + globalIdxOffset, 0, 0);
}
}
globalIdxOffset += static_cast<uint32>(cmd_list->IdxBuffer.Size);
globalVtxOffset += static_cast<uint32>(cmd_list->VtxBuffer.Size);
}
}
} // namespace Juliet
#endif // JULIET_ENABLE_IMGUI