Commit Graph

218 Commits

Author SHA1 Message Date
413f4c178f Enhance OpenGLCommandList with comprehensive rendering API
- Add ClearFlags, ClearColor, ClearDepth, ClearStencil, ClearDepthStencil
- Add SetVertexBuffers (multiple buffers)
- Add SetIndexBuffer with offset
- Add BindVertexArray with index buffer
- Add SetViewport with depth range, SetViewports
- Add SetScissor, SetScissorRects, EnableScissorTest
- Add depth test/write/func methods
- Add stencil test methods
- Add blending methods (enable, blend func, equation, color)
- Add culling methods (enable, cull face, front face, polygon mode)
- Add instanced drawing (DrawInstanced, DrawIndexedInstanced)
- Add indirect drawing (DrawIndirect, DrawIndexedIndirect)
- Add MultiDrawArrays, MultiDrawElements
- Add Dispatch and Compute Shader support
- Add MemoryBarrier and TextureBarrier
- Add texture/sampler binding methods
- Add buffer binding (BindBufferBase, BindBufferRange)
- Add Enable/Disable for OpenGL caps
- Add uniform setting methods
- Add query methods
- Add ReadPixels, BlitFramebuffer, CopyImageSubData
- Add framebuffer invalidation
- Add debug group push/pop
2026-03-17 02:13:02 +08:00
a54666df11 Enhance OpenGLTexture with more texture types
- Add OpenGLTextureType enum (1D, 2D, 2DArray, 3D, Cube, CubeArray)
- Add OpenGLFormat enum for texture formats
- Add Initialize() method for generic texture creation
- Add InitializeCubeMap() for cubemap textures
- Add BindImage() for image load/store
- Add GenerateMipmap(), SetFiltering(), SetWrapping() methods
- Add GetType(), GetMipLevels(), GetDepth() getters
2026-03-17 02:10:53 +08:00
56c32bfbde Enhance OpenGLBuffer with more buffer types and features
- Add OpenGLBufferType enum (Vertex, Index, Uniform, CopyRead, CopyWrite, etc.)
- Add Initialize() method with buffer type parameter
- Add Map/Unmap for direct buffer access
- Add SetData for dynamic updates
- Add BindBase for buffer binding to indexed targets
- Add GetType and IsDynamic getters
2026-03-17 02:08:49 +08:00
312699e262 Add CreateDescriptorRange helper 2026-03-17 01:33:17 +08:00
271c05d8c7 Add CreateDesc for D3D12RenderTargetView 2026-03-17 01:32:22 +08:00
f615a86aab Add CreateDesc for D3D12ShaderResourceView 2026-03-17 01:26:40 +08:00
83e91b16c7 Add CreateDesc for D3D12DepthStencilView 2026-03-17 01:23:23 +08:00
9fda349fa1 Add CreateDesc helper for DescriptorHeap 2026-03-17 01:21:17 +08:00
3d6787b6a4 Add CreateSamplerDesc helper method 2026-03-17 01:19:21 +08:00
64bd8c5074 Refactor: use engine helpers for RootSignature and PSO creation 2026-03-17 01:16:39 +08:00
73627f62f4 Fix CreateDescriptorTable: pass descriptor ranges array instead of using static 2026-03-17 01:03:13 +08:00
988f94eb29 Add static helper methods to D3D12RootSignature and D3D12PipelineState 2026-03-17 00:57:35 +08:00
7874033379 Add RootSignatureBuilder and PipelineStateBuilder for cleaner RHI API 2026-03-17 00:52:24 +08:00
472f106a12 Refactor D3D12: remove ICommandQueue, IFence dependencies 2026-03-16 21:50:54 +08:00
4a0f6d65d1 Remove OpenGLMesh (not needed, D3D12 has no Mesh) 2026-03-16 19:15:18 +08:00
801c563eb5 Add OpenGLMesh class to engine (not yet integrated in main.cpp) 2026-03-16 19:12:27 +08:00
bf98fa0b89 Add OpenGLRenderTargetView and OpenGLDepthStencilView 2026-03-16 19:06:21 +08:00
3cd47ea4c8 Add OpenGLSampler 2026-03-16 18:52:00 +08:00
aee4ae88db Add OpenGLFence 2026-03-16 18:48:12 +08:00
377f43260b Add OpenGLSwapChain 2026-03-16 18:41:05 +08:00
fce3d2421c Add OpenGLCommandList 2026-03-16 18:35:02 +08:00
0be91748c2 Add OpenGLPipelineState and integrate into main.cpp 2026-03-16 18:25:58 +08:00
430d23b719 Replace GLFW window management with OpenGLDevice from engine 2026-03-16 18:06:57 +08:00
fee738b0b9 Move OpenGL backend classes from tests/OpenGL to engine/
- Relocated OpenGLDevice, OpenGLShader, OpenGLBuffer, OpenGLVertexArray, OpenGLTexture to engine/
- Updated engine/CMakeLists.txt to include OpenGL backend source files
- Updated tests/OpenGL/CMakeLists.txt to use engine backend
- Added OpenGLTexture class implementation
2026-03-16 17:22:45 +08:00
0ce312e648 Remove RHI interface inheritance from all D3D12 backend classes
- D3D12Device, D3D12CommandQueue, D3D12CommandAllocator, D3D12Fence
- D3D12DescriptorHeap, D3D12QueryHeap, D3D12RootSignature
- D3D12PipelineState, D3D12Sampler, D3D12Shader
- D3D12Buffer, D3D12Texture, D3D12SwapChain

All D3D12 backend classes now directly use D3D12 APIs without
going through RHI interface abstraction. This decouples the
D3D12 backend from the RHI abstraction layer.

Test: D3D12 rendering test passed (screenshot comparison 100% match)
2026-03-16 15:48:14 +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
554c48448b Implement IShader and ISwapChain interfaces for D3D12 backend
- D3D12Shader now implements IShader interface with GetBytecode, GetBytecodeSize, GetType, GetInputLayout
- D3D12SwapChain now implements ISwapChain interface with GetBackBuffer returning IResource*
- Added D3D12Texture back buffer storage to SwapChain
- Fixed ISwapChain const correctness (GetCurrentBackBufferIndex, GetBackBuffer)
- main.cpp: use GetD3D12Bytecode() instead of GetBytecode() for PSO creation
2026-03-16 12:38:17 +08:00
8c1d68da57 Make D3D12RootSignature implement IRootSignature interface 2026-03-16 00:09:42 +08:00
37750fda7d Make D3D12DescriptorHeap implement IDescriptorHeap interface 2026-03-16 00:00:46 +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
d52028e196 Update main.cpp to use D3D12CommandList wrapper methods, add SetRenderTargets and Clear overloads 2026-03-15 20:36:42 +08:00
2a5fc4f0d4 Add GetDescriptorHandleIncrementSize to D3D12Device and update main.cpp to use wrapper 2026-03-15 20:31:37 +08:00
13818fe641 Replace vertex/index buffer creation with D3D12Buffer wrapper 2026-03-15 19:58:22 +08:00
38e23e45c4 Replace depth buffer creation with D3D12Texture wrapper 2026-03-15 19:54:00 +08:00
632cba821d Replace RTV/DSV/SRV creation with wrapper classes 2026-03-15 19:48:20 +08:00
ff5dfc21db Replace CreateTexture2D with D3D12Texture wrapper 2026-03-15 19:39:16 +08:00
3959f74908 Add D3D12QueryHeap and D3D12UnorderedAccessView 2026-03-15 19:30:19 +08:00
f1cbf4e3a6 Add D3D12Buffer::InitializeWithData for vertex/index buffers 2026-03-15 19:16:46 +08:00
42c17ee106 Add D3D12 view wrapper classes: RTV, DSV, SRV, CBV 2026-03-15 19:10:32 +08:00
c62dc58157 Replace constant buffer with D3D12Buffer wrapper 2026-03-15 18:59:28 +08:00
c3feeda5d4 feat: 实现 D3D12Shader 着色器类
- 添加 D3D12Shader.h/cpp
- 支持从文件编译着色器
- 支持从内存编译着色器
- 测试通过
2026-03-15 18:51:38 +08:00
db8e8633c8 feat: 实现 D3D12Sampler 采样器类
- 添加 D3D12Sampler.h/cpp
- 支持采样器描述符
- 测试通过
2026-03-15 18:48:04 +08:00
017bbf281d feat: 实现 D3D12Texture 和 D3D12Buffer 资源类
- 添加 D3D12Texture.h/cpp - 纹理资源封装
- 添加 D3D12Buffer.h/cpp - 缓冲区资源封装
- 支持 CreateCommittedResource 创建资源
- 测试通过
2026-03-15 18:45:11 +08:00
2a8f50134c feat: 实现 D3D12PipelineState 并替换到 tests/D3D12
- 添加 D3D12PipelineState.h/cpp
- 全局变量 gPipelineState
- 使用 D3D12PipelineState::Initialize 替代原生 CreateGraphicsPipelineState
- 测试通过
2026-03-15 18:41:27 +08:00
2bdd6d3199 feat: 实现 D3D12RootSignature 根签名类
- 添加 D3D12RootSignature.h 头文件
- 实现 ID3D12RootSignature 封装
- 支持序列化根签名描述符
- 测试通过
2026-03-15 18:36:11 +08:00
88cd65d082 fix: 修复 D3D12SwapChain 重复创建 swapchain 问题
- 添加 Initialize(IDXGISwapChain*, width, height) 重载方法
- 接受已存在的 swapchain 而不是重复创建
- 测试通过,日志显示正常渲染
2026-03-15 18:30:14 +08:00
f187aa3b37 feat: 实现 D3D12SwapChain 交换链类
- 添加 D3D12SwapChain.h 头文件
- 实现 IDXGISwapChain3 封装
- 实现 Initialize、Present、Resize 等方法
- 测试通过
2026-03-15 18:24:02 +08:00
7f064e9e71 feat: 实现 D3D12DescriptorHeap 描述符堆类
- 添加 D3D12DescriptorHeap.h 头文件
- 实现 ID3D12DescriptorHeap 封装
- 支持 RTV、DSV、CBV_SRV_UAV、Sampler 堆类型
- 支持 GPU 可见描述符堆
- 添加 GetCPUDescriptorHandle、GetGPUDescriptorHandle 等方法
- 测试通过
2026-03-15 18:17:59 +08:00
ddd3140114 refactor: 继续用 D3D12CommandList 替换原生 API
- 添加更多 wrapper 方法: SetDescriptorHeaps, SetGraphicsRootConstantBufferView, SetGraphicsRoot32BitConstants, SetGraphicsRootDescriptorTable, SetGraphicsRootShaderResourceView
- 使用 wrapper 方法替换 main.cpp 中的原生 API 调用
- 测试通过
2026-03-15 18:13:53 +08:00