Files
XCEngine/docs/api/rhi/sampler/get-id.md
2026-03-20 02:35:45 +08:00

46 lines
1.0 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.
# RHISampler::GetID
```cpp
virtual unsigned int GetID() = 0;
```
获取采样器的唯一标识符。该方法返回分配给采样器的唯一整数 ID可用于采样器的识别、缓存管理或调试目的。
**参数:**
**返回:** 采样器的唯一无符号整数标识符
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
#include "XCEngine/RHI/RHISampler.h"
class MySampler : public XCEngine::RHI::RHISampler {
public:
void Shutdown() override { }
void Bind(unsigned int unit) override { }
void Unbind(unsigned int unit) override { }
void* GetNativeHandle() override { return nullptr; }
unsigned int GetID() override { return m_id; }
private:
unsigned int m_id = 1;
};
void Example() {
MySampler sampler1;
MySampler sampler2;
unsigned int id1 = sampler1.GetID();
unsigned int id2 = sampler2.GetID();
}
```
## 相关文档
- [RHISampler 总览](sampler.md) - 返回类总览
- [RHISampler::GetNativeHandle](get-native-handle.md) - 获取原生句柄