Files
XCEngine/docs/api/rhi/swap-chain/swap-chain.md
ssdfasd 8df04c120f docs: 更新 API 文档 - 多模块修复和完善
- audio: 更新 audio-system 方法文档
- components: 新增 audio-listener/audio-source 组件方法文档,新增 remove-component 方法
- core: 更新 filewriter, types 文档
- math: 更新 box 方法文档
- memory: 更新 proxy-allocator 文档
- resources: 更新 loader 和 texture 文档
- rhi: 更新 opengl 设备、shader、swap-chain 文档
- threading: 更新 mutex 和 task-system 文档
2026-03-26 01:58:45 +08:00

48 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# RHISwapChain
**命名空间**: `XCEngine::RHI`
**类型**: `class` (abstract)
**头文件**: `XCEngine/RHI/RHISwapChain.h`
**描述**: GPU 交换链抽象接口,管理窗口渲染和帧缓冲区切换。
## 概述
`RHISwapChain` 是 RHI 模块中的核心接口之一,负责管理渲染目标帧缓冲区的切换和呈现。该抽象类为不同图形 APID3D12、Vulkan 等)提供统一接口,使上层渲染代码无需关心底层实现细节。
主要职责:
- 管理前后台缓冲区切换
- 协调垂直同步呈现
- 提供原生 API 句柄供高级用法
## 公共方法
| 方法 | 描述 |
|------|------|
| [`~RHISwapChain`](destructor.md) | 虚析构函数 |
| [`Shutdown`](shutdown.md) | 关闭并释放资源 |
| [`GetCurrentBackBufferIndex`](get-current-back-buffer-index.md) | 获取当前后台缓冲区索引 |
| [`GetCurrentBackBuffer`](get-current-back-buffer.md) | 获取当前后台缓冲区 |
| [`Present`](present.md) | 呈现画面 |
| [`Resize`](resize.md) | 调整交换链大小 |
| [`GetNativeHandle`](get-native-handle.md) | 获取原生句柄 |
## 使用示例
```cpp
RHITexture* backBuffer = swapChain->GetCurrentBackBuffer();
commandList->Reset();
commandList->SetRenderTargets(1, &backBuffer, nullptr);
commandList->ClearRenderTarget(backBuffer, clearColor);
commandList->Close();
commandQueue->ExecuteCommandLists(1, (void**)&commandList);
swapChain->Present(1, 0);
```
## 相关文档
- [RHI 模块总览](../rhi.md) - RHI 模块总览
- [RHITexture](../texture/texture.md) - 纹理资源