55 lines
1.6 KiB
C
55 lines
1.6 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"
|
||
|
|
|
||
|
|
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
|