test: Add RHI integration test framework
Add integration tests for RHI module: - Add tests/RHI/integration/ directory with CMakeLists.txt - Add RHIIntegrationFixture for shared test utilities - Add minimal integration test (window creation, basic rendering) - Add compare_ppm.py for image comparison - Add run_integration_test.py test runner script These integration tests verify the complete rendering pipeline by comparing rendered output against ground truth PPM files.
This commit is contained in:
55
tests/RHI/integration/fixtures/RHIIntegrationFixture.h
Normal file
55
tests/RHI/integration/fixtures/RHIIntegrationFixture.h
Normal file
@@ -0,0 +1,55 @@
|
||||
#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"
|
||||
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
namespace Integration {
|
||||
|
||||
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; }
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
} // namespace Integration
|
||||
} // namespace RHI
|
||||
} // namespace XCEngine
|
||||
Reference in New Issue
Block a user