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

@@ -0,0 +1,28 @@
# RHITexture::~RHITexture
```cpp
virtual ~RHITexture() = default;
```
虚析构函数,确保派生类对象通过基类指针删除时能正确调用析构函数。
**参数:**
**返回:**
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
// 通过基类指针销毁纹理对象
RHITexture* texture = device->CreateTexture(desc);
// ... 使用 texture ...
delete texture; // 自动调用派生类析构函数
```
## 相关文档
- [RHITexture 总览](texture.md) - 返回类总览

View File

@@ -6,10 +6,20 @@ virtual uint32_t GetDepth() const = 0;
获取纹理深度3D 纹理)。
**返回** 纹理深度
**参数**
**返回:** 纹理深度。对于 1D/2D 纹理返回 1
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
uint32_t depth = texture->GetDepth();
```
## 相关文档
- [RHITexture 总览](texture.md) - 返回类总览

View File

@@ -6,10 +6,20 @@ virtual Format GetFormat() const = 0;
获取纹理格式。
**参数:**
**返回:** 纹理格式枚举值
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
Format format = texture->GetFormat();
```
## 相关文档
- [RHITexture 总览](texture.md) - 返回类总览

View File

@@ -6,10 +6,20 @@ virtual uint32_t GetHeight() const = 0;
获取纹理高度(像素)。
**返回** 纹理高度
**参数**
**返回:** 纹理高度(像素)
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
uint32_t height = texture->GetHeight();
```
## 相关文档
- [RHITexture 总览](texture.md) - 返回类总览

View File

@@ -6,10 +6,20 @@ virtual uint32_t GetMipLevels() const = 0;
获取 Mipmap 级别数。
**参数:**
**返回:** Mipmap 级别数
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
uint32_t mipLevels = texture->GetMipLevels();
```
## 相关文档
- [RHITexture 总览](texture.md) - 返回类总览

View File

@@ -1,20 +1,26 @@
# RHITexture::GetName / SetName
# RHITexture::GetName
```cpp
virtual const std::string& GetName() const = 0;
virtual void SetName(const std::string& name) = 0;
```
获取或设置纹理名称(用于调试)。
获取纹理名称(用于调试)。
**参数:**
**返回:** 纹理名称字符串引用
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
texture->SetName("DiffuseMap_Main");
const std::string& name = texture->GetName();
```
## 相关文档
- [RHITexture 总览](texture.md) - 返回类总览
- [SetName](set-name.md) - 设置资源名称

View File

@@ -4,12 +4,22 @@
virtual void* GetNativeHandle() = 0;
```
获取原生 API 句柄。
获取原生 API 句柄(用于平台特定操作)
**返回** 原生纹理句柄
**参数**
**返回:** 原生纹理句柄(根据后端返回 D3D12 纹理指针或 OpenGL 纹理 ID 等)
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
void* handle = texture->GetNativeHandle();
```
## 相关文档
- [RHITexture 总览](texture.md) - 返回类总览

View File

@@ -6,10 +6,20 @@ virtual ResourceStates GetState() const = 0;
获取当前资源状态。
**返回** 资源状态枚举值
**参数**
**返回:** 当前资源状态枚举值
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
ResourceStates state = texture->GetState();
```
## 相关文档
- [RHITexture 总览](texture.md) - 返回类总览

View File

@@ -6,10 +6,23 @@ virtual TextureType GetTextureType() const = 0;
获取纹理类型。
**返回** 纹理类型枚举值
**参数**
**返回:** 纹理类型枚举值1D、2D、3D、立方体等
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
TextureType type = texture->GetTextureType();
if (type == TextureType::TextureCube) {
// 处理立方体贴图
}
```
## 相关文档
- [RHITexture 总览](texture.md) - 返回类总览

View File

@@ -6,10 +6,20 @@ virtual uint32_t GetWidth() const = 0;
获取纹理宽度(像素)。
**返回** 纹理宽度
**参数**
**返回:** 纹理宽度(像素)
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
uint32_t width = texture->GetWidth();
```
## 相关文档
- [RHITexture 总览](texture.md) - 返回类总览

View File

@@ -9,6 +9,10 @@ virtual void SetName(const std::string& name) = 0;
**参数:**
- `name` - 新名称
**返回:**
**线程安全:**
**复杂度:** O(1)
**示例:**

View File

@@ -9,6 +9,10 @@ virtual void SetState(ResourceStates state) = 0;
**参数:**
- `state` - 新的资源状态
**返回:**
**线程安全:**
**复杂度:** O(1)
**示例:**

View File

@@ -4,10 +4,22 @@
virtual void Shutdown() = 0;
```
释放纹理资源。
关闭并释放纹理资源。
**参数:**
**返回:**
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
texture->Shutdown();
```
## 相关文档
- [RHITexture 总览](texture.md) - 返回类总览

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) - 缓冲区资源