从 GPU 获取完整桌面屏幕截图

发布于 2024-11-17 17:36:01 字数 620 浏览 0 评论 0 原文

我一直在使用 Windows API 的 BitBlt 函数来执行屏幕抓取。

但也有很多缺点:

  1. DWM 和 Aero 会导致速度大幅减慢(仅调用 BitBlt 就需要 3 毫秒 --> 35 毫秒)——要解决此问题需要禁用 Aero,但我不想这样做。屏幕闪烁,事物发生变化。
  2. 数据必须重新传输到 GPU 才能加载数据,因为
  3. 没有 CAPTUREBLT 标志就无法捕获纹理分层窗口。启用后,捕获时鼠标光标会闪烁。这看起来似乎是一个小问题,但是当应用程序没有其他错误时,它就非常烦人了。作为解决方法,我打算将分层窗口渲染为附加光标。

我已经在使用 OpenGL 来显示和操作捕获的屏幕数据。 BitBlt 为我提供像素数据,并且将其加载到纹理中相对容易。然而,这有点荒谬,因为当数据应该在 GPU 上可用时,我手动将数据重新发送回 GPU。数据肯定在那里,但尝试访问它是另一回事。

我认为此功能在供应商的待办事项列表(或可能在任何与此相关的列表中)中并不重要,但我想询问知情人士是否有 AMD(ATI)或NVidia 在其驱动程序中用于读取屏幕缓冲区(例如读取 OpenGL 上下文)。我对现代 GPU 架构了解不够,不知道从哪里开始寻找答案。

I have been using the Windows API's BitBlt function to perform the screen grab.

There are many drawbacks however:

  1. DWM and Aero cause a massive slowdown (3ms --> 35ms just to call BitBlt) -- to work around this would require disabling Aero which I'd just rather not do. The screen flickers and things shift around.
  2. Data must be re-transferred to the GPU in order to load data as texture
  3. Layered Windows cannot be captured without CAPTUREBLT flag. When enabled, the mouse cursor blinks when capturing. This may seem like a minor issue, but it is exceedingly annoying when the application is otherwise bug-free. As a workaround for this I intend to render a layered window as an additional cursor.

I am already using OpenGL to display and manipulate the captured screen data. BitBlt gives me the pixel data and it is relatively easy to load it into a texture. However this is slightly absurd because I am manually re-sending the data back to the GPU when it should be available on the GPU to begin with. The data most certainly is there, but trying to access it is a different matter.

I presume that this functionality is not high on the to-do list (or likely on any list for that matter) for vendors but I would like to ask those in the know if there are any provisions at all provided by AMD(ATI) or NVidia in their drivers for reading the screen buffer (into an OpenGL context for instance). I simply do not know enough about modern GPU architecture to know where to start digging for answers.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

も让我眼熟你 2024-11-24 17:36:01

OpenGL 只能读取上下文帧缓冲区(窗口)以及您创建的任何帧缓冲区或 pbuffer。 OpenGL 无法触摸桌面或任何其他窗口。

OpenGL can only read the context framebuffer (a window), and any framebuffers or pbuffers you have created. OpenGL cannot touch the desktop or any other window.

紧拥背影 2024-11-24 17:36:01

这是一个有趣的问题。不幸的是,我认为这并没有得到真正的支持。我发现有关创建全屏不可见窗口并使用 glReadPixels 读取像素数据取得一定程度成功的报告:

http://www.virtualdub.org/blog/pivot/entry.php?id=142

http://www.opentk.com/node/2430

但是,我相信这样做时的行为是未定义,仅适用于特定的硬件/操作系统配置。

This is an interesting question. Unfortunately I don't think this is really supported. I have found reports of some level of success with creating a full screen invisible window and reading the pixel data with glReadPixels:

http://www.virtualdub.org/blog/pivot/entry.php?id=142

http://www.opentk.com/node/2430

However, I believe the behavior when doing this is undefined and will only work on specific hardware/OS configurations.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文