i965/fs: Add support for non-shadow textureGrad (TXD) on Ivybridge.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 8 Jun 2011 23:08:07 +0000 (16:08 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Sun, 19 Jun 2011 00:53:47 +0000 (17:53 -0700)
This is somewhat ugly, but I couldn't think of a nicer way to handle the
interleaved coordinate/derivative parameter loading.

Ironlake and Sandybridge will still hit an assertion in visit().

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/brw_fs_emit.cpp
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp

index 6b7c434949c01029f8ccbd7e8d9c43983c85be87..844b89b7dc322904ecc105ccbe36c1f8d2fda534 100644 (file)
@@ -273,7 +273,8 @@ fs_visitor::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src)
         }
         break;
       case FS_OPCODE_TXD:
-        assert(!"TXD isn't supported on gen5+ yet.");
+        assert(!inst->shadow_compare);
+        msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_DERIVS;
         break;
       }
    } else {
index b4857871c78b75bdb1fe043d503bf4844a891180..7255946586485615d7989851188b2065e904ddca 100644 (file)
@@ -796,20 +796,52 @@ fs_visitor::emit_texture_gen7(ir_texture *ir, fs_reg dst, fs_reg coordinate,
       emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), this->result);
       mlen += reg_width;
       break;
-   case ir_txd:
+   case ir_txd: {
+      if (c->dispatch_width == 16)
+        fail("Gen7 does not support sample_d/sample_d_c in SIMD16 mode.");
+
+      ir->lod_info.grad.dPdx->accept(this);
+      fs_reg dPdx = this->result;
+
+      ir->lod_info.grad.dPdy->accept(this);
+      fs_reg dPdy = this->result;
+
+      /* Load dPdx and the coordinate together:
+       * [hdr], [ref], x, dPdx.x, dPdy.x, y, dPdx.y, dPdy.y, z, dPdx.z, dPdy.z
+       */
+      for (int i = 0; i < ir->coordinate->type->vector_elements; i++) {
+        fs_inst *inst = emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen),
+                             coordinate);
+        if (i < 3 && c->key.gl_clamp_mask[i] & (1 << sampler))
+           inst->saturate = true;
+        coordinate.reg_offset++;
+        mlen += reg_width;
+
+        emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), dPdx);
+        dPdx.reg_offset++;
+        mlen += reg_width;
+
+        emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen), dPdy);
+        dPdy.reg_offset++;
+        mlen += reg_width;
+      }
+      break;
+   }
    case ir_txf:
       assert(!"GLSL 1.30 features unsupported");
       break;
    }
 
-   /* Set up the coordinate */
-   for (int i = 0; i < ir->coordinate->type->vector_elements; i++) {
-      fs_inst *inst = emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen),
-                          coordinate);
-      if (i < 3 && c->key.gl_clamp_mask[i] & (1 << sampler))
-        inst->saturate = true;
-      coordinate.reg_offset++;
-      mlen += reg_width;
+   /* Set up the coordinate (except for TXD where it was done earlier) */
+   if (ir->op != ir_txd) {
+      for (int i = 0; i < ir->coordinate->type->vector_elements; i++) {
+        fs_inst *inst = emit(BRW_OPCODE_MOV, fs_reg(MRF, base_mrf + mlen),
+                             coordinate);
+        if (i < 3 && c->key.gl_clamp_mask[i] & (1 << sampler))
+           inst->saturate = true;
+        coordinate.reg_offset++;
+        mlen += reg_width;
+      }
    }
 
    /* Generate the SEND */