2026-03-19 00:31:14 +08:00
|
|
|
|
# RHIPipelineState::GetNativeHandle
|
|
|
|
|
|
|
|
|
|
|
|
```cpp
|
|
|
|
|
|
virtual void* GetNativeHandle() = 0;
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
|
获取底层图形 API 的原生句柄。此方法返回的句柄类型取决于具体实现:
|
2026-03-19 00:31:14 +08:00
|
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
|
- **D3D12**: `ID3D12PipelineState*`
|
|
|
|
|
|
- **OpenGL**: `GLuint`(管线对象 ID)
|
|
|
|
|
|
- **Vulkan**: `VkPipeline`
|
|
|
|
|
|
- **Metal**: `id<MTLRenderPipelineState>`
|
|
|
|
|
|
|
|
|
|
|
|
**参数:** 无
|
|
|
|
|
|
|
|
|
|
|
|
**返回:** `void*` - 指向底层图形 API 管线状态对象的指针
|
|
|
|
|
|
|
|
|
|
|
|
**线程安全:** ❌
|
2026-03-19 00:31:14 +08:00
|
|
|
|
|
|
|
|
|
|
**复杂度:** O(1)
|
|
|
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
|
**示例:**
|
|
|
|
|
|
|
|
|
|
|
|
```cpp
|
|
|
|
|
|
#include "XCEngine/RHI/RHIPipelineState.h"
|
|
|
|
|
|
#include "XCEngine/RHI/RHIEnums.h"
|
|
|
|
|
|
|
|
|
|
|
|
void InspectNativeHandle(RHIPipelineState* pipeline) {
|
|
|
|
|
|
void* handle = pipeline->GetNativeHandle();
|
|
|
|
|
|
|
|
|
|
|
|
PipelineType type = pipeline->GetType();
|
|
|
|
|
|
|
|
|
|
|
|
if (type == PipelineType::Graphics && handle) {
|
|
|
|
|
|
// D3D12: ID3D12PipelineState* d3d12Pipeline = static_cast<ID3D12PipelineState*>(handle);
|
|
|
|
|
|
// OpenGL: GLuint glPipeline = static_cast<GLuint>(reinterpret_cast<uintptr_t>(handle));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2026-03-19 00:31:14 +08:00
|
|
|
|
## 相关文档
|
|
|
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
|
- [RHIPipelineState](pipeline-state.md) - 返回类总览
|
|
|
|
|
|
- [RHIPipelineState::GetType](get-type.md) - 获取管线类型
|