[Nouveau] Handling UMAD with a negative modifier, or why glsl-fs-atan-3 was failing

Ilia Mirkin imirkin at alum.mit.edu
Wed Jan 8 23:16:56 PST 2014


So I figured out what was going on. The shader has a

UMAD TEMP[0].x, TEMP[0].xxxx, -TEMP[5].xxxx, TEMP[0].xxxx

instruction, in which the -TEMP[5].xxxx got emitted as

cvt neg u32 $r1 u32 $r1

If instead I fudge mkOp() to force a s32 dtype on OP_NEG, everything
starts to work. Similarly, if I fudge emitCVT to basically do the same
thing, it also works. (Of note -- changing both stype and dtype to s32
does _not_ work, which makes sense.) I'm not sure which approach is
the right one -- advice? It's a very short patch either way. Perhaps
someone with a NVC0+ card could check that piglit test and see if my
patch breaks things...

Thanks,

  -ilia

--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_build_util.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_build_util.cpp
@@ -70,6 +70,9 @@
    insn->setDef(0, dst);
    insn->setSrc(0, src);

+   if (op == OP_NEG && ty == TYPE_U32)
+      insn->dType = TYPE_S32;
+
    insert(insn);
    return insn;
 }


More information about the Nouveau mailing list