2026-03-18 17:49:22 +08:00
|
|
|
|
# RHICapabilities
|
|
|
|
|
|
|
|
|
|
|
|
**命名空间**: `XCEngine::RHI`
|
|
|
|
|
|
|
|
|
|
|
|
**类型**: `struct`
|
|
|
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
|
**头文件**: `XCEngine/RHI/RHICapabilities.h`
|
|
|
|
|
|
|
2026-03-18 17:49:22 +08:00
|
|
|
|
**描述**: GPU 设备能力结构体,描述了当前图形设备支持的各种功能和限制。
|
|
|
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
|
## 概述
|
|
|
|
|
|
|
|
|
|
|
|
`RHICapabilities` 是一个纯数据结构的 struct,用于在运行时查询当前 GPU 设备的能力和限制。开发者可以通过 `RHIDevice::GetCapabilities()` 获取设备能力信息,据此决定是否启用特定图形特性(如光线追踪、网格着色器等),或在进行资源创建时确保不超过设备支持的范围。
|
|
|
|
|
|
|
|
|
|
|
|
## 结构体成员
|
|
|
|
|
|
|
|
|
|
|
|
| 成员 | 类型 | 描述 | 默认值 |
|
|
|
|
|
|
|------|------|------|--------|
|
|
|
|
|
|
| `bSupportsRayTracing` | `bool` | 支持光线追踪 | - |
|
|
|
|
|
|
| `bSupportsMeshShaders` | `bool` | 支持 Mesh 着色器 | - |
|
|
|
|
|
|
| `bSupportsExplicitMultiThreading` | `bool` | 支持显式多线程 | - |
|
|
|
|
|
|
| `bSupportsGeometryShaders` | `bool` | 支持几何着色器 | - |
|
|
|
|
|
|
| `bSupportsTessellation` | `bool` | 支持曲面细分 | - |
|
|
|
|
|
|
| `bSupportsComputeShaders` | `bool` | 支持计算着色器 | - |
|
|
|
|
|
|
| `bSupportsDepthBoundsTest` | `bool` | 支持深度范围测试 | - |
|
|
|
|
|
|
| `bSupportsAlphaToCoverage` | `bool` | 支持 Alpha 到覆盖 | - |
|
|
|
|
|
|
| `bSupportsIndependentBlend` | `bool` | 支持独立混合 | - |
|
|
|
|
|
|
| `bSupportsLogicOps` | `bool` | 支持逻辑操作 | - |
|
|
|
|
|
|
| `bSupportsMultiViewport` | `bool` | 支持多视口 | - |
|
|
|
|
|
|
| `bSupportsConservativeRasterization` | `bool` | 支持保守光栅化 | - |
|
|
|
|
|
|
| `bSupportsProgrammableSamplePositions` | `bool` | 支持可编程采样位置 | - |
|
2026-03-18 17:49:22 +08:00
|
|
|
|
|
|
|
|
|
|
### 资源限制
|
|
|
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
|
| 成员 | 类型 | 描述 | 默认值 |
|
|
|
|
|
|
|------|------|------|--------|
|
|
|
|
|
|
| `maxTexture2DSize` | `uint32_t` | 最大 2D 纹理尺寸 | - |
|
|
|
|
|
|
| `maxTexture3DSize` | `uint32_t` | 最大 3D 纹理尺寸 | - |
|
|
|
|
|
|
| `maxTextureCubeSize` | `uint32_t` | 最大立方体贴图尺寸 | - |
|
|
|
|
|
|
| `maxRenderTargets` | `uint32_t` | 最大渲染目标数量 | - |
|
|
|
|
|
|
| `maxViewports` | `uint32_t` | 最大视口数量 | - |
|
|
|
|
|
|
| `maxVertexAttribs` | `uint32_t` | 最大顶点属性数量 | - |
|
|
|
|
|
|
| `maxConstantBufferSize` | `uint32_t` | 最大常量缓冲大小 | - |
|
|
|
|
|
|
| `maxAnisotropy` | `uint32_t` | 最大各向异性级别 | - |
|
|
|
|
|
|
| `maxColorAttachments` | `uint32_t` | 最大颜色附件数量 | - |
|
2026-03-18 17:49:22 +08:00
|
|
|
|
|
2026-03-19 00:31:14 +08:00
|
|
|
|
### 线宽和点大小
|
|
|
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
|
| 成员 | 类型 | 描述 | 默认值 |
|
|
|
|
|
|
|------|------|------|--------|
|
|
|
|
|
|
| `minSmoothedLineWidth` | `float` | 最小平滑线宽 | - |
|
|
|
|
|
|
| `maxSmoothedLineWidth` | `float` | 最大平滑线宽 | - |
|
|
|
|
|
|
| `minPointSize` | `float` | 最小点大小 | - |
|
|
|
|
|
|
| `maxPointSize` | `float` | 最大点大小 | - |
|
|
|
|
|
|
| `maxPointSizeAA` | `float` | 抗锯齿最大点大小 | - |
|
|
|
|
|
|
| `maxLineWidth` | `float` | 最大线宽 | - |
|
|
|
|
|
|
| `maxLineWidthAA` | `float` | 抗锯齿最大线宽 | - |
|
2026-03-19 00:31:14 +08:00
|
|
|
|
|
2026-03-18 17:49:22 +08:00
|
|
|
|
### 版本信息
|
|
|
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
|
| 成员 | 类型 | 描述 | 默认值 |
|
|
|
|
|
|
|------|------|------|--------|
|
|
|
|
|
|
| `majorVersion` | `int` | 主版本号 | - |
|
|
|
|
|
|
| `minorVersion` | `int` | 次版本号 | - |
|
|
|
|
|
|
| `shaderModel` | `std::string` | 着色器模型版本 | - |
|
2026-03-18 17:49:22 +08:00
|
|
|
|
|
|
|
|
|
|
## 使用示例
|
|
|
|
|
|
|
|
|
|
|
|
```cpp
|
|
|
|
|
|
const RHICapabilities& caps = device->GetCapabilities();
|
|
|
|
|
|
|
|
|
|
|
|
if (caps.bSupportsRayTracing) {
|
|
|
|
|
|
// 启用光线追踪功能
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (caps.bSupportsComputeShaders) {
|
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-18 17:49:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t textureSize = std::min(requestedSize, caps.maxTexture2DSize);
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## 相关文档
|
|
|
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
|
- [RHI 模块](../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) - 设备对象
|