Commit Graph

553 Commits

Author SHA1 Message Date
56ec2e9b85 refactor(editor): Phase 1 architecture refactoring
- Decouple Panel from Core::Layer (P0 issue resolved)
- Add EventBus with type-safe event system
- Add ISelectionManager interface with SelectionManagerImpl
- Add IEditorContext for dependency injection
- Update EditorLayer to use new architecture
- Update Application to create and inject EditorContext

New files:
- editor/src/Core/EventBus.h
- editor/src/Core/EditorEvents.h
- editor/src/Core/ISelectionManager.h
- editor/src/Core/SelectionManagerImpl.h
- editor/src/Core/IEditorContext.h
- editor/src/Core/EditorContextImpl.h

This enables future improvements: Undo/Redo, serialization, component extensibility.
2026-03-25 15:35:00 +08:00
3478fb414a docs: Update RHI test coverage matrix to v1.4 (P1-7 Compute/Dispatch completed) 2026-03-25 15:10:10 +08:00
720dd422d5 RHI: Add Compute/Dispatch unit tests (P1-7) and fix shader type bugs
Bug fixes:
- D3D12Shader::Compile: Set m_type based on target string (cs_/vs_/ps_/gs_)
- OpenGLShader::Compile: Parse target parameter to determine shader type
- OpenGLShader::CompileCompute: Set m_type = ShaderType::Compute
- D3D12CommandList::SetPipelineState: Use correct PSO handle for Compute

New tests (test_compute.cpp, 8 tests):
- ComputeShader_Compile_ValidShader
- ComputeShader_GetType_ReturnsCompute
- ComputeShader_Shutdown_Invalidates
- PipelineState_SetComputeShader
- PipelineState_HasComputeShader_ReturnsTrue
- PipelineState_GetType_Compute
- PipelineState_EnsureValid_Compute
- CommandList_Dispatch_Basic

Test results: 232/232 passed (D3D12: 116, OpenGL: 116)
2026-03-25 13:52:11 +08:00
da1f8cfb58 docs: Update RHI test coverage matrix and file list 2026-03-25 13:33:49 +08:00
920d3be78b RHI: Add DescriptorPool unit tests (8 tests, P1-5) 2026-03-25 13:21:13 +08:00
fbbf5dca55 docs: Update RHI test refactoring status to v1.2 2026-03-25 13:05:01 +08:00
2ac32e1330 RHI: Add RenderPass and Framebuffer unit tests with CMake support 2026-03-25 13:03:07 +08:00
41cea4d1a2 RHI: Implement CreateRenderPass/CreateFramebuffer in D3D12 and OpenGL backends 2026-03-25 13:03:02 +08:00
2313124cc5 RHI: Add CreateRenderPass/CreateFramebuffer to RHIDevice interface 2026-03-25 13:02:57 +08:00
cad6f586fb Editor: Fix InspectorPanel AddComponent popup crash
- Remove SeparatorText which causes PopStyleVar mismatch in ImGui
- Add stderr redirection for better error capture
- Add debug logging to InspectorPanel
- Fix EditorLayer commented out undefined functions
2026-03-25 12:56:51 +08:00
0834ccb7aa Editor: Add crash exception filter to InspectorPanel AddComponent
- Add Windows structured exception handling to catch crashes during component addition
- Log crashes to file and stderr for debugging
2026-03-25 12:30:35 +08:00
0948e0fdbe docs: Update RHI test refactoring status
- Mark P0-1 (Shader) and P0-2 (PipelineState) as completed
- Update test coverage matrix
- Add changelog v1.1
2026-03-25 12:30:05 +08:00
f808f8d197 RHI: Replace IsFinalized/Finalize with IsValid/EnsureValid
Unified PSO validation semantics across D3D12 and OpenGL backends:
- IsValid() returns whether PSO is ready to use
- EnsureValid() ensures PSO is valid (compiles if needed)

Behavior by backend:
- D3D12: IsValid=false after creation, true after EnsureValid() with shaders
- OpenGL: IsValid always=true (immediate model)

Also added test_pipeline_state.cpp with 10 tests for RHIPipelineState.
2026-03-25 12:28:33 +08:00
ca0d73c197 docs: update README to reflect current project structure after refactoring
- Correct directory structure (ui_editor -> editor, remove scripts/)
- Add Platform/ module (cross-platform abstraction layer)
- Add Input/ module
- Add Layer/LayerStack to Core module
- Add missing RHI abstraction files (DescriptorPool, DescriptorSet, RenderPass, Framebuffer, etc.)
- Add missing D3D12 backend files
- Add missing OpenGL backend files
- Add GLAD to third_party
- Add reference/ directory
- Add Res/ to mvs/
- Update editor directory structure
2026-03-25 12:06:10 +08:00
32c04b86b7 RHI: Add embedded shader source support via ShaderCompileDesc
- Add ShaderLanguage enum (HLSL, GLSL, SPIRV)
- Extend ShaderCompileDesc with source/sourceLanguage fields
- D3D12Device::CompileShader supports both file and embedded source
- OpenGLDevice::CompileShader supports embedded GLSL source
- Refactor test_shader.cpp to use embedded source for both backends

This enables consistent shader compilation across D3D12 and OpenGL
backends while maintaining backend-specific shader language support.
2026-03-25 12:00:26 +08:00
600892bbe2 Refactor RHI documentation and remove unused files 2026-03-25 01:31:09 +08:00
c9e459c179 Editor: UI panels and GameObject updates 2026-03-25 01:23:08 +08:00
dc970d215b RHI: Internalize OpenGL-specific methods in OpenGLDevice
- Remove GetTextureUnitAllocator/GetUniformBufferManager from public interface
- Remove SwapBuffers from public interface (friend OpenGLSwapChain can still access)
- Add MakeContextCurrent() and GetNativeContext() public methods
- Update integration tests to use MakeContextCurrent() instead of wglMakeCurrent
- Update RenderDoc calls to use GetNativeContext() instead of GetGLContext()
- Remove Device_SwapBuffers_NoErrors test (SwapBuffers no longer public)
- Mark Priority 7 as completed in RHI_Design_Issues.md
2026-03-25 01:20:38 +08:00
6328ac8d37 RHI: Add Compute Pipeline abstraction with D3D12 and OpenGL support
- Add SetComputeShader/GetComputeShader/HasComputeShader to RHIPipelineState
- Add m_computePipelineState for D3D12 compute PSO
- Add m_computeProgram/m_computeShader for OpenGL
- Fix OpenGLCommandList::DispatchCompute bug (was ignoring x,y,z params)
- Fix OpenGLShader::GetID usage in OpenGLPipelineState
- Mark Priority 8 as completed in RHI_Design_Issues.md
2026-03-25 01:05:03 +08:00
da48b808cd RHI: Remove无效的SetGlobal*方法 - 死代码清理
问题:SetGlobal*方法(SetGlobalInt/SetGlobalFloat/SetGlobalVec3/SetGlobalVec4/SetGlobalMat4/SetGlobalTexture)在D3D12和OpenGL中都只是缓存值,从不提交到GPU。

移除内容:
- RHICommandList.h: 移除6个SetGlobal*纯虚方法声明
- D3D12CommandList.h/cpp: 移除6个override声明+6个缓存变量+6个方法实现+Shutdown()中的缓存清理
- OpenGLCommandList.h/cpp: 同上

原因:
- SetGlobal*从未被代码库调用(死代码)
- SetUniform*已正常工作,使用shader reflection+实际GPU绑定
- 移除后无功能损失

测试状态:150个RHI单元测试全部通过,8个集成测试全部通过
2026-03-25 00:52:36 +08:00
a2fc8eca02 RHI: Remove无效的动态状态方法 - SetDepthStencilState/SetBlendState
重构原因:
- D3D12 PSO是不可变的,SetDepthStencilState/SetBlendState调用原本就是空实现(TODO)
- 这些方法在D3D12中完全无效,是死代码

移除的方法:
- SetDepthStencilState(const DepthStencilState&) - D3D12空实现,OpenGL直接调用GL函数
- SetBlendState(const BlendState&) - D3D12只设置BlendFactor其他忽略,OpenGL直接调用GL函数

保留的真正动态状态:
- SetViewport/SetViewports
- SetScissorRect/SetScissorRects
- SetStencilRef (D3D12动态状态)
- SetBlendFactor (D3D12动态状态)

注:PrimitiveTopology保留在CommandList,因为D3D12允许动态改变topology type

测试状态:150个RHI单元测试全部通过,8个集成测试全部通过
2026-03-25 00:37:18 +08:00
f8a2507bdf docs: Update RHI_Design_Issues.md - mark Priority 1 DescriptorSet as completed 2026-03-25 00:26:47 +08:00
c6fe9547aa RHI: Add DescriptorSet abstraction for D3D12 and OpenGL backends
- Add RHIDescriptorSet base class with Update/UpdateSampler/GetNativeHandle
- Add RHIDescriptorPool with AllocateSet/FreeSet methods
- Add SetGraphicsDescriptorSets/SetComputeDescriptorSets to RHICommandList
- Implement D3D12DescriptorSet using descriptor heap allocation
- Implement OpenGLDescriptorSet using TextureUnitAllocator
- Add CreateDescriptorPool/CreateDescriptorSet factory methods to RHIDevice
- Fix unit test SetVertexBuffer -> SetVertexBuffers API
- Add SetVertexBuffer convenience method for D3D12 backward compatibility
- Update CMakeLists.txt with new source files
2026-03-25 00:26:16 +08:00
c5c43ae7aa docs: Update RHI_Design_Issues.md with completed items status 2026-03-25 00:00:36 +08:00
5eb731bc2d RHI: Add explicit RenderPass abstraction (BeginRenderPass/EndRenderPass)
New abstractions:
- RHIFramebuffer: Framebuffer interface with Initialize/Bind/GetHandle
- RHIRenderPass: RenderPass interface with AttachmentDesc for load/store actions
- D3D12Framebuffer/D3D12RenderPass: D3D12 implementation
- OpenGLFramebuffer/OpenGLRenderPass: OpenGL implementation (adapted from existing)

RHICommandList changes:
- Added BeginRenderPass(RHIRenderPass*, RHIFramebuffer*, Rect, clearValues...)
- Added EndRenderPass()

Implementation notes:
- D3D12: Uses OMSetRenderTargets + ClearRenderTargetView (fallback from native RenderPass API)
- OpenGL: Uses glBindFramebuffer + glClearBufferfv for LoadOp handling
- Old SetRenderTargets/ClearRenderTarget retained for backward compatibility

All 845 tests pass.
2026-03-24 23:59:44 +08:00
1e88beacb8 RHI: Fix view type signatures in CommandList abstraction
- Unified RHICommandList interface to use RHIResourceView* for all view types
- Fixed OpenGLCommandList override signatures (SetVertexBuffers, SetIndexBuffer, etc.)
- Fixed D3D12CommandList by removing duplicate SetVertexBuffer methods
- Updated OpenGLCommandList.cpp to match new signatures
- Build and all 845 tests pass
2026-03-24 23:41:57 +08:00
7a66913f2b refactor(RHI): 将窗口职责从RHI移到Platform层
- RHIDeviceDesc 删除 windowHandle/width/height/appName
- SwapChainDesc 添加 windowHandle 字段
- RHISwapChain 删除 PollEvents/ShouldClose/SetFullscreen 等窗口相关接口
- OpenGLDevice 删除 CreateRenderWindow,改用 InitializeWithExistingWindow
- 更新所有集成测试使用新API
- 273个单元测试 + 8个集成测试全部通过
2026-03-24 23:00:49 +08:00
9fae910854 Editor: 更新编辑器面板和UI控件系统
- 添加新的UI控件系统(Core.h, ScalarControls.h, VectorControls.h, UI.h)
- 更新SceneManager支持场景层级管理
- 优化SelectionManager选择管理
- 改进InspectorPanel/GameViewPanel/HierarchyPanel等面板
- 更新RHI文档说明Vulkan实现计划
2026-03-24 20:02:38 +08:00
cab290b17d RHI: 增强RHIResourceView抽象接口,添加GetViewType/GetDimension/GetFormat虚函数
- 在RHIResourceView基类添加3个纯虚函数:GetViewType()、GetDimension()、GetFormat()
- D3D12ResourceView和OpenGLResourceView子类实现这些虚函数
- 在各InitializeAs*方法中正确存储format和dimension信息
- 消除调用者必须向下转型才能获取视图类型的需求
2026-03-24 20:01:54 +08:00
0f5d018c1a refactor(RHI): 完成 Shader uniform 设置迁移到 CommandList
- 删除 RHIShader 的 OpenGL 风格 SetMat4/SetVec3/SetInt 等方法
- 添加 UniformInfo 结构体和 GetUniformInfos/GetUniformInfo 接口
- D3D12Shader 和 OpenGLShader 实现 CacheUniformInfos
- RHICommandList 添加 SetUniform*/SetGlobal* 统一接口
- D3D12 实现 D3D12PipelineLayout 管理 root signature 映射
- 修复 D3D12CommandList::SetPipelineStateInternal 在 Reset 后未重新应用 root signature 的问题
- 更新 OpenGL 集成测试使用新的 SetUniform* API
- 所有单元测试和集成测试通过 (8/8 integration tests)
2026-03-24 19:47:22 +08:00
135fe9145b refactor(editor): 重构 Editor 使用 Engine 的 Component/Scene 系统
- Editor CMakeLists.txt 链接 XCEngine 库
- 删除 editor/src/Core/GameObject.h (简化版)
- SelectionManager 使用 Engine::Components::GameObject*
- SceneManager 使用 Engine::Scene
- HierarchyPanel 使用 Engine GameObject API
- InspectorPanel 使用 Engine TransformComponent

注意: Engine RHI Shader 接口有编译错误需要修复
2026-03-24 18:38:01 +08:00
c66ba2feb3 refactor(RHI): complete PipelineState Unity SRP style refactoring
- Fix Chinese character encoding issues causing MSVC C4819 warnings
- Add m_rootSignature member to D3D12PipelineState for PSO creation
- All integration tests pass: OpenGL 4/4, D3D12 4/4
- All RHI unit tests pass: 158/158
2026-03-24 18:33:16 +08:00
6ed033890a docs: 整理 plan 文档,废弃文档移至 used 目录
- 废弃的计划文档移动到 docs/plan/used/
- 更新 RHI 抽象层设计文档
- 保留当前有效的计划文档
2026-03-24 18:21:53 +08:00
612342d170 docs: 更正 Editor 设计文档中的 Component 系统描述
- 更正: Engine 核心已有完整组件系统,Editor Inspector 只是未完善
- 补充: Editor 和 Engine 使用两套不同的 GameObject/Component 系统 (重大架构问题)
- 补充: Scene 序列化依赖描述修正
- 补充: 架构问题中新增 Editor/Engine 系统差异分析
2026-03-24 18:20:10 +08:00
4daed24a05 docs: 添加 Editor 设计与实现分析文档
- 对比分析 XCEngine Editor 与 Fermion Boson Editor 各面板功能
- 详细列出缺失的面板: SettingsPanel, OverlayRenderPanel, MaterialEditorPanel, TextureConfigPanel, AssetManagerPanel
- 分析核心系统差异: Application 架构、SceneManager、UI 控件封装、选择系统、资源系统
- 制定改进计划分阶段实施路线
2026-03-24 18:15:03 +08:00
0dde7234b7 refactor(RHI): remove void* from CommandList interfaces and fix OpenGL MRT bug
- Remove void* parameters from RHICommandList abstract interface
- TransitionBarrier, SetVertexBuffer, SetIndexBuffer, SetRenderTargets,
  ClearRenderTarget, ClearDepthStencil, CopyResource now use RHIResourceView*
- SetPipelineState now uses RHIPipelineState* instead of void*
- Simplified SetVertexBuffer to 3 params, SetIndexBuffer to 2 params
- Add internal D3D12 APIs for native type support (low-level escape hatch)
- Fix OpenGL SetRenderTargets to call glDrawBuffers for MRT support
- Update tests to match new interface signatures

All 289 RHI tests pass (158 unit + 64 OpenGL backend + 58 D3D12 backend + 8 integration + 1 disabled)
2026-03-24 17:20:51 +08:00
ac5c98584a refactor: rename ui_editor to editor for consistency 2026-03-24 16:23:04 +08:00
d575532966 docs: update TEST_SPEC.md and README.md to reflect new directory structure
- TEST_SPEC.md: Updated test directory structure to reflect Core/Asset,
  Core/IO, and Resources/<Type> subdirectories
- TEST_SPEC.md: Updated module names and test counts (852 total)
- TEST_SPEC.md: Updated build commands for new Resources subdirectories
- README.md: Updated engine structure with Core/Asset/ and Core/IO/
- README.md: Updated Resources section with layered architecture
- README.md: Updated test coverage table with accurate counts
2026-03-24 16:14:05 +08:00
0b3423966d refactor(tests): reorganize tests directory to match engine structure
- Created tests/Core/Asset/ with tests for IResource, ResourceTypes, ResourceHandle, ResourceCache, ResourceDependencyGraph, ResourceGUID
- Created tests/Core/IO/ with tests for IResourceLoader, ResourcePath, ResourceFileSystem, FileArchive, ResourcePackage
- Reorganized tests/Resources/ into subdirectories: Texture/, Mesh/, Material/, Shader/, AudioClip/
- Added CMakeLists.txt for each new test subdirectory
- Fixed Material.h missing ResourceManager.h include (lost during engine refactor)
- tests/Core/CMakeLists.txt updated to include Asset/ and IO/ subdirectories
2026-03-24 15:44:13 +08:00
0345ce50cf refactor(tests): update Resources include paths to new directory structure
- Updated 23 test files in tests/Resources/ to use new include paths:
  - Core/Asset: IResource, ResourceTypes, ResourceHandle, ResourceManager, ResourceCache, AsyncLoader, ResourceDependencyGraph
  - Core/IO: IResourceLoader, ResourceFileSystem, ResourcePackage, ResourcePath, FileArchive
  - Resources subdirs: Texture/*, Shader/*, Mesh/*, Material/*, AudioClip/*
2026-03-24 15:02:59 +08:00
50c0ffdb9e refactor: reorganize Resources module into Core/Asset, Core/IO and Resources subdirectories
- Split core resource architecture into Core/Asset/ (IResource, ResourceManager, ResourceCache, etc.)
- Moved IO layer into Core/IO/ (IResourceLoader, ResourceFileSystem, etc.)
- Reorganized concrete resource types into Resources/{Texture,Mesh,Material,Shader,AudioClip}/
- Updated all include paths from relative to <XCEngine/...> format
- Fixed circular dependency in Material.h (removed unnecessary ResourceManager.h include)
- Fixed malformed include syntax in ResourceManager.h and AsyncLoader.h
- Fixed glad.h path issues in CMakeLists.txt
2026-03-24 14:46:17 +08:00
b1829bcfc5 【关键节点】OpenGLCommandList实现RHIResourceView*方法完成统一资源绑定
OpenGL实现:
- TransitionBarrier: 调用glMemoryBarrier(GL_ALL_BARRIER_BITS)
- SetRenderTargets: 通过framebuffer绑定渲染目标
- SetVertexBuffer: 绑定GL_ARRAY_BUFFER并设置顶点属性
- SetIndexBuffer: 绑定GL_ELEMENT_ARRAY_BUFFER
- ClearRenderTarget: 临时切换framebuffer清除颜色缓冲
- ClearDepthStencil: 临时切换framebuffer清除深度 stencil缓冲
- CopyResource: 使用glCopyImageSubData复制纹理数据

新增单元测试:
- CommandList_TransitionBarrier_WithResourceView
- CommandList_SetRenderTargets_WithResourceView
- CommandList_SetVertexBuffer_WithResourceView
- CommandList_SetIndexBuffer_WithResourceView
- CommandList_ClearRenderTarget_WithResourceView
- CommandList_ClearDepthStencil_WithResourceView
- CommandList_CopyResource_WithResourceView

验证: 158个RHI单元测试全部通过, OpenGL集成测试全部通过
2026-03-24 05:23:42 +08:00
1d1eee823d fix: D3D12单元测试CommandQueue_Execute_EmptyCommandLists修复ExecuteCommandLists参数类型
将GetCommandList()->GetCommandList()改为GetCommandList(),
因为ExecuteCommandLists现在通过GetNativeHandle()获取原生句柄,
需要传递D3D12CommandList*而非ID3D12GraphicsCommandList*

验证: 58个D3D12后端测试全部通过
2026-03-24 05:16:37 +08:00
e2050e35ec 【关键节点】RHICommandList添加RHIResourceView*方法重载实现统一资源绑定接口
- 在RHICommandList.h中添加7个RHIResourceView*方法重载:
  - TransitionBarrier(RHIResourceView*, ...)
  - SetRenderTargets(count, RHIResourceView**, RHIResourceView*)
  - SetVertexBuffer(slot, RHIResourceView*, ...)
  - SetIndexBuffer(RHIResourceView*, ...)
  - ClearRenderTarget(RHIResourceView*, ...)
  - ClearDepthStencil(RHIResourceView*, ...)
  - CopyResource(RHIResourceView*, RHIResourceView*)

- D3D12CommandList完整实现:
  - 通过D3D12ResourceView::GetResource()获取底层资源
  - 通过D3D12ResourceView::GetCPUHandle()获取RTV/DSV句柄

- OpenGLCommandList添加stub实现保持接口一致

- 验证: 144个单元测试全部通过, 4个D3D12集成测试全部通过
2026-03-24 05:11:47 +08:00
eb4840eac4 【关键节点】修复D3D12CommandQueue::ExecuteCommandLists类型混淆bug并完善集成测试配置
1. D3D12CommandQueue::ExecuteCommandLists修复:确保正确调用GetNativeHandle()
2. 集成测试修复:传递&gCommandList而不是gCommandList.GetCommandList()
3. CMakeLists.txt修复:添加renderdoc.dll到所有D3D12/OpenGL集成测试的POST_BUILD命令

测试验证:
- 单元测试:144/144通过
- D3D12集成测试:minimal/quad/triangle/sphere全部通过
- OpenGL集成测试:minimal/quad/triangle/sphere全部通过
2026-03-24 05:00:38 +08:00
0a3fe842b9 Refactor RHI ResourceView abstraction layer for unified cross-platform interface
- Create unified RHIResourceView base interface with type-specific Initialize methods
- Implement D3D12ResourceView with RTV/DSV/SRV/UAV/CBV support
- Implement OpenGL ResourceView simulation layer using FBO, texture units, and UBO
- Add OpenGLTextureUnitAllocator for managing texture unit bindings
- Add OpenGLUniformBufferManager for UBO binding points
- Add OpenGLFramebuffer for FBO management
- Remove deprecated D3D12 view classes (RenderTargetView, DepthStencilView, etc.)
- Fix ExecuteCommandLists type confusion bug by adding GetNativeHandle to RHICommandList
- Fix test bug where Close() was called before ExecuteCommandLists
- Update all integration tests to use new D3D12ResourceView class
- All tests pass: 144 unit tests + 8 integration tests
2026-03-24 03:49:13 +08:00
86b6d6b042 Clean up: remove test artifacts and add 工作/ to gitignore
- Remove minimal.ppm and test.py from tracking (test artifacts)
- Add 工作/ to gitignore (personal directory)
2026-03-24 02:50:26 +08:00
92ab6f5484 Fix D3D12CommandQueue::ExecuteCommandLists type confusion bug
- Cast void* to ID3D12CommandList* directly instead of D3D12CommandList*
- Remove erroneous Reset() call - caller is responsible for resetting
- Fixes SEH exception 0xc0000005 when executing command lists
2026-03-24 02:35:59 +08:00
512161bf81 docs: Fix markdown formatting in RHIFence.md 2026-03-24 02:29:52 +08:00
3147adcc3e Fix OpenGL fence tests: use EXPECT_GE instead of EXPECT_EQ for GetCompletedValue
GetCompletedValue() semantics: returns the highest confirmed completed value,
not the last Signal() target value. When Signal(5) -> Signal(3),
GetCompletedValue() should still return >= 5 since GPU already completed that.
2026-03-24 02:11:14 +08:00