Files
XCEngine/docs/api/rhi/pipeline-state/pipeline-state.md
2026-03-20 02:35:45 +08:00

59 lines
1.8 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.
# RHIPipelineState
**命名空间**: `XCEngine::RHI`
**类型**: `class` (abstract)
**头文件**: `XCEngine/RHI/RHIPipelineState.h`
**描述**: 管线状态接口,管理渲染管线状态
## 概述
`RHIPipelineState` 是 XCEngine RHI 模块中的抽象基类,定义了渲染管线状态的统一接口。它提供了绑定、解绑定、获取原生句柄以及查询管线类型等基本操作。作为抽象基类,具体实现由各图形 APID3D12、OpenGL、Vulkan、Metal自行实现。
此接口的主要作用是:
- 提供统一的管线状态管理抽象
- 屏蔽不同图形 API 的底层差异
- 支持图形管线、计算管线和光线追踪管线的管理
## 公共方法
| 方法 | 描述 |
|------|------|
| [`Shutdown`](shutdown.md) | 关闭并释放管线状态资源 |
| [`Bind`](bind.md) | 将管线状态绑定到渲染上下文 |
| [`Unbind`](unbind.md) | 将管线状态从渲染上下文解绑 |
| [`GetNativeHandle`](get-native-handle.md) | 获取底层图形 API 的原生句柄 |
| [`GetType`](get-type.md) | 获取管线类型(图形/计算/光线追踪) |
## 使用示例
```cpp
#include "XCEngine/RHI/RHIPipelineState.h"
#include "XCEngine/RHI/RHIEnums.h"
void ExampleUsage(RHIPipelineState* pipelineState) {
if (!pipelineState) {
return;
}
PipelineType type = pipelineState->GetType();
if (type == PipelineType::Graphics) {
pipelineState->Bind();
}
void* nativeHandle = pipelineState->GetNativeHandle();
pipelineState->Unbind();
pipelineState->Shutdown();
}
```
## 相关文档
- [RHIDevice](../device/device.md) - 设备接口,创建管线状态
- [RHIPipelineLayout](../pipeline-layout/pipeline-layout.md) - 管线布局
- [RHICommandList](../command-list/command-list.md) - 命令列表,执行绘制命令