fix(RHI): 修复 OpenGL 测试接口不匹配问题
- 修复 RHIDeviceInfo 缺少 majorVersion/minorVersion - 修复 OpenGLTexture 使用 GetTextureType 替代 GetType - 修复 OpenGLSampler 使用 OpenGLSamplerDesc - 修复 BlendFactor::OneMinusSrcAlpha -> InvSrcAlpha - 修复 OpenGLRenderTargetViewDesc/OpenGLDepthStencilViewDesc 重定义问题 - 恢复 OpenGL 测试文件到 CMakeLists
This commit is contained in:
@@ -19,7 +19,7 @@ enum class DepthStencilType {
|
||||
TextureCube
|
||||
};
|
||||
|
||||
struct DepthStencilViewDesc {
|
||||
struct OpenGLDepthStencilViewDesc {
|
||||
DepthStencilType type = DepthStencilType::Texture2D;
|
||||
int mipLevel = 0;
|
||||
int baseArraySlice = 0;
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
OpenGLDepthStencilView();
|
||||
~OpenGLDepthStencilView();
|
||||
|
||||
bool Initialize(unsigned int texture, const DepthStencilViewDesc& desc);
|
||||
bool Initialize(unsigned int texture, const OpenGLDepthStencilViewDesc& desc);
|
||||
bool Initialize(unsigned int texture, int mipLevel = 0);
|
||||
bool InitializeCubemap(unsigned int cubemap, int face, int mipLevel = 0);
|
||||
void Shutdown();
|
||||
|
||||
@@ -15,7 +15,7 @@ enum class RenderTargetType {
|
||||
TextureCubeArray
|
||||
};
|
||||
|
||||
struct RenderTargetViewDesc {
|
||||
struct OpenGLRenderTargetViewDesc {
|
||||
RenderTargetType type = RenderTargetType::Texture2D;
|
||||
int mipLevel = 0;
|
||||
int baseArraySlice = 0;
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
OpenGLRenderTargetView();
|
||||
~OpenGLRenderTargetView();
|
||||
|
||||
bool Initialize(unsigned int texture, const RenderTargetViewDesc& desc);
|
||||
bool Initialize(unsigned int texture, const OpenGLRenderTargetViewDesc& desc);
|
||||
bool Initialize(unsigned int texture, int mipLevel = 0);
|
||||
bool InitializeCubemap(unsigned int cubemap, int face, int mipLevel = 0);
|
||||
void Shutdown();
|
||||
|
||||
@@ -253,6 +253,8 @@ struct RHIDeviceInfo {
|
||||
std::wstring vendor;
|
||||
std::wstring renderer;
|
||||
std::wstring version;
|
||||
uint32_t majorVersion = 0;
|
||||
uint32_t minorVersion = 0;
|
||||
uint64_t dedicatedVideoMemory = 0;
|
||||
uint64_t dedicatedSystemMemory = 0;
|
||||
uint64_t sharedSystemMemory = 0;
|
||||
|
||||
@@ -20,7 +20,7 @@ OpenGLDepthStencilView::~OpenGLDepthStencilView() {
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
bool OpenGLDepthStencilView::Initialize(unsigned int texture, const DepthStencilViewDesc& desc) {
|
||||
bool OpenGLDepthStencilView::Initialize(unsigned int texture, const OpenGLDepthStencilViewDesc& desc) {
|
||||
m_texture = texture;
|
||||
m_mipLevel = desc.mipLevel;
|
||||
m_type = desc.type;
|
||||
@@ -53,7 +53,7 @@ bool OpenGLDepthStencilView::Initialize(unsigned int texture, const DepthStencil
|
||||
}
|
||||
|
||||
bool OpenGLDepthStencilView::Initialize(unsigned int texture, int mipLevel) {
|
||||
DepthStencilViewDesc desc;
|
||||
OpenGLDepthStencilViewDesc desc;
|
||||
desc.mipLevel = mipLevel;
|
||||
return Initialize(texture, desc);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ OpenGLRenderTargetView::~OpenGLRenderTargetView() {
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
bool OpenGLRenderTargetView::Initialize(unsigned int texture, const RenderTargetViewDesc& desc) {
|
||||
bool OpenGLRenderTargetView::Initialize(unsigned int texture, const OpenGLRenderTargetViewDesc& desc) {
|
||||
m_texture = texture;
|
||||
m_mipLevel = desc.mipLevel;
|
||||
m_type = desc.type;
|
||||
@@ -69,7 +69,7 @@ bool OpenGLRenderTargetView::Initialize(unsigned int texture, const RenderTarget
|
||||
}
|
||||
|
||||
bool OpenGLRenderTargetView::Initialize(unsigned int texture, int mipLevel) {
|
||||
RenderTargetViewDesc desc;
|
||||
OpenGLRenderTargetViewDesc desc;
|
||||
desc.type = RenderTargetType::Texture2D;
|
||||
desc.mipLevel = mipLevel;
|
||||
return Initialize(texture, desc);
|
||||
|
||||
@@ -20,17 +20,17 @@ find_package(GTest REQUIRED)
|
||||
set(TEST_SOURCES
|
||||
${CMAKE_SOURCE_DIR}/tests/OpenGL/package/src/glad.c
|
||||
fixtures/OpenGLTestFixture.cpp
|
||||
# test_device.cpp # RHIDeviceInfo 不匹配
|
||||
test_device.cpp
|
||||
# test_buffer.cpp
|
||||
# test_fence.cpp
|
||||
# test_texture.cpp # OpenGLTexture 缺少 GetType
|
||||
# test_sampler.cpp # SamplerDesc 类型不匹配
|
||||
test_texture.cpp
|
||||
test_sampler.cpp
|
||||
# test_shader.cpp
|
||||
# test_pipeline_state.cpp # BlendFunc 枚举问题
|
||||
test_pipeline_state.cpp
|
||||
test_vertex_array.cpp
|
||||
test_command_list.cpp
|
||||
# test_render_target_view.cpp # 结构体重定义
|
||||
# test_depth_stencil_view.cpp # 结构体重定义
|
||||
test_render_target_view.cpp
|
||||
test_depth_stencil_view.cpp
|
||||
test_swap_chain.cpp
|
||||
)
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ TEST_F(OpenGLTestFixture, PipelineState_SetBlendState) {
|
||||
BlendState state;
|
||||
state.blendEnable = true;
|
||||
state.srcBlend = BlendFactor::SrcAlpha;
|
||||
state.dstBlend = BlendFactor::OneMinusSrcAlpha;
|
||||
state.dstBlend = BlendFactor::InvSrcAlpha;
|
||||
|
||||
pipeline.SetBlendState(state);
|
||||
pipeline.ApplyBlend();
|
||||
|
||||
@@ -5,7 +5,7 @@ using namespace XCEngine::RHI;
|
||||
|
||||
TEST_F(OpenGLTestFixture, Sampler_Initialize_Default) {
|
||||
OpenGLSampler sampler;
|
||||
SamplerDesc desc;
|
||||
OpenGLSamplerDesc desc;
|
||||
|
||||
bool result = sampler.Initialize(desc);
|
||||
|
||||
@@ -17,7 +17,7 @@ TEST_F(OpenGLTestFixture, Sampler_Initialize_Default) {
|
||||
|
||||
TEST_F(OpenGLTestFixture, Sampler_Initialize_Custom) {
|
||||
OpenGLSampler sampler;
|
||||
SamplerDesc desc;
|
||||
OpenGLSamplerDesc desc;
|
||||
desc.minFilter = SamplerFilter::LinearMipmapLinear;
|
||||
desc.magFilter = SamplerFilter::Linear;
|
||||
desc.wrapS = SamplerWrapMode::Repeat;
|
||||
@@ -34,7 +34,7 @@ TEST_F(OpenGLTestFixture, Sampler_Initialize_Custom) {
|
||||
|
||||
TEST_F(OpenGLTestFixture, Sampler_Bind_Unbind) {
|
||||
OpenGLSampler sampler;
|
||||
SamplerDesc desc;
|
||||
OpenGLSamplerDesc desc;
|
||||
sampler.Initialize(desc);
|
||||
|
||||
sampler.Bind(0);
|
||||
@@ -51,7 +51,7 @@ TEST_F(OpenGLTestFixture, Sampler_Bind_Unbind) {
|
||||
|
||||
TEST_F(OpenGLTestFixture, Sampler_GetID_ReturnsValid) {
|
||||
OpenGLSampler sampler;
|
||||
SamplerDesc desc;
|
||||
OpenGLSamplerDesc desc;
|
||||
sampler.Initialize(desc);
|
||||
|
||||
EXPECT_NE(sampler.GetID(), 0u);
|
||||
|
||||
@@ -12,7 +12,7 @@ TEST_F(OpenGLTestFixture, Texture_Initialize_2DTexture) {
|
||||
EXPECT_NE(texture.GetID(), 0u);
|
||||
EXPECT_EQ(texture.GetWidth(), 64);
|
||||
EXPECT_EQ(texture.GetHeight(), 64);
|
||||
EXPECT_EQ(texture.GetType(), OpenGLTextureType::Texture2D);
|
||||
EXPECT_EQ(texture.GetTextureType(), TextureType::Texture2D);
|
||||
|
||||
texture.Shutdown();
|
||||
}
|
||||
@@ -26,7 +26,7 @@ TEST_F(OpenGLTestFixture, Texture_Initialize_CubeMap) {
|
||||
EXPECT_NE(texture.GetID(), 0u);
|
||||
EXPECT_EQ(texture.GetWidth(), 64);
|
||||
EXPECT_EQ(texture.GetHeight(), 64);
|
||||
EXPECT_EQ(texture.GetType(), OpenGLTextureType::TextureCube);
|
||||
EXPECT_EQ(texture.GetTextureType(), TextureType::TextureCube);
|
||||
|
||||
texture.Shutdown();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user