WGL:无双缓冲 +多次采样=失败?

发布于 2024-08-07 21:44:53 字数 749 浏览 10 评论 0原文

我通常使用 wglChoosePixelFormatARB() 和这些参数(以及其他参数)创建像素格式:

WGL_DOUBLE_BUFFER_ARB = GL_TRUE
WGL_SAMPLE_BUFFERS_ARB = GL_TRUE
WGL_SAMPLES_ARB = 4

即双缓冲和 x4 多重采样。这工作得很好。
但是当我尝试关闭双缓冲时:

WGL_DOUBLE_BUFFER_ARB = GL_FALSE
WGL_SAMPLE_BUFFERS_ARB = GL_TRUE
WGL_SAMPLES_ARB = 4

wglChoosePixelFormatARB() 的调用失败(或者更确切地说表明它没有创建任何内容)
当我有效地关闭多重采样时:

WGL_DOUBLE_BUFFER_ARB = GL_FALSE
WGL_SAMPLE_BUFFERS_ARB = GL_TRUE
WGL_SAMPLES_ARB = 1

我又工作得很好了。

是否有一些固有的因素阻止非双缓冲像素格式与多重采样一起使用?

我关闭双缓冲的原因是为了实现不受限制的帧速率。使用双缓冲时,我得到的帧速率最多仅为 60 FPS(这台笔记本电脑 LCD 工作在 60Hz)。但关闭双缓冲后,我可以获得高达 1500 FPS 的帧率。有没有办法通过双缓冲来实现这一点?

I usually create a pixel format using wglChoosePixelFormatARB() with these arguments (among others):

WGL_DOUBLE_BUFFER_ARB = GL_TRUE
WGL_SAMPLE_BUFFERS_ARB = GL_TRUE
WGL_SAMPLES_ARB = 4

i.e. double buffering on and x4 multisampling. This works just fine.
But when I try to turn of the double buffering:

WGL_DOUBLE_BUFFER_ARB = GL_FALSE
WGL_SAMPLE_BUFFERS_ARB = GL_TRUE
WGL_SAMPLES_ARB = 4

The call to wglChoosePixelFormatARB() fails (or rather indicates it didn't create anything)
When I effectively turn multisampling off:

WGL_DOUBLE_BUFFER_ARB = GL_FALSE
WGL_SAMPLE_BUFFERS_ARB = GL_TRUE
WGL_SAMPLES_ARB = 1

I works fine again.

Is there something inherent that prevents a non-double buffered pixel format to work with multisampling?

The reason I'm turning double buffering off is to achieve unconstrained frame rate. with double buffering the frame rate I get is only up to 60 FPS (this laptop LCD works at 60Hz). But with double buffering off I can get up to 1500 FPS. Is there a way to achieve this with double buffering on?

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

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

发布评论

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

评论(1

∞琼窗梦回ˉ 2024-08-14 21:44:53

理论上,在单缓冲区模式下绘图意味着您直接修改屏幕上呈现的内容(也称为前缓冲区)。
由于该内存已经采用特定格式,因此您无法选择其他格式。
(我说的是理论上,因为平台在实践中确实做到了它满意的程度。例如,Aero 不允许访问前缓冲区)。

此外,在进行多重采样时,将 X 个样本/像素转换为 1 个像素进行绘制的步骤是在将后缓冲区复制到前缓冲区时(称为解析步骤)。在单缓冲模式下,没有这样的步骤。

至于 60 fps 锁定,您可能需要查看WGL_EXT_swap_control。这里的问题是,您通常不希望在屏幕刷新数据时更新屏幕上显示的内容;它会产生撕裂。因此,默认情况下,Swap 仅在屏幕垂直同步(又称垂直同步)时更新,因此您最终会锁定屏幕的刷新率。

如果您不介意显示器显示不同帧的部分内容,则可以将其关闭。

为了完整起见,有一种称为三重缓冲的替代模式,该模式本质上是在显示前缓冲区时在 2 个后缓冲区之间进行 GPU 乒乓渲染。当需要更改屏幕上显示的内容(垂直同步)时,由 GPU 来选择最后完成的后台缓冲区。遗憾的是,我不知道 WGL 方法可以要求三重缓冲。

In theory, drawing in a single-buffer mode means that you're directly modifying what is being presented to the screen (aka the front buffer).
Since that memory is in a specific format already, you don't get to choose another one.
(I'm saying in theory because the platform does however it pleases it in practice. Aero for example does not allow access to the front-buffer).

Moreover, when doing multisampling, the step that converts the X samples/pixel to 1 pixel for drawing is when the back-buffer is copied to the front buffer (what is called the resolve step). In single buffer mode, there is no such step.

As to your 60 fps locking, you might want to look atWGL_EXT_swap_control. The issue here is that you don't generally want to update what is being shown on screen while the screen refreshes the data; it creates tearing. So by default, Swap only updates while the screen is vertical syncing (aka vsync), so you end up locking to the refresh rate of the screen.

If you don't mind your display showing parts of different frames, you can turn it off.

For completeness, there is an alternative mode called triple buffering, that essentially has the GPU ping-pong rendering between 2 back-buffers while the front buffer is shown. It is up to the gpu to pick the last finished back-buffer when comes time to change what shows on screen (vsync). Sadly, I am not aware of a WGL method to ask for triple buffering.

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