简体   繁体   English

正确删除纹理

[英]properly delete texture

I am trying to delete a texture when I'm done with it on android running opengl es 1.1 我在运行opengl es 1.1的android上完成纹理后试图删除它

On Galaxy S (phone) and Droid X, everything seems to work fine. 在Galaxy S(手机)和Droid X上,一切似乎都可以正常工作。 In fact it works too well, I don't seem to even need to delete the texture when I'm done with it, I never seem to run out of memory... 实际上,它工作得很好,完成处理后,我似乎甚至不需要删除纹理,我似乎永远不会用完内存...

On another device (not allowed to name at the moment) it seems like glDeleteTextures doesn't work. 在另一台设备(目前不允许命名)上,glDeleteTextures似乎无法正常工作。 After I load 6 large texture (and a number of other small ones) no new textures can be loaded, they just come out white. 加载6个大纹理(以及许多其他小纹理)后,无法加载新纹理,它们只会变成白色。

On a nexus one, I have a report that it turns white and throws the following error log 在一个联系上,我有一个报告,报告变成白色并抛出以下错误日志

E/Adreno200-EGL( 632): eglLockWindowSurface: failed to map the memory for fd=37 offs=4796416 E/Adreno200-EGL( 632): eglLockWindowSurface: failed to map the memory for fd=38 offs=1662976 E/Adreno200-EGL( 632): eglLockWindowSurface: failed to map the memory for fd=37 offs=4796416 E/Adreno200-EGL( 632): eglLockWindowSurface: failed to map the memory for fd=38 offs=1662976 E/Adreno200-EGL( 632): eglLockWindowSurface: failed to map the memory for fd=37 offs=4796416 E/Adreno200-EGL( 632): eglLockWindowSurface: failed to map the memory for fd=38 offs=1662976 E/Adreno200-EGL( 632): eglLockWindowSurface: failed to map the memory for fd=37 offs=4796416 E/Adreno200-EGL( 632): eglLockWindowSurface: failed to map the memory for fd=38 offs=1662976 E / Adreno200-EGL(632):eglLockWindowSurface:未能为fd = 37 offs = 4796416映射内存E / Adreno200-EGL(632):eglLockWindowSurface:无法为fd = 38 offs = 1662976 E / Adreno200- EGL(632):eglLockWindowSurface:无法为fd = 37 offs = 4796416 E / Adreno200-EGL(632)映射内存:eglLockWindowSurface:fd = 38 offs = 1662976 E / Adreno200-EGL(632)无法映射内存:eglLockWindowSurface:无法为fd = 37 offs = 4796416 E / Adreno200-EGL(632)映射内存:eglLockWindowSurface:无法为fd = 38 offs = 1662976 E / Adreno200-EGL(632):emlLockWindowSurface:失败映射内存为fd = 37 offs = 4796416 E / Adreno200-EGL(632)映射内存:eglLockWindowSurface:无法为fd = 38 offs = 1662976映射内存

I'm far from an expert on OpenGL, but: a) I can't find a complete example that both creates and deletes textures to ensure my code is correct b) the exact same methodology works perfectly on iPhone 我距离OpenGL专家还很远,但是:a)我找不到完整的示例来创建和删除纹理以确保我的代码正确b)完全相同的方法可以完美地在iPhone上运行

The only thing I can think of is I am using a fair amount of threading so perhaps my unbinds are escaping the correct thread, or in some way not being timed correctly. 我唯一能想到的是我正在使用大量线程,因此我的绑定可能逃避了正确的线程,或者以某种方式未正确计时。 I don't have any hardware at the moment that has the error so I can't test this theory until I get another device myself. 我目前没有任何硬件有此错误,因此在我自己购买另一台设备之前,我无法测试该理论。

Do you need to do anything special before deleting a texture, or should you be able to just slip a glDeleteTextures() in wherever in your flow and it should work? 您是否需要在删除纹理之前做任何特殊的事情,还是应该仅将glDeleteTextures()滑入流程中的任何位置,并且它应该可以工作?

Apologies for not posting any example code, I currently have some restrictions on it. 很抱歉没有发布任何示例代码,目前我对此有一些限制。

So far as I know, all OpenGL functions must be called in the same thread as the device is created. 据我所知,所有OpenGL函数必须在创建设备的同一线程中调用。 Both OpenGL and OpenGL ES applies. OpenGL和OpenGL ES均适用。

I seem to have solved this. 我似乎已经解决了这个问题。 Some devices (unsure if it's the graphics chipsets or something else with the device) apparently can only delete textures from the graphics context thread. 某些设备(不确定是图形芯片集还是设备的其他东西)显然只能从图形上下文线程中删除纹理。 My textures were being deleted in a cleanup call to my main texture variable which apparently wasn't getting executed in the right place. 我的纹理在对我的主纹理变量的清理调用中被删除,显然没有在正确的位置执行该纹理。 Now my glDeleteTexuters() gets qued in an event under the GLSurface so it's executed in the right thread in the right context. 现在,我的glDeleteTexuters()在GLSurface下的事件中被排队,因此它在正确的上下文中的正确线程中执行。

Not sure if it's related but the device I have that was having the problem creates textureID's in linear order (eg 1, 2, 3, 4 then I delete 2, it will create 2, 5, 6, etc.) where as the galaxy S with no problems seems to create texture ID's that are random. 不知道它是否相关,但是我遇到问题的设备以线性顺序创建TextureID(例如1、2、3、4,然后我删除2,它将创建2、5、6等),其中没有问题的S似乎可以创建随机的纹理ID。 Might be an indication of how the chipset handles the textures? 可能表明芯片组如何处理纹理? just a guess. 只是一个猜测。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM