1

在 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 视频内存,这似乎是不合理的。我错过了什么?

4

1 回答 1

1

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

于 2011-04-28T01:39:46.343 回答