glDepthMask(GL_FALSE) 会破坏某些 GPU 上的帧缓冲区
我有时会在帧渲染期间通过 glDepthMask(GL_FALSE)
禁用深度缓冲区写入。这在某些 GPU 上工作得非常好(比如摩托罗拉 Droid 的 PowerVR),但在带有 Adreno GPU 的 HTC EVO 上,我最终得到的帧缓冲区完全是垃圾(我在某处看到了我渲染的网格的痕迹,但是整个屏幕大部分都是垃圾)。
如果我强制 glDepthMask 始终为 true,则一切正常。
我需要在 alpha 渲染的部分过程中关闭 glDepthMask。关闭深度注销会导致帧缓冲区被破坏的原因是什么?
I sometimes disable depth buffer writing via glDepthMask(GL_FALSE)
during the rendering of a frame. That works perfectly fine on some GPUs (like the Motorola Droid's PowerVR), but on the HTC EVO with the Adreno GPU for example, I end up with the frame buffer being complete garbage (I see traces of the meshes I rendered somewhere, but the entire screen is mostly trashed).
If I force glDepthMask to be true the entire time, everything works fine.
I need glDepthMask to be off during parts of the alpha rendering. What can cause the framebuffer to get destroyed by turning the depth writing off?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
问题是调用
glClearDepth
时glDepthMask
需要为 true。这显然仅适用于 Adreno GPU,不适用于 PowerVR GPU。The problem was that
glDepthMask
needs to be true when callingglClearDepth
. This apparently only applies to Adreno GPUs, not to PowerVR GPUs.不确定这是否有帮助,但我想知道您是否仍然需要清除深度缓冲区 - 特别是在禁用 glDepthMask 之前。我相信 glDepthMask 仅启用/禁用写入,而不是深度测试。也许 GL 实现仍在针对先前渲染通道中的旧深度缓冲区信息进行测试,因此仅绘制到屏幕的一部分。然后看起来就很垃圾了。某些实现可能会清除深度缓冲区,其他实现可能不会?如果这个建议完全没有达到目的,请忽略。
无论如何,希望能在一些小方面有所帮助。
Not sure if this will help, but me wonders if you still need to clear the depth buffer - especially before you disable glDepthMask. I believe that glDepthMask only enables/disable writes, not depth tests. Maybe the GL implementation is still testing against old depth buffer information from a previous render pass and thus only drawing to part of your screen. Then it looks trashed. Some implementations might clear the depth buffer, other might not? Feel to disregard if this suggestion totally misses the mark.
Anyways, hope that helps in some small way.
iPhone4/iOS模拟器。如果我在 glClear 之前没有将 glDepthMask 设置为 true,我的渲染就会被丢弃。我花了两天时间解决这个问题,将帧缓冲区转储到磁盘,调查整个帧的踪迹,单步执行代码......
这是唯一有效的方法。
没关系。我很傻。我正在执行深度掩码 = false 的 glClear(COLOR | DEPTH) ,因此深度缓冲区根本没有被清除。
我的第一个回复是由于一整天的调试造成的:/
iPhone4/iOS Simulator. If I do not put glDepthMask to true before the glClear, I get my rendering trashed. I spent two days with this problem, dumping framebuffers to disk, investigating the trace of the whole frame, stepping into the code...
This was the only thing that worked.
NEVERMIND. I'm stupid. I was executing a glClear(COLOR | DEPTH) with depth mask = false, so the depth buffer wasn't cleared at all.
My first reply was caused by a whole day of debugging :/