Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

功能请求:添加 1/2 帧数垂直同步 #451

Open
PJ-568 opened this issue Dec 8, 2024 · 5 comments
Open

功能请求:添加 1/2 帧数垂直同步 #451

PJ-568 opened this issue Dec 8, 2024 · 5 comments

Comments

@PJ-568
Copy link

PJ-568 commented Dec 8, 2024

1/2 帧数垂直同步可方便显卡驱动和补帧软件正确获取关键帧。

@xfangfang
Copy link
Owner

xfangfang commented Dec 8, 2024

@PJ-568 方便的话可以手动修改一下代码,在本地编译测试。

应该把下面链接中的 glfwSwapInterval(1) 改为 glfwSwapInterval(2) 就是屏幕刷新率的 1/2 了(我在Mac上测试没啥效果,不知道其他平台是否有用)

如果您那边测试改了之后有效果的话,下个版本就调整一下,将 1/2 帧数垂直同步添加到现在的设置中。

https://github.com/xfangfang/borealis/blob/4a275c429260ec43f27c07a25cf18453a7e6dcd9/library/lib/platforms/glfw/glfw_video.cpp#L340


这是目前支持的设置:

image

@PJ-568
Copy link
Author

PJ-568 commented Dec 9, 2024

我将 /library/borealis/library/lib/platforms/glfw/glfw_video.cpp 文件中的第一个 glfwSwapInterval(1); 替换为 glfwSwapInterval(2); 后编译。

用现有配置文件运行编译的 Windows d3d-x86_64 二进制文件将设置切换到垂直同步时,帧率仍限制为显示器最大帧率而非二分之一显示器最大帧率。
所有设置的效果似乎没有变化。

用现有配置文件运行编译的 Windows gl-x86_64 二进制文件将设置切换到任意设置,帧率都限制为二分之一显示器最大帧率。

详见:https://github.com/PJ-568/wiliwili/actions/runs/12228053188

@PJ-568
Copy link
Author

PJ-568 commented Dec 9, 2024

如果您那边测试改了之后有效果的话,下个版本就调整一下,将 1/2 帧数垂直同步添加到现在的设置中。

考虑到高刷新率用户,建议同时添加 1/4 帧率垂直同步和 1/8 帧率垂直同步。

@dragonflylee
Copy link
Contributor

@PJ-568 d3d 这边需要修改

https://github.com/xfangfang/borealis/blob/wiliwili/library/lib/platforms/driver/d3d11.cpp#L327

this->swapChain->Present1(2, 0, &presentParameters);

从微软官方文档来看,d3d11 支持的值为 1 到 4

https://learn.microsoft.com/zh-cn/windows/win32/api/dxgi1_2/nf-dxgi1_2-idxgiswapchain1-present1

@PJ-568
Copy link
Author

PJ-568 commented Dec 9, 2024

好了。在替换 this->swapChain->Present1(2, 0, &presentParameters); 后:

现在 Windows d3d-x86_64 二进制文件将设置切换到任意设置,帧率都限制为二分之一显示器最大帧率。

详见:https://github.com/PJ-568/wiliwili/actions/runs/12228644266

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants