英文:
glClear() gives GL_OUT_OF_MEMORY on Intel HD 4000 (GL 4.0) but not GeForce (GL 4.2)... why?
问题
现在,这是一个非常奇怪的行为。
TL;DR - 在渲染到纹理的设置中,当调整窗口大小(帧缓冲0)时,只有绑定到帧缓冲0(窗口的客户区域)的下一个glClear(GL_COLOR_BUFFER_BIT)调用会出现GL_OUT_OF_MEMORY错误,只在两个GPU中的一个上,但渲染仍然正常进行。
现在,所有细节:
这是在一台带有两个GPU的Vaio Z上(可以通过机器上的物理切换按钮进行切换):
-
OpenGL 4.2.0 @ NVIDIA Corporation GeForce GT 640M LE/PCIe/SSE2(GLSL:4.20 NVIDIA通过Cg编译器)
-
OpenGL 4.0.0 - Build 9.17.10.2867 @ Intel Intel(R) HD Graphics 4000(GLSL:4.00 - Build 9.17.10.2867)
我的程序是在Go 1.0.3 64位下的Win 7 64位上使用的GLFW 64位。
我有一个相当简单和直接的渲染到纹理的“迷你管线”。首先,使用最简单的着色器(没有光照,什么都没有,只是纹理化的三角形网格,它们只是一些立方体和平面的数量)渲染正常的3D几何体到一个帧缓冲,该帧缓冲具有深度/模板渲染缓冲作为深度/模板附件和一个texture2D作为颜色附件。对于纹理,所有过滤都被禁用,包括mip-maps。
然后,我使用texelFetch(tex, gl_FragCoord.xy, 0)从该帧缓冲纹理(颜色附件)中采样,渲染一个全屏四边形(实际上是一个“超大”全屏三角形),所以不使用包装。
两个GPU都可以正常渲染,无论我是否强制使用核心配置文件或不使用。对于此操作,从未报告任何GL错误,所有渲染结果都符合预期。除非我在使用Intel HD 4000 GPU的GL 4.0渲染器(无论是核心配置文件还是Comp配置文件)时调整窗口大小。只有在这种情况下,调整大小后的下一个glClear(GL_COLOR_BUFFER_BIT)调用会在帧缓冲0(屏幕)上记录一个GL_OUT_OF_MEMORY错误,但仅在调整大小后的一次调用中,而不是在每个后续循环迭代中。
有趣的是,实际上我在调整大小时甚至没有进行任何分配!我已经临时禁用了在窗口调整大小时发生的所有逻辑 - 也就是说,现在我完全忽略窗口调整大小事件,这意味着RTT帧缓冲及其深度和颜色附件的分辨率甚至没有改变/重新创建。这意味着下一个glViewPort仍将使用与窗口和GL上下文首次创建时相同的尺寸,但是无论如何错误都发生在glClear()上(不是之前,只有之后,只有一次 - 我已经进行了双重和三重检查)。
这可能是驱动程序的错误,还是我在这里做错了什么?
英文:
Now, this is an extremely odd behavior.
TL;DR -- in a render-to-texture setup, upon resizing the window (framebuffer 0) only the very next call to glClear(GL_COLOR_BUFFER_BIT) for bound framebuffer 0 (the window's client area) gives GL_OUT_OF_MEMORY, only on one of two GPUs, however rendering still proceeds properly and correctly.
Now, all the gritty details:
So this is on a Vaio Z with two GPUs (that can be switched-to with a physical toggle button on the machine):
-
OpenGL 4.2.0 @ NVIDIA Corporation GeForce GT 640M LE/PCIe/SSE2 (GLSL: 4.20 NVIDIA via Cg compiler)
-
OpenGL 4.0.0 - Build 9.17.10.2867 @ Intel Intel(R) HD Graphics 4000 (GLSL: 4.00 - Build 9.17.10.2867)
My program is in Go 1.0.3 64-bit under Win 7 64-bit using GLFW 64-bit.
I have a fairly simple and straightforward render-to-texture "mini pipeline". First, normal 3D geometry is rendered with the simplest of shaders (no lighting, nothing, just textured triangle meshes which are just a number of cubes and planes) to a framebuffer that has both a depth/stencil renderbuffer as depth/stencil attachment and a texture2D as color attachment. For the texture all filtering is disabled as are mip-maps.
Then I render a full-screen quad (a single "oversized" full-screen tri actually) just sampling from said framebuffer texture (color attachment) with texelFetch(tex, gl_FragCoord.xy, 0) so no wrapping is used.
Both GPUs render this just fine, both when I force a core profile and when I don't. No GL errors are ever reported for this, all renders as expected too. Except when I resize the window while using the Intel HD 4000 GPU's GL 4.0 renderer (both in Core profile and Comp profile). Only in that case, a single resize will record a GL_OUT_OF_MEMORY error directly after the very next glClear(GL_COLOR_BUFFER_BIT) call on framebuffer 0 (the screen), but only once after the resize, not in every subsequent loop iteration.
Interestingly, I don't even actually do any allocations on resize! I have temporarily disabled ALL logic occuring on window resize -- that is, right now I simply fully ignore the window-resize event, meaning the RTT framebuffer and its depth and color attachment resolutions are not even changed/recreated. Meaning the next glViewPort will still use the same dimensions as when the window and GL context was first created, but anyhoo the error occurs on glClear() (not before, only after, only once -- I've double- and triple-checked).
Would this be a driver bug, or is there anything I could be doing wrongly here?
答案1
得分: 2
有趣的是,HD的GL驱动程序似乎存在一个故障:
当我切换到渲染到纹理的设置时,我还将主帧缓冲区0(即屏幕/窗口)的深度/模板位设置为0。从那时起,我开始看到这个错误,并且帧速率与之前相比变得非常缓慢。
我试验性地将(严格来说不需要的)深度位设置为8,这两个问题都消失了。所以看起来当前的HD 4000 GL 4.0驱动程序版本在GL上下文创建时不喜欢深度缓冲区位的值为0。
英文:
Interesting glitch in the HD's GL driver, it seems:
When I switched to the render-to-texture setup, I also set the depth/stencil bits at GL context creation for the primary framebuffer 0 (ie. the screen/window) both to 0. This is when I started seeing this error and framerate became quite sluggish compared to before.
I experimentally set the (strictly speaking unneeded) depth-bits to 8 and both of these issues are gone. So seems like the current HD 4000 GL 4.0 driver version just doesn't like a value of 0 for its depth buffer bits at GL context creation.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论