From b9889517f5e7eceb14bd103bbdff9ff47ce6ed25 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 29 Jul 2009 16:27:03 -0600 Subject: gallium: fix SSE shadow texture instructions When sampling a 2D shadow map we need 3 texcoord components, not 2. The third component (distance from light source) is compared against the texture sample to return the result (visible vs. occluded). Also, enable proper handling of TGSI_TEXTURE_SHADOW targets in Mesa->TGSI translation. There's a possibility for breakage in gallium drivers if they fail to handle the TGSI_TEXTURE_SHADOW1D / TGSI_TEXTURE_SHADOW2D / TGSI_TEXTURE_SHADOWRECT texture targets for TGSI_OPCODE_TEX/TXP instructions, but that should be easy to fix. With these changes, progs/demos/shadowtex.c renders properly again with softpipe. --- src/gallium/auxiliary/tgsi/tgsi_sse2.c | 6 +++--- src/mesa/state_tracker/st_mesa_to_tgsi.c | 6 ------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c index 781ea1e75cf..16848f7cc5e 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c @@ -1467,15 +1467,15 @@ emit_tex( struct x86_function *func, switch (inst->InstructionExtTexture.Texture) { case TGSI_TEXTURE_1D: - case TGSI_TEXTURE_SHADOW1D: count = 1; break; case TGSI_TEXTURE_2D: case TGSI_TEXTURE_RECT: - case TGSI_TEXTURE_SHADOW2D: - case TGSI_TEXTURE_SHADOWRECT: count = 2; break; + case TGSI_TEXTURE_SHADOW1D: + case TGSI_TEXTURE_SHADOW2D: + case TGSI_TEXTURE_SHADOWRECT: case TGSI_TEXTURE_3D: case TGSI_TEXTURE_CUBE: count = 3; diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 6380cd6b2a8..c8fb39d558f 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -158,12 +158,6 @@ map_texture_target( GLuint textarget, GLboolean shadow ) { -#if 1 - /* XXX remove this line after we've checked that the rest of gallium - * can handle the TGSI_TEXTURE_SHADOWx tokens. - */ - shadow = GL_FALSE; -#endif switch( textarget ) { case TEXTURE_1D_INDEX: if (shadow) -- cgit v1.2.3