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
|
|
|
|
|
|
|
|
|
|
|
|
**命名空间**: `XCEngine::RHI`
|
|
|
|
|
|
|
|
|
|
|
|
**类型**: `class` (abstract)
|
|
|
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
|
**头文件**: `XCEngine/RHI/RHITexture.h`
|
|
|
|
|
|
|
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
|
|
|
|
**描述**: GPU 纹理资源抽象接口,用于管理 1D、2D、3D 纹理和立方体贴图等 GPU 资源。
|
|
|
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
|
## 概述
|
|
|
|
|
|
|
|
|
|
|
|
`RHITexture` 是 GPU 纹理资源的抽象接口,封装了 1D、2D、3D 纹理和立方体贴图等资源的创建、状态管理、查询等操作。通过 RHI 抽象层,RHITexture 可在不同图形 API(DirectX 12、OpenGL)之间无缝切换。
|
|
|
|
|
|
|
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-20 02:35:45 +08:00
|
|
|
|
| [`~RHITexture`](dtor.md) | 虚析构函数 |
|
2026-03-19 02:01:18 +08:00
|
|
|
|
| [`GetWidth`](get-width.md) | 获取纹理宽度 |
|
|
|
|
|
|
| [`GetHeight`](get-height.md) | 获取纹理高度 |
|
|
|
|
|
|
| [`GetDepth`](get-depth.md) | 获取纹理深度 |
|
|
|
|
|
|
| [`GetMipLevels`](get-mip-levels.md) | 获取 Mip 级别数量 |
|
|
|
|
|
|
| [`GetFormat`](get-format.md) | 获取纹理格式 |
|
|
|
|
|
|
| [`GetTextureType`](get-texture-type.md) | 获取纹理类型 |
|
|
|
|
|
|
| [`GetState`](get-state.md) | 获取资源状态 |
|
|
|
|
|
|
| [`SetState`](set-state.md) | 设置资源状态 |
|
|
|
|
|
|
| [`GetNativeHandle`](get-native-handle.md) | 获取原生句柄 |
|
|
|
|
|
|
| [`GetName`](get-name.md) | 获取资源名称 |
|
|
|
|
|
|
| [`SetName`](set-name.md) | 设置资源名称 |
|
2026-03-20 02:35:45 +08:00
|
|
|
|
| [`Shutdown`](shutdown.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
|
|
|
|
|
|
|
|
|
|
## 纹理类型 (TextureType)
|
|
|
|
|
|
|
|
|
|
|
|
| 枚举值 | 描述 |
|
|
|
|
|
|
|--------|------|
|
|
|
|
|
|
| `TextureType::Texture1D` | 1D 纹理 |
|
|
|
|
|
|
| `TextureType::Texture2D` | 2D 纹理 |
|
|
|
|
|
|
| `TextureType::Texture2DArray` | 2D 纹理数组 |
|
|
|
|
|
|
| `TextureType::Texture3D` | 3D 纹理(体积纹理) |
|
|
|
|
|
|
| `TextureType::TextureCube` | 立方体贴图 |
|
|
|
|
|
|
| `TextureType::TextureCubeArray` | 立方体贴图数组 |
|
|
|
|
|
|
|
|
|
|
|
|
## 纹理格式 (Format)
|
|
|
|
|
|
|
|
|
|
|
|
| 格式 | 描述 |
|
|
|
|
|
|
|------|------|
|
2026-03-19 00:43:16 +08:00
|
|
|
|
| `Format::Unknown` | 未知格式 |
|
|
|
|
|
|
| `Format::R8_UNorm` | 单通道 8 位归一化 |
|
|
|
|
|
|
| `Format::R8G8_UNorm` | 双通道 8 位归一化 |
|
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
|
|
|
|
| `Format::R8G8B8A8_UNorm` | 四通道 8 位归一化 |
|
|
|
|
|
|
| `Format::R16G16B16A16_Float` | 四通道 16 位浮点 |
|
2026-03-19 00:43:16 +08:00
|
|
|
|
| `Format::R32G32B32A32_Float` | 四通道 32 位浮点 |
|
|
|
|
|
|
| `Format::R16_Float` | 单通道 16 位浮点 |
|
|
|
|
|
|
| `Format::R32_Float` | 单通道 32 位浮点 |
|
|
|
|
|
|
| `Format::D16_UNorm` | 16 位深度 |
|
|
|
|
|
|
| `Format::D24_UNorm_S8_UInt` | 24 位深度 + 8 位模板 |
|
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
|
|
|
|
| `Format::D32_Float` | 32 位深度 |
|
|
|
|
|
|
| `Format::BC1_UNorm` | BC1 压缩 (DXT1) |
|
2026-03-19 00:43:16 +08:00
|
|
|
|
| `Format::BC2_UNorm` | BC2 压缩 (DXT2/3) |
|
|
|
|
|
|
| `Format::BC3_UNorm` | BC3 压缩 (DXT4/5) |
|
|
|
|
|
|
| `Format::BC4_UNorm` | BC4 压缩 |
|
|
|
|
|
|
| `Format::BC5_UNorm` | BC5 压缩 |
|
|
|
|
|
|
| `Format::BC6H_UF16` | BC6H 压缩 (UF16) |
|
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
|
|
|
|
| `Format::BC7_UNorm` | BC7 高质量压缩 |
|
2026-03-19 00:43:16 +08:00
|
|
|
|
| `Format::R32G32B32A32_UInt` | 四通道 32 位无符号整数 |
|
|
|
|
|
|
| `Format::R32_UInt` | 单通道 32 位无符号整数 |
|
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
|
2026-03-20 02:35:45 +08:00
|
|
|
|
// 假设已通过 RHIDevice 创建了纹理
|
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 = device->CreateTexture(desc);
|
2026-03-20 02:35:45 +08:00
|
|
|
|
|
|
|
|
|
|
// 查询纹理属性
|
|
|
|
|
|
uint32_t width = texture->GetWidth();
|
|
|
|
|
|
uint32_t height = texture->GetHeight();
|
|
|
|
|
|
Format format = texture->GetFormat();
|
|
|
|
|
|
TextureType type = texture->GetTextureType();
|
|
|
|
|
|
|
|
|
|
|
|
// 设置资源状态
|
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
|
|
|
|
texture->SetState(ResourceStates::PixelShaderResource);
|
2026-03-20 02:35:45 +08:00
|
|
|
|
|
|
|
|
|
|
// 设置调试名称
|
|
|
|
|
|
texture->SetName("DiffuseMap_Main");
|
|
|
|
|
|
|
|
|
|
|
|
// 获取原生句柄(用于平台特定操作)
|
|
|
|
|
|
void* nativeHandle = texture->GetNativeHandle();
|
|
|
|
|
|
|
|
|
|
|
|
// 关闭并释放资源
|
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
|
|
|
|
texture->Shutdown();
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## 相关文档
|
|
|
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
|
- [../rhi.md](../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
|
|
|
|
- [RHIDevice](../device/device.md) - 创建设备
|
|
|
|
|
|
- [RHIBuffer](../buffer/buffer.md) - 缓冲区资源
|