# D3D12SwapChain::GetBackBuffer ## 函数签名 ```cpp D3D12Texture& GetBackBuffer(uint32_t index) const D3D12Texture& GetBackBuffer(uint32_t index) const ``` ## 中文描述 获取指定索引的后台缓冲区。返回引用而非指针,避免空指针检查。 ## 参数 | 参数 | 类型 | 描述 | |------|------|------| | `index` | `uint32_t` | 缓冲区索引(必须在有效范围内) | ## 返回值 `D3D12Texture&` - 后台缓冲区纹理引用 ## 注意事项 - 返回引用而非指针,调用者无需检查空值 - 如果索引越界,会触发 assert 断言失败 - 返回的引用在 SwapChain 存活期间有效,SwapChain 销毁后引用失效 ## 复杂度 O(1) ## 示例 ```cpp // 获取后台缓冲区(返回引用) D3D12Texture& buffer = swapChain.GetBackBuffer(0); // 使用封装接口 gCommandList.TransitionBarrier(buffer.GetResource(), ResourceStates::Present, ResourceStates::RenderTarget); ``` ## 相关文档 - [D3D12SwapChain](swap-chain.md) - 类总览