OpenGL 内存不足错误,大型 FBO

发布于 2024-11-03 11:10:25 字数 1784 浏览 0 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

秋日私语 2024-11-10 11:10:25

首先,请注意,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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文