- 修复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分类
2.7 KiB
2.7 KiB
RHIRenderPass
命名空间: XCEngine::RHI
类型: class (abstract)
头文件: XCEngine/RHI/RHIRenderPass.h
描述: 渲染通道抽象接口,定义了渲染操作所需的附件配置和加载/存储行为。
概述
RHIRenderPass 是 RHI 抽象层的渲染通道接口,用于描述渲染操作所需的附件配置。每个渲染通道定义了:
- 颜色附件的数量和格式
- 深度/模板附件(可选)
- 每个附件的加载操作(LoadAction)
- 每个附件的存储操作(StoreAction)
- 清除值(ClearValue)
渲染通道是延迟渲染和多渲染目标(MRT)等高级渲染技术的基础,它允许 GPU 预先知道帧缓冲配置,从而优化内存访问。
AttachmentDesc 结构体
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 |
初始化渲染通道 |
Shutdown |
关闭渲染通道 |
GetNativeHandle |
获取原生句柄 |
GetColorAttachmentCount |
获取颜色附件数量 |
GetColorAttachments |
获取颜色附件描述数组 |
GetDepthStencilAttachment |
获取深度模板附件描述 |
使用示例
#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 - 帧缓冲接口