有必要调用 gl clear 吗? [英] Is calling gl clear necessary?

查看:92
本文介绍了有必要调用 gl clear 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在此处发现了这个问题回答.就我而言,我正在绘制整个填充的矩形屏幕.因此,看到将没有剩余的用于绘制的像素,在这种非常特殊的情况下省略 GLclear 会提高性能吗?

I found this question here while searching for an answer. In my case I'm drawing an entire filled rectangular screen. So seeing that there will be no leftover pixels for drawing, will omitting GLclear in this very specific scenario increase performance?

推荐答案

在您的情况下,glClear 不是必需的(前提是您不使用 深度测试模板测试混合).glClear(GL_COLOR_BUFFER_BIT) 只是设置帧缓冲区中每个片段的颜色.如果在渲染的时候写入每个fragment,就不需要glClear.
相对性能增益取决于场景的复杂性和渲染管线.最有可能的是,它不是那么大,但会有影响.

In your case, glClear is not necessary (provided you don't use a Depth Test, Stencil test or Blending). glClear(GL_COLOR_BUFFER_BIT) just sets the color of each fragment in the framebuffer. If you write into each fragment during the rendering, there is no need for glClear.
The relative performance gain depends on the complexity of your scene and the render pipeline. Most likely, it's not that big, but there will be an effect.

这篇关于有必要调用 gl clear 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆