【问题标题】:OpenGL out of memory error, large FBOOpenGL内存不足错误,FBO大
【发布时间】:2011-04-29 00:33:31
【问题描述】:

在 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 显存。我错过了什么?

【问题讨论】:

    标签: opengl fbo pyopengl video-memory


    【解决方案1】:

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

    【讨论】:

    • 感谢您的回答,我刚刚找到了一个名为 GPU-Z 的显卡分析器,它没有显示我的第二个 GPU 的内存使用情况,只有我的第一个。所以我假设我的 SLI 设置搞砸了,我只有 1GB 的 vram。无论如何,在我运行我的脚本之前的基准视频内存使用量是 26mb。我以最大的帧缓冲区大小运行我的脚本,经过反复试验,我发现它恰好是 7287^2,vram 使用峰值为 589mb,然后我将图像大小增加到 7288^2,然后退出内存错误。奇怪,除了内存限制之外,帧缓冲区大小可能还有上限?
    • 在 SLI 中,纹理需要加载到两张卡上(否则两张卡上的纹理单元如何高效运行),因此您无法将 VRAM 大小加在一起。
    • 这还是很有道理的; vram 使用量达到 589mb 的峰值,因此对于一个稍微大一点的帧缓冲区来说,它的内存不足似乎很奇怪。
    • @Leo:请记住,您的程序并不是唯一使用 VRAM 的东西——可能您的 OS/Window 系统和可能正在运行的任何其他程序也会影响它。视频内存可能只是碎片化,因此有足够的可用内存,但不是在一个连续的块中。
    • 啊,谢谢;就是这样,非连续内存,我将纹理分成四个单独的帧缓冲区,问题就消失了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-13
    • 2015-09-20
    • 1970-01-01
    • 2011-09-01
    相关资源
    最近更新 更多