From 915858c0d3163dcdd54e2eb416b3fe8398de2feb Mon Sep 17 00:00:00 2001 From: Patedam Date: Thu, 9 Jan 2025 22:35:33 -0500 Subject: [PATCH] Moved stuff around + start of graphics device support (dx12) --- Juliet/Juliet.vcxproj | 149 +++++++++--------- Juliet/include/Core/Logging/LogTypes.h | 9 +- Juliet/include/Graphics/Graphics.h | 8 +- Juliet/include/Graphics/GraphicsConfig.h | 19 +-- Juliet/src/Core/HAL/Display/Display.cpp | 1 + .../directx/D3D12TokenizedProgramFormat.hpp | 0 .../{RHI => }/DX12/D3D12/directx/DirectML.h | 0 .../{RHI => }/DX12/D3D12/directx/d3d12.h | 0 .../{RHI => }/DX12/D3D12/directx/d3d12.idl | 0 .../DX12/D3D12/directx/d3d12compatibility.h | 0 .../DX12/D3D12/directx/d3d12compatibility.idl | 0 .../DX12/D3D12/directx/d3d12sdklayers.h | 0 .../DX12/D3D12/directx/d3d12sdklayers.idl | 0 .../DX12/D3D12/directx/d3d12shader.h | 0 .../{RHI => }/DX12/D3D12/directx/d3d12video.h | 0 .../DX12/D3D12/directx/d3d12video.idl | 0 .../{RHI => }/DX12/D3D12/directx/d3dcommon.h | 0 .../DX12/D3D12/directx/d3dcommon.idl | 0 .../{RHI => }/DX12/D3D12/directx/d3dx12.h | 0 .../DX12/D3D12/directx/d3dx12_barriers.h | 0 .../directx/d3dx12_check_feature_support.h | 0 .../DX12/D3D12/directx/d3dx12_core.h | 0 .../DX12/D3D12/directx/d3dx12_default.h | 0 .../directx/d3dx12_pipeline_state_stream.h | 0 .../directx/d3dx12_property_format_table.cpp | 0 .../directx/d3dx12_property_format_table.h | 0 .../DX12/D3D12/directx/d3dx12_render_pass.h | 0 .../D3D12/directx/d3dx12_resource_helpers.h | 0 .../D3D12/directx/d3dx12_root_signature.h | 0 .../DX12/D3D12/directx/d3dx12_state_object.h | 0 .../{RHI => }/DX12/D3D12/directx/dxcore.h | 0 .../DX12/D3D12/directx/dxcore_interface.h | 0 .../{RHI => }/DX12/D3D12/directx/dxgicommon.h | 0 .../DX12/D3D12/directx/dxgicommon.idl | 0 .../{RHI => }/DX12/D3D12/directx/dxgiformat.h | 0 .../DX12/D3D12/directx/dxgiformat.idl | 0 .../{RHI => }/DX12/D3D12/dxguids/dxguids.cpp | 0 .../{RHI => }/DX12/D3D12/dxguids/dxguids.h | 0 .../{RHI => }/DX12/D3D12/wsl/stubs/basetsd.h | 0 .../{RHI => }/DX12/D3D12/wsl/stubs/oaidl.h | 0 .../{RHI => }/DX12/D3D12/wsl/stubs/ocidl.h | 0 .../{RHI => }/DX12/D3D12/wsl/stubs/rpc.h | 0 .../{RHI => }/DX12/D3D12/wsl/stubs/rpcndr.h | 0 .../{RHI => }/DX12/D3D12/wsl/stubs/unknwn.h | 0 .../DX12/D3D12/wsl/stubs/unknwnbase.h | 0 .../DX12/D3D12/wsl/stubs/winapifamily.h | 0 .../DX12/D3D12/wsl/stubs/wrl/client.h | 0 .../DX12/D3D12/wsl/stubs/wrl/implements.h | 0 .../{RHI => }/DX12/D3D12/wsl/winadapter.h | 0 .../{RHI => }/DX12/D3D12/wsl/wrladapter.h | 0 .../src/Graphics/DX12/DX12GraphicsDevice.cpp | 28 ++++ .../Graphics/{RHI => }/DX12/DX12Includes.h | 0 .../src/Graphics/{RHI => }/DX12/DX12Utils.h | 2 + Juliet/src/Graphics/Graphics.cpp | 56 ++++++- Juliet/src/Graphics/GraphicsDevice.h | 20 +++ JulietApp/Editor/EditorMain_win32.cpp | 8 +- 56 files changed, 207 insertions(+), 93 deletions(-) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/D3D12TokenizedProgramFormat.hpp (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/DirectML.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/d3d12.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/d3d12.idl (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/d3d12compatibility.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/d3d12compatibility.idl (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/d3d12sdklayers.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/d3d12sdklayers.idl (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/d3d12shader.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/d3d12video.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/d3d12video.idl (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/d3dcommon.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/d3dcommon.idl (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/d3dx12.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/d3dx12_barriers.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/d3dx12_check_feature_support.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/d3dx12_core.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/d3dx12_default.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/d3dx12_pipeline_state_stream.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/d3dx12_property_format_table.cpp (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/d3dx12_property_format_table.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/d3dx12_render_pass.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/d3dx12_resource_helpers.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/d3dx12_root_signature.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/d3dx12_state_object.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/dxcore.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/dxcore_interface.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/dxgicommon.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/dxgicommon.idl (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/dxgiformat.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/directx/dxgiformat.idl (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/dxguids/dxguids.cpp (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/dxguids/dxguids.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/wsl/stubs/basetsd.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/wsl/stubs/oaidl.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/wsl/stubs/ocidl.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/wsl/stubs/rpc.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/wsl/stubs/rpcndr.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/wsl/stubs/unknwn.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/wsl/stubs/unknwnbase.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/wsl/stubs/winapifamily.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/wsl/stubs/wrl/client.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/wsl/stubs/wrl/implements.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/wsl/winadapter.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/D3D12/wsl/wrladapter.h (100%) create mode 100644 Juliet/src/Graphics/DX12/DX12GraphicsDevice.cpp rename Juliet/src/Graphics/{RHI => }/DX12/DX12Includes.h (100%) rename Juliet/src/Graphics/{RHI => }/DX12/DX12Utils.h (78%) create mode 100644 Juliet/src/Graphics/GraphicsDevice.h diff --git a/Juliet/Juliet.vcxproj b/Juliet/Juliet.vcxproj index 1061f1f..9d5cd4b 100644 --- a/Juliet/Juliet.vcxproj +++ b/Juliet/Juliet.vcxproj @@ -141,86 +141,91 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + MultiThreadedDebugDll + Disabled + true + NoListing + W:\Classified\Juliet\Intermediate\Juliet\x64\Debug\ + false + W:\Classified\Juliet\Intermediate\Juliet\x64\Debug\ + Default + Default + Column + false + false + false + NotSet + Fast + Default + false + stdcpp20 + Default + W:\Classified\Juliet\Intermediate\Juliet\x64\Debug\ + false + Neither + W:\Classified\Juliet\Intermediate\Juliet\x64\Debug\ + Cdecl + Use + pch.h + W:\Classified\Juliet\Intermediate\Juliet\x64\Debug\Juliet.pch + false + false + false + false + false + W:\Classified\Juliet\Intermediate\Juliet\x64\Debug\ + true + true + false + Default + W:\Classified\Juliet\Intermediate\Juliet\x64\Debug\Juliet.tlog\ + true + false + Level3 + W:\Classified\Juliet\Intermediate\Juliet\x64\Debug\ + ProgramDatabase + false + false + true + _DEBUG;_LIB;JULIET_WIN32;_UNICODE;UNICODE; + false + true + true + Default + --target=amd64-pc-windows-msvc + Create Create - - - - - - - - - - - + diff --git a/Juliet/include/Core/Logging/LogTypes.h b/Juliet/include/Core/Logging/LogTypes.h index 06e438f..35984fd 100644 --- a/Juliet/include/Core/Logging/LogTypes.h +++ b/Juliet/include/Core/Logging/LogTypes.h @@ -12,9 +12,10 @@ namespace Juliet enum class LogCategory : uint8 { Core = 0, - Networking = 1, - Engine = 2, - Editor = 3, - Game = 4, + Graphics = 1, + Networking = 2, + Engine = 3, + Editor = 4, + Game = 5, }; } // namespace Juliet diff --git a/Juliet/include/Graphics/Graphics.h b/Juliet/include/Graphics/Graphics.h index 29e69a0..e703134 100644 --- a/Juliet/include/Graphics/Graphics.h +++ b/Juliet/include/Graphics/Graphics.h @@ -3,7 +3,9 @@ #include // Graphics Interface -namespace Juliet::Graphics +namespace Juliet { - // Add functions to create windows, device, attach to the window etc... -} // namespace Juliet::Graphics + struct GraphicsDevice; + + extern GraphicsDevice* CreateGraphicsDevice(GraphicsConfig config); +} // namespace Juliet diff --git a/Juliet/include/Graphics/GraphicsConfig.h b/Juliet/include/Graphics/GraphicsConfig.h index 2b8f322..4838eac 100644 --- a/Juliet/include/Graphics/GraphicsConfig.h +++ b/Juliet/include/Graphics/GraphicsConfig.h @@ -2,13 +2,14 @@ namespace Juliet { -enum class RendererType -{ - DX12 = 0 -}; + enum class RendererType : uint8 + { + Any = 0, + DX12 = 1, + }; -struct GraphicsConfig -{ - RendererType Renderer = RendererType::DX12; -}; -} \ No newline at end of file + struct GraphicsConfig + { + RendererType PreferredRenderer = RendererType::DX12; + }; +} // namespace Juliet diff --git a/Juliet/src/Core/HAL/Display/Display.cpp b/Juliet/src/Core/HAL/Display/Display.cpp index 3123c77..eb982b8 100644 --- a/Juliet/src/Core/HAL/Display/Display.cpp +++ b/Juliet/src/Core/HAL/Display/Display.cpp @@ -11,6 +11,7 @@ namespace Juliet { DisplayDevice* CurrentDisplayDevice = nullptr; + // TODO : IfDef new factories that are not compatible constexpr DisplayDeviceFactory* Factories[] = { &Win32DisplayDeviceFactory, nullptr }; } // namespace diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/D3D12TokenizedProgramFormat.hpp b/Juliet/src/Graphics/DX12/D3D12/directx/D3D12TokenizedProgramFormat.hpp similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/D3D12TokenizedProgramFormat.hpp rename to Juliet/src/Graphics/DX12/D3D12/directx/D3D12TokenizedProgramFormat.hpp diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/DirectML.h b/Juliet/src/Graphics/DX12/D3D12/directx/DirectML.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/DirectML.h rename to Juliet/src/Graphics/DX12/D3D12/directx/DirectML.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3d12.h b/Juliet/src/Graphics/DX12/D3D12/directx/d3d12.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3d12.h rename to Juliet/src/Graphics/DX12/D3D12/directx/d3d12.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3d12.idl b/Juliet/src/Graphics/DX12/D3D12/directx/d3d12.idl similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3d12.idl rename to Juliet/src/Graphics/DX12/D3D12/directx/d3d12.idl diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3d12compatibility.h b/Juliet/src/Graphics/DX12/D3D12/directx/d3d12compatibility.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3d12compatibility.h rename to Juliet/src/Graphics/DX12/D3D12/directx/d3d12compatibility.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3d12compatibility.idl b/Juliet/src/Graphics/DX12/D3D12/directx/d3d12compatibility.idl similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3d12compatibility.idl rename to Juliet/src/Graphics/DX12/D3D12/directx/d3d12compatibility.idl diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3d12sdklayers.h b/Juliet/src/Graphics/DX12/D3D12/directx/d3d12sdklayers.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3d12sdklayers.h rename to Juliet/src/Graphics/DX12/D3D12/directx/d3d12sdklayers.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3d12sdklayers.idl b/Juliet/src/Graphics/DX12/D3D12/directx/d3d12sdklayers.idl similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3d12sdklayers.idl rename to Juliet/src/Graphics/DX12/D3D12/directx/d3d12sdklayers.idl diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3d12shader.h b/Juliet/src/Graphics/DX12/D3D12/directx/d3d12shader.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3d12shader.h rename to Juliet/src/Graphics/DX12/D3D12/directx/d3d12shader.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3d12video.h b/Juliet/src/Graphics/DX12/D3D12/directx/d3d12video.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3d12video.h rename to Juliet/src/Graphics/DX12/D3D12/directx/d3d12video.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3d12video.idl b/Juliet/src/Graphics/DX12/D3D12/directx/d3d12video.idl similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3d12video.idl rename to Juliet/src/Graphics/DX12/D3D12/directx/d3d12video.idl diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dcommon.h b/Juliet/src/Graphics/DX12/D3D12/directx/d3dcommon.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dcommon.h rename to Juliet/src/Graphics/DX12/D3D12/directx/d3dcommon.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dcommon.idl b/Juliet/src/Graphics/DX12/D3D12/directx/d3dcommon.idl similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dcommon.idl rename to Juliet/src/Graphics/DX12/D3D12/directx/d3dcommon.idl diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12.h b/Juliet/src/Graphics/DX12/D3D12/directx/d3dx12.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12.h rename to Juliet/src/Graphics/DX12/D3D12/directx/d3dx12.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12_barriers.h b/Juliet/src/Graphics/DX12/D3D12/directx/d3dx12_barriers.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12_barriers.h rename to Juliet/src/Graphics/DX12/D3D12/directx/d3dx12_barriers.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12_check_feature_support.h b/Juliet/src/Graphics/DX12/D3D12/directx/d3dx12_check_feature_support.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12_check_feature_support.h rename to Juliet/src/Graphics/DX12/D3D12/directx/d3dx12_check_feature_support.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12_core.h b/Juliet/src/Graphics/DX12/D3D12/directx/d3dx12_core.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12_core.h rename to Juliet/src/Graphics/DX12/D3D12/directx/d3dx12_core.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12_default.h b/Juliet/src/Graphics/DX12/D3D12/directx/d3dx12_default.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12_default.h rename to Juliet/src/Graphics/DX12/D3D12/directx/d3dx12_default.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12_pipeline_state_stream.h b/Juliet/src/Graphics/DX12/D3D12/directx/d3dx12_pipeline_state_stream.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12_pipeline_state_stream.h rename to Juliet/src/Graphics/DX12/D3D12/directx/d3dx12_pipeline_state_stream.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12_property_format_table.cpp b/Juliet/src/Graphics/DX12/D3D12/directx/d3dx12_property_format_table.cpp similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12_property_format_table.cpp rename to Juliet/src/Graphics/DX12/D3D12/directx/d3dx12_property_format_table.cpp diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12_property_format_table.h b/Juliet/src/Graphics/DX12/D3D12/directx/d3dx12_property_format_table.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12_property_format_table.h rename to Juliet/src/Graphics/DX12/D3D12/directx/d3dx12_property_format_table.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12_render_pass.h b/Juliet/src/Graphics/DX12/D3D12/directx/d3dx12_render_pass.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12_render_pass.h rename to Juliet/src/Graphics/DX12/D3D12/directx/d3dx12_render_pass.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12_resource_helpers.h b/Juliet/src/Graphics/DX12/D3D12/directx/d3dx12_resource_helpers.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12_resource_helpers.h rename to Juliet/src/Graphics/DX12/D3D12/directx/d3dx12_resource_helpers.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12_root_signature.h b/Juliet/src/Graphics/DX12/D3D12/directx/d3dx12_root_signature.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12_root_signature.h rename to Juliet/src/Graphics/DX12/D3D12/directx/d3dx12_root_signature.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12_state_object.h b/Juliet/src/Graphics/DX12/D3D12/directx/d3dx12_state_object.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/d3dx12_state_object.h rename to Juliet/src/Graphics/DX12/D3D12/directx/d3dx12_state_object.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/dxcore.h b/Juliet/src/Graphics/DX12/D3D12/directx/dxcore.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/dxcore.h rename to Juliet/src/Graphics/DX12/D3D12/directx/dxcore.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/dxcore_interface.h b/Juliet/src/Graphics/DX12/D3D12/directx/dxcore_interface.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/dxcore_interface.h rename to Juliet/src/Graphics/DX12/D3D12/directx/dxcore_interface.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/dxgicommon.h b/Juliet/src/Graphics/DX12/D3D12/directx/dxgicommon.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/dxgicommon.h rename to Juliet/src/Graphics/DX12/D3D12/directx/dxgicommon.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/dxgicommon.idl b/Juliet/src/Graphics/DX12/D3D12/directx/dxgicommon.idl similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/dxgicommon.idl rename to Juliet/src/Graphics/DX12/D3D12/directx/dxgicommon.idl diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/dxgiformat.h b/Juliet/src/Graphics/DX12/D3D12/directx/dxgiformat.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/dxgiformat.h rename to Juliet/src/Graphics/DX12/D3D12/directx/dxgiformat.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/directx/dxgiformat.idl b/Juliet/src/Graphics/DX12/D3D12/directx/dxgiformat.idl similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/directx/dxgiformat.idl rename to Juliet/src/Graphics/DX12/D3D12/directx/dxgiformat.idl diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/dxguids/dxguids.cpp b/Juliet/src/Graphics/DX12/D3D12/dxguids/dxguids.cpp similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/dxguids/dxguids.cpp rename to Juliet/src/Graphics/DX12/D3D12/dxguids/dxguids.cpp diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/dxguids/dxguids.h b/Juliet/src/Graphics/DX12/D3D12/dxguids/dxguids.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/dxguids/dxguids.h rename to Juliet/src/Graphics/DX12/D3D12/dxguids/dxguids.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/wsl/stubs/basetsd.h b/Juliet/src/Graphics/DX12/D3D12/wsl/stubs/basetsd.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/wsl/stubs/basetsd.h rename to Juliet/src/Graphics/DX12/D3D12/wsl/stubs/basetsd.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/wsl/stubs/oaidl.h b/Juliet/src/Graphics/DX12/D3D12/wsl/stubs/oaidl.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/wsl/stubs/oaidl.h rename to Juliet/src/Graphics/DX12/D3D12/wsl/stubs/oaidl.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/wsl/stubs/ocidl.h b/Juliet/src/Graphics/DX12/D3D12/wsl/stubs/ocidl.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/wsl/stubs/ocidl.h rename to Juliet/src/Graphics/DX12/D3D12/wsl/stubs/ocidl.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/wsl/stubs/rpc.h b/Juliet/src/Graphics/DX12/D3D12/wsl/stubs/rpc.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/wsl/stubs/rpc.h rename to Juliet/src/Graphics/DX12/D3D12/wsl/stubs/rpc.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/wsl/stubs/rpcndr.h b/Juliet/src/Graphics/DX12/D3D12/wsl/stubs/rpcndr.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/wsl/stubs/rpcndr.h rename to Juliet/src/Graphics/DX12/D3D12/wsl/stubs/rpcndr.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/wsl/stubs/unknwn.h b/Juliet/src/Graphics/DX12/D3D12/wsl/stubs/unknwn.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/wsl/stubs/unknwn.h rename to Juliet/src/Graphics/DX12/D3D12/wsl/stubs/unknwn.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/wsl/stubs/unknwnbase.h b/Juliet/src/Graphics/DX12/D3D12/wsl/stubs/unknwnbase.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/wsl/stubs/unknwnbase.h rename to Juliet/src/Graphics/DX12/D3D12/wsl/stubs/unknwnbase.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/wsl/stubs/winapifamily.h b/Juliet/src/Graphics/DX12/D3D12/wsl/stubs/winapifamily.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/wsl/stubs/winapifamily.h rename to Juliet/src/Graphics/DX12/D3D12/wsl/stubs/winapifamily.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/wsl/stubs/wrl/client.h b/Juliet/src/Graphics/DX12/D3D12/wsl/stubs/wrl/client.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/wsl/stubs/wrl/client.h rename to Juliet/src/Graphics/DX12/D3D12/wsl/stubs/wrl/client.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/wsl/stubs/wrl/implements.h b/Juliet/src/Graphics/DX12/D3D12/wsl/stubs/wrl/implements.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/wsl/stubs/wrl/implements.h rename to Juliet/src/Graphics/DX12/D3D12/wsl/stubs/wrl/implements.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/wsl/winadapter.h b/Juliet/src/Graphics/DX12/D3D12/wsl/winadapter.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/wsl/winadapter.h rename to Juliet/src/Graphics/DX12/D3D12/wsl/winadapter.h diff --git a/Juliet/src/Graphics/RHI/DX12/D3D12/wsl/wrladapter.h b/Juliet/src/Graphics/DX12/D3D12/wsl/wrladapter.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/D3D12/wsl/wrladapter.h rename to Juliet/src/Graphics/DX12/D3D12/wsl/wrladapter.h diff --git a/Juliet/src/Graphics/DX12/DX12GraphicsDevice.cpp b/Juliet/src/Graphics/DX12/DX12GraphicsDevice.cpp new file mode 100644 index 0000000..5f5daeb --- /dev/null +++ b/Juliet/src/Graphics/DX12/DX12GraphicsDevice.cpp @@ -0,0 +1,28 @@ +#include + +#include + +namespace Juliet +{ + // TODO : Use DLL instead of static link + namespace + { + bool CheckDriver() + { + return false; + } + + GraphicsDevice* CreateGraphicsDevice() + { + return nullptr; + } + } // namespace + + // clang-format off + GraphicsDeviceFactory DX12DeviceFactory = { + .Name="DirectX12", + .Type=RendererType::DX12, + .CheckDriver = CheckDriver, + .CreateGraphicsDevice = CreateGraphicsDevice }; + // clang-format on +} // namespace Juliet diff --git a/Juliet/src/Graphics/RHI/DX12/DX12Includes.h b/Juliet/src/Graphics/DX12/DX12Includes.h similarity index 100% rename from Juliet/src/Graphics/RHI/DX12/DX12Includes.h rename to Juliet/src/Graphics/DX12/DX12Includes.h diff --git a/Juliet/src/Graphics/RHI/DX12/DX12Utils.h b/Juliet/src/Graphics/DX12/DX12Utils.h similarity index 78% rename from Juliet/src/Graphics/RHI/DX12/DX12Utils.h rename to Juliet/src/Graphics/DX12/DX12Utils.h index 5a6c145..211d583 100644 --- a/Juliet/src/Graphics/RHI/DX12/DX12Utils.h +++ b/Juliet/src/Graphics/DX12/DX12Utils.h @@ -1,5 +1,7 @@ #pragma once +#include + namespace Juliet::RHI::DX12 { inline void AssertOnFailure(HRESULT hr) diff --git a/Juliet/src/Graphics/Graphics.cpp b/Juliet/src/Graphics/Graphics.cpp index b89c48a..c43defb 100644 --- a/Juliet/src/Graphics/Graphics.cpp +++ b/Juliet/src/Graphics/Graphics.cpp @@ -1,8 +1,60 @@ #include #include +#include -namespace Juliet::Graphics +namespace Juliet { + namespace + { + GraphicsDevice* CurrentGraphicsDevice = nullptr; -} // namespace Juliet::Graphics + // TODO : IfDef new factories that are not compatible + // Low chance of porting on something else than windows though. May be linux but will use vulkan that works on windows + constexpr GraphicsDeviceFactory* Factories[] = { &DX12DeviceFactory }; + + GraphicsDeviceFactory* ChooseFactory(GraphicsConfig config) + { + // First try to check the preferred renderer from the config if any. + if (config.PreferredRenderer != RendererType::Any) + { + for (GraphicsDeviceFactory* factory : Factories) + { + // If the config has a preferred renderer, immediately pick it up. + if (factory->Type == config.PreferredRenderer) + { + if (factory->CheckDriver()) + { + return factory; + } + } + } + } + + // If not preferred renderer was set, use the first one that works in the list + for (GraphicsDeviceFactory* factory : Factories) + { + // TODO : Make sure it's supported by querying it first. If supported -> Lets go + if (factory->CheckDriver()) + { + return factory; + } + } + + Log(LogLevel::Error, LogCategory::Graphics, "CreateGraphicsDevice::ChooseFactory: No valid driver found"); + return nullptr; + } + } // namespace + + GraphicsDevice* CreateGraphicsDevice(GraphicsConfig config) + { + GraphicsDeviceFactory* chosenFactory = ChooseFactory(config); + if (chosenFactory) + { + GraphicsDevice* newDevice = chosenFactory->CreateGraphicsDevice(); + newDevice->Name = chosenFactory->Name; + return newDevice; + } + return nullptr; + } +} // namespace Juliet diff --git a/Juliet/src/Graphics/GraphicsDevice.h b/Juliet/src/Graphics/GraphicsDevice.h new file mode 100644 index 0000000..0302b4b --- /dev/null +++ b/Juliet/src/Graphics/GraphicsDevice.h @@ -0,0 +1,20 @@ +#pragma once +#include + +namespace Juliet +{ + struct GraphicsDevice + { + const char* Name = "Unknown"; + }; + + struct GraphicsDeviceFactory + { + const char* Name = "Unknown"; + RendererType Type = RendererType::Any; + bool (*CheckDriver)(void); + GraphicsDevice* (*CreateGraphicsDevice)(void); + }; + + extern GraphicsDeviceFactory DX12DeviceFactory; +} \ No newline at end of file diff --git a/JulietApp/Editor/EditorMain_win32.cpp b/JulietApp/Editor/EditorMain_win32.cpp index 53ac097..2f814ca 100644 --- a/JulietApp/Editor/EditorMain_win32.cpp +++ b/JulietApp/Editor/EditorMain_win32.cpp @@ -11,6 +11,7 @@ #include // TODO : Replace with message box from framework + call main and not winmain + subsystem +#include #include namespace Juliet @@ -21,8 +22,9 @@ namespace Juliet MainWindow = CreatePlatformWindow("Juliet Editor", 1280, 720); - GraphicsConfig config; - // InitializeGraphics(config); + GraphicsConfig config; + GraphicsDevice* device = CreateGraphicsDevice(config); + Assert(!device && "Currently not implemented so device should be null"); Running = MainWindow != nullptr; } @@ -31,7 +33,7 @@ namespace Juliet { Log(LogLevel::Message, LogCategory::Editor, "Shutdown Editor Application..."); - if (MainWindow ) + if (MainWindow) { DestroyPlatformWindow(MainWindow); }