i965/fs: Implement texelFetch() on Ironlake and Sandybridge.
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 26 Aug 2011 00:13:37 +0000 (17:13 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 19 Sep 2011 22:30:54 +0000 (15:30 -0700)
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/brw_defines.h
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs.h
src/mesa/drivers/dri/i965/brw_fs_emit.cpp
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
src/mesa/program/ir_to_mesa.cpp

index 5f349392ae9e198dbf12cbced1cfb8d87a140f61..055aa4a6c5a84d87534c75735d87b9a82a3126fa 100644 (file)
@@ -633,6 +633,7 @@ enum opcode {
    FS_OPCODE_TEX,
    FS_OPCODE_TXB,
    FS_OPCODE_TXD,
+   FS_OPCODE_TXF,
    FS_OPCODE_TXL,
    FS_OPCODE_TXS,
    FS_OPCODE_DISCARD,
@@ -782,6 +783,7 @@ enum opcode {
 #define GEN5_SAMPLER_MESSAGE_SAMPLE_DERIVS       4
 #define GEN5_SAMPLER_MESSAGE_SAMPLE_BIAS_COMPARE 5
 #define GEN5_SAMPLER_MESSAGE_SAMPLE_LOD_COMPARE  6
+#define GEN5_SAMPLER_MESSAGE_SAMPLE_LD           7
 #define GEN5_SAMPLER_MESSAGE_SAMPLE_RESINFO      10
 
 /* for GEN5 only */
index 7f5194b06ed0797a9f40ec9d6585c4f7165038c3..9a89f88b61fe8aef1100cbcae246a92628f8efa3 100644 (file)
@@ -156,6 +156,7 @@ fs_visitor::implied_mrf_writes(fs_inst *inst)
    case FS_OPCODE_TEX:
    case FS_OPCODE_TXB:
    case FS_OPCODE_TXD:
+   case FS_OPCODE_TXF:
    case FS_OPCODE_TXL:
    case FS_OPCODE_TXS:
       return 1;
index f3d8fbf3ec15b2bfc00eb3a06068bac5020f35cb..0bd518f77020f265bd71f567fe1cc8a12c35e18b 100644 (file)
@@ -291,6 +291,7 @@ public:
       return (opcode == FS_OPCODE_TEX ||
              opcode == FS_OPCODE_TXB ||
              opcode == FS_OPCODE_TXD ||
+             opcode == FS_OPCODE_TXF ||
              opcode == FS_OPCODE_TXL ||
              opcode == FS_OPCODE_TXS);
    }
index ba0d2a26f1e98393ec69cc1d0fe57e1c1b9c308d..906c15821e00dab73f76799d2673e4485c294811 100644 (file)
@@ -249,6 +249,9 @@ fs_visitor::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src)
         /* There is no sample_d_c message; comparisons are done manually */
         msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_DERIVS;
         break;
+      case FS_OPCODE_TXF:
+        msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_LD;
+        break;
       default:
         assert(!"not reached");
         break;
@@ -782,6 +785,7 @@ fs_visitor::generate_code()
       case FS_OPCODE_TEX:
       case FS_OPCODE_TXB:
       case FS_OPCODE_TXD:
+      case FS_OPCODE_TXF:
       case FS_OPCODE_TXL:
       case FS_OPCODE_TXS:
         generate_tex(inst, dst, src[0]);
index ba7ee2f3181ba489697f33c4e979e83fd7973b40..09aaca960da970b8b418dc95562597ffed0e0d14 100644 (file)
@@ -785,7 +785,8 @@ fs_visitor::emit_texture_gen5(ir_texture *ir, fs_reg dst, fs_reg coordinate,
 
    for (int i = 0; i < vector_elements; i++) {
       fs_inst *inst = emit(BRW_OPCODE_MOV,
-                          fs_reg(MRF, base_mrf + mlen + i * reg_width),
+                          fs_reg(MRF, base_mrf + mlen + i * reg_width,
+                                 coordinate.type),
                           coordinate);
       if (i < 3 && c->key.gl_clamp_mask[i] & (1 << sampler))
         inst->saturate = true;
@@ -861,7 +862,13 @@ fs_visitor::emit_texture_gen5(ir_texture *ir, fs_reg dst, fs_reg coordinate,
       inst = emit(FS_OPCODE_TXS, dst);
       break;
    case ir_txf:
-      assert(!"GLSL 1.30 features unsupported");
+      mlen = header_present + 4 * reg_width;
+
+      ir->lod_info.lod->accept(this);
+      emit(BRW_OPCODE_MOV,
+          fs_reg(MRF, base_mrf + mlen - reg_width, BRW_REGISTER_TYPE_UD),
+          this->result);
+      inst = emit(FS_OPCODE_TXF, dst);
       break;
    }
    inst->base_mrf = base_mrf;
index 69a84de397bf7ff0c2f12593c2c154e943614660..5e565e4ed0859635bcabe930641af6f40d98738c 100644 (file)
@@ -2139,6 +2139,8 @@ ir_to_mesa_visitor::visit(ir_texture *ir)
       ir->lod_info.bias->accept(this);
       lod_info = this->result;
       break;
+   case ir_txf:
+      /* Pretend to be TXL so the sampler, coordinate, lod are available */
    case ir_txl:
       opcode = OPCODE_TXL;
       ir->lod_info.lod->accept(this);
@@ -2151,9 +2153,6 @@ ir_to_mesa_visitor::visit(ir_texture *ir)
       ir->lod_info.grad.dPdy->accept(this);
       dy = this->result;
       break;
-   case ir_txf:
-      assert(!"GLSL 1.30 features unsupported");
-      break;
    }
 
    const glsl_type *sampler_type = ir->sampler->type;