OpenGL 内存不足错误,大型 FBO
在 PyOpenGL/PyQt 中创建大型 (2^13) 帧缓冲区对象时出现内存不足错误:
width = 8192
height = 8192
self.textureFbo = QtOpenGL.QGLFramebufferObject(width,height)
self.textureFbo.bind()
texture = self.bindTexture(QtGui.QPixmap(self.textureFilePath)) # 2^13
glClearColor (0.0, 0.0, 0.0, 0.0);
glClear (GL_COLOR_BUFFER_BIT);
glLoadIdentity()
glViewport(0, 0, width, height)
glMatrixMode(GL_PROJECTION);
glLoadIdentity()
glOrtho(0, +1, +1, 0, -0.1, 2.0);
glBegin(GL_POLYGON);
glTexCoord2d(1.0, 0.0)
glVertex3f (0.0, 0.0, 0.0)
glTexCoord2d(1.0, 1.0)
glVertex3f (1.0, 0.0, 0.0)
glTexCoord2d(0.0, 1.0)
glVertex3f (1.0, 1.0, 0.0)
glTexCoord2d(0.0, 0.0)
glVertex3f (0.0, 1.0, 0.0)
glEnd();
self.deleteTexture(texture)
self.textureFbo.release()
self.textureFboLoaded = True
给出:
OpenGL.error.GLError: GLError(
err = 1285,
description = 'out of memory',
baseOperation = glClear,
cArguments = (GL_COLOR_BUFFER_BIT,)
)
QGLFramebufferObject: Framebuffer incomplete attachment.
Traceback (most recent call last):
File "main.py", line 286, in paintGL
self.loadTextureFBO()
File "main.py", line 357, in loadTextureFBO
glEnable(GL_TEXTURE_2D)
File "C:\Python27\lib\site-packages\OpenGL\error.py", line 208, in glCheckErro
r
baseOperation = baseOperation,
OpenGL.error.GLError: GLError(
err = 1285,
description = 'out of memory',
baseOperation = glEnable,
cArguments = (GL_TEXTURE_2D,)
)
QImage: out of memory, returning null image
但是,如果我逐步降低到 2^12 纹理或 FBO,则效果很好。
对我来说,两个大约 132mb 268mb(4 字节*8192^2)的图像(FBO+纹理)应该填满我的 1GB 视频内存,这似乎不合理。我缺少什么?
I'm getting out of memory errors when creating a large (2^13) framebuffer object in PyOpenGL/PyQt:
width = 8192
height = 8192
self.textureFbo = QtOpenGL.QGLFramebufferObject(width,height)
self.textureFbo.bind()
texture = self.bindTexture(QtGui.QPixmap(self.textureFilePath)) # 2^13
glClearColor (0.0, 0.0, 0.0, 0.0);
glClear (GL_COLOR_BUFFER_BIT);
glLoadIdentity()
glViewport(0, 0, width, height)
glMatrixMode(GL_PROJECTION);
glLoadIdentity()
glOrtho(0, +1, +1, 0, -0.1, 2.0);
glBegin(GL_POLYGON);
glTexCoord2d(1.0, 0.0)
glVertex3f (0.0, 0.0, 0.0)
glTexCoord2d(1.0, 1.0)
glVertex3f (1.0, 0.0, 0.0)
glTexCoord2d(0.0, 1.0)
glVertex3f (1.0, 1.0, 0.0)
glTexCoord2d(0.0, 0.0)
glVertex3f (0.0, 1.0, 0.0)
glEnd();
self.deleteTexture(texture)
self.textureFbo.release()
self.textureFboLoaded = True
gives:
OpenGL.error.GLError: GLError(
err = 1285,
description = 'out of memory',
baseOperation = glClear,
cArguments = (GL_COLOR_BUFFER_BIT,)
)
QGLFramebufferObject: Framebuffer incomplete attachment.
Traceback (most recent call last):
File "main.py", line 286, in paintGL
self.loadTextureFBO()
File "main.py", line 357, in loadTextureFBO
glEnable(GL_TEXTURE_2D)
File "C:\Python27\lib\site-packages\OpenGL\error.py", line 208, in glCheckErro
r
baseOperation = baseOperation,
OpenGL.error.GLError: GLError(
err = 1285,
description = 'out of memory',
baseOperation = glEnable,
cArguments = (GL_TEXTURE_2D,)
)
QImage: out of memory, returning null image
However this works fine if I step down to either a 2^12 texture, or FBO.
It seems unreasonable to me that two images (FBO+texure) of around132mb 268mb each (4 bytes*8192^2) should fill up my 1gb of video memory. What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,请注意,4 x 8192^2 是 268M,而不是 132,因此对于这两个对象,我们谈论的是超过半 GB。想必还有其他对内存的要求。我同意听起来你应该没有问题,但我不知道还发生了什么。
First, note that 4 x 8192^2 is 268M, not 132, so we're talking over half a GB, for these two objects. Presumably there are other demands on memory, too. I agree it sounds like you should not have a problem, but I don't know what else is going on.