Mesa (master): nv50: handle TGSI_OPCODE_ROUND

Christoph Bumiller chrisbmr at kemper.freedesktop.org
Tue Aug 30 11:57:16 UTC 2011


Module: Mesa
Branch: master
Commit: eabb9b0fd9d3a8b757c54465618b0d050ae0852f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=eabb9b0fd9d3a8b757c54465618b0d050ae0852f

Author: Christoph Bumiller <e0425955 at student.tuwien.ac.at>
Date:   Sat Aug 27 21:00:39 2011 +0200

nv50: handle TGSI_OPCODE_ROUND

Will round to nearest-even.

---

 src/gallium/drivers/nv50/nv50_pc.c         |    1 +
 src/gallium/drivers/nv50/nv50_pc.h         |    3 ++-
 src/gallium/drivers/nv50/nv50_pc_emit.c    |    6 ++++--
 src/gallium/drivers/nv50/nv50_pc_print.c   |    1 +
 src/gallium/drivers/nv50/nv50_tgsi_to_nc.c |    2 ++
 5 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/nv50/nv50_pc.c b/src/gallium/drivers/nv50/nv50_pc.c
index 7900bf8..9137f87 100644
--- a/src/gallium/drivers/nv50/nv50_pc.c
+++ b/src/gallium/drivers/nv50/nv50_pc.c
@@ -102,6 +102,7 @@ nv50_nvi_can_load(struct nv_instruction *nvi, int s, struct nv_value *value)
    case NV_OP_FLOOR:
    case NV_OP_TRUNC:
    case NV_OP_CVT:
+   case NV_OP_ROUND:
    case NV_OP_NEG:
    case NV_OP_MAD:
    case NV_OP_MUL:
diff --git a/src/gallium/drivers/nv50/nv50_pc.h b/src/gallium/drivers/nv50/nv50_pc.h
index 5bb0e12..45804d3 100644
--- a/src/gallium/drivers/nv50/nv50_pc.h
+++ b/src/gallium/drivers/nv50/nv50_pc.h
@@ -86,7 +86,8 @@
 #define NV_OP_SELECT    54
 #define NV_OP_EXPORT    55
 #define NV_OP_JOIN      56
-#define NV_OP_COUNT     57
+#define NV_OP_ROUND     57
+#define NV_OP_COUNT     58
 
 #define NV_FILE_GPR      0
 #define NV_FILE_OUT      1
diff --git a/src/gallium/drivers/nv50/nv50_pc_emit.c b/src/gallium/drivers/nv50/nv50_pc_emit.c
index 600850d..2b177c6 100644
--- a/src/gallium/drivers/nv50/nv50_pc_emit.c
+++ b/src/gallium/drivers/nv50/nv50_pc_emit.c
@@ -94,7 +94,7 @@ const ubyte nv50_inst_min_size_tab[NV_OP_COUNT] =
    0, 0, 0, 8, 8, 4, 4, 4, 8, 4, 4, 8, 8, 8, 8, 8, /* 15 */
    8, 8, 8, 4, 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, /* 31 */
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, /* 47 */
-   4, 8, 8, 8, 8, 8, 0, 0, 8
+   4, 8, 8, 8, 8, 8, 0, 0, 8, 8
 };
 
 unsigned
@@ -1009,13 +1009,14 @@ emit_cvt(struct nv_pc *pc, struct nv_instruction *nvi)
    }
    if (pc->emit[1] == CVT_F32_F32 &&
        (nvi->opcode == NV_OP_CEIL || nvi->opcode == NV_OP_FLOOR ||
-	nvi->opcode == NV_OP_TRUNC))
+        nvi->opcode == NV_OP_TRUNC || nvi->opcode == NV_OP_ROUND))
        pc->emit[1] |= CVT_RI;
 
    switch (nvi->opcode) {
    case NV_OP_CEIL:  pc->emit[1] |= CVT_CEIL; break;
    case NV_OP_FLOOR: pc->emit[1] |= CVT_FLOOR; break;
    case NV_OP_TRUNC: pc->emit[1] |= CVT_TRUNC; break;
+   case NV_OP_ROUND: pc->emit[1] |= CVT_RN; break;
 
    case NV_OP_ABS: pc->emit[1] |= CVT_ABS; break;
    case NV_OP_SAT: pc->emit[1] |= CVT_SAT; break;
@@ -1163,6 +1164,7 @@ nv50_emit_instruction(struct nv_pc *pc, struct nv_instruction *i)
    case NV_OP_CEIL:
    case NV_OP_FLOOR:
    case NV_OP_TRUNC:
+   case NV_OP_ROUND:
       emit_cvt(pc, i);
       break;
    case NV_OP_DFDX:
diff --git a/src/gallium/drivers/nv50/nv50_pc_print.c b/src/gallium/drivers/nv50/nv50_pc_print.c
index 984f6cb..dabbb83 100644
--- a/src/gallium/drivers/nv50/nv50_pc_print.c
+++ b/src/gallium/drivers/nv50/nv50_pc_print.c
@@ -96,6 +96,7 @@ static const char *nv_opcode_names[NV_OP_COUNT + 1] = {
    "select",
    "export",
    "join",
+   "round",
    "BAD_OP"
 };
 
diff --git a/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c b/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c
index 15aa40c..4b11ae1 100644
--- a/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c
+++ b/src/gallium/drivers/nv50/nv50_tgsi_to_nc.c
@@ -803,6 +803,7 @@ translate_opcode(uint opcode)
    case TGSI_OPCODE_CEIL: return NV_OP_CEIL;
    case TGSI_OPCODE_FLR: return NV_OP_FLOOR;
    case TGSI_OPCODE_TRUNC: return NV_OP_TRUNC;
+   case TGSI_OPCODE_ROUND: return NV_OP_ROUND;
    case TGSI_OPCODE_COS: return NV_OP_COS;
    case TGSI_OPCODE_SIN: return NV_OP_SIN;
    case TGSI_OPCODE_DDX: return NV_OP_DFDX;
@@ -1819,6 +1820,7 @@ bld_instruction(struct bld_context *bld,
    case TGSI_OPCODE_CEIL:
    case TGSI_OPCODE_FLR:
    case TGSI_OPCODE_TRUNC:
+   case TGSI_OPCODE_ROUND:
    case TGSI_OPCODE_DDX:
    case TGSI_OPCODE_DDY:
       FOR_EACH_DST0_ENABLED_CHANNEL(c, insn) {




More information about the mesa-commit mailing list