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

52 lines
1.2 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.
# D3D12Sampler
**命名空间**: `XCEngine::RHI`
**类型**: `class`
**继承**: `RHISampler`
**描述**: DirectX 12 采样器的 D3D12 实现,提供对 D3D12 采样器资源的封装和管理。
## 公共方法
| 方法 | 描述 |
|------|------|
| [`Initialize`](initialize.md) | 初始化采样器 |
| [`GetDesc`](get-desc.md) | 获取采样器描述符 |
| [`GetID`](get-id.md) | 获取采样器 ID |
## 继承方法
以下方法继承自 `RHISampler`
| 方法 | 描述 |
|------|------|
| [`Shutdown`](shutdown.md) | 关闭采样器 |
| [`GetNativeHandle`](get-native-handle.md) | 获取原生句柄 |
| [`Bind`](bind.md) | 绑定采样器到纹理单元 |
| [`Unbind`](unbind.md) | 解绑采样器 |
## 使用示例
```cpp
D3D12Sampler sampler;
D3D12_SAMPLER_DESC desc = {};
desc.Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR;
desc.AddressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP;
desc.AddressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP;
desc.AddressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP;
if (sampler.Initialize(device, desc)) {
sampler.Bind(0);
// 使用采样器...
sampler.Unbind(0);
sampler.Shutdown();
}
```
## 相关文档
- [D3D12 后端总览](../d3d12.md) - D3D12 模块总览
- [RHISampler](../../sampler/sampler.md) - 抽象采样器接口