[Mesa-dev] [PATCH 6/8] nvc0/ir: remove restarts for non-0 vertex streams

Ilia Mirkin imirkin at alum.mit.edu
Thu Jun 26 21:40:14 PDT 2014


Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
 .../nouveau/codegen/nv50_ir_lowering_nvc0.cpp      | 26 +++++++++++++++++++---
 .../nouveau/codegen/nv50_ir_lowering_nvc0.h        |  1 +
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp
index fb9bed4..5a3d46d 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp
@@ -73,6 +73,23 @@ NVC0LegalizeSSA::handleRCPRSQ(Instruction *i)
    // TODO
 }
 
+void
+NVC0LegalizeSSA::handleOUT(Instruction *i)
+{
+   // We need to get rid of restart operations with a non-zero stream
+   ImmediateValue stream;
+
+   if (i->op == OP_EMIT && i->subOp == 0)
+      return;
+
+   if (i->src(1).getImmediate(stream) && stream.reg.data.u32 != 0) {
+      if (i->op == OP_RESTART)
+         delete_Instruction(prog, i);
+      else
+         i->subOp = 0;
+   }
+}
+
 bool
 NVC0LegalizeSSA::visit(Function *fn)
 {
@@ -86,18 +103,21 @@ NVC0LegalizeSSA::visit(BasicBlock *bb)
    Instruction *next;
    for (Instruction *i = bb->getEntry(); i; i = next) {
       next = i->next;
-      if (i->dType == TYPE_F32)
-         continue;
       switch (i->op) {
       case OP_DIV:
       case OP_MOD:
-         handleDIV(i);
+         if (i->dType != TYPE_F32)
+            handleDIV(i);
          break;
       case OP_RCP:
       case OP_RSQ:
          if (i->dType == TYPE_F64)
             handleRCPRSQ(i);
          break;
+      case OP_EMIT:
+      case OP_RESTART:
+         handleOUT(i);
+         break;
       default:
          break;
       }
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.h b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.h
index 7f39c28..f758b22 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.h
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.h
@@ -34,6 +34,7 @@ private:
    // we want to insert calls to the builtin library only after optimization
    void handleDIV(Instruction *); // integer division, modulus
    void handleRCPRSQ(Instruction *); // double precision float recip/rsqrt
+   void handleOUT(Instruction *); // remove restart with non-zero stream
 
 private:
    BuildUtil bld;
-- 
1.8.5.5



More information about the mesa-dev mailing list