diff options
author | Kenneth Graunke <[email protected]> | 2013-03-15 14:48:24 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2013-04-05 19:01:09 -0700 |
commit | 0c5fa7ae0eeb09b3dfd65541f12f64e91cd30c96 (patch) | |
tree | d76ae9271a99ded76b2646c6b8713c443328a4ff | |
parent | 725c671d61a5b1861af45c81d60d64c0740e8608 (diff) |
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 <[email protected]>
Signed-off-by: Kenneth Graunke <[email protected]>
(cherry picked from commit d86efc075ed84a8c45bfb71cee56dcd18858f727)
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index 5735c021010..657a56f06fd 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -770,7 +770,8 @@ brw_get_texture_swizzle(const struct gl_context *ctx, case GL_RED: case GL_RG: case GL_RGB: - swizzles[3] = SWIZZLE_ONE; + if (_mesa_get_format_bits(img->TexFormat, GL_ALPHA_BITS) > 0) + swizzles[3] = SWIZZLE_ONE; break; } |