OSDN Git Service

gallium: fix SSE shadow texture instructions
authorBrian Paul <brianp@vmware.com>
Wed, 29 Jul 2009 22:27:03 +0000 (16:27 -0600)
committerBrian Paul <brianp@vmware.com>
Wed, 29 Jul 2009 22:33:58 +0000 (16:33 -0600)
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
src/mesa/state_tracker/st_mesa_to_tgsi.c

index 781ea1e..16848f7 100644 (file)
@@ -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;
index 6380cd6..c8fb39d 100644 (file)
@@ -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)