OpenGL内存不足错误,FBO大



在PyOpenGL/PyQt中创建一个大型(2^13)framebuffer对象时,我正在摆脱内存错误:

    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:Python27libsite-packagesOpenGLerror.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,这就可以了。

对我来说似乎不合理,两个图像(FBO+纹理)大约132mb 268mb每个(4字节*8192^2)应该填满我的1gb视频内存。我错过了什么?

首先,注意4 x 8192^2是268M,而不是132,所以对于这两个对象,我们讨论的是超过半GB。大概还有其他对内存的需求。我同意,听起来你应该没有问题,但我不知道还发生了什么。

最新更新