删除GLSL着色器的正确方法? [英] Proper way to delete GLSL shader?

查看:126
本文介绍了删除GLSL着色器的正确方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码以这种方式处理GLSL着色器管理,即创建每个着色器和关联的程序,并删除每个着色器和程序.我最近阅读了 http://www.opengl.org/wiki/GLSL_Object 并指出:

My code approaches GLSL shader management in the way, that it creates each shader and the associated program and deletes each shader and program. I recently read http://www.opengl.org/wiki/GLSL_Object and there it is stated that:

由于附加到程序对象,着色器对象将 即使删除着色器对象,它仍然存在.它只会 当它不再附加到任何程序时被系统删除 对象(当然,当用户要求删除它时).

The shader object, due to being attached to the program object, will continue to exist even if you delete the shader object. It will only be deleted by the system when it is no longer attached to any program object (and when the user has asked to delete it, of course).

如果链接到程序后在着色器对象上调用glDeleteShader(),我是否正确理解了该程序,我只需要跟踪该程序?可以肯定这是真的吗?

Do I get this correctly, if I call glDeleteShader() on the shader object after linking to the program, I only need to track the program? Is it safe to assume this is always true?

推荐答案

是的-实际上,非常需要尽快分离和删除着色器对象.这样,驱动程序就可以释放所有用于保存着色器源和未链接目标代码的副本的内存,这可能是非常重要的.我所做的测量表明,不删除着色器对象会使每个着色器的增量内存使用量增加5-10倍

Yes -- in fact it is highly desireable to detach and delete your shader objects as soon as possible. That way the driver can free up all the memory it is using to hold a copy of the shader source and unlinked object code, which can be quite substantial. Measurements I have done indicate that NOT deleting the shader objects increases the incremental memory use per shader by 5-10x

这篇关于删除GLSL着色器的正确方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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