QOpenGLTexture encounters GL_OUT_OF_MEMORY
-
Hi, i'm not sure this is a Qt issue or pure OpenGL issue. I'm using the following in Qt5.15.2 on Ubuntu 20 to load an image as a texure in QOpenGLWidget.
if (m_image.load(filename)) { m_texture = new QOpenGLTexture(m_image.mirrored()); CheckGLError(419); // 419 is just line number
Im able to load a small size image (e.g. 500k) successfully. But loading larger image (~50M) as txture will encounter the following error:
GL Error at Line 419: GL_OUT_OF_MEMORY
My PC has a Nvidia 1080 graphics card with 8G memory. How come it is out of memory for a 50M size image?
My glxinfo lists:
name of display: :0 display: :0 screen: 0 direct rendering: Yes Extended renderer info (GLX_MESA_query_renderer): Vendor: nouveau (0x10de) Device: NV134 (0x1b80) Version: 21.2.6 Accelerated: yes Video memory: 8173MB Unified memory: no Preferred profile: core (0x1) Max core profile version: 4.3 Max compat profile version: 4.3 Max GLES1 profile version: 1.1 Max GLES[23] profile version: 3.2 OpenGL vendor string: nouveau OpenGL renderer string: NV134 OpenGL core profile version string: 4.3 (Core Profile) Mesa 21.2.6 OpenGL core profile shading language version string: 4.30 OpenGL core profile context flags: (none) OpenGL core profile profile mask: core profile OpenGL version string: 4.3 (Compatibility Profile) Mesa 21.2.6 OpenGL shading language version string: 4.30 OpenGL context flags: (none) OpenGL profile mask: compatibility profile OpenGL ES profile version string: OpenGL ES 3.2 Mesa 21.2.6 OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
-
Hi,
What kind of image are you loading ?
What is its size ?
Which format are you using for the texture ?
Do you have other textures ?The fact that it already weighs 50M hints that it's quite large. It also likely uses some form or another of compression which means that the uncompressed version will be pretty large.
-
@SGaist Hi it is a PNG file, 42.9MB (dimension 15000X15000), I can open it with apps like windows photo viewer.
I'm not sure what exactly the format it is using, im just using this code to load this image and draw
if (m_image.load(filename)) { m_texture = new QOpenGLTexture(m_image.mirrored()); .... m_texture->bind(); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
I have only this one texture as a background view for my app. But I did try to load other smaller images, and it is quite OK. Check this screenshot when I load a 1M size Iron man wallpaper as texture.
Weird thing is previously my app was built with Qt5.12 on Ubuntu16 with integrated intel card running lower version mesa driver, this big texture image was successfully loaded and shown. I encountered this out of memory issue actually after I upgraded to Qt5.15 on Ubuntu20 with Nvidia card running nouveau driver. I did not change any code during the upgrade except one GLSL shader function (texture2D() changed to texture(), I think texture2D is for old GLSL and deprecated). So im still guessing it is related to the new graphics driver or OpenGL.