i965: Do texture swizzling in hardware on Haswell.
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 21 Sep 2012 10:13:36 +0000 (03:13 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 30 Jan 2013 17:45:46 +0000 (09:45 -0800)
commit42df904f88a3515bf8bea5c1228380714c9146fb
tree47fa8fcaf81ffae6ca7b73614788e7742e94a68d
parent3ebfd3f7743e5c05661eab977b23441e45441b39
i965: Do texture swizzling in hardware on Haswell.

Haswell supports EXT_texture_swizzle and legacy DEPTH_TEXTURE_MODE
swizzling by setting SURFACE_STATE entries.  This means we don't have to
bake the swizzle settings into the shader code by emitting MOV
instructions, and thus don't have to recompile shaders whenever the
swizzles change.

Unfortunately, we can't handle GL_ALPHA this way: unlike all the others,
which store the comparison result in the .r channel (and possibly others
as well), GL_ALPHA puts it in the .a channel.  The GLSL 1.30+ style
functions which return a float always simply return the .r channel,
which would be zero if we handled this as a surface override.  In this
case, fall back to doing it the old way.  DEPTH_TEXTURE_MODE = GL_ALPHA
isn't an interesting performance path anyway.

Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit 6d6aef79742ece3bb570ae44e6c13791aae15e01)
src/mesa/drivers/dri/i965/brw_wm.c
src/mesa/drivers/dri/i965/gen7_wm_surface_state.c