Bug 19910 - Can't blend with the alpha from an RGB texture updated via texture-from-pixmap
Summary: Can't blend with the alpha from an RGB texture updated via texture-from-pixmap
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/DRI/i915 (show other bugs)
Version: unspecified
Hardware: x86 (IA32) Linux (All)
: high major
Assignee: Eric Anholt
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: intel-3d-release
  Show dependency treegraph
 
Reported: 2009-02-02 08:56 UTC by Neil Roberts
Modified: 2009-03-20 10:54 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Test case (10.21 KB, text/plain)
2009-02-02 08:56 UTC, Neil Roberts
Details
Image of what it should look like (4.20 KB, image/png)
2009-02-02 09:04 UTC, Neil Roberts
Details

Description Neil Roberts 2009-02-02 08:56:27 UTC
Created attachment 22487 [details]
Test case

In metacity-clutter (Mutter) we use multi-texturing to render shaped windows. The shape of the window is copied into a GL_ALPHA texture which is blended with the window's texture using multi-texturing such that the areas outside the window's shape end up with zero alpha and aren't displayed.

The texture for the window should usually be GL_RGB format and is updated using the texture from pixmap extension. The texture environment is set up so that layer 0 (the window texture) is left at the default and layer 1 uses GL_COMBINE. The RGB is set to GL_REPLACE with the values from the previous texture (the window texture). The alpha is set to GL_MODULATE with the mask layer and the previous layer.

As far as I understand from the man pages for glTexEnv, the alpha from an RGB texture when used for blending will be constant 1 so it should work. It works fine on my i965 laptop with Mesa 7.2 (from Ubuntu Intrepid) when LIBGL_ALWAYS_INDIRECT enabled and also on an Nvidia box.

However, when testing on an Aspire One (i945) with the Moblin alpha release image, the blending does not work correctly. The shaped windows appear completely transparent as if maybe the non-existent alpha value from the window texture is being used.

We currently workaround this in Mutter by using a different blending mode when the window has a 24 bit depth. In this case we ignore the alpha from the window texture and modulate directly with GL_PRIMARY_COLOR.

The attached test case demonstrates this without using Clutter. It creates a small white window with a black circle outline drawn it and then creates another window which clones the small window using texture from pixmap. The texture is blended with a 2x2 GL_ALPHA texture which is full opacity except the bottom left pixel. So the window should appear as a black scaled up circle on a white background except for the bottom left corner which should show the blue underneath.

Under Moblin, it shows a completely blue window instead. You can enable the workaround by setting the WORKAROUND environment variable.
Comment 1 Neil Roberts 2009-02-02 09:04:58 UTC
Created attachment 22488 [details]
Image of what it should look like

In case it's not clear from my description of the test, this is what it should look like when it's working.
Comment 2 Eric Anholt 2009-03-20 10:54:15 UTC
Thanks for the excellent testcase!  I've come up with a more minimal case and put it into piglit as texturing/tfp.  I've also pushed the fix:

commit 66175aac7609ad314f25fbdff0d3958af310dc24
Author: Eric Anholt <eric@anholt.net>
Date:   Wed Mar 18 12:07:09 2009 -0700

    Fix DRI2 accelerated EXT_texture_from_pixmap with GL_RGB format.


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.