OSDN Git Service

i965: Don't use texture swizzling to force alpha to 1.0 if unnecessary.
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 15 Mar 2013 21:48:24 +0000 (14:48 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 20 Mar 2013 17:37:34 +0000 (10:37 -0700)
commitd86efc075ed84a8c45bfb71cee56dcd18858f727
tree65dcaf5451a5adc06146f193f1bde1d198dd4e79
parent2dd22130cd708bad4d6ae4acb706394b1dd6ecd9
i965: Don't use texture swizzling to force alpha to 1.0 if unnecessary.

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.

NOTE: This is a candidate for the 9.1 branch.

Reviewed-by: Carl Worth <cworth@cworth.org>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_wm_surface_state.c