Files
DX12/Engine/Graphics/Direct3D12/D3D12CommonHeader.h
SpecialX 3fdc774f3f 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
2026-03-26 19:01:51 +08:00

55 lines
1.8 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include "CommonHeader.h"
#include "Graphics\Renderer.h"
// 引入 DirectX Graphics InfrastructureDXGI6.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>
#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