From eabb9b0fd9d3a8b757c54465618b0d050ae0852f Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 27 Aug 2011 21:00:39 +0200 Subject: 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 7900bf811d..9137f871f5 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 5bb0e1296b..45804d3a91 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 600850da01..2b177c6cb2 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 984f6cbe17..dabbb836aa 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 15aa40cddd..4b11ae1e62 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) { -- cgit v1.2.3