feat: add Graphics module with D3D12 backend and documentation
Graphics Module: - Add platform abstraction layer (GraphicsPlatformInterface) - Add unified renderer entry point (Renderer) - Add D3D12 backend implementation (D3D12Core, D3D12Interface) - Add TestRenderer for multi-window rendering tests Documentation: - Add Graphics渲染架构分析.md - Add D3D12学习Wiki.md - Add changelogs directory with per-commit documentation - Add 20260326-dx12-initial.md for initial framework - Add 20260326-d3d12-foundation.md for Graphics module Fixes: - Resolve header include issues and type redefinition errors
This commit is contained in:
@@ -33,6 +33,10 @@
|
||||
<ClInclude Include="EngineAPI\ScriptComponent.h" />
|
||||
<ClInclude Include="EngineAPI\TransformComponent.h" />
|
||||
<ClInclude Include="EngineAPI\Light.h" />
|
||||
<ClInclude Include="Graphics\Direct3D12\D3D12CommonHeader.h" />
|
||||
<ClInclude Include="Graphics\Direct3D12\D3D12Core.h" />
|
||||
<ClInclude Include="Graphics\Direct3D12\D3D12Interface.h" />
|
||||
<ClInclude Include="Graphics\GraphicsPlatformInterface.h" />
|
||||
<ClInclude Include="Graphics\Renderer.h" />
|
||||
<ClInclude Include="Platform\IncludeWindowCpp.h" />
|
||||
<ClInclude Include="Platform\Platform.h" />
|
||||
@@ -53,6 +57,8 @@
|
||||
<ClCompile Include="Content\ContentToEngine.cpp" />
|
||||
<ClCompile Include="Core\EngineWin32.cpp" />
|
||||
<ClCompile Include="Core\MainWin32.cpp" />
|
||||
<ClCompile Include="Graphics\Direct3D12\D3D12Core.cpp" />
|
||||
<ClCompile Include="Graphics\Direct3D12\D3D12Interface.cpp" />
|
||||
<ClCompile Include="Graphics\Renderer.cpp" />
|
||||
<ClCompile Include="Platform\PlatformWin32.cpp" />
|
||||
<ClCompile Include="Platform\Window.cpp" />
|
||||
@@ -224,4 +230,4 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -25,6 +25,10 @@
|
||||
<ClInclude Include="EngineAPI\Camera.h" />
|
||||
<ClInclude Include="EngineAPI\Light.h" />
|
||||
<ClInclude Include="Graphics\Renderer.h" />
|
||||
<ClInclude Include="Graphics\Direct3D12\D3D12CommonHeader.h" />
|
||||
<ClInclude Include="Graphics\Direct3D12\D3D12Core.h" />
|
||||
<ClInclude Include="Graphics\Direct3D12\D3D12Interface.h" />
|
||||
<ClInclude Include="Graphics\GraphicsPlatformInterface.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Components\Entity.cpp" />
|
||||
@@ -37,5 +41,8 @@
|
||||
<ClCompile Include="Platform\PlatformWin32.cpp" />
|
||||
<ClCompile Include="Platform\Window.cpp" />
|
||||
<ClCompile Include="Content\ContentToEngine.cpp" />
|
||||
<ClCompile Include="Graphics\Renderer.cpp" />
|
||||
<ClCompile Include="Graphics\Direct3D12\D3D12Core.cpp" />
|
||||
<ClCompile Include="Graphics\Direct3D12\D3D12Interface.cpp" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
17
Engine/Graphics/Direct3D12/D3D12CommonHeader.h
Normal file
17
Engine/Graphics/Direct3D12/D3D12CommonHeader.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "CommonHeader.h"
|
||||
#include "Graphics\Renderer.h"
|
||||
|
||||
// 引入 DirectX Graphics Infrastructure(DXGI)6.0
|
||||
// 头文件,用于访问 DXGI 接口(如 IDXGIFactory6、
|
||||
// IDXGIAdapter4 等),支持枚举 GPU、查询显示模式、管理
|
||||
// 交换链等底层图形功能
|
||||
#include <dxgi1_6.h>
|
||||
// 引入 Direct3D 12 头文件,提供 D3D12 API 接口,
|
||||
// 用于创建渲染管线、管理资源与 GPU 命令
|
||||
#include <d3d12.h>
|
||||
|
||||
// 引入 Windows Runtime C++ 模板库(WRL)头文件,提供智能指针(如 Microsoft::WRL::ComPtr)
|
||||
// 用于简化 COM 对象的生命周期管理
|
||||
#include <wrl.h>
|
||||
20
Engine/Graphics/Direct3D12/D3D12Core.cpp
Normal file
20
Engine/Graphics/Direct3D12/D3D12Core.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "D3D12Core.h"
|
||||
#include "D3D12CommonHeader.h"
|
||||
|
||||
namespace XEngine::graphics::d3d12::core{
|
||||
namespace{
|
||||
|
||||
ID3D12Device8* main_device;
|
||||
|
||||
}// anonymous namespace
|
||||
bool
|
||||
initialize()
|
||||
{
|
||||
// determine which adapter
|
||||
return true;
|
||||
}
|
||||
void
|
||||
shutdown()
|
||||
{
|
||||
}
|
||||
}// namespace XEngine::graphics::d3d12::core
|
||||
6
Engine/Graphics/Direct3D12/D3D12Core.h
Normal file
6
Engine/Graphics/Direct3D12/D3D12Core.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace XEngine::graphics::d3d12::core{
|
||||
bool initialize();
|
||||
void shutdown();
|
||||
}// namespace XEngine::graphics::d3d12
|
||||
14
Engine/Graphics/Direct3D12/D3D12Interface.cpp
Normal file
14
Engine/Graphics/Direct3D12/D3D12Interface.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "D3D12Interface.h"
|
||||
#include "D3D12Core.h"
|
||||
#include "Graphics\GraphicsPlatformInterface.h"
|
||||
|
||||
namespace XEngine::graphics::d3d12{
|
||||
void get_platform_interface(platform_interface& pi)
|
||||
{
|
||||
pi.initialize = core::initialize;
|
||||
pi.shutdown = core::shutdown;
|
||||
}
|
||||
}// namespace XEngine::graphics::d3d12
|
||||
|
||||
|
||||
|
||||
9
Engine/Graphics/Direct3D12/D3D12Interface.h
Normal file
9
Engine/Graphics/Direct3D12/D3D12Interface.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
namespace XEngine::graphics{
|
||||
struct platform_interface;
|
||||
}
|
||||
|
||||
namespace XEngine::graphics::d3d12{
|
||||
void get_platform_interface(platform_interface& gfx);
|
||||
}// namespace XEngine::graphics::d3d12
|
||||
11
Engine/Graphics/GraphicsPlatformInterface.h
Normal file
11
Engine/Graphics/GraphicsPlatformInterface.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
#include "CommonHeader.h"
|
||||
#include "Renderer.h"
|
||||
|
||||
namespace XEngine::graphics{
|
||||
struct platform_interface{
|
||||
bool(*initialize)(void);
|
||||
void(*shutdown)(void);
|
||||
};
|
||||
}// namespace XEngine::graphics
|
||||
|
||||
38
Engine/Graphics/Renderer.cpp
Normal file
38
Engine/Graphics/Renderer.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "Renderer.h"
|
||||
#include "GraphicsPlatformInterface.h"
|
||||
#include "Direct3D12/D3D12Interface.h"
|
||||
|
||||
namespace XEngine::graphics {
|
||||
namespace {
|
||||
platform_interface gfx{};
|
||||
bool
|
||||
set_platform_interface(graphics_platform platform)
|
||||
{
|
||||
switch (platform)
|
||||
{
|
||||
case graphics_platform::direct3d12:
|
||||
d3d12::get_platform_interface(gfx);
|
||||
break;
|
||||
case graphics_platform::vulkan:
|
||||
//vulkan::get_platform_interface(gfx);
|
||||
break;
|
||||
case graphics_platform::opengl:
|
||||
//opengl::get_platform_interface(gfx);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return gfx.initialize();
|
||||
}
|
||||
}// anonymous namespace
|
||||
|
||||
bool initialize(graphics_platform platform)
|
||||
{
|
||||
return set_platform_interface(platform);
|
||||
}
|
||||
|
||||
void shutdown()
|
||||
{
|
||||
gfx.shutdown();
|
||||
}
|
||||
}// namespace XEngine::graphics
|
||||
28
Engine/Graphics/Renderer.h
Normal file
28
Engine/Graphics/Renderer.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
#include "CommonHeader.h"
|
||||
#include "..\Platform\Window.h"
|
||||
|
||||
|
||||
namespace XEngine::graphics {
|
||||
|
||||
class surface
|
||||
{
|
||||
};
|
||||
|
||||
struct render_surface
|
||||
{
|
||||
platform::window window{};
|
||||
surface surface{};
|
||||
};
|
||||
|
||||
enum class graphics_platform : u32
|
||||
{
|
||||
direct3d12 = 0,
|
||||
vulkan = 1,
|
||||
opengl = 2,
|
||||
};
|
||||
|
||||
bool initialize(graphics_platform platform);
|
||||
void shutdown();
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user