的OpenGL ES 1.1 - Android的 - 确实gl.glDeleteTextures免费视频内存? [英] OpenGL es 1.1 - android - does gl.glDeleteTextures free video memory?

查看:332
本文介绍了的OpenGL ES 1.1 - Android的 - 确实gl.glDeleteTextures免费视频内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文:

我使用gl.glGenTextures负载2成纹理大小为2的int [],然后纹理绑定到INT []的每个插槽。 (这工作得很好,我能够每个纹理绘制到纹理广场我有prepared)

I load 2 textures into an int[] of size 2 using gl.glGenTextures and then bind a texture to each slot of the int[]. (This works fine, and I am able to draw each texture to the "texture squares" I had prepared)

现在,我的实际关注:

将在运行gl.glDeleteTextures(2,INT []含2质地指针,0)清理所产生的进入我的INT [] 2纹理使用的内存?还是这恰恰释放了纹理名称?

Will running gl.glDeleteTextures(2, int[] containing 2 texture pointers, 0) clear up the memory used by the 2 textures generated into my int[]? Or does this just free up the "texture names"?

推荐答案

它确实删除纹理数据。内存可能会在拨打电话不会被立即释放,但他们最终都会被释放。或至少​​通过其他分配可供再利用。内存管理的细节高度的平台和特定的驱动程序。但是,随着对OpenGL API的用户,可以考虑 glDeleteTextures()电话后释放的内存。

It does delete the texture data. The memory might not be freed immediately when you make the call, but it will get freed eventually. Or at least made available for reuse by other allocations. The details of memory management are highly platform and driver specific. But as a user of the OpenGL API, you can consider the memory freed after the glDeleteTextures() call.

为什么内存可能不会立即释放其原因是OpenGL的异步操作。在这样一个典型的调用顺序:

The reason why the memory might not be freed immediately is that OpenGL operates asynchronously. In a typical call sequence like this:

glBindTexture(GL_TEXTURE_2D, texId);
glDrawArrays(...);
glDeleteTextures(1, &texId);

绘图调用是最有可能仍然在执行队列中由GPU的 glDeleteTextures()调用时。由于绘制调用使用纹理数据,它不能被立即删除。之后,GPU执行完成绘制调用的内存只能被释放。

The draw call is most likely still queued up for execution by the GPU when the glDeleteTextures() call is made. Since the draw call uses the texture data, it cannot be deleted immediately. The memory can only be freed after the GPU finished executing the draw call.

有几个例外,其中纹理实际上将不会被后释放glDeleteTextures()叫就可以了。他们不是很常见的场景,而是应该完整性提到:

There are a couple of exceptions where the texture will actually not be freed after glDeleteTextures() is called on it. They are not very common scenarios, but should be mentioned for completeness:


  1. 如果纹理附加到FBO,并且FBO当前未束缚,FBO的纹理参考将保持纹理活着直到纹理是从FBO分离,或FBO被删除。请注意,对于当前绑定FBO,纹理时会自动被删除分离的

  1. If the texture is attached to an FBO, and that FBO is not currently bound, the texture reference of the FBO will keep the texture alive until either the texture is detached from the FBO, or the FBO is deleted. Note that for a currently bound FBO, the texture will automatically be detached when it is deleted.

如果资源被多个上下文之间共享,事情也变得更加复杂。这是最好请教一下在这种情况下的确切行为的规格。

If resources are shared between multiple contexts, things also get more complicated. It's best to consult the specs about the exact behavior in this case.

这篇关于的OpenGL ES 1.1 - Android的 - 确实gl.glDeleteTextures免费视频内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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