refactor(docs): RHI模块文档重构 - 修复18处链接错误并新增RHIFramebuffer/RHIRenderPass文档
- 修复opengl/下13个文件对overview.md的错误引用,改为opengl.md - 修复opengl/shader/下2处get-native-handle.md的错误路径引用 - 修复rhi.md中rhifactory路径错误 - 修复opengl.md中对d3d12.md的错误引用 - 修复opengl/README.md中的overview.md引用 - 新增RHIFramebuffer完整文档(7个文件) - 新增RHIRenderPass完整文档(7个文件) - 更新rhi.md总览页,添加RHIFramebuffer和RHIRenderPass分类
This commit is contained in:
54
docs/api/rhi/framebuffer/framebuffer.md
Normal file
54
docs/api/rhi/framebuffer/framebuffer.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# RHIFramebuffer
|
||||
|
||||
**命名空间**: `XCEngine::RHI`
|
||||
|
||||
**类型**: `class (abstract)`
|
||||
|
||||
**头文件**: `XCEngine/RHI/RHIFramebuffer.h`
|
||||
|
||||
**描述**: 帧缓冲抽象接口,封装渲染目标帧缓冲的创建和管理。
|
||||
|
||||
## 概述
|
||||
|
||||
`RHIFramebuffer` 是 RHI 抽象层的帧缓冲接口,用于管理渲染目标(Render Target)的帧缓冲对象。它代表一个可用的帧缓冲结构,包含颜色附件、深度附件和模板附件。不同图形 API 后端(OpenGL、D3D12)通过实现此接口提供各自的帧缓冲管理机制。
|
||||
|
||||
帧缓冲是渲染管线中的核心对象,用于:
|
||||
- 存储渲染操作的颜色、深度、模板数据
|
||||
- 作为纹理输入传递给后续渲染步骤
|
||||
- 支持多重渲染目标(MRT)和延迟渲染
|
||||
|
||||
## 公共方法
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| [`Initialize`](initialize.md) | 初始化帧缓冲 |
|
||||
| [`Shutdown`](shutdown.md) | 关闭帧缓冲 |
|
||||
| [`GetNativeHandle`](get-native-handle.md) | 获取原生句柄 |
|
||||
| [`GetWidth`](get-width.md) | 获取帧缓冲宽度 |
|
||||
| [`GetHeight`](get-height.md) | 获取帧缓冲高度 |
|
||||
| [`IsValid`](is-valid.md) | 检查帧缓冲是否有效 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/RHI/RHIFramebuffer.h>
|
||||
#include <XCEngine/RHI/RHIRenderPass.h>
|
||||
|
||||
// 通过 RHIDevice 创建帧缓冲
|
||||
RHIFramebuffer* framebuffer = device->CreateFramebuffer(
|
||||
renderPass,
|
||||
width, height,
|
||||
colorAttachmentCount,
|
||||
colorAttachments,
|
||||
depthStencilAttachment
|
||||
);
|
||||
|
||||
if (framebuffer && framebuffer->IsValid()) {
|
||||
// 使用帧缓冲进行渲染
|
||||
framebuffer->Shutdown();
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RHIRenderPass](../render-pass/render-pass.md) - 渲染通道接口
|
||||
17
docs/api/rhi/framebuffer/get-height.md
Normal file
17
docs/api/rhi/framebuffer/get-height.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# RHIFramebuffer::GetHeight
|
||||
|
||||
获取帧缓冲的高度。
|
||||
|
||||
```cpp
|
||||
virtual uint32_t GetHeight() const = 0;
|
||||
```
|
||||
|
||||
**返回:** `uint32_t` - 帧缓冲高度(像素)
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
uint32_t height = framebuffer->GetHeight();
|
||||
```
|
||||
25
docs/api/rhi/framebuffer/get-native-handle.md
Normal file
25
docs/api/rhi/framebuffer/get-native-handle.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# RHIFramebuffer::GetNativeHandle
|
||||
|
||||
获取帧缓冲的原生句柄。
|
||||
|
||||
```cpp
|
||||
virtual void* GetNativeHandle() = 0;
|
||||
```
|
||||
|
||||
返回底层图形 API 的帧缓冲句柄。不同后端返回不同类型:
|
||||
- OpenGL: 返回 `GLuint`(帧缓冲对象 ID)
|
||||
- D3D12: 返回 `ID3D12Resource*` 指针
|
||||
|
||||
**返回:** `void*` - 原生句柄
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
void* handle = framebuffer->GetNativeHandle();
|
||||
#ifdef XCENGINE_OPENGL
|
||||
GLuint fbo = static_cast<GLuint>(reinterpret_cast<intptr_t>(handle));
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
#endif
|
||||
```
|
||||
17
docs/api/rhi/framebuffer/get-width.md
Normal file
17
docs/api/rhi/framebuffer/get-width.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# RHIFramebuffer::GetWidth
|
||||
|
||||
获取帧缓冲的宽度。
|
||||
|
||||
```cpp
|
||||
virtual uint32_t GetWidth() const = 0;
|
||||
```
|
||||
|
||||
**返回:** `uint32_t` - 帧缓冲宽度(像素)
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
uint32_t width = framebuffer->GetWidth();
|
||||
```
|
||||
49
docs/api/rhi/framebuffer/initialize.md
Normal file
49
docs/api/rhi/framebuffer/initialize.md
Normal file
@@ -0,0 +1,49 @@
|
||||
# RHIFramebuffer::Initialize
|
||||
|
||||
初始化帧缓冲对象。
|
||||
|
||||
```cpp
|
||||
virtual bool Initialize(
|
||||
class RHIRenderPass* renderPass,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t colorAttachmentCount,
|
||||
RHIResourceView** colorAttachments,
|
||||
RHIResourceView* depthStencilAttachment
|
||||
) = 0;
|
||||
```
|
||||
|
||||
根据指定的渲染通道和附件配置,创建并初始化帧缓冲对象。
|
||||
|
||||
**参数:**
|
||||
- `renderPass` - 关联的渲染通道对象
|
||||
- `width` - 帧缓冲宽度(像素)
|
||||
- `height` - 帧缓冲高度(像素)
|
||||
- `colorAttachmentCount` - 颜色附件数量
|
||||
- `colorAttachments` - 颜色附件资源视图数组
|
||||
- `depthStencilAttachment` - 深度模板附件资源视图,可为 `nullptr`
|
||||
|
||||
**返回:** `bool` - 初始化成功返回 `true`,失败返回 `false`
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**注意:**
|
||||
- `width` 和 `height` 必须大于 0
|
||||
- `colorAttachments` 数组长度必须与 `colorAttachmentCount` 匹配
|
||||
- 所有附件的尺寸必须与指定的 `width`、`height` 一致
|
||||
- 帧缓冲创建后,其尺寸不可更改,需调用 `Shutdown` 后重新初始化
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
// 创建带有颜色和深度附件的帧缓冲
|
||||
RHIResourceView* colorViews[1] = { colorRTView };
|
||||
RHIResourceView* depthView = depthStencilView;
|
||||
|
||||
bool success = framebuffer->Initialize(
|
||||
renderPass,
|
||||
1920, 1080,
|
||||
1, colorViews,
|
||||
depthView
|
||||
);
|
||||
```
|
||||
27
docs/api/rhi/framebuffer/is-valid.md
Normal file
27
docs/api/rhi/framebuffer/is-valid.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# RHIFramebuffer::IsValid
|
||||
|
||||
检查帧缓冲是否有效。
|
||||
|
||||
```cpp
|
||||
virtual bool IsValid() const = 0;
|
||||
```
|
||||
|
||||
判断帧缓冲是否已正确初始化且可用于渲染操作。
|
||||
|
||||
**返回:** `bool` - 帧缓冲有效返回 `true`,无效返回 `false`
|
||||
|
||||
**线程安全:** ✅
|
||||
|
||||
**注意:**
|
||||
- 返回 `false` 可能原因:未初始化、初始化失败、已被 `Shutdown`
|
||||
- 在调用 `Initialize` 前调用此方法会返回 `false`
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
if (framebuffer->IsValid()) {
|
||||
// 执行渲染操作
|
||||
} else {
|
||||
// 处理无效帧缓冲
|
||||
}
|
||||
```
|
||||
21
docs/api/rhi/framebuffer/shutdown.md
Normal file
21
docs/api/rhi/framebuffer/shutdown.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# RHIFramebuffer::Shutdown
|
||||
|
||||
关闭帧缓冲并释放相关资源。
|
||||
|
||||
```cpp
|
||||
virtual void Shutdown() = 0;
|
||||
```
|
||||
|
||||
销毁帧缓冲对象,释放底层图形 API 资源。调用后,帧缓冲不再有效,需要重新调用 `Initialize` 才能使用。
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**注意:**
|
||||
- 调用此方法后,帧缓冲对象仍可被安全地重复调用 `Shutdown`
|
||||
- 确保在帧缓冲未被任何活跃渲染操作使用时调用
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
framebuffer->Shutdown();
|
||||
```
|
||||
Reference in New Issue
Block a user