feat: 帧率控制——手动限帧 + VSync 开关
- Application 帧率控制 API:SetLimitFps/SetTargetFps/SetVSync。 限帧目标最低 24fps(防止过低刷新导致交互卡死),无上限; vsync 开启时 present 自带节奏,手动限帧不生效 - 限帧策略:sleep 到剩 ~2ms 后自旋,精度高且不烧 CPU - Swapchain 加 VSync 开关:ChoosePresentMode 按开关选 Mailbox(低延迟垂直同步)/ Immediate(不限速可撕裂), FIFO 兜底;切换经 SetVSync → 重建 swapchain(复用 HandleResize) - Scene Debug 面板新增 Frame 区块(vsync/limit/目标滑条) - Run 循环新增 CPU 归属遥测(update/ui/render/total,每 120 帧)
This commit is contained in:
@@ -754,6 +754,13 @@ namespace Engine
|
||||
m_RenderGraph->SetTargetExtent(m_Extent); // 触发首次 Compile
|
||||
}
|
||||
|
||||
void Renderer::SetVSync(bool vsync)
|
||||
{
|
||||
if (m_Swapchain->GetVSync() == vsync) return;
|
||||
m_Swapchain->SetVSync(vsync);
|
||||
HandleResize(); // present mode 变化需要重建 swapchain
|
||||
}
|
||||
|
||||
void Renderer::HandleResize()
|
||||
{
|
||||
m_Device->GetDevice().waitIdle();
|
||||
|
||||
Reference in New Issue
Block a user