我正在渲染一个图像,该图像通过使其成为方形 2D 板(由 2 个三角形组成)的纹理来每帧更新一次。但是,GPU 内存似乎随着每一帧的单调增加而增加。
绘制函数如下所示:
prog = gloo.Program(vertex, fragment, count=4)
def Draw(self, inImRGB):
texture = inImRGB.copy().view(gloo.Texture2D)
texture.interpolation = gl.GL_LINEAR
CBackgroundImage._prog['texture'] = texture
CBackgroundImage._prog.draw(gl.GL_TRIANGLE_STRIP)
并且使用以下回调定期为每个新的可用映像调用它:
from glumpy import app
window = app.Window(...)
@window.event
def on_draw():
window.clear()
bgImageObj.Draw(newImRGB)
知道为什么GPU内存不断累积吗? 我应该以某种方式释放每个新帧的纹理,还是以不同的方式填充它?如果是这样,如何?
texture = inImRGB.copy().view(gloo.Texture2D)
创建所有新的纹理;最终Phython GC将清理旧的东西,但这不会发生,如果内存不缺的话。
在初始化期间创建纹理,然后重复使用。