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
|
|
|
# D3D12Shader
|
|
|
|
|
|
|
|
|
|
**命名空间**: `XCEngine::RHI`
|
|
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
**类型**: 类 (继承自 `RHIShader`)
|
|
|
|
|
|
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
|
|
|
**描述**: DirectX 12 着色器的 D3D12 实现,继承自 `RHIShader`。
|
|
|
|
|
|
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
|
|
|
| 方法 | 描述 |
|
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`](../../shader/compile-from-file.md) | 从文件编译着色器 |
|
|
|
|
|
| [`Compile`](../../shader/compile.md) | 从源码编译着色器 |
|
2026-03-20 02:35:45 +08:00
|
|
|
| [`Shutdown`](../../shader/shutdown.md) | 关闭着色器 |
|
2026-03-19 02:01:18 +08:00
|
|
|
| [`GetD3D12Bytecode`](get-d3d12-bytecode.md) | 获取 D3D12 字节码 |
|
|
|
|
|
| [`GetBytecode`](get-bytecode.md) | 获取字节码 |
|
|
|
|
|
| [`GetBytecodeSize`](get-bytecode-size.md) | 获取字节码大小 |
|
2026-03-20 02:35:45 +08:00
|
|
|
| [`GetType`](../../shader/get-type.md) | 获取着色器类型 |
|
2026-03-19 02:01:18 +08:00
|
|
|
| [`GetInputLayout`](get-input-layout.md) | 获取输入布局 |
|
2026-03-20 02:35:45 +08:00
|
|
|
| [`GetNativeHandle`](../../shader/get-native-handle.md) | 获取原生句柄 |
|
2026-03-19 02:01:18 +08:00
|
|
|
| [`IsValid`](../../shader/is-valid.md) | 检查是否有效 |
|
|
|
|
|
| [`Bind`](../../shader/bind.md) | 绑定着色器 |
|
|
|
|
|
| [`Unbind`](../../shader/unbind.md) | 解绑着色器 |
|
2026-03-20 02:35:45 +08:00
|
|
|
| [`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) | 设置矩阵 uniform |
|
|
|
|
|
|
|
|
|
|
## 使用示例
|
|
|
|
|
|
|
|
|
|
```cpp
|
|
|
|
|
#include "XCEngine/RHI/D3D12/D3D12Shader.h"
|
|
|
|
|
|
|
|
|
|
auto shader = std::make_unique<D3D12Shader>();
|
|
|
|
|
if (shader->CompileFromFile(L"shaders/vertex.hlsl", "VSMain", "vs_6_0")) {
|
|
|
|
|
D3D12_SHADER_BYTECODE bytecode = shader->GetD3D12Bytecode();
|
|
|
|
|
// 使用字节码创建 PSO...
|
|
|
|
|
}
|
|
|
|
|
```
|
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
|
|
|
- [D3D12 后端总览](../d3d12.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
|
|
|
- [RHIShader](../../shader/shader.md) - 抽象着色器接口
|