Add CreateDesc helper for DescriptorHeap

This commit is contained in:
2026-03-17 01:21:17 +08:00
parent f4db1eafea
commit 9fda349fa1
2 changed files with 11 additions and 0 deletions

View File

@@ -31,6 +31,8 @@ public:
D3D12_CPU_DESCRIPTOR_HANDLE GetCPUDescriptorHandleForHeapStart() const; D3D12_CPU_DESCRIPTOR_HANDLE GetCPUDescriptorHandleForHeapStart() const;
D3D12_GPU_DESCRIPTOR_HANDLE GetGPUDescriptorHandleForHeapStart() const; D3D12_GPU_DESCRIPTOR_HANDLE GetGPUDescriptorHandleForHeapStart() const;
static D3D12_DESCRIPTOR_HEAP_DESC CreateDesc(DescriptorHeapType type, uint32_t numDescriptors, bool shaderVisible = false);
private: private:
ComPtr<ID3D12DescriptorHeap> m_descriptorHeap; ComPtr<ID3D12DescriptorHeap> m_descriptorHeap;
DescriptorHeapType m_type; DescriptorHeapType m_type;

View File

@@ -70,5 +70,14 @@ uint32_t D3D12DescriptorHeap::GetDescriptorCount() const {
return m_numDescriptors; return m_numDescriptors;
} }
D3D12_DESCRIPTOR_HEAP_DESC D3D12DescriptorHeap::CreateDesc(DescriptorHeapType type, uint32_t numDescriptors, bool shaderVisible) {
D3D12_DESCRIPTOR_HEAP_DESC desc = {};
desc.Type = ToD3D12(type);
desc.NumDescriptors = numDescriptors;
desc.Flags = shaderVisible ? D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE : D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
desc.NodeMask = 0;
return desc;
}
} // namespace RHI } // namespace RHI
} // namespace XCEngine } // namespace XCEngine