44 lines
1.1 KiB
Markdown
44 lines
1.1 KiB
Markdown
# RHIPipelineState::GetNativeHandle
|
||
|
||
```cpp
|
||
virtual void* GetNativeHandle() = 0;
|
||
```
|
||
|
||
获取底层图形 API 的原生句柄。此方法返回的句柄类型取决于具体实现:
|
||
|
||
- **D3D12**: `ID3D12PipelineState*`
|
||
- **OpenGL**: `GLuint`(管线对象 ID)
|
||
- **Vulkan**: `VkPipeline`
|
||
- **Metal**: `id<MTLRenderPipelineState>`
|
||
|
||
**参数:** 无
|
||
|
||
**返回:** `void*` - 指向底层图形 API 管线状态对象的指针
|
||
|
||
**线程安全:** ❌
|
||
|
||
**复杂度:** O(1)
|
||
|
||
**示例:**
|
||
|
||
```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));
|
||
}
|
||
}
|
||
```
|
||
|
||
## 相关文档
|
||
|
||
- [RHIPipelineState](pipeline-state.md) - 返回类总览
|
||
- [RHIPipelineState::GetType](get-type.md) - 获取管线类型
|