Files
XCEngine/docs/api/rhi/swap-chain/swap-chain.md
ssdfasd d83ed56177 fix(rhi): Fix RHI abstraction layer API docs per api-skill.md template
- Rename texture/dtor.md to destructor.md per template spec
- Remove duplicate non-hyphenated fence docs (getnativehandle.md, issignaled.md, getcompletedvalue.md)
- Fix template field issues:
  - swap-chain, command-queue: 类型 now uses 'class (abstract)'
  - sampler: 头文件 now uses full path 'XCEngine/RHI/RHISampler.h'
  - types: 类型 fixed from 'structs' to 'struct'
  - enums: 类型 fixed from 'enums' to 'enum class'
- Fix include paths in command-queue and pipeline-layout code examples
- Create missing constructor/destructor docs for 11 classes:
  buffer, texture, shader, device, command-list, command-queue,
  fence, sampler, swap-chain, pipeline-state, pipeline-layout
- Update class overview pages to include constructor/destructor entries
2026-03-22 03:07:41 +08:00

58 lines
2.0 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`](constructor.md) | 默认构造函数 |
| [`~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) | 调整交换链大小 |
| [`SetFullscreen`](set-fullscreen.md) | 设置全屏模式 |
| [`IsFullscreen`](is-fullscreen.md) | 检查是否全屏 |
| [`ShouldClose`](should-close.md) | 检查是否应关闭 |
| [`SetShouldClose`](set-should-close.md) | 设置关闭标志 |
| [`PollEvents`](poll-events.md) | 处理窗口事件 |
| [`GetNativeHandle`](get-native-handle.md) | 获取原生句柄 |
## 使用示例
```cpp
while (!swapChain->ShouldClose()) {
swapChain->PollEvents();
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) - 纹理资源