docs: update RHI API docs
This commit is contained in:
@@ -4,19 +4,49 @@
|
||||
|
||||
**类型**: `class` (abstract)
|
||||
|
||||
**头文件**: `XCEngine/RHI/RHIDescriptorPool.h`
|
||||
|
||||
**描述**: GPU 描述符堆池抽象接口,用于管理 GPU 描述符的分配和回收。
|
||||
|
||||
## 概述
|
||||
|
||||
`RHIDescriptorPool` 是 RHI 模块中的抽象类,提供 GPU 描述符堆的统一接口。描述符堆用于存储 GPU 资源视图(如常量缓冲区视图、着色器资源视图、采样器等)。该类管理描述符的分配和回收,支持着色器可见性配置。
|
||||
|
||||
## 公共方法
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| [`Initialize`](../../threading/task-system/initialize.md) | 初始化描述符池 |
|
||||
| [`Shutdown`](../../threading/task-system/shutdown.md) | 关闭并释放资源 |
|
||||
| [`GetNativeHandle`](../buffer/get-native-handle.md) | 获取原生句柄 |
|
||||
| [`~RHIDescriptorPool`](destructor.md) | 虚析构函数 |
|
||||
| [`Initialize`](initialize.md) | 初始化描述符池 |
|
||||
| [`Shutdown`](shutdown.md) | 关闭并释放资源 |
|
||||
| [`GetNativeHandle`](get-native-handle.md) | 获取原生句柄 |
|
||||
| [`GetDescriptorCount`](get-descriptor-count.md) | 获取描述符数量 |
|
||||
| [`GetType`](../command-queue/get-type.md) | 获取描述符类型 |
|
||||
| [`GetType`](get-type.md) | 获取描述符类型 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
// 创建描述符池
|
||||
DescriptorPoolDesc desc;
|
||||
desc.device = device;
|
||||
desc.type = DescriptorHeapType::CBV_SRV_UAV;
|
||||
desc.descriptorCount = 256;
|
||||
desc.shaderVisible = true;
|
||||
|
||||
RHIDescriptorPool* pool = yourFactory->CreateDescriptorPool();
|
||||
if (pool->Initialize(desc)) {
|
||||
// 获取描述符数量
|
||||
uint32_t count = pool->GetDescriptorCount();
|
||||
|
||||
// 获取原生句柄
|
||||
void* handle = pool->GetNativeHandle();
|
||||
|
||||
// 使用完后关闭
|
||||
pool->Shutdown();
|
||||
}
|
||||
delete pool;
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [../rhi/rhi.md](../rhi.md) - RHI 模块总览
|
||||
- [RHIDevice](../device/device.md) - 创建设备
|
||||
- [RHI 模块总览](../rhi.md) - RHI 模块总览
|
||||
|
||||
33
docs/api/rhi/descriptor-pool/destructor.md
Normal file
33
docs/api/rhi/descriptor-pool/destructor.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# RHIDescriptorPool::~RHIDescriptorPool
|
||||
|
||||
```cpp
|
||||
virtual ~RHIDescriptorPool() = default;
|
||||
```
|
||||
|
||||
虚析构函数,确保派生类对象能被正确销毁。
|
||||
|
||||
## 详细描述
|
||||
|
||||
析构函数是虚函数,允许通过基类指针正确删除派生类对象。在销毁描述符池前,应确保已经调用 [`Shutdown`](shutdown.md) 释放资源。
|
||||
|
||||
## 参数列表
|
||||
|
||||
无参数。
|
||||
|
||||
## 返回值
|
||||
|
||||
无返回值。
|
||||
|
||||
## 示例代码
|
||||
|
||||
```cpp
|
||||
// 通过基类指针销毁派生类对象
|
||||
RHIDescriptorPool* pool = factory->CreateDescriptorPool();
|
||||
// ... 使用 pool
|
||||
delete pool; // 正确调用析构函数
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RHIDescriptorPool 总览](descriptor-pool.md) - 返回类总览
|
||||
- [Shutdown](shutdown.md) - 关闭描述符池
|
||||
@@ -6,9 +6,15 @@ virtual uint32_t GetDescriptorCount() const = 0;
|
||||
|
||||
获取描述符数量。
|
||||
|
||||
**返回:** 描述符池中的描述符数量
|
||||
## 参数列表
|
||||
|
||||
**示例:**
|
||||
无参数。
|
||||
|
||||
## 返回值
|
||||
|
||||
`uint32_t` - 描述符池中的描述符数量
|
||||
|
||||
## 示例代码
|
||||
|
||||
```cpp
|
||||
uint32_t count = descriptorPool->GetDescriptorCount();
|
||||
@@ -17,3 +23,6 @@ uint32_t count = descriptorPool->GetDescriptorCount();
|
||||
## 相关文档
|
||||
|
||||
- [RHIDescriptorPool 总览](descriptor-pool.md) - 返回类总览
|
||||
- [Initialize](initialize.md) - 初始化描述符池
|
||||
- [Shutdown](shutdown.md) - 关闭描述符池
|
||||
- [GetType](get-type.md) - 获取描述符类型
|
||||
|
||||
34
docs/api/rhi/descriptor-pool/get-native-handle.md
Normal file
34
docs/api/rhi/descriptor-pool/get-native-handle.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# RHIDescriptorPool::GetNativeHandle
|
||||
|
||||
获取描述符池的原生 API 句柄。
|
||||
|
||||
## 方法签名
|
||||
|
||||
```cpp
|
||||
virtual void* GetNativeHandle() = 0;
|
||||
```
|
||||
|
||||
## 详细描述
|
||||
|
||||
返回描述符池在底层图形 API(DirectX 12/Vulkan)中的原生句柄。用于与原生 API 进行交互。
|
||||
|
||||
## 参数列表
|
||||
|
||||
无参数。
|
||||
|
||||
## 返回值
|
||||
|
||||
`void*` - 原生 API 句柄指针。DirectX 12 下为 `ID3D12DescriptorHeap*`,Vulkan 下为 `VkDescriptorPool`
|
||||
|
||||
## 示例代码
|
||||
|
||||
```cpp
|
||||
void* handle = descriptorPool->GetNativeHandle();
|
||||
// 使用原生句柄进行 API 特定操作
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RHIDescriptorPool 总览](descriptor-pool.md) - 返回类总览
|
||||
- [GetDescriptorCount](get-descriptor-count.md) - 获取描述符数量
|
||||
- [GetType](get-type.md) - 获取描述符类型
|
||||
36
docs/api/rhi/descriptor-pool/get-type.md
Normal file
36
docs/api/rhi/descriptor-pool/get-type.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# RHIDescriptorPool::GetType
|
||||
|
||||
获取描述符堆类型。
|
||||
|
||||
## 方法签名
|
||||
|
||||
```cpp
|
||||
virtual DescriptorHeapType GetType() const = 0;
|
||||
```
|
||||
|
||||
## 详细描述
|
||||
|
||||
返回描述符池所管理的描述符堆类型。类型决定了这个池可以分配哪些类型的描述符。
|
||||
|
||||
## 参数列表
|
||||
|
||||
无参数。
|
||||
|
||||
## 返回值
|
||||
|
||||
`DescriptorHeapType` - 描述符堆类型枚举值
|
||||
|
||||
## 示例代码
|
||||
|
||||
```cpp
|
||||
DescriptorHeapType type = descriptorPool->GetType();
|
||||
if (type == DescriptorHeapType::CBV_SRV_UAV) {
|
||||
// 处理 CBV/SRV/UAV 描述符
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RHIDescriptorPool 总览](descriptor-pool.md) - 返回类总览
|
||||
- [GetNativeHandle](get-native-handle.md) - 获取原生句柄
|
||||
- [GetDescriptorCount](get-descriptor-count.md) - 获取描述符数量
|
||||
45
docs/api/rhi/descriptor-pool/initialize.md
Normal file
45
docs/api/rhi/descriptor-pool/initialize.md
Normal file
@@ -0,0 +1,45 @@
|
||||
# RHIDescriptorPool::Initialize
|
||||
|
||||
初始化描述符池。
|
||||
|
||||
## 方法签名
|
||||
|
||||
```cpp
|
||||
virtual bool Initialize(const DescriptorPoolDesc& desc) = 0;
|
||||
```
|
||||
|
||||
## 详细描述
|
||||
|
||||
使用指定的描述符池描述初始化描述符池。分配 GPU 描述符堆资源,使其可以分配描述符。
|
||||
|
||||
## 参数列表
|
||||
|
||||
| 参数 | 类型 | 描述 |
|
||||
|------|------|------|
|
||||
| `desc` | `const DescriptorPoolDesc&` | 描述符池配置,包含设备指针、堆类型、描述符数量和着色器可见性 |
|
||||
|
||||
## 返回值
|
||||
|
||||
`bool` - 初始化成功返回 `true`,失败返回 `false`
|
||||
|
||||
## 示例代码
|
||||
|
||||
```cpp
|
||||
DescriptorPoolDesc desc;
|
||||
desc.device = device;
|
||||
desc.type = DescriptorHeapType::CBV_SRV_UAV;
|
||||
desc.descriptorCount = 256;
|
||||
desc.shaderVisible = true;
|
||||
|
||||
if (descriptorPool->Initialize(desc)) {
|
||||
// 初始化成功
|
||||
} else {
|
||||
// 初始化失败
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RHIDescriptorPool 总览](descriptor-pool.md) - 返回类总览
|
||||
- [Shutdown](shutdown.md) - 关闭描述符池
|
||||
- [GetDescriptorCount](get-descriptor-count.md) - 获取描述符数量
|
||||
@@ -1,41 +0,0 @@
|
||||
# RHIDescriptorPool 方法
|
||||
|
||||
## Initialize
|
||||
|
||||
```cpp
|
||||
virtual bool Initialize(const DescriptorPoolDesc& desc) = 0;
|
||||
```
|
||||
|
||||
初始化描述符池。
|
||||
|
||||
## Shutdown
|
||||
|
||||
```cpp
|
||||
virtual void Shutdown() = 0;
|
||||
```
|
||||
|
||||
释放描述符池资源。
|
||||
|
||||
## GetNativeHandle
|
||||
|
||||
```cpp
|
||||
virtual void* GetNativeHandle() = 0;
|
||||
```
|
||||
|
||||
获取原生 API 句柄。
|
||||
|
||||
## GetDescriptorCount
|
||||
|
||||
```cpp
|
||||
virtual uint32_t GetDescriptorCount() const = 0;
|
||||
```
|
||||
|
||||
获取描述符数量。
|
||||
|
||||
## GetType
|
||||
|
||||
```cpp
|
||||
virtual DescriptorHeapType GetType() const = 0;
|
||||
```
|
||||
|
||||
获取堆类型。
|
||||
33
docs/api/rhi/descriptor-pool/shutdown.md
Normal file
33
docs/api/rhi/descriptor-pool/shutdown.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# RHIDescriptorPool::Shutdown
|
||||
|
||||
关闭描述符池并释放所有相关资源。
|
||||
|
||||
## 方法签名
|
||||
|
||||
```cpp
|
||||
virtual void Shutdown() = 0;
|
||||
```
|
||||
|
||||
## 详细描述
|
||||
|
||||
关闭描述符池,释放所有已分配的 GPU 描述符堆资源。此操作不可撤销。
|
||||
|
||||
## 参数列表
|
||||
|
||||
无参数。
|
||||
|
||||
## 返回值
|
||||
|
||||
无返回值。
|
||||
|
||||
## 示例代码
|
||||
|
||||
```cpp
|
||||
descriptorPool->Shutdown();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RHIDescriptorPool 总览](descriptor-pool.md) - 返回类总览
|
||||
- [Initialize](initialize.md) - 初始化描述符池
|
||||
- [GetDescriptorCount](get-descriptor-count.md) - 获取描述符数量
|
||||
Reference in New Issue
Block a user