feat: add RHI abstraction layer unit tests

- Add RHITestFixture with RHI_BACKEND env var support for backend selection
- Add unit tests for: Device, Buffer, Texture, SwapChain, CommandList, CommandQueue, Shader, Fence, Sampler
- Tests can run against D3D12 or OpenGL backends via RHI_BACKEND env var
- Add integration folder placeholder for future integration tests
This commit is contained in:
2026-03-22 16:18:51 +08:00
parent a980f2bd66
commit 8d4447915d
15 changed files with 1260 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
#pragma once
#include <gtest/gtest.h>
#include <string>
#include "XCEngine/RHI/RHIFactory.h"
#include "XCEngine/RHI/RHIDevice.h"
#include "XCEngine/RHI/RHICommandQueue.h"
#include "XCEngine/RHI/RHICommandList.h"
#include "XCEngine/RHI/RHIBuffer.h"
#include "XCEngine/RHI/RHITexture.h"
#include "XCEngine/RHI/RHISwapChain.h"
#include "XCEngine/RHI/RHIShader.h"
#include "XCEngine/RHI/RHIFence.h"
#include "XCEngine/RHI/RHISampler.h"
#include "XCEngine/RHI/RHIDescriptorPool.h"
#include "XCEngine/RHI/RHIPipelineLayout.h"
namespace XCEngine {
namespace RHI {
class RHITestFixture : public ::testing::Test {
protected:
void SetUp() override;
void TearDown() override;
static void SetUpTestSuite();
static void TearDownTestSuite();
RHIDevice* GetDevice() { return mDevice; }
RHIType GetBackendType() const { return mBackendType; }
private:
static RHIType mBackendType;
RHIDevice* mDevice = nullptr;
};
} // namespace RHI
} // namespace XCEngine