docs: update RHI API docs

This commit is contained in:
2026-03-20 02:35:45 +08:00
parent ea756c0177
commit 070b444f8f
501 changed files with 13493 additions and 2022 deletions

View File

@@ -4,12 +4,19 @@
**类型**: `class` (abstract)
**头文件**: `XCEngine/RHI/RHITexture.h`
**描述**: GPU 纹理资源抽象接口,用于管理 1D、2D、3D 纹理和立方体贴图等 GPU 资源。
## 概述
`RHITexture` 是 GPU 纹理资源的抽象接口,封装了 1D、2D、3D 纹理和立方体贴图等资源的创建、状态管理、查询等操作。通过 RHI 抽象层RHITexture 可在不同图形 APIDirectX 12、OpenGL之间无缝切换。
## 公共方法
| 方法 | 描述 |
|------|------|
| [`~RHITexture`](dtor.md) | 虚析构函数 |
| [`GetWidth`](get-width.md) | 获取纹理宽度 |
| [`GetHeight`](get-height.md) | 获取纹理高度 |
| [`GetDepth`](get-depth.md) | 获取纹理深度 |
@@ -18,10 +25,10 @@
| [`GetTextureType`](get-texture-type.md) | 获取纹理类型 |
| [`GetState`](get-state.md) | 获取资源状态 |
| [`SetState`](set-state.md) | 设置资源状态 |
| [`Shutdown`](shutdown.md) | 关闭并释放资源 |
| [`GetNativeHandle`](get-native-handle.md) | 获取原生句柄 |
| [`GetName`](get-name.md) | 获取资源名称 |
| [`SetName`](set-name.md) | 设置资源名称 |
| [`Shutdown`](shutdown.md) | 关闭并释放资源 |
## 纹理类型 (TextureType)
@@ -62,19 +69,30 @@
## 使用示例
```cpp
TextureDesc desc;
desc.width = 1024;
desc.height = 1024;
desc.format = (uint32_t)Format::R8G8B8A8_UNorm;
desc.textureType = (uint32_t)TextureType::Texture2D;
// 假设已通过 RHIDevice 创建了纹理
RHITexture* texture = device->CreateTexture(desc);
// 查询纹理属性
uint32_t width = texture->GetWidth();
uint32_t height = texture->GetHeight();
Format format = texture->GetFormat();
TextureType type = texture->GetTextureType();
// 设置资源状态
texture->SetState(ResourceStates::PixelShaderResource);
// 设置调试名称
texture->SetName("DiffuseMap_Main");
// 获取原生句柄(用于平台特定操作)
void* nativeHandle = texture->GetNativeHandle();
// 关闭并释放资源
texture->Shutdown();
```
## 相关文档
- [../rhi/rhi.md](../rhi.md) - RHI 模块总览
- [../rhi.md](../rhi.md) - RHI 模块总览
- [RHIDevice](../device/device.md) - 创建设备
- [RHIBuffer](../buffer/buffer.md) - 缓冲区资源