fix: 修复截图保存功能和CreateCommittedResource参数问题
- 修复SaveScreenshot函数中D3D12_RESOURCE_DESC的初始化 - 添加完整的SampleDesc和Layout字段 - 修复从PRESENT状态正确转换到COPY_SOURCE进行读取 - 启用D3D12 Debug Layer以获取更好的调试信息 - 添加日志输出到文件以便捕获调试信息
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "XCEngine/RHI/D3D12/D3D12Device.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef _DEBUG
|
||||
#include <dxgidebug.h>
|
||||
@@ -75,8 +76,7 @@ void D3D12Device::Shutdown() {
|
||||
bool D3D12Device::CreateDXGIFactory(bool enableDebugLayer) {
|
||||
UINT dxgiFactoryFlags = 0;
|
||||
|
||||
#ifdef _DEBUG
|
||||
if (enableDebugLayer) {
|
||||
{
|
||||
ID3D12Debug* debugController = nullptr;
|
||||
if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&debugController)))) {
|
||||
debugController->EnableDebugLayer();
|
||||
@@ -84,14 +84,19 @@ bool D3D12Device::CreateDXGIFactory(bool enableDebugLayer) {
|
||||
debugController->Release();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
HRESULT hr = CreateDXGIFactory2(dxgiFactoryFlags, IID_PPV_ARGS(&m_factory));
|
||||
return SUCCEEDED(hr);
|
||||
}
|
||||
|
||||
bool D3D12Device::CreateDevice(IDXGIAdapter1* adapter) {
|
||||
OutputDebugStringA("[DEBUG] CreateDevice: start\n");
|
||||
HRESULT hr = D3D12CreateDevice(adapter, D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&m_device));
|
||||
if (FAILED(hr)) {
|
||||
char buf[256];
|
||||
sprintf(buf, "[DEBUG] CreateDevice: D3D12CreateDevice failed! hr=%08X\n", hr);
|
||||
OutputDebugStringA(buf);
|
||||
}
|
||||
return SUCCEEDED(hr);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user