[Mesa-dev] [PATCH] i965: Don't use texture swizzling to force alpha to 1.0 if unnecessary.

Eric Anholt eric at anholt.net
Sat Mar 16 10:09:05 PDT 2013

Kenneth Graunke <kenneth at whitecape.org> writes:

> On 03/15/2013 04:54 PM, Eric Anholt wrote:
>> Kenneth Graunke <kenneth at whitecape.org> writes:
>>> Commit 33599433c7 began setting the texture swizzle mode to XYZ1 for
>>> RED, RG, and RGB textures in order to force alpha to 1.0 in case we
>>> actually stored the texture as RGBA.
>>> This had a unforseen performance implication: the shader precompile
>>> assumes that the texture swizzle mode will be XYZW for non-shadow
>>> sampler types.  By setting it to XYZ1, this means every shader used with
>>> a RED, RG, or RGB texture has to be recompiled.  This is a very common
>>> case.
>>> Unfortunately, there's no way to improve the precompile, since RGBA
>>> textures still need XYZW, and there's no way to know by looking at
>>> the shader source what texture formats might be used.
>>> However, we only need to smash alpha to 1.0 if the texture's memory
>>> format actually has alpha bits.  If not, the sampler already returns 1.0
>>> for us without any special swizzling.  XRGB8888, for example, is a very
>>> common case where this occurs.
>>> This partially fixes a performance regression since commit 33599433c7.
>>> More work is required to fully fix it in all cases.  This at least helps
>>> Warsow.
>> Now that we have MESA_FORMAT_XBGR16161616_FLOAT and company, we could
>> potentially make this conditional just die by using those formats.
> Absolutely - I believe the real fix is to use XRGB formats when 
> sampling, and ARGB formats when rendering.  I'm pretty sure we have 
> formats for all of those now.  We should do that.
> In the meantime, this patch improves things and is simple and easily 
> cherry-pickable...

Fair enough.  Are there some big performance changes?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20130316/7c2637b5/attachment.pgp>

More information about the mesa-dev mailing list