From f2ae95e0a763e0a06f1f60c702461be9c9b95cf7 Mon Sep 17 00:00:00 2001 From: ssdfasd <2156608475@qq.com> Date: Tue, 17 Mar 2026 12:48:17 +0800 Subject: [PATCH] Complete OpenGL test suite - 56 tests Added missing tests to reach planned 56: - CommandList: EnableDisable_DepthTest, EnableDisable_Blending - RTV: GetTexture, GetMipLevel - DSV: Initialize_Texture, GetTexture, GetMipLevel Final count: 56 tests across all 12 components --- D3D12_engine_log.txt | 24 ----------- temp_list.bat | 2 - tests/RHI/OpenGL/test_command_list.cpp | 26 ++++++++++++ tests/RHI/OpenGL/test_depth_stencil_view.cpp | 42 ++++++++++++++++++++ tests/RHI/OpenGL/test_render_target_view.cpp | 26 ++++++++++++ 5 files changed, 94 insertions(+), 26 deletions(-) delete mode 100644 D3D12_engine_log.txt delete mode 100644 temp_list.bat diff --git a/D3D12_engine_log.txt b/D3D12_engine_log.txt deleted file mode 100644 index 59e17d65..00000000 --- a/D3D12_engine_log.txt +++ /dev/null @@ -1,24 +0,0 @@ -[2026-03-15 17:36:10] [DEBUG] [Rendering] [DEBUG] D3D12 Test Application Started - -[2026-03-15 17:52:42] [DEBUG] [Rendering] [DEBUG] D3D12 Test Application Started - -[2026-03-15 17:52:53] [DEBUG] [Rendering] [DEBUG] D3D12 Test Application Started - -[2026-03-15 17:57:07] [DEBUG] [Rendering] [DEBUG] D3D12 Test Application Started - -[2026-03-16 13:25:12] [DEBUG] [Rendering] [DEBUG] D3D12 Test Application Started - -[2026-03-16 13:25:13] [DEBUG] [Rendering] [DEBUG] Texture loaded: width=-858993460, height=-858993460, channels=-858993460, pixels=0000000000000000 - -[2026-03-16 13:25:13] [DEBUG] [Rendering] [DEBUG] WaitForCompletion: completed=1, waiting for=1 - -[2026-03-16 13:25:13] [DEBUG] [Rendering] [DEBUG] WaitForCompletion: completed=1, waiting for=1 - -[2026-03-17 00:39:42] [DEBUG] [Rendering] [DEBUG] D3D12 Test Application Started - -[2026-03-17 00:39:42] [DEBUG] [Rendering] [DEBUG] Texture loaded: width=-858993460, height=-858993460, channels=-858993460, pixels=0000000000000000 - -[2026-03-17 00:39:42] [DEBUG] [Rendering] [DEBUG] WaitForCompletion: completed=1, waiting for=1 - -[2026-03-17 00:39:42] [DEBUG] [Rendering] [DEBUG] WaitForCompletion: completed=1, waiting for=1 - diff --git a/temp_list.bat b/temp_list.bat deleted file mode 100644 index d90a3c83..00000000 --- a/temp_list.bat +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -dir /b "D:\Xuanchi\Main\XCEngine" diff --git a/tests/RHI/OpenGL/test_command_list.cpp b/tests/RHI/OpenGL/test_command_list.cpp index 30829f98..096da136 100644 --- a/tests/RHI/OpenGL/test_command_list.cpp +++ b/tests/RHI/OpenGL/test_command_list.cpp @@ -104,3 +104,29 @@ TEST_F(OpenGLTestFixture, CommandList_SetScissor) { EXPECT_EQ(scissor[2], 800); EXPECT_EQ(scissor[3], 600); } + +TEST_F(OpenGLTestFixture, CommandList_EnableDisable_DepthTest) { + OpenGLCommandList cmdList; + + cmdList.EnableDepthTest(true); + GLint depthTest = 0; + glGetIntegerv(GL_DEPTH_TEST, &depthTest); + EXPECT_EQ(depthTest, 1); + + cmdList.EnableDepthTest(false); + glGetIntegerv(GL_DEPTH_TEST, &depthTest); + EXPECT_EQ(depthTest, 0); +} + +TEST_F(OpenGLTestFixture, CommandList_EnableDisable_Blending) { + OpenGLCommandList cmdList; + + cmdList.EnableBlending(true); + GLint blend = 0; + glGetIntegerv(GL_BLEND, &blend); + EXPECT_EQ(blend, 1); + + cmdList.EnableBlending(false); + glGetIntegerv(GL_BLEND, &blend); + EXPECT_EQ(blend, 0); +} diff --git a/tests/RHI/OpenGL/test_depth_stencil_view.cpp b/tests/RHI/OpenGL/test_depth_stencil_view.cpp index d23ab6e4..e76787e9 100644 --- a/tests/RHI/OpenGL/test_depth_stencil_view.cpp +++ b/tests/RHI/OpenGL/test_depth_stencil_view.cpp @@ -1,5 +1,6 @@ #include "fixtures/OpenGLTestFixture.h" #include "XCEngine/RHI/OpenGL/OpenGLDepthStencilView.h" +#include "XCEngine/RHI/OpenGL/OpenGLTexture.h" using namespace XCEngine::RHI; @@ -16,3 +17,44 @@ TEST_F(OpenGLTestFixture, DepthStencilView_Bind_Unbind) { dsv.Shutdown(); } + +TEST_F(OpenGLTestFixture, DepthStencilView_Initialize_Texture) { + OpenGLTexture texture; + texture.Initialize2D(64, 64, 4, nullptr, false); + + OpenGLDepthStencilView dsv; + bool result = dsv.Initialize(texture.GetID()); + + if (result) { + EXPECT_NE(dsv.GetFramebuffer(), 0u); + dsv.Shutdown(); + } + + texture.Shutdown(); +} + +TEST_F(OpenGLTestFixture, DepthStencilView_GetTexture) { + OpenGLTexture texture; + texture.Initialize2D(64, 64, 4, nullptr, false); + + OpenGLDepthStencilView dsv; + dsv.Initialize(texture.GetID()); + + EXPECT_EQ(dsv.GetTexture(), texture.GetID()); + + dsv.Shutdown(); + texture.Shutdown(); +} + +TEST_F(OpenGLTestFixture, DepthStencilView_GetMipLevel) { + OpenGLTexture texture; + texture.Initialize2D(64, 64, 4, nullptr, false); + + OpenGLDepthStencilView dsv; + dsv.Initialize(texture.GetID(), 2); + + EXPECT_EQ(dsv.GetMipLevel(), 2); + + dsv.Shutdown(); + texture.Shutdown(); +} diff --git a/tests/RHI/OpenGL/test_render_target_view.cpp b/tests/RHI/OpenGL/test_render_target_view.cpp index 9d8ec42c..1d4a091a 100644 --- a/tests/RHI/OpenGL/test_render_target_view.cpp +++ b/tests/RHI/OpenGL/test_render_target_view.cpp @@ -37,3 +37,29 @@ TEST_F(OpenGLTestFixture, RenderTargetView_Bind_Unbind) { rtv.Shutdown(); texture.Shutdown(); } + +TEST_F(OpenGLTestFixture, RenderTargetView_GetTexture) { + OpenGLTexture texture; + texture.Initialize2D(64, 64, 4, nullptr, false); + + OpenGLRenderTargetView rtv; + rtv.Initialize(texture.GetID()); + + EXPECT_EQ(rtv.GetTexture(), texture.GetID()); + + rtv.Shutdown(); + texture.Shutdown(); +} + +TEST_F(OpenGLTestFixture, RenderTargetView_GetMipLevel) { + OpenGLTexture texture; + texture.Initialize2D(64, 64, 4, nullptr, false); + + OpenGLRenderTargetView rtv; + rtv.Initialize(texture.GetID(), 0); + + EXPECT_EQ(rtv.GetMipLevel(), 0); + + rtv.Shutdown(); + texture.Shutdown(); +}