docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
- math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
- containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
- core: 修复 types 链接错误
- debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
- memory: 修复头文件路径, malloc vs operator new, 新增方法文档
- resources: 修复 Shader/Texture 链接错误
- threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
# RHISampler
|
|
|
|
|
|
|
|
|
|
**命名空间**: `XCEngine::RHI`
|
|
|
|
|
|
|
|
|
|
**类型**: `class` (abstract)
|
|
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
**头文件**: `RHISampler.h`
|
|
|
|
|
|
|
|
|
|
**描述**: GPU 纹理采样器抽象接口,用于配置纹理过滤和寻址模式。采样器定义了如何对纹理进行采样,包括过滤模式、寻址模式和各向异性级别等参数。
|
|
|
|
|
|
|
|
|
|
## 概述
|
|
|
|
|
|
|
|
|
|
`RHISampler` 是 RHI 抽象层中的纹理采样器接口,提供跨平台的纹理采样配置能力。通过 `RHIDevice::CreateSampler` 创建采样器实例。
|
|
|
|
|
|
|
|
|
|
**关键特性**:
|
|
|
|
|
- 支持点采样、线性采样和各向异性采样
|
|
|
|
|
- 支持 Wrap、Mirror、Clamp、Border 等寻址模式
|
|
|
|
|
- 提供原生 API 句柄访问
|
docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
- math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
- containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
- core: 修复 types 链接错误
- debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
- memory: 修复头文件路径, malloc vs operator new, 新增方法文档
- resources: 修复 Shader/Texture 链接错误
- threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
|
|
|
|
|
## 公共方法
|
|
|
|
|
|
2026-03-19 02:01:18 +08:00
|
|
|
| 方法 | 描述 |
|
docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
- math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
- containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
- core: 修复 types 链接错误
- debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
- memory: 修复头文件路径, malloc vs operator new, 新增方法文档
- resources: 修复 Shader/Texture 链接错误
- threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
|------|------|
|
2026-03-19 02:01:18 +08:00
|
|
|
| [`Shutdown`](shutdown.md) | 关闭并释放资源 |
|
2026-03-20 02:35:45 +08:00
|
|
|
| [`Bind`](bind.md) | 绑定采样器到纹理单元 |
|
|
|
|
|
| [`Unbind`](unbind.md) | 解绑采样器 |
|
2026-03-19 02:01:18 +08:00
|
|
|
| [`GetNativeHandle`](get-native-handle.md) | 获取原生句柄 |
|
|
|
|
|
| [`GetID`](get-id.md) | 获取采样器 ID |
|
docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
- math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
- containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
- core: 修复 types 链接错误
- debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
- memory: 修复头文件路径, malloc vs operator new, 新增方法文档
- resources: 修复 Shader/Texture 链接错误
- threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
## 使用示例
|
|
|
|
|
|
|
|
|
|
```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();
|
|
|
|
|
```
|
|
|
|
|
|
docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
- math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
- containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
- core: 修复 types 链接错误
- debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
- memory: 修复头文件路径, malloc vs operator new, 新增方法文档
- resources: 修复 Shader/Texture 链接错误
- threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
## 相关文档
|
|
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
- [RHI 模块总览](../rhi.md) - RHI 模块总览
|
docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
- math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
- containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
- core: 修复 types 链接错误
- debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
- memory: 修复头文件路径, malloc vs operator new, 新增方法文档
- resources: 修复 Shader/Texture 链接错误
- threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
- [RHITexture](../texture/texture.md) - 纹理资源
|
2026-03-20 02:35:45 +08:00
|
|
|
- [RHIDevice::CreateSampler](../device/create-sampler.md) - 创建采样器
|