#pragma once #include #include #include #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 { 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(bool includeDepthStencil = false); 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; D3D12Texture* mDepthStencilTexture = nullptr; std::vector mRTVs; RHIResourceView* mDSV = nullptr; #endif }; } // namespace Integration } // namespace RHI } // namespace XCEngine