Files
XCEngine/docs/api/rhi/render-pass/render-pass.md
ssdfasd 1cf744b755 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分类
2026-03-26 01:29:00 +08:00

80 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# RHIRenderPass
**命名空间**: `XCEngine::RHI`
**类型**: `class (abstract)`
**头文件**: `XCEngine/RHI/RHIRenderPass.h`
**描述**: 渲染通道抽象接口,定义了渲染操作所需的附件配置和加载/存储行为。
## 概述
`RHIRenderPass` 是 RHI 抽象层的渲染通道接口,用于描述渲染操作所需的附件配置。每个渲染通道定义了:
- 颜色附件的数量和格式
- 深度/模板附件(可选)
- 每个附件的加载操作LoadAction
- 每个附件的存储操作StoreAction
- 清除值ClearValue
渲染通道是延迟渲染和多渲染目标MRT等高级渲染技术的基础它允许 GPU 预先知道帧缓冲配置,从而优化内存访问。
## AttachmentDesc 结构体
```cpp
struct AttachmentDesc {
Format format = Format::Unknown;
LoadAction loadOp = LoadAction::Undefined;
StoreAction storeOp = StoreAction::Store;
LoadAction stencilLoadOp = LoadAction::Undefined;
StoreAction stencilStoreOp = StoreAction::Undefined;
ClearValue clearValue;
};
```
| 成员 | 类型 | 描述 |
|------|------|------|
| `format` | `Format` | 附件的像素格式 |
| `loadOp` | `LoadAction` | 渲染前颜色数据的加载操作 |
| `storeOp` | `StoreAction` | 渲染后颜色数据的存储操作 |
| `stencilLoadOp` | `LoadAction` | 渲染前模板数据的加载操作 |
| `stencilStoreOp` | `StoreAction` | 渲染后模板数据的存储操作 |
| `clearValue` | `ClearValue` | 清除颜色值 |
## 公共方法
| 方法 | 描述 |
|------|------|
| [`Initialize`](initialize.md) | 初始化渲染通道 |
| [`Shutdown`](shutdown.md) | 关闭渲染通道 |
| [`GetNativeHandle`](get-native-handle.md) | 获取原生句柄 |
| [`GetColorAttachmentCount`](get-color-attachment-count.md) | 获取颜色附件数量 |
| [`GetColorAttachments`](get-color-attachments.md) | 获取颜色附件描述数组 |
| [`GetDepthStencilAttachment`](get-depth-stencil-attachment.md) | 获取深度模板附件描述 |
## 使用示例
```cpp
#include <XCEngine/RHI/RHIRenderPass.h>
// 配置颜色附件
AttachmentDesc colorAttachments[1];
colorAttachments[0].format = Format::RGBA8_UNORM;
colorAttachments[0].loadOp = LoadAction::Clear;
colorAttachments[0].storeOp = StoreAction::Store;
colorAttachments[0].clearValue.color = { 0.0f, 0.0f, 0.0f, 1.0f };
// 配置深度附件(可选)
AttachmentDesc depthAttachment;
depthAttachment.format = Format::D24_UNORM_S8_UINT;
depthAttachment.loadOp = LoadAction::Clear;
depthAttachment.storeOp = StoreAction::Store;
// 创建渲染通道
RHIRenderPass* renderPass = device->CreateRenderPass(1, colorAttachments, &depthAttachment);
```
## 相关文档
- [RHIFramebuffer](../framebuffer/framebuffer.md) - 帧缓冲接口