Commit Graph

234 Commits

Author SHA1 Message Date
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
d6ff7b6d1b D3D12: Refactor integration tests with separate output directories 2026-03-20 19:17:20 +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
45fd25dce3 D3D12: Add triangle integration test with rainbow gradient
- Add triangle test with vertex buffer and custom pipeline state
- Add triangle.hlsl shader with position and color per vertex
- Fix cull mode (NONE) and disable depth test for correct rendering
- Register D3D12_Triangle_Integration CTest
- Add GT.ppm golden image
2026-03-20 19:05:22 +08:00
26fe3cd835 D3D12: Add bounds check to GetBackBuffer and update unit tests
- Add assert() bounds check to GetBackBuffer() to catch invalid indices
- Include <cassert> in D3D12SwapChain.cpp
- Update test_swap_chain.cpp to use reference return type
- Mark InvalidIndex test as DISABLED (assert aborts on invalid index)
- Update get-back-buffer.md documentation
2026-03-20 18:35:00 +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
34c04af6cb D3D12: Fix texture ownership semantics and remove GetSwapChain() exposure
This commit fixes the D3D12 texture architecture issues:

1. D3D12Texture ownership semantics:
   - Add m_ownsResource member to track resource ownership
   - InitializeFromExisting() now takes ownsResource parameter (default false)
   - Shutdown() only releases resource if ownsResource is true
   - Initialize() sets m_ownsResource = true for created resources

2. D3D12SwapChain changes:
   - Remove GetSwapChain() method (was exposing native D3D12 API)
   - Change GetBackBuffer() to return reference instead of pointer
   - Back buffers initialized with ownsResource = false

3. minimal/main.cpp updates:
   - Remove gColorRTs[2] array (was duplicating back buffer wrapping)
   - Direct use of gSwapChain.GetBackBuffer(i) instead
   - All references updated to use encapsulated API

4. Documentation:
   - Update TEST_SPEC.md v1.3
   - Remove known limitation 7.2 (minimal GetBuffer issue fixed)
   - Add D3D12_Texture_Architecture_Fix_Plan.md design document
2026-03-20 17:58:27 +08:00
0017388498 Rename GT_minimal.ppm to GT.ppm for D3D12 minimal integration test
- Rename golden image file to match simpler convention
- Update CMakeLists.txt reference
- Update TEST_SPEC.md documentation
- Update run_tests.py reference
2026-03-20 17:41:07 +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
3cd3b04c7e D3D12: Add Screenshot wrapper overload and document known limitations
- Add D3D12Screenshot::Capture(D3D12Device&, D3D12CommandQueue&, D3D12Texture&, const char*) wrapper overload
- Update minimal integration test to use encapsulated APIs
- Add DescriptorHeap wrapper unit tests
- Document minimal GetBuffer native call as known limitation in TEST_SPEC.md
2026-03-20 17:36:51 +08:00
c52b4ef35c 修复D3D12SwapChain初始化bug并添加单元测试
- 修复Initialize(IDXGIFactory4*, ...)重载缺少m_backBuffers初始化的问题
- 新增test_swap_chain.cpp单元测试文件,包含6个SwapChain测试用例
- 更新unit CMakeLists.txt添加test_swap_chain.cpp和Res路径
2026-03-20 17:07:24 +08:00
dba3dc23f2 重构D3D12集成测试目录结构,每个测试独立子文件夹隔离资源 2026-03-20 16:33:35 +08:00
33e9958751 删除nul测试文件 2026-03-20 16:12:33 +08:00
31273fdac4 docs: restructure test specification into two-level system
- tests/TEST_SPEC.md: General test spec for all modules
- tests/RHI/D3D12/TEST_SPEC.md: D3D12-specific spec with CI integration
2026-03-20 03:33:40 +08:00
983d6d61cd ci: add unified test runner scripts/run_tests.py 2026-03-20 03:27:30 +08:00
9ad699cd6f test: rename unit tests to Component_Category_SubBehavior format, remove Placeholder tests 2026-03-20 03:18:30 +08:00
9c5bd3c33f docs: add TEST_SPEC.md for D3D12 test规范 2026-03-20 03:14:55 +08:00
b2228db3ee test: add test improvement plan, update CMakeLists with correct GT_minimal reference 2026-03-20 03:13:24 +08:00
e242b0f5a7 test: register integration tests in CTest with Python wrapper 2026-03-20 03:08:08 +08:00
fae520854e refactor: reorganize unit tests into separate folder
- Move test_*.cpp and fixtures/ to tests/RHI/D3D12/unit/
- Create unit/CMakeLists.txt with proper test configuration
- Simplify parent CMakeLists.txt to use add_subdirectory
- Integration tests remain in integration/ folder
2026-03-20 02:58:33 +08:00
4c6e7af02e refactor: encapsulate frame fence synchronization in CommandQueue
- Add WaitForPreviousFrame() and GetCurrentFrame() to RHICommandQueue interface
- D3D12CommandQueue now manages frame fence internally
- ExecuteCommandLists automatically signals fence after command execution
- OpenGLCommandQueue provides stub implementations for interface compliance
- Minimal test now uses CommandQueue::WaitForPreviousFrame() instead of manual fence
2026-03-20 02:51:34 +08:00
b7d66a09de fix: replace Sleep with proper fence synchronization in minimal test 2026-03-20 02:49:19 +08:00
77ef74bec6 fix: D3D12 screenshot implementation and tests 2026-03-20 02:35:59 +08:00
a647f5e8ec 修复 D3D12 截图功能:修复 GPU 过载导致的设备移除问题
问题根因:
1. 渲染循环帧率过高导致 GPU 过载(TDR)
2. D3D12CommandList::Reset() 未正确调用底层 Reset()

修复内容:
1. 在 Present 后添加 Sleep(10) 延迟防止 GPU 过载
2. 修复 D3D12CommandList::Reset() 正确调用底层 m_commandList->Reset()
3. 在 D3D12CommandList 中存储 CommandAllocator 引用
4. 在 main_minimal.cpp 中添加截图调用逻辑(30帧后截图保存为 minimal.ppm)

修改文件:
- engine/include/XCEngine/RHI/D3D12/D3D12CommandList.h
- engine/src/RHI/D3D12/D3D12CommandList.cpp
- tests/RHI/D3D12/integration/main_minimal.cpp (新增)
2026-03-20 02:25:15 +08:00
fc7c8f6797 feat: 完成资源系统导入设置类实现
- 新增 ImportSettings 基类
- 新增 TextureImportSettings 纹理导入设置类
- 新增 MeshImportSettings 网格导入设置类
- 新增 ResourcePath 资源路径类
- 完善 CMakeLists.txt 配置
- 新增对应单元测试 (45个测试用例)
2026-03-18 13:39:32 +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
70571316da feat(RHI): 添加 RHIFactory 工厂类
- 新增 RHIFactory 头文件和实现,支持通过 RHIType 或字符串创建设备
- 修复 D3D12Buffer 缺失的 Map/Unmap/SetData 实现
- 添加 RHI 工厂测试用例
- 更新 CMakeLists.txt 添加新文件
2026-03-18 01:33:15 +08:00
d2585f14b3 feat(Resources): Add ResourceDependencyGraph for resource dependency tracking
- Implement dependency graph for resource management
- Add/remove nodes and dependencies
- Reference counting support
- Circular dependency detection
- Add unit tests
2026-03-18 01:13:02 +08:00
bd69c3e124 feat(Resources): Add ResourcePackage system for asset bundling
- Implement ResourcePackageBuilder for creating .xcp packages
- Implement ResourcePackage for reading packaged assets
- Add unit tests for package builder and package reader
2026-03-18 00:49:22 +08:00
02ca59edf6 test(Resources): Add comprehensive resource system tests (8 new test files, +48 test cases)
- Add Shader tests (8 test cases)
- Add Material tests (13 test cases)
- Add FileArchive tests (7 test cases)
- Add Loader tests for Texture, Mesh, Audio, Shader, Material (4 tests each)
- Implement IResourceLoader.cpp with ReadFileData and GetExtension
- Update CMakeLists.txt to include new test files and source
2026-03-18 00:09:06 +08:00
640557cbb5 test(Resources): Add ResourceFileSystem tests (4 test cases) 2026-03-17 23:46:46 +08:00
e71edc2f46 test(Resources): Add AudioClip tests (2 test cases) 2026-03-17 23:45:06 +08:00
8cc4322d22 test(Resources): Add Texture and Mesh tests (8 test cases) 2026-03-17 23:38:29 +08:00
2325b4ba7d test(Resources): Add IResourceLoader/LoadResult tests (4 test cases) 2026-03-17 23:36:12 +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
0b50a57239 test(Resources): Add ResourceCache tests (8 test cases) 2026-03-17 23:07:33 +08:00
6ca1487279 test(Resources): Add ResourceHandle tests (11 test cases) 2026-03-17 22:52:30 +08:00
0e31cd804b test(Resources): Add IResource tests (3 test cases) 2026-03-17 22:50:21 +08:00
4710e6ba60 feat: Implement resource system Phase 2 - Concrete resource types
- Add Material class with shader/texture bindings and property system
- Add MaterialLoader for .mat/.json format
- Add Shader class (Vertex/Fragment/Geometry/Compute)
- Add ShaderLoader for .vert/.frag/.glsl/.hlsl
- Add AudioClip class (WAV/OGG/MP3/FLAC support)
- Add AudioLoader for audio files
- Add Texture/Mesh classes and loaders (from design doc)
- Fix HashMap iterator and String API usage
- Fix Mutex compatibility with std::lock_guard
- Update CMakeLists.txt with new resource files
- All tests pass: 11 Resources + 51 Containers
2026-03-17 22:32:27 +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
94bf04f06c feat(Resources): 添加资源系统基础框架
- ResourceTypes: 资源类型枚举、ResourceGUID生成
- IResource: 资源基类接口
- ResourceHandle: 资源句柄智能指针
- IResourceLoader: 加载器接口
- ResourceManager: 资源管理器(单例模式)
- ResourceCache: LRU缓存实现
- AsyncLoader: 异步加载器
- 测试框架: test_resource_types, test_resource_guid

Note: 当前与现有容器API存在编译差异,需要后续修复
2026-03-17 19:38:27 +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