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
This commit is contained in:
2026-03-25 00:26:16 +08:00
parent c5c43ae7aa
commit c6fe9547aa
22 changed files with 688 additions and 1 deletions

View File

@@ -4,6 +4,7 @@
#include "XCEngine/RHI/D3D12/D3D12CommandAllocator.h"
#include "XCEngine/RHI/D3D12/D3D12Fence.h"
#include "XCEngine/RHI/D3D12/D3D12DescriptorHeap.h"
#include "XCEngine/RHI/D3D12/D3D12DescriptorSet.h"
#include "XCEngine/RHI/D3D12/D3D12QueryHeap.h"
#include "XCEngine/RHI/D3D12/D3D12RootSignature.h"
#include "XCEngine/RHI/D3D12/D3D12PipelineLayout.h"
@@ -324,6 +325,24 @@ RHISampler* D3D12Device::CreateSampler(const SamplerDesc& desc) {
return nullptr;
}
RHIDescriptorPool* D3D12Device::CreateDescriptorPool(const DescriptorPoolDesc& desc) {
auto* pool = new D3D12DescriptorHeap();
DescriptorPoolDesc poolDesc = desc;
poolDesc.device = m_device.Get();
if (pool->Initialize(poolDesc)) {
return pool;
}
delete pool;
return nullptr;
}
RHIDescriptorSet* D3D12Device::CreateDescriptorSet(RHIDescriptorPool* pool, const DescriptorSetLayoutDesc& layout) {
if (pool == nullptr) {
return nullptr;
}
return pool->AllocateSet(layout);
}
RHIFence* D3D12Device::CreateFence(const FenceDesc& desc) {
auto* fence = new D3D12Fence();
if (fence->Initialize(m_device.Get(), desc.initialValue)) {