gallium: use the TGSI_TEXTURE_SHADOW1D/2D/RECT texture types for TEX instructions
authorBrian Paul <brianp@vmware.com>
Fri, 20 Feb 2009 21:06:25 +0000 (14:06 -0700)
committerBrian Paul <brianp@vmware.com>
Fri, 20 Feb 2009 21:06:25 +0000 (14:06 -0700)
These texture types were defined but never put to use.
For the time being though, the Mesa->TGSI translater isn't emitting these
targets.  See the XXX comment in map_texture_target().

src/gallium/auxiliary/tgsi/tgsi_exec.c
src/gallium/drivers/i915simple/i915_fpc_translate.c
src/mesa/state_tracker/st_mesa_to_tgsi.c

index 5c5d8d25500cc2b67b0a218a76d7ec7c49ad9fd4..94589cf79f1a7f1ce4e79df3f1eb4e85c7b53bfa 100644 (file)
@@ -1614,6 +1614,7 @@ exec_tex(struct tgsi_exec_machine *mach,
 
    switch (inst->InstructionExtTexture.Texture) {
    case TGSI_TEXTURE_1D:
+   case TGSI_TEXTURE_SHADOW1D:
 
       FETCH(&r[0], 0, CHAN_X);
 
@@ -1636,6 +1637,8 @@ exec_tex(struct tgsi_exec_machine *mach,
 
    case TGSI_TEXTURE_2D:
    case TGSI_TEXTURE_RECT:
+   case TGSI_TEXTURE_SHADOW2D:
+   case TGSI_TEXTURE_SHADOWRECT:
 
       FETCH(&r[0], 0, CHAN_X);
       FETCH(&r[1], 0, CHAN_Y);
index d92bdc1bc657c5f1bbd7acbf63577f78a83b5f31..961c1bf213478c3e61d3ab4c4d79eececbb805a6 100644 (file)
@@ -321,16 +321,27 @@ static uint
 translate_tex_src_target(struct i915_fp_compile *p, uint tex)
 {
    switch (tex) {
+   case TGSI_TEXTURE_SHADOW1D:
+      /* fall-through */
    case TGSI_TEXTURE_1D:
       return D0_SAMPLE_TYPE_2D;
+
+   case TGSI_TEXTURE_SHADOW2D:
+      /* fall-through */
    case TGSI_TEXTURE_2D:
       return D0_SAMPLE_TYPE_2D;
+
+   case TGSI_TEXTURE_SHADOWRECT:
+      /* fall-through */
    case TGSI_TEXTURE_RECT:
       return D0_SAMPLE_TYPE_2D;
+
    case TGSI_TEXTURE_3D:
       return D0_SAMPLE_TYPE_VOLUME;
+
    case TGSI_TEXTURE_CUBE:
       return D0_SAMPLE_TYPE_CUBE;
+
    default:
       i915_program_error(p, "TexSrc type");
       return 0;
index 862d29fb1bdafa3cc850f50f522b47723d5d4608..8ce0b201135e9dce2bf228f6c643ddec3fb54232 100644 (file)
@@ -132,19 +132,35 @@ map_register_file_index(
  */
 static GLuint
 map_texture_target(
-   GLuint textarget )
+    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:
-      return TGSI_TEXTURE_1D;
+      if (shadow)
+         return TGSI_TEXTURE_SHADOW1D;
+      else
+         return TGSI_TEXTURE_1D;
    case TEXTURE_2D_INDEX:
-      return TGSI_TEXTURE_2D;
+      if (shadow)
+         return TGSI_TEXTURE_SHADOW2D;
+      else
+         return TGSI_TEXTURE_2D;
    case TEXTURE_3D_INDEX:
       return TGSI_TEXTURE_3D;
    case TEXTURE_CUBE_INDEX:
       return TGSI_TEXTURE_CUBE;
    case TEXTURE_RECT_INDEX:
-      return TGSI_TEXTURE_RECT;
+      if (shadow)
+         return TGSI_TEXTURE_SHADOWRECT;
+      else
+         return TGSI_TEXTURE_RECT;
    default:
       assert( 0 );
    }
@@ -514,7 +530,8 @@ compile_instruction(
       /* ordinary texture lookup */
       fullinst->Instruction.Opcode = TGSI_OPCODE_TEX;
       fullinst->Instruction.NumSrcRegs = 2;
-      fullinst->InstructionExtTexture.Texture = map_texture_target( inst->TexSrcTarget );
+      fullinst->InstructionExtTexture.Texture =
+         map_texture_target( inst->TexSrcTarget, inst->TexShadow );
       fullinst->FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_SAMPLER;
       fullinst->FullSrcRegisters[1].SrcRegister.Index = inst->TexSrcUnit;
       break;
@@ -522,7 +539,8 @@ compile_instruction(
       /* texture lookup with LOD bias */
       fullinst->Instruction.Opcode = TGSI_OPCODE_TXB;
       fullinst->Instruction.NumSrcRegs = 2;
-      fullinst->InstructionExtTexture.Texture = map_texture_target( inst->TexSrcTarget );
+      fullinst->InstructionExtTexture.Texture =
+         map_texture_target( inst->TexSrcTarget, inst->TexShadow );
       fullinst->FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_SAMPLER;
       fullinst->FullSrcRegisters[1].SrcRegister.Index = inst->TexSrcUnit;
       break;
@@ -530,7 +548,8 @@ compile_instruction(
       /* texture lookup with explicit partial derivatives */
       fullinst->Instruction.Opcode = TGSI_OPCODE_TXD;
       fullinst->Instruction.NumSrcRegs = 4;
-      fullinst->InstructionExtTexture.Texture = map_texture_target( inst->TexSrcTarget );
+      fullinst->InstructionExtTexture.Texture =
+         map_texture_target( inst->TexSrcTarget, inst->TexShadow );
       /* src[0] = coord, src[1] = d[strq]/dx, src[2] = d[strq]/dy */
       fullinst->FullSrcRegisters[3].SrcRegister.File = TGSI_FILE_SAMPLER;
       fullinst->FullSrcRegisters[3].SrcRegister.Index = inst->TexSrcUnit;
@@ -539,7 +558,8 @@ compile_instruction(
       /* texture lookup with explicit LOD */
       fullinst->Instruction.Opcode = TGSI_OPCODE_TXL;
       fullinst->Instruction.NumSrcRegs = 2;
-      fullinst->InstructionExtTexture.Texture = map_texture_target( inst->TexSrcTarget );
+      fullinst->InstructionExtTexture.Texture =
+         map_texture_target( inst->TexSrcTarget, inst->TexShadow );
       fullinst->FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_SAMPLER;
       fullinst->FullSrcRegisters[1].SrcRegister.Index = inst->TexSrcUnit;
       break;
@@ -548,7 +568,8 @@ compile_instruction(
       /* convert to TEX w/ special flag for division */
       fullinst->Instruction.Opcode = TGSI_OPCODE_TXP;
       fullinst->Instruction.NumSrcRegs = 2;
-      fullinst->InstructionExtTexture.Texture = map_texture_target( inst->TexSrcTarget );
+      fullinst->InstructionExtTexture.Texture =
+         map_texture_target( inst->TexSrcTarget, inst->TexShadow );
       fullinst->FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_SAMPLER;
       fullinst->FullSrcRegisters[1].SrcRegister.Index = inst->TexSrcUnit;
       break;