Commit Graph

239 Commits

Author SHA1 Message Date
b68cde82b2 Add IAudioEffect interface and FFTFilter DSP effect using KissFFT 2026-03-21 12:08:16 +08:00
dfc948fc89 Move kissfft to engine/third_party and add AudioMixer class 2026-03-21 12:06:15 +08:00
d786914552 Engine: 添加 /FS 标志修复 MSVC PDB 冲突问题
- 在 CMakeLists.txt 中为 MSVC 编译选项添加 /FS 标志
- 添加 OpenGL Screenshot 模块支持
2026-03-21 11:56:59 +08:00
85c106d5dd Fix audio module: add NOMINMAX, include WASAPIBackend.h, add AudioClip and TransformComponent includes 2026-03-20 20:48:09 +08:00
47808f5f90 Add audio module foundation: AudioTypes, AudioConfig, IAudioBackend, WASAPIBackend, AudioSystem, AudioSourceComponent, AudioListenerComponent, and third-party KissFFT library 2026-03-20 20:31:24 +08:00
00f70eccf1 Engine: 实现 Components 和 Scene 模块,包含完整单元测试
新增 Components 模块:
- Component 基类 (生命周期、启用状态管理)
- TransformComponent (本地/世界空间变换、矩阵缓存、父子层级)
- GameObject (组件管理、父子层级、激活状态、静态查找)

新增 Scene 模块:
- Scene (场景管理、对象创建销毁、查找、生命周期)
- SceneManager (单例模式、多场景管理、场景切换)

新增测试:
- test_component.cpp (12 个测试)
- test_transform_component.cpp (35 个测试)
- test_game_object.cpp (26 个测试)
- test_scene.cpp (20 个测试)
- test_scene_manager.cpp (17 个测试)

所有测试均已编译通过。
2026-03-20 20:22:04 +08:00
810b0861c5 Docs: Add audio module architecture design document
- Add XCEngine音频模块架构设计.md
- Design audio system following Unity-style architecture
- Include AudioSourceComponent, AudioListenerComponent, AudioClip, AudioMixer
- Document DSP effect system (FFT, Reverb, EQ, Compressor)
- Document 3D spatial audio with HRTF support
- Define IAudioBackend abstraction layer with WASAPI/OpenAL backends
- Outline 5-phase implementation priorities
2026-03-20 19:59:06 +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
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
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
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
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
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
8344057886 feat(resources): add LoadGroup and UnloadGroup for batch resource loading 2026-03-18 03:20:18 +08:00
508d8b165b feat(RHI): 添加 RHIPipelineLayout 抽象类 2026-03-18 03:04:13 +08:00
17e71218e7 feat(OpenGL): 初始化 RHICapabilities
- 在 OpenGLDevice 初始化时查询 GL 扩展和硬件限制
- 设置 majorVersion、minorVersion
- 设置几何着色器、计算着色器、细分着色器支持标志
- 设置最大纹理尺寸、最大渲染目标数、最大视口数、各向异性最大值、顶点属性最大数
2026-03-18 02:36:40 +08:00
65ce9c84c6 feat(RHI): 在 RHIBuffer 基类中添加资源状态接口
- 添加 GetState() 和 SetState() 纯虚函数到 RHIBuffer 抽象基类
- D3D12Buffer 已有实现,现在通过基类接口可用
- OpenGLBuffer 添加空实现(OpenGL 无资源状态概念)
2026-03-18 02:34:17 +08:00
60c8461be3 refactor(RHI): 将窗口管理接口从 RHIDevice 移至 RHISwapChain
- 从 RHIDevice 抽象基类中移除 PollEvents/SwapBuffers/ShouldClose/SetShouldClose 接口
- 这些功能现在应该通过 RHISwapChain 访问
- 符合设计文档中定义的分层架构
2026-03-18 02:32:31 +08:00
83c2426830 fix(OpenGL): 修复工厂方法返回 nullptr 的问题
- OpenGLDevice::CreateBuffer 现在创建并返回 OpenGLBuffer 对象
- OpenGLDevice::CreateTexture 现在创建并返回 OpenGLTexture 对象
- OpenGLDevice::CreateSwapChain 现在创建并返回 OpenGLSwapChain 对象
- OpenGLDevice::CreateCommandList 现在创建并返回 OpenGLCommandList 对象
- OpenGLDevice::CreateCommandQueue 现在创建并返回 OpenGLCommandQueue 对象
- OpenGLDevice::CompileShader 现在创建并返回 OpenGLShader 对象
- OpenGLDevice::CreatePipelineState 现在创建并返回 OpenGLPipelineState 对象
- OpenGLDevice::CreateFence 现在创建并返回 OpenGLFence 对象
- OpenGLDevice::CreateSampler 现在创建并返回 OpenGLSampler 对象
2026-03-18 02:29:12 +08:00
a532cabf92 feat(RHI): 添加 RHIDescriptorPool 抽象类
- 新增 RHIDescriptorPool 抽象基类,定义描述符池统一接口
- D3D12DescriptorHeap 现在继承自 RHIDescriptorPool
- 添加 DescriptorPoolDesc 结构体,包含设备指针、类型、数量等信息
- 添加 Initialize(const DescriptorPoolDesc&) 统一初始化方法
2026-03-18 01:46:01 +08:00
a220638298 fix(D3D12): 修复 D3D12Fence::IsSignaled() 实现错误
- 原来实现假设 GetCompletedValue() > 0 即为 signaled,这是错误的
- 添加 m_signalValue 成员变量跟踪最后一次 signal 的值
- IsSignaled() 现在正确检查 GetCompletedValue() >= m_signalValue
2026-03-18 01:37:55 +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
254f794cdc feat(RHI): add rendering state abstraction to RHICommandList
- Add DepthStencilState and BlendState structs to RHICommandList
- Add SetPrimitiveTopology, SetDepthStencilState, SetStencilRef,
  SetBlendState, SetBlendFactor virtual methods
- Implement new methods in OpenGL backend with full state control
- Implement stub methods in D3D12 backend (states controlled via PSO)
2026-03-17 23:17:43 +08:00
417477c2ca feat: Implement resource system Phase 4.5 - ResourceFileSystem (4 files, +305 lines) 2026-03-17 22:43:59 +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
05c879a818 fix(OpenGL): 修复 RHIDeviceInfo majorVersion/minorVersion 为0的问题 2026-03-17 19:44:50 +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
a257ff2d8b fix(RHI): 修复抽象基类编译问题 2026-03-17 18:24:08 +08:00
20445999fc feat(RHI): 实现 RHIPipelineState 抽象基类 2026-03-17 18:09:34 +08:00
354b6a5cfc feat(RHI): 实现 RHISwapChain 抽象基类 2026-03-17 18:05:40 +08:00
55865a0252 feat(RHI): 实现 RHICommandList 抽象基类 2026-03-17 18:01:55 +08:00
4638539f17 feat(RHI): 实现 RHICommandQueue 抽象基类 2026-03-17 17:54:44 +08:00
14fb51e61e feat(RHI): 实现 RHIDevice 抽象基类 2026-03-17 17:45:01 +08:00
af718279ff feat(RHI): 实现 RHIFence 抽象基类
- 新增 RHIFence 抽象基类
- D3D12Fence 继承 RHIFence
- OpenGLFence 继承 RHIFence
- 文档更新 RHIFence 差异处理策略
2026-03-17 17:36:17 +08:00
f046e17ad6 feat(RHI): 实现 RHISampler 抽象基类
- 新增 RHISampler 抽象基类
- D3D12Sampler 继承 RHISampler
- OpenGLSampler 继承 RHISampler,使用 OpenGLSamplerDesc
- 文档更新 RHISampler 差异处理策略
2026-03-17 17:31:32 +08:00
e38d5ccede feat(RHI): 实现 RHIBuffer, RHITexture, RHIShader 抽象基类
- 新增 RHIBuffer, RHITexture, RHIShader 抽象基类
- D3D12Buffer/Texture/Shader 继承抽象基类
- OpenGLBuffer/Texture/Shader 继承抽象基类
- 添加 RHICapabilities, RHIDevice 头文件
- RHIEnums 添加 Fragment/TessControl/TessEvaluation
- 文档更新差异处理策略
2026-03-17 17:26:41 +08:00
8c6516183e test: 添加 D3D12 引擎测试框架
- 修复 engine/CMakeLists.txt 路径问题
- 在 tests/D3D12_engine/test/ 创建测试框架
- 添加基础测试夹具 D3D12TestFixture
- 添加 13 个基础测试用例
- 所有测试通过
2026-03-17 03:29:39 +08:00
d1c7c23527 test: 添加 D3D12 测试框架基础设施
- 创建 engine/src/RHI/D3D12/test/ 目录
- 添加 CMakeLists.txt 构建配置
- 添加基础测试夹具 D3D12TestFixture.h
- 添加各组件测试文件框架
- 更新 tests/CMakeLists.txt 集成新测试
2026-03-17 02:51:34 +08:00