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

cpu占用率过高,该如何优化呢 #35

Open
HelloTodayWolrd opened this issue Jul 19, 2021 · 1 comment
Open

cpu占用率过高,该如何优化呢 #35

HelloTodayWolrd opened this issue Jul 19, 2021 · 1 comment

Comments

@HelloTodayWolrd
Copy link

No description provided.

@DotCppWilliam
Copy link

大佬是这样实现显示捕获的屏幕帧的。

  1. 用d3d11捕获屏幕帧,这个是在显存里
  2. 然后使用CPU从显存复制到内存的一段空间里(如果你的分辨率过大,那么这个拷贝性能会很高。比如4k分辨率,RGBA格式,计算公式就是 3840 x 2160 * 4 = 33,177,600字节(约33.18MB),可想而知,每几十毫秒就这样频繁复制)
  3. 显示屏幕帧,调用CaptureFrame,这个又会造成一次拷贝,将捕获到的屏幕帧复制到参数里。
  4. 最后使用SDL去渲染。

优化地方:
避免使用CPU来复制内存; 使用opengl渲染rgba数据,这样会很快.

  1. 使用d3d11捕获屏幕帧后, 可以使用WGL_NV_DX_interop 技术将这个显存的数据共享给opengl
  2. 然后opengl直接用d3d11捕获屏幕帧里的数据渲染到窗口上。这样能把CPU占用率为15-28%左右,我的是i7-9700k

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

2 participants