feat: 实现 D3D12DescriptorHeap 描述符堆类

- 添加 D3D12DescriptorHeap.h 头文件
- 实现 ID3D12DescriptorHeap 封装
- 支持 RTV、DSV、CBV_SRV_UAV、Sampler 堆类型
- 支持 GPU 可见描述符堆
- 添加 GetCPUDescriptorHandle、GetGPUDescriptorHandle 等方法
- 测试通过
This commit is contained in:
2026-03-15 18:17:59 +08:00
parent ddd3140114
commit 7f064e9e71
3 changed files with 107 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
#pragma once
#include <d3d12.h>
#include <wrl/client.h>
#include "../Enums.h"
#include "D3D12Enum.h"
using Microsoft::WRL::ComPtr;
namespace XCEngine {
namespace RHI {
class D3D12DescriptorHeap {
public:
D3D12DescriptorHeap();
~D3D12DescriptorHeap();
bool Initialize(ID3D12Device* device, DescriptorHeapType type, uint32_t numDescriptors, bool shaderVisible = false);
void Shutdown();
ID3D12DescriptorHeap* GetDescriptorHeap() const { return m_descriptorHeap.Get(); }
D3D12_CPU_DESCRIPTOR_HANDLE GetCPUDescriptorHandle(uint32_t index) const;
D3D12_GPU_DESCRIPTOR_HANDLE GetGPUDescriptorHandle(uint32_t index) const;
uint32_t GetDescriptorCount() const { return m_numDescriptors; }
DescriptorHeapType GetType() const { return m_type; }
uint32_t GetDescriptorSize() const { return m_descriptorSize; }
D3D12_CPU_DESCRIPTOR_HANDLE GetCPUDescriptorHandleForHeapStart() const;
D3D12_GPU_DESCRIPTOR_HANDLE GetGPUDescriptorHandleForHeapStart() const;
private:
ComPtr<ID3D12DescriptorHeap> m_descriptorHeap;
DescriptorHeapType m_type;
uint32_t m_numDescriptors;
uint32_t m_descriptorSize;
bool m_shaderVisible;
};
} // namespace RHI
} // namespace XCEngine