feat(RHI): 添加 RHIDescriptorPool 抽象类
- 新增 RHIDescriptorPool 抽象基类,定义描述符池统一接口 - D3D12DescriptorHeap 现在继承自 RHIDescriptorPool - 添加 DescriptorPoolDesc 结构体,包含设备指针、类型、数量等信息 - 添加 Initialize(const DescriptorPoolDesc&) 统一初始化方法
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "../RHIEnums.h"
|
||||
#include "../RHITypes.h"
|
||||
#include "../RHIDescriptorPool.h"
|
||||
#include "D3D12Enum.h"
|
||||
|
||||
using Microsoft::WRL::ComPtr;
|
||||
@@ -12,25 +13,29 @@ using Microsoft::WRL::ComPtr;
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
class D3D12DescriptorHeap {
|
||||
class D3D12DescriptorHeap : public RHIDescriptorPool {
|
||||
public:
|
||||
D3D12DescriptorHeap();
|
||||
~D3D12DescriptorHeap();
|
||||
~D3D12DescriptorHeap() override;
|
||||
|
||||
bool Initialize(ID3D12Device* device, DescriptorHeapType type, uint32_t numDescriptors, bool shaderVisible = false);
|
||||
void Shutdown();
|
||||
void Shutdown() override;
|
||||
|
||||
bool Initialize(const DescriptorPoolDesc& desc) override;
|
||||
|
||||
ID3D12DescriptorHeap* GetDescriptorHeap() const { return m_descriptorHeap.Get(); }
|
||||
|
||||
CPUDescriptorHandle GetCPUDescriptorHandle(uint32_t index);
|
||||
GPUDescriptorHandle GetGPUDescriptorHandle(uint32_t index);
|
||||
uint32_t GetDescriptorCount() const;
|
||||
DescriptorType GetType() const;
|
||||
uint32_t GetDescriptorCount() const override;
|
||||
DescriptorHeapType GetType() const override;
|
||||
|
||||
uint32_t GetDescriptorSize() const { return m_descriptorSize; }
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE GetCPUDescriptorHandleForHeapStart() const;
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE GetGPUDescriptorHandleForHeapStart() const;
|
||||
|
||||
void* GetNativeHandle() override { return m_descriptorHeap.Get(); }
|
||||
|
||||
static D3D12_DESCRIPTOR_HEAP_DESC CreateDesc(DescriptorHeapType type, uint32_t numDescriptors, bool shaderVisible = false);
|
||||
|
||||
private:
|
||||
|
||||
30
engine/include/XCEngine/RHI/RHIDescriptorPool.h
Normal file
30
engine/include/XCEngine/RHI/RHIDescriptorPool.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include "RHIEnums.h"
|
||||
#include <cstdint>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
struct DescriptorPoolDesc {
|
||||
void* device;
|
||||
DescriptorHeapType type;
|
||||
uint32_t descriptorCount;
|
||||
bool shaderVisible;
|
||||
};
|
||||
|
||||
class RHIDescriptorPool {
|
||||
public:
|
||||
virtual ~RHIDescriptorPool() = default;
|
||||
|
||||
virtual bool Initialize(const DescriptorPoolDesc& desc) = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
|
||||
virtual void* GetNativeHandle() = 0;
|
||||
|
||||
virtual uint32_t GetDescriptorCount() const = 0;
|
||||
virtual DescriptorHeapType GetType() const = 0;
|
||||
};
|
||||
|
||||
} // namespace RHI
|
||||
} // namespace XCEngine
|
||||
Reference in New Issue
Block a user