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
|
|
|
# RHIShader
|
|
|
|
|
|
|
|
|
|
**命名空间**: `XCEngine::RHI`
|
|
|
|
|
|
|
|
|
|
**类型**: `class` (abstract)
|
|
|
|
|
|
|
|
|
|
**描述**: GPU 着色器资源抽象接口,用于管理着色器代码的编译和绑定。
|
|
|
|
|
|
|
|
|
|
## 公共方法
|
|
|
|
|
|
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
|
|
|
| [`CompileFromFile`](compile-from-file.md) | 从文件编译着色器 |
|
|
|
|
|
| [`Compile`](compile.md) | 从源码编译着色器 |
|
|
|
|
|
| [`GetType`](get-type.md) | 获取着色器类型 |
|
|
|
|
|
| [`IsValid`](is-valid.md) | 检查着色器是否有效 |
|
|
|
|
|
| [`Bind`](bind.md) | 绑定着色器 |
|
|
|
|
|
| [`Unbind`](unbind.md) | 解绑着色器 |
|
|
|
|
|
| [`SetInt`](set-int.md) | 设置整数 uniform |
|
|
|
|
|
| [`SetFloat`](set-float.md) | 设置浮点数 uniform |
|
|
|
|
|
| [`SetVec3`](set-vec3.md) | 设置 vec3 uniform |
|
|
|
|
|
| [`SetVec4`](set-vec4.md) | 设置 vec4 uniform |
|
|
|
|
|
| [`SetMat4`](set-mat4.md) | 设置 mat4 uniform |
|
|
|
|
|
| [`Shutdown`](shutdown.md) | 关闭并释放资源 |
|
|
|
|
|
| [`GetNativeHandle`](get-native-handle.md) | 获取原生句柄 |
|
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
|
|
|
|
|
|
|
|
## 着色器类型 (ShaderType)
|
|
|
|
|
|
|
|
|
|
| 枚举值 | 描述 |
|
|
|
|
|
|--------|------|
|
2026-03-19 00:35:26 +08:00
|
|
|
| `ShaderType::Vertex` | 顶点着色器 |
|
|
|
|
|
| `ShaderType::Fragment` | 片元着色器 |
|
|
|
|
|
| `ShaderType::Geometry` | 几何着色器 |
|
|
|
|
|
| `ShaderType::Compute` | 计算着色器 |
|
|
|
|
|
| `ShaderType::TessControl` | 曲面细分控制着色器 |
|
|
|
|
|
| `ShaderType::TessEvaluation` | 曲面细分评估着色器 |
|
|
|
|
|
| `ShaderType::Hull` | Hull 着色器 (D3D12) |
|
|
|
|
|
| `ShaderType::Domain` | Domain 着色器 (D3D12) |
|
|
|
|
|
| `ShaderType::Amplification` | 放大着色器 (Mesh Shader) |
|
|
|
|
|
| `ShaderType::Mesh` | Mesh 着色器 |
|
|
|
|
|
| `ShaderType::Library` | 着色器库 |
|
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
|
|
|
|
|
|
|
|
## 使用示例
|
|
|
|
|
|
|
|
|
|
```cpp
|
|
|
|
|
RHIShader* vs = device->CompileShader({});
|
|
|
|
|
vs->CompileFromFile(L"shaders/vertex.hlsl", "main", "vs_6_0");
|
|
|
|
|
vs->SetMat4("modelMatrix", modelMatrix);
|
|
|
|
|
vs->Bind();
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 相关文档
|
|
|
|
|
|
|
|
|
|
- [../rhi/rhi.md](../rhi.md) - RHI 模块总览
|
|
|
|
|
- [RHIDevice](../device/device.md) - 创建设备
|