diff --git a/tests/RHI/D3D12/fixtures/D3D12TestFixture.h b/tests/RHI/D3D12/fixtures/D3D12TestFixture.h index 657454fc..3e36d893 100644 --- a/tests/RHI/D3D12/fixtures/D3D12TestFixture.h +++ b/tests/RHI/D3D12/fixtures/D3D12TestFixture.h @@ -23,7 +23,7 @@ protected: ID3D12Device* GetDevice() { return mDevice.Get(); } ID3D12CommandQueue* GetCommandQueue() { return mCommandQueue.Get(); } - ID3D12CommandList* GetCommandList() { return mCommandList.Get(); } + ID3D12GraphicsCommandList* GetCommandList() { return mCommandList.Get(); } ID3D12CommandAllocator* GetCommandAllocator() { return mCommandAllocator.Get(); } void WaitForGPU(); @@ -32,5 +32,5 @@ private: static ComPtr mDevice; ComPtr mCommandQueue; ComPtr mCommandAllocator; - ComPtr mCommandList; + ComPtr mCommandList; }; diff --git a/tests/RHI/D3D12/test_command_allocator.cpp b/tests/RHI/D3D12/test_command_allocator.cpp index 152b1740..e8d40162 100644 --- a/tests/RHI/D3D12/test_command_allocator.cpp +++ b/tests/RHI/D3D12/test_command_allocator.cpp @@ -1,5 +1,45 @@ #include "fixtures/D3D12TestFixture.h" TEST_F(D3D12TestFixture, CommandAllocator_Placeholder) { - ASSERT_TRUE(true); + ASSERT_NE(GetCommandAllocator(), nullptr); +} + +TEST_F(D3D12TestFixture, CommandAllocator_Reset) { + ComPtr allocator; + HRESULT hr = GetDevice()->CreateCommandAllocator( + D3D12_COMMAND_LIST_TYPE_DIRECT, + IID_PPV_ARGS(&allocator) + ); + ASSERT_HRESULT_SUCCEEDED(hr); + + hr = allocator->Reset(); + ASSERT_HRESULT_SUCCEEDED(hr); +} + +TEST_F(D3D12TestFixture, CommandAllocator_MultipleReset) { + ComPtr allocator; + HRESULT hr = GetDevice()->CreateCommandAllocator( + D3D12_COMMAND_LIST_TYPE_DIRECT, + IID_PPV_ARGS(&allocator) + ); + ASSERT_HRESULT_SUCCEEDED(hr); + + for (int i = 0; i < 10; ++i) { + hr = allocator->Reset(); + ASSERT_HRESULT_SUCCEEDED(hr); + } +} + +TEST_F(D3D12TestFixture, CommandAllocator_DifferentTypes) { + D3D12_COMMAND_LIST_TYPE types[] = { + D3D12_COMMAND_LIST_TYPE_DIRECT, + D3D12_COMMAND_LIST_TYPE_COMPUTE, + D3D12_COMMAND_LIST_TYPE_COPY + }; + + for (auto type : types) { + ComPtr allocator; + HRESULT hr = GetDevice()->CreateCommandAllocator(type, IID_PPV_ARGS(&allocator)); + ASSERT_HRESULT_SUCCEEDED(hr); + } } diff --git a/tests/RHI/D3D12/test_command_list.cpp b/tests/RHI/D3D12/test_command_list.cpp index 26aaf168..dbf74599 100644 --- a/tests/RHI/D3D12/test_command_list.cpp +++ b/tests/RHI/D3D12/test_command_list.cpp @@ -1,5 +1,15 @@ #include "fixtures/D3D12TestFixture.h" TEST_F(D3D12TestFixture, CommandList_Placeholder) { - ASSERT_TRUE(true); + ASSERT_NE(GetCommandList(), nullptr); +} + +TEST_F(D3D12TestFixture, CommandList_Close) { + HRESULT hr = GetCommandList()->Close(); + ASSERT_HRESULT_SUCCEEDED(hr); +} + +TEST_F(D3D12TestFixture, CommandList_GetDesc) { + D3D12_COMMAND_LIST_TYPE type = GetCommandList()->GetType(); + EXPECT_EQ(type, D3D12_COMMAND_LIST_TYPE_DIRECT); } diff --git a/tests/RHI/D3D12/test_command_queue.cpp b/tests/RHI/D3D12/test_command_queue.cpp index 4e8db22d..40768e16 100644 --- a/tests/RHI/D3D12/test_command_queue.cpp +++ b/tests/RHI/D3D12/test_command_queue.cpp @@ -1,5 +1,27 @@ #include "fixtures/D3D12TestFixture.h" TEST_F(D3D12TestFixture, CommandQueue_Placeholder) { - ASSERT_TRUE(true); + ASSERT_NE(GetCommandQueue(), nullptr); +} + +TEST_F(D3D12TestFixture, CommandQueue_GetTimestampFrequency) { + D3D12_COMMAND_QUEUE_DESC desc = {}; + desc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; + + ComPtr queue; + HRESULT hr = GetDevice()->CreateCommandQueue(&desc, IID_PPV_ARGS(&queue)); + ASSERT_HRESULT_SUCCEEDED(hr); + + UINT64 frequency; + hr = queue->GetTimestampFrequency(&frequency); + ASSERT_HRESULT_SUCCEEDED(hr); + EXPECT_GT(frequency, 0); +} + +TEST_F(D3D12TestFixture, CommandQueue_ExecuteCommandLists_Empty) { + GetCommandList()->Reset(GetCommandAllocator(), nullptr); + ID3D12CommandList* commandLists[] = { GetCommandList() }; + GetCommandQueue()->ExecuteCommandLists(1, commandLists); + GetCommandList()->Close(); + WaitForGPU(); }