Commit Graph

36 Commits

Author SHA1 Message Date
5267c61c2c Fix OpenGL integration tests for new SwapChain API
- triangle/quad/sphere tests: Update to use new Initialize signature with OpenGLDevice*
- triangle/quad/sphere tests: Use GetGLContext() for RenderDoc SetDevice
- triangle/quad/sphere tests: Add wglMakeCurrent in render loop
- triangle/quad/sphere tests: Update capture timing to frame 25-35
- unit test fixture: Add GetDevice() method
- unit test swap_chain: Update to use new Initialize signature
2026-03-23 21:48:46 +08:00
003d6ed630 Refactor OpenGL SwapChain HDC management
- OpenGLSwapChain now gets HDC from OpenGLDevice instead of creating its own
- Renamed OpenGLDevice::GetContext() to GetGLContext() for clarity
- Renamed OpenGLDevice::GetDC() to GetPresentationDC() for clarity
- OpenGLDevice now owns the HDC/HGLRC lifecycle
- OpenGLSwapChain::Initialize() now takes OpenGLDevice* parameter
- OpenGLSwapChain::Present() uses device's HDC for SwapBuffers
- Updated minimal test to use new API and capture from frame 25-35
- RenderDoc SetDevice now uses GetGLContext() for proper OpenGL hook
2026-03-23 21:43:32 +08:00
bc6b47ffcf fix: RHI单元测试修复与命名规范统一
RHI抽象层测试修复:
- OpenGL Shader: 空描述符正确返回nullptr
- OpenGL Texture: 修复TextureType映射(case 2/3)
- OpenGL Buffer: 设置stride和state支持
- OpenGL Texture: 添加Format和State支持
- OpenGL SwapChain: 修复IsFullscreen硬编码false问题

命名规范统一( snake_case + _test后缀):
- D3D12_Minimal -> d3d12_minimal_test
- D3D12_Triangle -> d3d12_triangle_test
- D3D12_Quad -> d3d12_quad_test
- D3D12_Sphere -> d3d12_sphere_test
- OpenGL_Minimal -> opengl_minimal_test
- OpenGL_Triangle -> opengl_triangle_test
- OpenGL_Quad -> opengl_quad_test
- OpenGL_Sphere -> opengl_sphere_test
- CTest名称去掉_Integration后缀

测试结果: 138个测试中从21个失败减少到16个失败
2026-03-23 20:32:33 +08:00
df7764e972 add RenderDocCapture to OpenGL quad, sphere, triangle integration tests 2026-03-23 20:25:53 +08:00
3af24bb1bc revert: restore BeginCapture/EndCapture instead of TriggerCapture
TriggerCapture caused incomplete rdc files due to async file writing.
BeginCapture/EndCapture ensures synchronous file write on EndCapture.
2026-03-23 20:23:20 +08:00
79422cfddd fix: simplify RenderDocCapture usage with TriggerCapture
- Remove BeginCapture/EndCapture complexity for manual frame capture
- Use TriggerCapture for single frame capture (simpler API)
- Move TriggerCapture before Present to ensure frame is captured
- Add SetForegroundWindow/SetFocus before TriggerCapture
- Remove default capture path in Initialize to allow SetCaptureFilePath to work
2026-03-23 19:40:50 +08:00
bf44438934 add renderdoc analysis script and sphere test asset 2026-03-23 19:08:05 +08:00
6a7be5c6fe cleanup: remove unused test scenes and update minimal RHI integration 2026-03-23 19:07:44 +08:00
6935a91a1f fix: RHI抽象层单元测试修复
- 实现 D3D12Device::CreateCommandQueue/CreateCommandList/CreateSwapChain
- 修复 Buffer::Map 对 DEFAULT heap 的问题 (Vertex/Index 使用 UPLOAD heap)
- 修复 Fence::IsSignaled() 初始值问题
- 修复 Sampler::GetNativeHandle() 返回值
- 修复 RHICapabilities 和 RHIDeviceInfo 初始化
- 修复 Shader 测试 (空 ShaderCompileDesc 预期)
- 修复 RHITestFixture 创建窗口句柄
- 重命名 opengl_engine_tests -> rhi_opengl_tests
- 添加 tests/RHI/unit/ 到构建系统

测试结果: 22 passed -> 59 passed
2026-03-23 18:53:29 +08:00
effc969ad3 Update minimal tests to use improved RenderDocCapture API
- OpenGL test: Use BeginCapture/EndCapture with bool return values
- D3D12 test: Use BeginCapture/EndCapture with bool return values
- Both tests: Use GetCapture() to log capture file info
- Added capture file path and size logging after capture
2026-03-23 18:44:12 +08:00
36683b4bb3 Fix RenderDoc OpenGL capture - pass HGLRC instead of HDC
Critical fix: For OpenGL, RenderDoc requires HGLRC (OpenGL context) as
the device pointer, not HDC. Previously OpenGL test incorrectly passed
HDC which caused capture to silently fail (NumCaptures=0).

Changes:
- OpenGLDevice: Add wglCreateContextAttribsARB support for debug context
- OpenGLDevice: Create OpenGL 4.6 core profile with debug flag
- RenderDocCapture: Pass correct window to SetActiveWindow/StartFrameCapture
- OpenGL test: Pass HGLRC via SetDevice(), use BeginCapture/EndCapture

Fix root cause identified via RenderDoc docs analysis:
  'For OpenGL it must be the HGLRC, GLXContext, or EGLContext'
2026-03-23 18:35:49 +08:00
537808c64d fix: OpenGL sphere test - correct perspective matrix, depth test, texture flip, and screenshot path 2026-03-23 01:42:48 +08:00
f427699ac6 refactor: improve test infrastructure and fix OpenGL GLAD initialization
- Rename D3D12Enum.h to D3D12Enums.h for naming consistency
- Fix OpenGL unit test GLAD initialization by using gladLoadGL()
  instead of gladLoadGLLoader(wglGetProcAddress) for fallback support
- Migrate remaining tests to use gtest_discover_tests for granular
  test discovery (math, core, containers, memory, threading, debug,
  components, scene, resources, input, opengl)
- Remove obsolete TEST_RESOURCES_DIR and copy_directory commands
  from OpenGL unit test CMakeLists (minimal/Res doesn't exist)
- Update TEST_SPEC.md with performance metrics and per-module
  build/test commands for faster development workflow
- Update CMake path references to use lowercase paths
2026-03-23 00:43:02 +08:00
74adeb74a0 cleanup: remove unused shader/model/image folders from RHI integration tests 2026-03-22 20:15:17 +08:00
1797e7fe17 fix: encapsulate OpenGL types in VertexAttribute to eliminate raw GL API usage in tests
- Add VertexAttributeType and VertexAttributeNormalized enums in OpenGLVertexArray.h
- Add ToGLAttributeType() converter in OpenGLVertexArray.cpp
- Remove glActiveTexture() call from quad test (already handled by texture.Bind())
- Remove #include <glad/glad.h> from triangle test
- Update unit tests to use encapsulated enums

All three OpenGL integration tests (minimal, triangle, quad) pass with 0% pixel difference.
2026-03-22 14:33:57 +08:00
11919aad2f Add OpenGL quad integration test with texture mapping
- Add tests/RHI/OpenGL/integration/quad/ with main.cpp, CMakeLists.txt
- Add GLSL shaders (quad.vert, quad.frag) for textured quad rendering
- Use OpenGLVertexArray, OpenGLBuffer, OpenGLShader, OpenGLPipelineState
- Add OpenGLTexture::LoadFromFile for texture loading (earth.png)
- Add OpenGLSampler for texture sampling configuration
- Disable depth test for 2D quad rendering
- GT.ppm generated from OpenGL rendering output (0% diff on re-run)
2026-03-22 03:03:14 +08:00
f8e7edd2c1 Add OpenGL triangle integration test with GLSL shaders
- Add tests/RHI/OpenGL/integration/triangle/ with main.cpp, CMakeLists.txt
- Add GLSL shaders (triangle.vert, triangle.frag) for vertex/fragment shading
- Use OpenGLVertexArray, OpenGLBuffer, OpenGLShader, OpenGLPipelineState
- Disable depth test to allow 2D triangle rendering
- GT.ppm reused from D3D12 triangle test (0% diff)
2026-03-22 02:30:52 +08:00
7a6cd412c8 Remove kissfft third party library and update OpenGL screenshot 2026-03-21 15:54:42 +08:00
93139813aa OpenGL: Use OpenGLCommandList instead of raw GL in minimal test
- Replace glViewport() with commandList.SetViewport()
- Replace glClearColor()+glClear() with commandList.Clear()
- Add OpenGLCommandList include and instance
2026-03-20 20:07:24 +08:00
394bec9db6 OpenGL: Add test documentation for minimal integration test
- Create TEST_SPEC.md with OpenGL test hierarchy and specifications
- Add section and inline comments to main.cpp explaining:
  - Window size calculation with AdjustWindowRect
  - glFinish before screenshot for GPU sync
  - Target frame count warm-up period
  - Shutdown order (reverse of initialization)
2026-03-20 19:56:48 +08:00
f8573d2715 OpenGL: Refactor integration test with separate output directory 2026-03-20 19:39:49 +08:00
28bf76cb00 OpenGL: Fix screenshot gray edge issue by correcting SetWindowPos usage
- OpenGLSwapChain::Initialize now uses AdjustWindowRect before SetWindowPos
- This ensures window client area matches expected size (1280x720)
- Previously SetWindowPos was given client area size instead of full window size
- Removed debug fprintf statements from OpenGLDevice
- Updated minimal integration test to use cleaner code
2026-03-20 19:33:58 +08:00
572e0e9bd5 OpenGL: Refactor integration test and enable CTest framework
- Simplify OpenGL integration test structure
- Enable CTest registration for OpenGL tests
- Refactor test fixtures and device enumeration
- Minor code cleanup and improvements
2026-03-20 19:05:50 +08:00
460a2477c3 OpenGL: Add minimal integration test and enable integration test framework
- Add OpenGL_Minimal integration test using Win32 native API + glad
- Copy run_integration_test.py and compare_ppm.py from D3D12
- Create minimal/main.cpp with red clear color (matching D3D12)
- Generate GT.ppm golden template for 1280x720 red window
- Add VertexArray_Bind_MultipleAttributes unit test
- Update integration/CMakeLists.txt to build OpenGL_Minimal target
2026-03-20 18:30:38 +08:00
0a19fdfb0f OpenGL: Restructure tests similar to D3D12 layout
- Move old test files to new unit/integration structure
- Add OpenGL Test Fixture
- Update CMakeLists.txt for new layout
- Add OpenGL_Test_Restructuring_Plan.md
2026-03-20 17:37:09 +08:00
3196261e9b fix(RHI): 添加 OpenGL 源文件到 CMakeLists 并修复编译错误
- 添加 OpenGL RHI 所有源文件到 engine/CMakeLists.txt
- 修复 OpenGLPipelineState 结构体重定义问题
- 修复 BufferDesc/TextureDesc/ShaderCompileDesc API 不匹配
- 添加 OpenGLShader 缺少的基类纯虚函数实现
- 修复 HashMap 迭代器支持和 ResourceManager API 调用
2026-03-18 03:37:34 +08:00
b7feca59c4 fix(test): zero-initialize state structs to avoid stack corruption 2026-03-17 23:29:31 +08:00
6fe21710e8 test(RHI): add rendering state tests for CommandList
- Add tests for SetPrimitiveTopology
- Add tests for SetDepthStencilState
- Add tests for SetBlendState
- Add tests for SetBlendFactor
- OpenGL tests now have 45 test cases
2026-03-17 23:25:40 +08:00
0a2f8050e5 fix(RHI): 修复 OpenGL 测试接口不匹配问题
- 修复 RHIDeviceInfo 缺少 majorVersion/minorVersion
- 修复 OpenGLTexture 使用 GetTextureType 替代 GetType
- 修复 OpenGLSampler 使用 OpenGLSamplerDesc
- 修复 BlendFactor::OneMinusSrcAlpha -> InvSrcAlpha
- 修复 OpenGLRenderTargetViewDesc/OpenGLDepthStencilViewDesc 重定义问题
- 恢复 OpenGL 测试文件到 CMakeLists
2026-03-17 19:43:20 +08:00
e138fb2075 fix(RHI): 修复 OpenGL/D3D12 后端编译问题
- 修复 OpenGLCommandList 方法签名匹配 RHI 抽象接口
- 修复 OpenGLSwapChain Present/Resize 方法签名
- 添加 OpenGL 特有方法重载支持后端测试(底层逃逸)
- 暂时禁用不兼容的 Resources 模块
- 更新 OpenGL 测试 CMakeLists
2026-03-17 19:35:51 +08:00
f2ae95e0a7 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
2026-03-17 12:48:17 +08:00
7bf586f6fa Add Phase 5: SwapChain tests (3 tests)
- Add SwapChain tests: Initialize, Present, Resize

=== OpenGL Test Suite Complete ===
Total: 49 tests across all phases:
- Phase 1: Device, Buffer, Fence (17 tests)
- Phase 2: Texture, Sampler (9 tests)
- Phase 3: Shader, PipelineState, VertexArray (11 tests)
- Phase 4: CommandList, RTV, DSV (9 tests)
- Phase 5: SwapChain (3 tests)
2026-03-17 12:41:29 +08:00
4b14831c57 Add Phase 4: CommandList, RTV, DSV tests (13 tests)
- Add CommandList tests: Clear (color/depth/stencil), SetIndexBuffer, Draw (VAO), SetViewport, SetScissor
- Add RTV tests: Initialize (Texture2D), Bind/Unbind
- Add DSV tests: Bind/Unbind
- Simplify tests to work with available GL context
2026-03-17 12:40:07 +08:00
276a9c476a Add Phase 3: Shader, PipelineState, VertexArray tests (11 tests)
- Add Shader tests: VertexFragment, Geometry, InvalidSource, SetUniforms
- Add PipelineState tests: DepthStencilState, BlendState, Viewport/Scissor
- Add VertexArray tests: Initialize, AddVertexBuffer, SetIndexBuffer, Bind/Unbind
2026-03-17 12:31:05 +08:00
1d181f1109 Add Phase 2: Texture and Sampler tests (9 tests)
- Add Texture tests: 2DTexture, CubeMap, Bind/Unbind, GenerateMipmap, SetFiltering/SetWrapping
- Add Sampler tests: Initialize (default/custom), Bind/Unbind, GetID
2026-03-17 12:27:47 +08:00
745f3ab225 Add OpenGL test infrastructure - Phase 1: Device, Buffer, Fence tests (17 tests)
- Create test directory structure at tests/RHI/OpenGL/
- Implement OpenGLTestFixture with GLFW/GLAD initialization
- Add Device tests: CreateRenderWindow, InitializeWithExistingWindow, GetDeviceInfo, SwapBuffers, PollEvents
- Add Buffer tests: VertexBuffer, IndexBuffer, UniformBuffer, Dynamic, Bind/Unbind, Map/Unmap
- Add Fence tests: Initialize (signaled/unsignaled), Signal, Wait, IsSignaled, GetStatus
- Add CMakeLists.txt with proper GLFW/GLAD/GTest linking
- Create implementation plan document at docs/OpenGL测试实施计划.md
2026-03-17 12:26:21 +08:00