1.8 KiB
1.8 KiB
OpenGLRenderPass::Initialize
bool Initialize(
uint32_t colorAttachmentCount,
const AttachmentDesc* colorAttachments,
const AttachmentDesc* depthStencilAttachment) override;
作用
把 RHI 层传入的附件描述复制到 OpenGLRenderPass 内部,供后续命令列表解释 load/store 语义。
前置条件
colorAttachmentCount > 0时,colorAttachments应指向至少同样长度的数组。- 该接口不做 OpenGL 上下文校验,因为当前实现不直接调用任何 GL API。
参数说明
colorAttachmentCount: 颜色附件数量。colorAttachments: 颜色附件描述数组。depthStencilAttachment: 可选的深度/模板附件描述。
返回值
- 当前实现恒定返回
true。
当前实现行为
- 把
colorAttachmentCount保存到m_colorAttachmentCount。 - 调整
m_colorAttachments大小,并逐项复制传入的颜色附件描述。 - 如果
depthStencilAttachment != nullptr:- 设置
m_hasDepthStencil = true - 复制一份
AttachmentDesc到m_depthStencilAttachment
- 设置
- 否则仅把
m_hasDepthStencil设为false。 - 不创建任何 OpenGL render pass 或 framebuffer 句柄。
设计说明
- 这和 Vulkan/D3D12 中“render pass 可能对应更强的后端对象”不同。
- 在当前 OpenGL 后端中,render pass 的职责更接近“本次渲染阶段的附件契约说明书”,命令列表只用它来判断哪些附件需要清除。
使用建议
- 不要把
true解释为“GPU 资源创建成功”;它仅表示元数据复制完成。 - 如果你需要真正的附件绑定结果,应关注 framebuffer 创建和
BeginRenderPass()的运行时行为。