Files
XCEngine/tests/RHI/integration/fixtures/RHIIntegrationFixture.h
ssdfasd a9b9a6ebfc test: Add RHI integration tests and update unit tests
- Add CommandQueue unit tests for WaitForIdle and synchronization
- Add SwapChain unit tests for Present and buffer operations
- Add Texture unit tests for various texture types and mipmaps
- Fix RHIIntegrationFixture with proper logging and debug output
- Update minimal integration test with RHI abstraction layer
- Add GT reference image for minimal test
- Update TEST_SPEC.md documentation
2026-03-25 20:50:49 +08:00

76 lines
2.4 KiB
C++

#pragma once
#include <gtest/gtest.h>
#include <string>
#include <windows.h>
#include "XCEngine/RHI/RHIFactory.h"
#include "XCEngine/RHI/RHIDevice.h"
#include "XCEngine/RHI/RHICommandQueue.h"
#include "XCEngine/RHI/RHICommandList.h"
#include "XCEngine/RHI/RHISwapChain.h"
#include "XCEngine/RHI/RHIScreenshot.h"
#include "XCEngine/RHI/RHIEnums.h"
#include "XCEngine/RHI/OpenGL/OpenGLDevice.h"
#include "XCEngine/Debug/Logger.h"
#include "XCEngine/Debug/ConsoleLogSink.h"
#if defined(XCENGINE_SUPPORT_D3D12)
#include "XCEngine/RHI/D3D12/D3D12Device.h"
#include "XCEngine/RHI/D3D12/D3D12CommandList.h"
#include "XCEngine/RHI/D3D12/D3D12SwapChain.h"
#include "XCEngine/RHI/D3D12/D3D12Texture.h"
#include "XCEngine/RHI/D3D12/D3D12DescriptorHeap.h"
#endif
namespace XCEngine {
namespace RHI {
namespace Integration {
void Log(const char* format, ...);
class RHIIntegrationFixture : public ::testing::TestWithParam<RHIType> {
protected:
void SetUp() override;
void TearDown() override;
void WaitForGPU();
void BeginRender();
void EndRender();
RHIDevice* GetDevice() { return mDevice; }
RHISwapChain* GetSwapChain() { return mSwapChain; }
RHICommandQueue* GetCommandQueue() { return mCommandQueue; }
RHICommandList* GetCommandList() { return mCommandList; }
RHIScreenshot* GetScreenshot() { return mScreenshot; }
RHIType GetBackendType() const { return GetParam(); }
HWND GetWindowHandle() const { return mWindow; }
int GetCurrentBackBufferIndex() const { return mCurrentBackBufferIndex; }
RHITexture* GetCurrentBackBuffer() { return mSwapChain ? mSwapChain->GetCurrentBackBuffer() : nullptr; }
void SetRenderTargetForClear();
virtual void RenderFrame() {}
bool TakeScreenshot(const char* filename);
bool CompareWithGoldenTemplate(const char* outputPpm, const char* gtPpm, float threshold = 0.0f);
private:
RHIDevice* mDevice = nullptr;
RHISwapChain* mSwapChain = nullptr;
RHICommandQueue* mCommandQueue = nullptr;
RHICommandList* mCommandList = nullptr;
RHIScreenshot* mScreenshot = nullptr;
HWND mWindow = nullptr;
int mCurrentBackBufferIndex = 0;
#if defined(XCENGINE_SUPPORT_D3D12)
D3D12DescriptorHeap* mRTVHeap = nullptr;
D3D12DescriptorHeap* mDSVHeap = nullptr;
std::vector<RHIResourceView*> mRTVs;
RHIResourceView* mDSV = nullptr;
#endif
};
} // namespace Integration
} // namespace RHI
} // namespace XCEngine