nv50: make FrontFacing -1 or +1
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>
Tue, 31 Aug 2010 17:09:15 +0000 (19:09 +0200)
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>
Wed, 1 Sep 2010 16:02:50 +0000 (18:02 +0200)
src/gallium/drivers/nv50/nv50_tgsi_to_nc.c

index 0a4c88c81790f67911daa5006bf1655349d618c4..c98d5e126ada1f2d30ae7b9d09a617273f75e2b4 100644 (file)
@@ -964,6 +964,14 @@ bld_saved_input(struct bld_context *bld, unsigned i, unsigned c)
 static struct nv_value *
 bld_interpolate(struct bld_context *bld, unsigned mode, struct nv_value *val)
 {
+   if (val->reg.id == 255) {
+      /* gl_FrontFacing: 0/~0 to -1.0/+1.0 */
+      val = bld_insn_1(bld, NV_OP_LINTERP, val);
+      val = bld_insn_2(bld, NV_OP_SHL, val, bld_imm_u32(bld, 31));
+      val->insn->src[0]->typecast = NV_TYPE_U32;
+      val = bld_insn_2(bld, NV_OP_XOR, val, bld_imm_f32(bld, -1.0f));
+      val->insn->src[0]->typecast = NV_TYPE_U32;
+   } else
    if (mode & (NV50_INTERP_LINEAR | NV50_INTERP_FLAT))
       val = bld_insn_1(bld, NV_OP_LINTERP, val);
    else
@@ -1029,9 +1037,8 @@ emit_fetch(struct bld_context *bld, const struct tgsi_full_instruction *insn,
       } else {
          assert(src->Dimension.Dimension == 0);
          res = bld_insn_1(bld, NV_OP_LDA, res);
+         assert(res->reg.type == type);
       }
-      assert(res->reg.type == type);
-
       bld->saved_inputs[bld->ti->input_map[idx][swz]] = res;
       break;
    case TGSI_FILE_TEMPORARY: