2026-03-15 03:15:12 +08:00
|
|
|
#include "XCEngine/RHI/D3D12/D3D12CommandAllocator.h"
|
refactor: improve test infrastructure and fix OpenGL GLAD initialization
- Rename D3D12Enum.h to D3D12Enums.h for naming consistency
- Fix OpenGL unit test GLAD initialization by using gladLoadGL()
instead of gladLoadGLLoader(wglGetProcAddress) for fallback support
- Migrate remaining tests to use gtest_discover_tests for granular
test discovery (math, core, containers, memory, threading, debug,
components, scene, resources, input, opengl)
- Remove obsolete TEST_RESOURCES_DIR and copy_directory commands
from OpenGL unit test CMakeLists (minimal/Res doesn't exist)
- Update TEST_SPEC.md with performance metrics and per-module
build/test commands for faster development workflow
- Update CMake path references to use lowercase paths
2026-03-23 00:43:02 +08:00
|
|
|
#include "XCEngine/RHI/D3D12/D3D12Enums.h"
|
2026-03-25 16:13:02 +08:00
|
|
|
#include <stdio.h>
|
2026-03-15 03:15:12 +08:00
|
|
|
|
|
|
|
|
namespace XCEngine {
|
|
|
|
|
namespace RHI {
|
|
|
|
|
|
|
|
|
|
D3D12CommandAllocator::D3D12CommandAllocator()
|
|
|
|
|
: m_type(CommandQueueType::Direct) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
D3D12CommandAllocator::~D3D12CommandAllocator() {
|
|
|
|
|
Shutdown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool D3D12CommandAllocator::Initialize(ID3D12Device* device, CommandQueueType type) {
|
|
|
|
|
m_type = type;
|
|
|
|
|
HRESULT hResult = device->CreateCommandAllocator(
|
|
|
|
|
ToD3D12(type),
|
|
|
|
|
IID_PPV_ARGS(&m_commandAllocator));
|
2026-03-25 16:13:02 +08:00
|
|
|
if (FAILED(hResult)) {
|
2026-03-25 16:20:21 +08:00
|
|
|
FILE* f = fopen("D:\\Xuanchi\\Main\\XCEngine\\debug_rhi.log", "a");
|
|
|
|
|
if (f) { fprintf(f, "[D3D12CommandAllocator] CreateCommandAllocator failed: hr=0x%08X\n", hResult); fclose(f); }
|
2026-03-25 17:30:16 +08:00
|
|
|
if (hResult == DXGI_ERROR_DEVICE_REMOVED) {
|
|
|
|
|
FILE* f2 = fopen("D:\\Xuanchi\\Main\\XCEngine\\debug_rhi.log", "a");
|
|
|
|
|
if (f2) { fprintf(f2, "[D3D12CommandAllocator] Device removed reason: %d\n", device->GetDeviceRemovedReason()); fclose(f2); }
|
|
|
|
|
}
|
2026-03-25 16:13:02 +08:00
|
|
|
}
|
2026-03-15 03:15:12 +08:00
|
|
|
return SUCCEEDED(hResult);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void D3D12CommandAllocator::Shutdown() {
|
|
|
|
|
m_commandAllocator.Reset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void D3D12CommandAllocator::Reset() {
|
|
|
|
|
m_commandAllocator->Reset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool D3D12CommandAllocator::IsReady() const {
|
|
|
|
|
return m_commandAllocator != nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace RHI
|
|
|
|
|
} // namespace XCEngine
|