开发者

glDepthMask(GL_FALSE) trashes the frame buffer on some GPUs

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 framebu开发者_运维知识库ffer to get destroyed by turning the depth writing off?


The problem was that glDepthMask needs to be true when calling glClearDepth. This apparently only applies to Adreno GPUs, not to PowerVR GPUs.


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 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 :/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜