Bug 17077 - glTexSubImage2D does not work correctly when using generated mip-maps
Summary: glTexSubImage2D does not work correctly when using generated mip-maps
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/DRI/i915 (show other bugs)
Version: git
Hardware: x86 (IA32) Linux (All)
: medium normal
Assignee: Eric Anholt
QA Contact:
Depends on:
Reported: 2008-08-11 08:03 UTC by Chris Lord
Modified: 2009-08-24 12:30 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:

This test-case exhibits the described bug (3.00 KB, text/x-csrc)
2008-08-11 08:05 UTC, Chris Lord

Description Chris Lord 2008-08-11 08:03:19 UTC
When using generated mip-maps (via GL_GENERATE_MIPMAP), glTexSubImage2D does not work correctly (sometimes clearing the texture before updating the sub-region, or producing other odd behaviour). This seems to occasionally affect the GL state of subsequently launched applications too, but I have no 100% reproducible test-case for this.

Attached is a demo app that exhibits this error. It creates a blue 512x512 texture with GL_GEN_TEXTURES set to true and displays this in the centre of the window. When you press the space bar, it updates a sub-region of that texture with a fully opaque red texture. This red sub-texture is treated as if it wasn't fully opaque.

If you build it with NO_MIPMAP defined, it will not use GL_GEN_TEXTURES and work correctly. Running this on nvidia hardware with the binary nvidia drivers works correctly.

The failure behaviour is not consistent, more complex test-cases produce different failures. Text in Clutter (http://clutter-project.org/) for example, disappears, as at some point, a sub-region update clears the entire glyph-cache texture to black.

I'm running mesa checked out on 7th August 2008, I've not seen any commit logs that look like they fixed this feature since then.
Comment 1 Chris Lord 2008-08-11 08:05:24 UTC
Created attachment 18217 [details]
This test-case exhibits the described bug
Comment 2 Chris Lord 2008-08-11 13:50:02 UTC
Just a note, I obviously meant GL_GENERATE_MIPMAP, not GL_GEN_TEXTURES in the second and third paragraphs.
Comment 3 Guillaume Melquiond 2008-08-11 23:15:17 UTC
The part about text disappearing caught my attention, as I'm experiencing the same issue in World of Warcraft (opengl mode) with mesa 7.1 while it was working fine with mesa 7.0. I tried a bisection, but the git repository is a bit of a mess due to various DRM changes for the intel driver between the two versions, so I couldn't pinpoint the bad commit.

Anyway, I have tried your testcase. It works fine with mesa 7.0, but the red square is not opaque with mesa 7.1, as you describe.
Comment 4 Eric Anholt 2008-08-20 15:05:25 UTC
The other mipmap levels aren't being updated on the first subimage call, though they get updated on subsequent ones.  The transparent effect is just that you're blending two mipmap levels in the rendering.  I'm cooking up a piglit regression test and then I'll fix the issue.
Comment 5 Eric Anholt 2008-08-20 23:20:52 UTC
Fixed in master, and regression test (gen-texsubimage) added to piglit.  Thanks for the easy-to-reproduce testcase!
Comment 6 Chris Lord 2008-08-26 04:08:54 UTC
Thanks, this is fixed, but I still see the bug with text in Clutter... I'm trying to produce another test-case that shows this regression.
Comment 7 Adam Jackson 2009-08-24 12:30:46 UTC
Mass version move, cvs -> git

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.