Files
XCEngine/docs/api/rhi/render-pass/initialize.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

44 lines
1.2 KiB
Markdown

# RHIRenderPass::Initialize
初始化渲染通道对象。
```cpp
virtual bool Initialize(
uint32_t colorAttachmentCount,
const AttachmentDesc* colorAttachments,
const AttachmentDesc* depthStencilAttachment
) = 0;
```
根据指定的附件配置创建并初始化渲染通道对象。
**参数:**
- `colorAttachmentCount` - 颜色附件数量
- `colorAttachments` - 颜色附件描述数组,长度必须等于 `colorAttachmentCount`
- `depthStencilAttachment` - 深度模板附件描述,可为 `nullptr`(如果不需要深度模板)
**返回:** `bool` - 初始化成功返回 `true`,失败返回 `false`
**线程安全:**
**注意:**
- `colorAttachmentCount` 必须大于 0
- 每个 `AttachmentDesc``format` 必须指定为有效的 `Format` 枚举值
- 渲染通道创建后不可修改其配置
**示例:**
```cpp
AttachmentDesc colorDesc;
colorDesc.format = Format::RGBA8_UNORM;
colorDesc.loadOp = LoadAction::Clear;
colorDesc.storeOp = StoreAction::Store;
AttachmentDesc depthDesc;
depthDesc.format = Format::D24_UNORM_S8_UINT;
depthDesc.loadOp = LoadAction::Clear;
depthDesc.storeOp = StoreAction::Store;
RHIRenderPass* pass = device->CreateRenderPass(1, &colorDesc, &depthDesc);
```