Fix GPU state issue - make device non-static per test
- Each test now creates its own D3D12 device, command queue, allocator, and command list - Properly cleanup in TearDown to avoid GPU state issues - All 29 tests now pass
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
#include "D3D12TestFixture.h"
|
||||
|
||||
ComPtr<ID3D12Device> D3D12TestFixture::mDevice;
|
||||
|
||||
void D3D12TestFixture::SetUpTestSuite() {
|
||||
}
|
||||
|
||||
void D3D12TestFixture::TearDownTestSuite() {
|
||||
}
|
||||
|
||||
void D3D12TestFixture::SetUp() {
|
||||
HRESULT hr = D3D12CreateDevice(
|
||||
nullptr,
|
||||
D3D_FEATURE_LEVEL_12_0,
|
||||
@@ -13,22 +17,11 @@ void D3D12TestFixture::SetUpTestSuite() {
|
||||
GTEST_SKIP() << "Failed to create D3D12 device";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void D3D12TestFixture::TearDownTestSuite() {
|
||||
mDevice.Reset();
|
||||
}
|
||||
|
||||
void D3D12TestFixture::SetUp() {
|
||||
if (!mDevice) {
|
||||
GTEST_SKIP() << "D3D12 device not available";
|
||||
return;
|
||||
}
|
||||
|
||||
D3D12_COMMAND_QUEUE_DESC queueDesc = {};
|
||||
queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
|
||||
|
||||
HRESULT hr = mDevice->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&mCommandQueue));
|
||||
hr = mDevice->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&mCommandQueue));
|
||||
if (FAILED(hr)) {
|
||||
GTEST_SKIP() << "Failed to create command queue";
|
||||
return;
|
||||
@@ -54,6 +47,7 @@ void D3D12TestFixture::TearDown() {
|
||||
mCommandList.Reset();
|
||||
mCommandAllocator.Reset();
|
||||
mCommandQueue.Reset();
|
||||
mDevice.Reset();
|
||||
}
|
||||
|
||||
void D3D12TestFixture::WaitForGPU() {
|
||||
|
||||
@@ -29,7 +29,7 @@ protected:
|
||||
void WaitForGPU();
|
||||
|
||||
private:
|
||||
static ComPtr<ID3D12Device> mDevice;
|
||||
ComPtr<ID3D12Device> mDevice;
|
||||
ComPtr<ID3D12CommandQueue> mCommandQueue;
|
||||
ComPtr<ID3D12CommandAllocator> mCommandAllocator;
|
||||
ComPtr<ID3D12GraphicsCommandList> mCommandList;
|
||||
|
||||
Reference in New Issue
Block a user