docs: update RHI API docs
This commit is contained in:
@@ -4,12 +4,19 @@
|
||||
|
||||
**类型**: `class` (abstract)
|
||||
|
||||
**头文件**: `XCEngine/RHI/RHITexture.h`
|
||||
|
||||
**描述**: GPU 纹理资源抽象接口,用于管理 1D、2D、3D 纹理和立方体贴图等 GPU 资源。
|
||||
|
||||
## 概述
|
||||
|
||||
`RHITexture` 是 GPU 纹理资源的抽象接口,封装了 1D、2D、3D 纹理和立方体贴图等资源的创建、状态管理、查询等操作。通过 RHI 抽象层,RHITexture 可在不同图形 API(DirectX 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) - 缓冲区资源
|
||||
|
||||
Reference in New Issue
Block a user