Commit Graph

22 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
89d13a4ae4 fix: D3D12 CreateTexture defaults and CommandList RTV support
- Add default value handling for sampleCount, mipLevels, depth in CreateTexture
- Add RTV descriptor heap to D3D12CommandList for future ClearRenderTarget implementation
- ClearRenderTarget remains stub (requires full D3D12 render pipeline state)
2026-03-23 21:46:14 +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
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
60c8461be3 refactor(RHI): 将窗口管理接口从 RHIDevice 移至 RHISwapChain
- 从 RHIDevice 抽象基类中移除 PollEvents/SwapBuffers/ShouldClose/SetShouldClose 接口
- 这些功能现在应该通过 RHISwapChain 访问
- 符合设计文档中定义的分层架构
2026-03-18 02:32:31 +08:00
e138fb2075 fix(RHI): 修复 OpenGL/D3D12 后端编译问题
- 修复 OpenGLCommandList 方法签名匹配 RHI 抽象接口
- 修复 OpenGLSwapChain Present/Resize 方法签名
- 添加 OpenGL 特有方法重载支持后端测试(底层逃逸)
- 暂时禁用不兼容的 Resources 模块
- 更新 OpenGL 测试 CMakeLists
2026-03-17 19:35:51 +08:00
14fb51e61e feat(RHI): 实现 RHIDevice 抽象基类 2026-03-17 17:45:01 +08:00
472f106a12 Refactor D3D12: remove ICommandQueue, IFence dependencies 2026-03-16 21:50:54 +08:00
0014c32fa5 Remove IRHIDevice inheritance from D3D12Device
- D3D12Device no longer inherits from IRHIDevice interface
- Removed interface factory methods (CreateCommandQueue, CreateCommandList, etc.)
- Keep concrete D3D12-specific methods (Initialize, Shutdown, GetDevice, etc.)
- This is the first step to decouple RHI abstraction from D3D12 backend
2026-03-16 15:41:30 +08:00
fb2b794156 Add IRHIDevice interface implementation to D3D12Device
- D3D12Device now inherits from IRHIDevice
- Implement factory methods: CreateCommandQueue, CreateCommandList, CreateFence, etc.
- Make D3D12CommandQueue implement ICommandQueue
- Add backward-compatible overloads for existing main.cpp code
- Remove duplicate Viewport/Rect definitions from D3D12CommandList.h
- Update main.cpp to use IRHIDevice* pointer
2026-03-15 23:03:06 +08:00
dfbd218435 Move D3D12 cpp files to src/RHI/D3D12/ subdirectory 2026-03-15 20:50:06 +08:00
f427eb2588 refactor: 删除旧的RHI实现,添加D3D12测试用例和第二阶段计划 2026-03-15 01:58:30 +08:00
15f42a1af5 feat: 添加CommandList常量和DSV支持,完善RenderContext 2026-03-15 00:08:03 +08:00
ab29013c01 fix: 修复VertexBuffer/IndexBuffer SizeInBytes错误及Fence Signal类型问题 2026-03-14 14:20:57 +08:00
3ad317afb2 feat: 修复RHI渲染循环问题
- 修复RootSignature参数数量与HelloEarth一致
- 修复StaticMeshComponent中device为nullptr的问题
- 修复CommandList::Reset类型转换问题
- 修复RTV创建使用nullptr而不是rtvDesc
- 添加SwapChain的GetCurrentRenderTarget方法
- 修复DepthStencil创建问题(暂时跳过)
- 渲染循环基本可运行
2026-03-14 03:13:10 +08:00
5f12393424 feat: 实现D3D12 RHI抽象层,修复PSO创建问题
- 添加RHI接口定义(IRHIDevice, ICommandList, IResource等)
- 实现D3D12Device, D3D12CommandList, D3D12PipelineState等
- 修复RootSignature参数数量(3->4)与HelloEarth一致
- 修复DSV格式设置(Unknown->D24_UNorm_S8_UInt)
- 添加Geometry Shader编译
- 创建XCEngineDemo项目验证RHI功能
2026-03-14 02:42:59 +08:00