After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 696094 - cogl_texture_get_data returns garbage for TFP textures
cogl_texture_get_data returns garbage for TFP textures
Status: RESOLVED NOTGNOME
Product: cogl
Classification: Platform
Component: CoglTexture
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Cogl maintainer(s)
Cogl maintainer(s)
: 699496 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-03-18 18:56 UTC by drago01
Modified: 2015-01-11 15:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Use cairo not cogl for subsurface in meta_shaped_texture_get_image (5.46 KB, patch)
2013-04-11 18:59 UTC, Neil Roberts
none Details | Review

Description drago01 2013-03-18 18:56:52 UTC
We use cogl_texture_get_data on TFP textures to create window screenshots in gnome-shell but for some reason when using the proprietary nvidia driver the resulting data is garbage.

I am not sure whether this is a driver or cogl bug. Reading back other textures works fine, we had a similar issues in the past see bug 669368 and bug 673137 there are not the same but we seem to need another code path there for a reason maybe it broke due to other changes.
Comment 1 drago01 2013-03-26 16:11:10 UTC
Jon is seeing this using the intel driver as well.
Comment 2 Neil Roberts 2013-04-11 18:58:25 UTC
I can't replicate this issue on my Intel Sandybridge laptop at least.

When grabbing the data for the window, Mutter will create a subtexture of a smaller region of the window and instead try to get the data for that. This will make it call texture_get_cb with a subregion of the texture. There is no GL function to read a subregion of the texture, so Cogl will try to work around this in one of two ways. Either it will create a temporary framebuffer object and call glReadPixels on that, or it will just read all of the data into a temporary buffer and copy that out.

When grabbing the texture, Mutter will also read back the texture data for the mask texture which I guess contains the window's shape. This is an alpha-component texture. I vaguely remember that creating an alpha-component framebuffer doesn't work on some hardware (I think it was nVidia) so it might be falling back to the temporary buffer in that case.

Creating a framebuffer to a TFP texture or an alpha texture seems like quite a corner case of the driver, so it doesn't seem totally unlikely that the driver doesn't like this. Perhaps we could try working around this by always reading back all of the texture data. I'm about to attach a patch for Mutter which would do this. It would be good to try this, even if just to rule out issues with FBOs.
Comment 3 Neil Roberts 2013-04-11 18:59:06 UTC
Created attachment 241295 [details] [review]
Use cairo not cogl for subsurface in meta_shaped_texture_get_image

Instead of using cogl_texture_new_from_sub_texture to create a sub
region of the source texture, it now just grabs all of the data from
the texture into a larger cairo surface and then creates a second
image surface which points into a sub region of the first surface.
Using Cogl to create the sub texture means it would end up trying to
read a sub-region of a GL texture. This is either implemented by
creating a temporary frame buffer object and then using glReadPixels,
or by reading the whole texture into a temporary buffer and then
copying it again into a second smaller buffer.

Using a framebuffer with a TFP texture or an alpha-only texture seems
like a likely candidate to cause problems and may be related to bug
696094 which is showing corruption. Using a full size buffer in Mutter
instead would work around any problems using glReadPixels. If Cogl is
using the second option where it will create its own temporary buffer,
then this approach will be faster because it will remove one copy.
Comment 4 drago01 2013-04-11 21:42:31 UTC
Review of attachment 241295 [details] [review]:

As I told you on IRC I have tried to skip this code path while debugging so I don't expect this to work. (maybe you somehow missed that),
I did just test with this patch and it did not help.
Comment 5 Jasper St. Pierre (not reading bugmail) 2013-05-06 20:03:44 UTC
It seems I'm having a similar issue on Ironlake here. It only happens when the window is wider than the screen itself. Try taking a window screenshot of a window larger than the screen, and you should see it for yourself.

The patch fixes the issue, by the way.
Comment 6 drago01 2013-05-07 12:54:37 UTC
*** Bug 699496 has been marked as a duplicate of this bug. ***
Comment 7 drago01 2013-07-03 10:01:33 UTC
OK seems like the NVIDIA related one is indeed a driver bug:
https://devtalk.nvidia.com/default/topic/526615/linux/gnome-screenshot-creates-garbled-window-screenshots/post/3843415/#3843415

"Sorry for the very slow update. We've identified the problem and it should be fixed in a future release. "