- Rename texture/dtor.md to destructor.md per template spec - Remove duplicate non-hyphenated fence docs (getnativehandle.md, issignaled.md, getcompletedvalue.md) - Fix template field issues: - swap-chain, command-queue: 类型 now uses 'class (abstract)' - sampler: 头文件 now uses full path 'XCEngine/RHI/RHISampler.h' - types: 类型 fixed from 'structs' to 'struct' - enums: 类型 fixed from 'enums' to 'enum class' - Fix include paths in command-queue and pipeline-layout code examples - Create missing constructor/destructor docs for 11 classes: buffer, texture, shader, device, command-list, command-queue, fence, sampler, swap-chain, pipeline-state, pipeline-layout - Update class overview pages to include constructor/destructor entries
59 lines
1.9 KiB
Markdown
59 lines
1.9 KiB
Markdown
# RHISampler
|
|
|
|
**命名空间**: `XCEngine::RHI`
|
|
|
|
**类型**: `class` (abstract)
|
|
|
|
**头文件**: `XCEngine/RHI/RHISampler.h`
|
|
|
|
**描述**: GPU 纹理采样器抽象接口,用于配置纹理过滤和寻址模式。采样器定义了如何对纹理进行采样,包括过滤模式、寻址模式和各向异性级别等参数。
|
|
|
|
## 概述
|
|
|
|
`RHISampler` 是 RHI 抽象层中的纹理采样器接口,提供跨平台的纹理采样配置能力。通过 `RHIDevice::CreateSampler` 创建采样器实例。
|
|
|
|
**关键特性**:
|
|
- 支持点采样、线性采样和各向异性采样
|
|
- 支持 Wrap、Mirror、Clamp、Border 等寻址模式
|
|
- 提供原生 API 句柄访问
|
|
|
|
## 公共方法
|
|
|
|
| 方法 | 描述 |
|
|
|------|------|
|
|
| [`RHISampler`](constructor.md) | 默认构造函数 |
|
|
| [`~RHISampler`](destructor.md) | 虚析构函数 |
|
|
| [`Shutdown`](shutdown.md) | 关闭并释放资源 |
|
|
| [`Bind`](bind.md) | 绑定采样器到纹理单元 |
|
|
| [`Unbind`](unbind.md) | 解绑采样器 |
|
|
| [`GetNativeHandle`](get-native-handle.md) | 获取原生句柄 |
|
|
| [`GetID`](get-id.md) | 获取采样器 ID |
|
|
|
|
## 使用示例
|
|
|
|
```cpp
|
|
// 通过 RHIDevice 创建采样器
|
|
SamplerDesc samplerDesc;
|
|
samplerDesc.filter = static_cast<uint32_t>(FilterMode::Anisotropic);
|
|
samplerDesc.addressU = static_cast<uint32_t>(TextureAddressMode::Wrap);
|
|
samplerDesc.addressV = static_cast<uint32_t>(TextureAddressMode::Wrap);
|
|
samplerDesc.addressW = static_cast<uint32_t>(TextureAddressMode::Wrap);
|
|
samplerDesc.maxAnisotropy = 16;
|
|
samplerDesc.minLod = 0;
|
|
samplerDesc.maxLod = FLT_MAX;
|
|
|
|
RHISampler* sampler = device->CreateSampler(samplerDesc);
|
|
|
|
// 绑定到纹理单元 0
|
|
sampler->Bind(0);
|
|
|
|
// 使用完毕后关闭
|
|
sampler->Shutdown();
|
|
```
|
|
|
|
## 相关文档
|
|
|
|
- [RHI 模块总览](../rhi.md) - RHI 模块总览
|
|
- [RHITexture](../texture/texture.md) - 纹理资源
|
|
- [RHIDevice::CreateSampler](../device/create-sampler.md) - 创建采样器
|