#include "D3D12TestFixture.h" #include namespace XCEngine { namespace RHI { void D3D12TestFixture::SetUpTestSuite() { } void D3D12TestFixture::TearDownTestSuite() { } void D3D12TestFixture::SetUp() { m_device = std::make_unique(); RHIDeviceDesc desc; desc.enableDebugLayer = false; desc.enableGPUValidation = false; if (!m_device->Initialize(desc)) { GTEST_SKIP() << "Failed to initialize D3D12Device"; return; } m_commandQueue = std::make_unique(); if (!m_commandQueue->Initialize(m_device->GetDevice(), CommandQueueType::Direct)) { GTEST_SKIP() << "Failed to create command queue"; return; } m_commandAllocator = std::make_unique(); if (!m_commandAllocator->Initialize(m_device->GetDevice(), CommandQueueType::Direct)) { GTEST_SKIP() << "Failed to create command allocator"; return; } m_commandList = std::make_unique(); if (!m_commandList->Initialize(m_device->GetDevice(), CommandQueueType::Direct, m_commandAllocator->GetCommandAllocator())) { GTEST_SKIP() << "Failed to create command list"; return; } } void D3D12TestFixture::TearDown() { if (m_commandQueue) { WaitForGPU(); } if (m_commandList) { m_commandList->Shutdown(); m_commandList.reset(); } if (m_commandAllocator) { m_commandAllocator->Shutdown(); m_commandAllocator.reset(); } if (m_commandQueue) { m_commandQueue->Shutdown(); m_commandQueue.reset(); } if (m_device) { m_device->Shutdown(); m_device.reset(); } } void D3D12TestFixture::WaitForGPU() { if (!m_commandQueue) return; auto fence = std::make_unique(); if (fence->Initialize(m_device->GetDevice(), 0)) { m_commandQueue->Signal(fence.get(), 1); fence->Wait(1); } } } // namespace RHI } // namespace XCEngine