fix: improve doc link navigation and tree display
- Fix link resolution with proper relative/absolute path handling - Improve link styling with underline decoration - Hide leaf nodes from tree, only show directories - Fix log file path for packaged app
This commit is contained in:
35
docs/api/rhi/device/compile-shader.md
Normal file
35
docs/api/rhi/device/compile-shader.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# RHIDevice::CompileShader
|
||||
|
||||
```cpp
|
||||
virtual RHIShader* CompileShader(const ShaderCompileDesc& desc) = 0;
|
||||
```
|
||||
|
||||
编译着色器程序。
|
||||
|
||||
**参数:**
|
||||
- `desc` - 着色器编译描述符,包含入口点、配置文件、源文件等
|
||||
|
||||
**返回:** 新创建的着色器指针,失败返回 `nullptr`
|
||||
|
||||
**复杂度:** O(n) - 取决于着色器代码复杂度
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
ShaderCompileDesc shaderDesc;
|
||||
shaderDesc.entryPoint = L"main";
|
||||
shaderDesc.profile = L"vs_6_0";
|
||||
shaderDesc.fileName = L"shaders/vertex.hlsl";
|
||||
shaderDesc.macros = {};
|
||||
|
||||
RHIShader* vertexShader = device->CompileShader(shaderDesc);
|
||||
if (!vertexShader->IsValid()) {
|
||||
// 处理编译错误
|
||||
vertexShader->Shutdown();
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RHIDevice 总览](device.md) - 返回类总览
|
||||
- [RHIShader](../shader/shader.md) - 着色器类
|
||||
32
docs/api/rhi/device/create-buffer.md
Normal file
32
docs/api/rhi/device/create-buffer.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# RHIDevice::CreateBuffer
|
||||
|
||||
```cpp
|
||||
virtual RHIBuffer* CreateBuffer(const BufferDesc& desc) = 0;
|
||||
```
|
||||
|
||||
创建 GPU 缓冲区资源。
|
||||
|
||||
**参数:**
|
||||
- `desc` - 缓冲区描述符,包含大小、类型、标志等
|
||||
|
||||
**返回:** 新创建的缓冲区指针,失败返回 `nullptr`
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
BufferDesc bufferDesc;
|
||||
bufferDesc.size = sizeof(Vertex) * vertexCount;
|
||||
bufferDesc.stride = sizeof(Vertex);
|
||||
bufferDesc.bufferType = (uint32_t)BufferType::Vertex;
|
||||
bufferDesc.flags = 0;
|
||||
|
||||
RHIBuffer* vertexBuffer = device->CreateBuffer(bufferDesc);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RHIDevice 总览](device.md) - 返回类总览
|
||||
- [RHIBuffer](../buffer/buffer.md) - 缓冲区类
|
||||
- [BufferDesc](../types/types.md) - 缓冲区描述结构体
|
||||
29
docs/api/rhi/device/create-command-list.md
Normal file
29
docs/api/rhi/device/create-command-list.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# RHIDevice::CreateCommandList
|
||||
|
||||
```cpp
|
||||
virtual RHICommandList* CreateCommandList(const CommandListDesc& desc) = 0;
|
||||
```
|
||||
|
||||
创建命令列表,用于录制 GPU 命令。
|
||||
|
||||
**参数:**
|
||||
- `desc` - 命令列表描述符,包含类型和节点掩码
|
||||
|
||||
**返回:** 新创建的命令列表指针,失败返回 `nullptr`
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
CommandListDesc cmdListDesc;
|
||||
cmdListDesc.commandListType = (uint32_t)CommandQueueType::Direct;
|
||||
cmdListDesc.nodeMask = 0;
|
||||
|
||||
RHICommandList* commandList = device->CreateCommandList(cmdListDesc);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RHIDevice 总览](device.md) - 返回类总览
|
||||
- [RHICommandList](../command-list/command-list.md) - 命令列表类
|
||||
31
docs/api/rhi/device/create-command-queue.md
Normal file
31
docs/api/rhi/device/create-command-queue.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# RHIDevice::CreateCommandQueue
|
||||
|
||||
```cpp
|
||||
virtual RHICommandQueue* CreateCommandQueue(const CommandQueueDesc& desc) = 0;
|
||||
```
|
||||
|
||||
创建命令队列,用于提交和执行命令列表。
|
||||
|
||||
**参数:**
|
||||
- `desc` - 命令队列描述符,包含队列类型和优先级
|
||||
|
||||
**返回:** 新创建的命令队列指针,失败返回 `nullptr`
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
CommandQueueDesc queueDesc;
|
||||
queueDesc.queueType = (uint32_t)CommandQueueType::Direct;
|
||||
queueDesc.priority = 0;
|
||||
queueDesc.nodeMask = 0;
|
||||
queueDesc.flags = 0;
|
||||
|
||||
RHICommandQueue* commandQueue = device->CreateCommandQueue(queueDesc);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RHIDevice 总览](device.md) - 返回类总览
|
||||
- [RHICommandQueue](../command-queue/command-queue.md) - 命令队列类
|
||||
29
docs/api/rhi/device/create-fence.md
Normal file
29
docs/api/rhi/device/create-fence.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# RHIDevice::CreateFence
|
||||
|
||||
```cpp
|
||||
virtual RHIFence* CreateFence(const FenceDesc& desc) = 0;
|
||||
```
|
||||
|
||||
创建同步栅栏,用于 CPU/GPU 同步。
|
||||
|
||||
**参数:**
|
||||
- `desc` - 栅栏描述符,包含初始值和标志
|
||||
|
||||
**返回:** 新创建的栅栏指针,失败返回 `nullptr`
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
FenceDesc fenceDesc;
|
||||
fenceDesc.initialValue = 0;
|
||||
fenceDesc.flags = 0;
|
||||
|
||||
RHIFence* fence = device->CreateFence(fenceDesc);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RHIDevice 总览](device.md) - 返回类总览
|
||||
- [RHIFence](../fence/fence.md) - 栅栏类
|
||||
29
docs/api/rhi/device/create-pipeline-state.md
Normal file
29
docs/api/rhi/device/create-pipeline-state.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# RHIDevice::CreatePipelineState
|
||||
|
||||
```cpp
|
||||
virtual RHIPipelineState* CreatePipelineState(const PipelineStateDesc& desc) = 0;
|
||||
```
|
||||
|
||||
创建渲染管线状态对象(PSO)。
|
||||
|
||||
**参数:**
|
||||
- `desc` - 管线状态描述符,包含编译好的着色器字节码
|
||||
|
||||
**返回:** 新创建的管线状态指针,失败返回 `nullptr`
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
PipelineStateDesc psoDesc;
|
||||
psoDesc.pBlob = compiledShaderBytecode;
|
||||
psoDesc.size = bytecodeSize;
|
||||
|
||||
RHIPipelineState* pipelineState = device->CreatePipelineState(psoDesc);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RHIDevice 总览](device.md) - 返回类总览
|
||||
- [RHIPipelineState](../pipeline-state/pipeline-state.md) - 管线状态类
|
||||
34
docs/api/rhi/device/create-sampler.md
Normal file
34
docs/api/rhi/device/create-sampler.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# RHIDevice::CreateSampler
|
||||
|
||||
```cpp
|
||||
virtual RHISampler* CreateSampler(const SamplerDesc& desc) = 0;
|
||||
```
|
||||
|
||||
创建纹理采样器。
|
||||
|
||||
**参数:**
|
||||
- `desc` - 采样器描述符,包含过滤模式、寻址模式等
|
||||
|
||||
**返回:** 新创建的采样器指针,失败返回 `nullptr`
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
SamplerDesc samplerDesc;
|
||||
samplerDesc.filter = (uint32_t)FilterMode::Anisotropic;
|
||||
samplerDesc.addressU = (uint32_t)TextureAddressMode::Wrap;
|
||||
samplerDesc.addressV = (uint32_t)TextureAddressMode::Wrap;
|
||||
samplerDesc.addressW = (uint32_t)TextureAddressMode::Wrap;
|
||||
samplerDesc.maxAnisotropy = 16;
|
||||
samplerDesc.minLod = 0;
|
||||
samplerDesc.maxLod = FLT_MAX;
|
||||
|
||||
RHISampler* sampler = device->CreateSampler(samplerDesc);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RHIDevice 总览](device.md) - 返回类总览
|
||||
- [RHISampler](../sampler/sampler.md) - 采样器类
|
||||
34
docs/api/rhi/device/create-swap-chain.md
Normal file
34
docs/api/rhi/device/create-swap-chain.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# RHIDevice::CreateSwapChain
|
||||
|
||||
```cpp
|
||||
virtual RHISwapChain* CreateSwapChain(const SwapChainDesc& desc) = 0;
|
||||
```
|
||||
|
||||
创建交换链,用于管理窗口渲染和帧缓冲区切换。
|
||||
|
||||
**参数:**
|
||||
- `desc` - 交换链描述符,包含尺寸、缓冲数量、格式等
|
||||
|
||||
**返回:** 新创建的交换链指针,失败返回 `nullptr`
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
SwapChainDesc swapChainDesc;
|
||||
swapChainDesc.width = 1280;
|
||||
swapChainDesc.height = 720;
|
||||
swapChainDesc.bufferCount = 2;
|
||||
swapChainDesc.format = (uint32_t)Format::R8G8B8A8_UNorm;
|
||||
swapChainDesc.refreshRate = 60;
|
||||
swapChainDesc.sampleCount = 1;
|
||||
swapChainDesc.sampleQuality = 0;
|
||||
|
||||
RHISwapChain* swapChain = device->CreateSwapChain(swapChainDesc);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RHIDevice 总览](device.md) - 返回类总览
|
||||
- [RHISwapChain](../swap-chain/swap-chain.md) - 交换链类
|
||||
38
docs/api/rhi/device/create-texture.md
Normal file
38
docs/api/rhi/device/create-texture.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# RHIDevice::CreateTexture
|
||||
|
||||
```cpp
|
||||
virtual RHITexture* CreateTexture(const TextureDesc& desc) = 0;
|
||||
```
|
||||
|
||||
创建 GPU 纹理资源。
|
||||
|
||||
**参数:**
|
||||
- `desc` - 纹理描述符,包含尺寸、格式、纹理类型等
|
||||
|
||||
**返回:** 新创建的纹理指针,失败返回 `nullptr`
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
TextureDesc textureDesc;
|
||||
textureDesc.width = 1024;
|
||||
textureDesc.height = 1024;
|
||||
textureDesc.depth = 1;
|
||||
textureDesc.mipLevels = 1;
|
||||
textureDesc.arraySize = 1;
|
||||
textureDesc.format = (uint32_t)Format::R8G8B8A8_UNorm;
|
||||
textureDesc.textureType = (uint32_t)TextureType::Texture2D;
|
||||
textureDesc.sampleCount = 1;
|
||||
textureDesc.sampleQuality = 0;
|
||||
textureDesc.flags = 0;
|
||||
|
||||
RHITexture* texture = device->CreateTexture(textureDesc);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RHIDevice 总览](device.md) - 返回类总览
|
||||
- [RHITexture](../texture/texture.md) - 纹理类
|
||||
- [TextureDesc](../types/types.md) - 纹理描述结构体
|
||||
73
docs/api/rhi/device/device.md
Normal file
73
docs/api/rhi/device/device.md
Normal file
@@ -0,0 +1,73 @@
|
||||
# RHIDevice
|
||||
|
||||
**命名空间**: `XCEngine::RHI`
|
||||
|
||||
**类型**: `class` (abstract)
|
||||
|
||||
**描述**: RHI 渲染设备抽象接口,代表一个图形设备实例。
|
||||
|
||||
## 概述
|
||||
|
||||
`RHIDevice` 是 RHI 模块的核心接口之一,负责创建和管理所有 GPU 资源。每个 RHI 后端(D3D12、OpenGL 等)都需要实现此接口。
|
||||
|
||||
## 公共方法
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| [`Initialize`](initialize.md) | 初始化设备 |
|
||||
| [`Shutdown`](shutdown.md) | 关闭设备 |
|
||||
| [`CreateBuffer`](create-buffer.md) | 创建缓冲区 |
|
||||
| [`CreateTexture`](create-texture.md) | 创建纹理 |
|
||||
| [`CreateSwapChain`](create-swap-chain.md) | 创建交换链 |
|
||||
| [`CreateCommandList`](create-command-list.md) | 创建命令列表 |
|
||||
| [`CreateCommandQueue`](create-command-queue.md) | 创建命令队列 |
|
||||
| [`CompileShader`](compile-shader.md) | 编译着色器 |
|
||||
| [`CreatePipelineState`](create-pipeline-state.md) | 创建管线状态 |
|
||||
| [`CreateFence`](create-fence.md) | 创建栅栏 |
|
||||
| [`CreateSampler`](create-sampler.md) | 创建采样器 |
|
||||
| [`GetCapabilities`](get-capabilities.md) | 获取设备能力 |
|
||||
| [`GetDeviceInfo`](get-device-info.md) | 获取设备信息 |
|
||||
| [`GetNativeDevice`](get-native-device.md) | 获取原生设备 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
// 创建 D3D12 设备
|
||||
RHI::RHIDevice* device = RHI::RHIFactory::CreateRHIDevice(RHI::RHIType::D3D12);
|
||||
|
||||
// 配置设备描述
|
||||
RHI::RHIDeviceDesc desc;
|
||||
desc.windowHandle = hwnd;
|
||||
desc.width = 1280;
|
||||
desc.height = 720;
|
||||
desc.appName = L"MyApp";
|
||||
desc.enableDebugLayer = true;
|
||||
|
||||
// 初始化设备
|
||||
if (device->Initialize(desc)) {
|
||||
const RHI::RHICapabilities& caps = device->GetCapabilities();
|
||||
if (caps.bSupportsRayTracing) {
|
||||
// 设备支持光线追踪
|
||||
}
|
||||
|
||||
const RHI::RHIDeviceInfo& info = device->GetDeviceInfo();
|
||||
printf("GPU: %ls\n", info.description.c_str());
|
||||
|
||||
// 创建资源
|
||||
RHI::BufferDesc bufferDesc;
|
||||
bufferDesc.size = 1024;
|
||||
bufferDesc.bufferType = (uint32_t)RHI::BufferType::Vertex;
|
||||
RHI::RHIBuffer* buffer = device->CreateBuffer(bufferDesc);
|
||||
|
||||
device->Shutdown();
|
||||
}
|
||||
|
||||
delete device;
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [../../rhi.md](../rhi.md) - RHI 模块总览
|
||||
- [RHIFactory](../factory/factory.md) - 设备工厂
|
||||
- [RHICapabilities](../capabilities/capabilities.md) - 设备能力
|
||||
- [RHITypes](../types/types.md) - 设备描述结构体
|
||||
32
docs/api/rhi/device/get-capabilities.md
Normal file
32
docs/api/rhi/device/get-capabilities.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# RHIDevice::GetCapabilities
|
||||
|
||||
```cpp
|
||||
virtual const RHICapabilities& GetCapabilities() const = 0;
|
||||
```
|
||||
|
||||
获取当前设备的图形能力。
|
||||
|
||||
**返回:** 设备能力结构体引用
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
const RHICapabilities& caps = device->GetCapabilities();
|
||||
|
||||
if (caps.bSupportsRayTracing) {
|
||||
// 启用光线追踪功能
|
||||
}
|
||||
|
||||
if (caps.bSupportsComputeShaders) {
|
||||
// 启用计算着色器
|
||||
}
|
||||
|
||||
uint32_t maxTexSize = caps.maxTexture2DSize;
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RHIDevice 总览](device.md) - 返回类总览
|
||||
- [RHICapabilities](../capabilities/capabilities.md) - 设备能力类
|
||||
27
docs/api/rhi/device/get-device-info.md
Normal file
27
docs/api/rhi/device/get-device-info.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# RHIDevice::GetDeviceInfo
|
||||
|
||||
```cpp
|
||||
virtual const RHIDeviceInfo& GetDeviceInfo() const = 0;
|
||||
```
|
||||
|
||||
获取当前设备的详细信息。
|
||||
|
||||
**返回:** 设备信息结构体引用
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
const RHIDeviceInfo& info = device->GetDeviceInfo();
|
||||
|
||||
printf("GPU: %ls\n", info.description.c_str());
|
||||
printf("Vendor: %ls\n", info.vendor.c_str());
|
||||
printf("Driver: %ls\n", info.version.c_str());
|
||||
printf("VRAM: %llu MB\n", info.dedicatedVideoMemory / 1024 / 1024);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RHIDevice 总览](device.md) - 返回类总览
|
||||
- [RHIDeviceInfo](../types/types.md) - 设备信息结构体
|
||||
29
docs/api/rhi/device/get-native-device.md
Normal file
29
docs/api/rhi/device/get-native-device.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# RHIDevice::GetNativeDevice
|
||||
|
||||
```cpp
|
||||
virtual void* GetNativeDevice() = 0;
|
||||
```
|
||||
|
||||
获取原生图形 API 设备指针。
|
||||
|
||||
**返回:**
|
||||
- D3D12 后端: `ID3D12Device*`
|
||||
- OpenGL 后端: `void*` (GLFWwindow* 或 GL 上下文指针)
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
void* nativeDevice = device->GetNativeDevice();
|
||||
|
||||
// D3D12 使用
|
||||
ID3D12Device* d3d12Device = static_cast<ID3D12Device*>(nativeDevice);
|
||||
|
||||
// OpenGL 使用
|
||||
GLFWwindow* glfwWindow = static_cast<GLFWwindow*>(nativeDevice);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RHIDevice 总览](device.md) - 返回类总览
|
||||
39
docs/api/rhi/device/initialize.md
Normal file
39
docs/api/rhi/device/initialize.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# RHIDevice::Initialize
|
||||
|
||||
```cpp
|
||||
virtual bool Initialize(const RHIDeviceDesc& desc) = 0;
|
||||
```
|
||||
|
||||
初始化 RHI 设备,建立与图形适配器的连接。
|
||||
|
||||
**参数:**
|
||||
- `desc` - 设备描述符,包含窗口句柄、分辨率、调试选项等配置
|
||||
|
||||
**返回:** 成功返回 `true`,失败返回 `false`
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
RHIDeviceDesc desc;
|
||||
desc.windowHandle = hwnd;
|
||||
desc.width = 1920;
|
||||
desc.height = 1080;
|
||||
desc.appName = L"MyApp";
|
||||
desc.enableDebugLayer = true;
|
||||
desc.enableGPUValidation = true;
|
||||
|
||||
RHIDevice* device = RHIFactory::CreateRHIDevice(RHIType::D3D12);
|
||||
if (device->Initialize(desc)) {
|
||||
// 设备初始化成功
|
||||
} else {
|
||||
// 处理初始化失败
|
||||
delete device;
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RHIDevice 总览](device.md) - 返回类总览
|
||||
- [RHIDeviceDesc](../types/types.md) - 设备描述结构体
|
||||
20
docs/api/rhi/device/shutdown.md
Normal file
20
docs/api/rhi/device/shutdown.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# RHIDevice::Shutdown
|
||||
|
||||
```cpp
|
||||
virtual void Shutdown() = 0;
|
||||
```
|
||||
|
||||
关闭 RHI 设备,释放所有相关资源。
|
||||
|
||||
**复杂度:** O(n) - 取决于管理的资源数量
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
device->Shutdown();
|
||||
delete device;
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [RHIDevice 总览](device.md) - 返回类总览
|
||||
Reference in New Issue
Block a user