docs: update RHI API docs
This commit is contained in:
55
docs/api/rhi/sampler/bind.md
Normal file
55
docs/api/rhi/sampler/bind.md
Normal file
@@ -0,0 +1,55 @@
|
||||
# RHISampler::Bind
|
||||
|
||||
```cpp
|
||||
virtual void Bind(unsigned int unit) = 0;
|
||||
```
|
||||
|
||||
将采样器绑定到指定的纹理单元。该方法将采样器状态设置到渲染管线的对应纹理采样槽位,使其后续的纹理采样操作可以使用此采样器。
|
||||
|
||||
**参数:**
|
||||
|
||||
| 参数 | 类型 | 描述 |
|
||||
|------|------|------|
|
||||
| `unit` | `unsigned int` | 纹理单元索引,指定绑定到哪个纹理采样槽位(通常 0-15) |
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include "XCEngine/RHI/RHISampler.h"
|
||||
|
||||
class MySampler : public XCEngine::RHI::RHISampler {
|
||||
public:
|
||||
void Shutdown() override { }
|
||||
void Bind(unsigned int unit) override {
|
||||
m_boundUnit = unit;
|
||||
}
|
||||
void Unbind(unsigned int unit) override {
|
||||
if (m_boundUnit == unit) {
|
||||
m_boundUnit = -1;
|
||||
}
|
||||
}
|
||||
void* GetNativeHandle() override { return nullptr; }
|
||||
unsigned int GetID() override { return 0; }
|
||||
|
||||
private:
|
||||
int m_boundUnit = -1;
|
||||
};
|
||||
|
||||
void Example() {
|
||||
MySampler sampler;
|
||||
sampler.Bind(0);
|
||||
sampler.Bind(1);
|
||||
sampler.Bind(2);
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RHISampler 总览](sampler.md) - 返回类总览
|
||||
- [RHISampler::Unbind](unbind.md) - 解绑采样器
|
||||
Reference in New Issue
Block a user