44 lines
1.2 KiB
Markdown
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);
|
||
|
|
```
|