feat: implement D3D12 device initialization with debug layer
D3D12 Core: - Implement complete device initialization flow - Add debug layer enablement in DEBUG mode - Add GPU adapter enumeration and selection - Add feature level checking (min 11.0) - Add DXCall and NAME_D3D12_OBJECT macros - Add release template function - Configure info queue for error/warning breakpoints Documentation: - Add changelog for D3D12 device initialization - Update D3D12 Wiki with current implementation status - Add Doxygen comments to Renderer and platform interface
This commit is contained in:
@@ -14,4 +14,41 @@
|
||||
|
||||
// 引入 Windows Runtime C++ 模板库(WRL)头文件,提供智能指针(如 Microsoft::WRL::ComPtr)
|
||||
// 用于简化 COM 对象的生命周期管理
|
||||
#include <wrl.h>
|
||||
#include <wrl.h>
|
||||
|
||||
|
||||
#pragma comment(lib, "dxgi.lib")
|
||||
#pragma comment(lib, "d3d12.lib")
|
||||
|
||||
|
||||
// 定义 DirectX 调试宏 DXCall,用于在调试模式下检查 DirectX API 调用返回值
|
||||
// 如果调用失败(FAILED),则输出错误信息(文件名、行号、调用语句)并触发断点
|
||||
// 在发布模式下,DXCall 宏不执行任何额外操作,直接执行原始调用
|
||||
#ifdef _DEBUG
|
||||
#ifndef DXCall
|
||||
#define DXCall(x) \
|
||||
if(FAILED(x)){ \
|
||||
char line_number[32]; \
|
||||
sprintf_s(line_number, "%u", __LINE__); \
|
||||
OutputDebugStringA("Error in: "); \
|
||||
OutputDebugStringA(__FILE__); \
|
||||
OutputDebugStringA("\nLine: "); \
|
||||
OutputDebugStringA(line_number); \
|
||||
OutputDebugStringA("\n"); \
|
||||
OutputDebugStringA(#x); \
|
||||
OutputDebugStringA("\n"); \
|
||||
__debugbreak(); \
|
||||
}
|
||||
#endif // !DXCall
|
||||
#else
|
||||
#ifndef DXCall
|
||||
#define DXCall(x) x
|
||||
#endif // !DXCall
|
||||
#endif // _DEBUG
|
||||
|
||||
// 定义 DirectX 对象命名宏,用于在调试模式下为 Direct3D 12 对象设置名称
|
||||
#ifdef _DEBUG
|
||||
#define NAME_D3D12_OBJECT(obj, name) obj->SetName(name); OutputDebugString(L"::D3D12 Object Created: ");OutputDebugString(name);OutputDebugString(L"\n");
|
||||
#else
|
||||
#define NAME_D3D12_OBJECT(obj, name)
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user